### Short-Circuiting Logic Example Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Demonstrates how to use 'short circuiting' in Java to bypass a code block by forcing a conditional to evaluate to false. This is a technique to minimize changes when modifying existing logic. ```java if (false && !this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed this.die(); this.h(); } ``` -------------------------------- ### Using Validate Package for Null Checks Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Illustrates replacing manual null checks with a more concise method from the `Validate` package, promoting cleaner code and reducing boilerplate. ```java Validate.notNull(sender, "Sender cannot be null"); ``` -------------------------------- ### Organized Import Statements Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Demonstrates the correct organization of import statements, separating and grouping by package, with CraftBukkit imports placed after standard library imports. ```java import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.Random; import java.util.concurrent.Callable; // CraftBukkit start import java.io.UnsupportedEncodingException; import java.util.concurrent.ExecutionException; ``` -------------------------------- ### Git Branching and Checking Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Commands for creating a new branch for your changes and checking for unnecessary whitespace before committing. It's recommended to name branches relevant to the changes being made. ```git git branch relevantBranchName git checkout relevantBranchName ``` ```git git diff --check ``` -------------------------------- ### Compile Spigot API with Maven Source: https://github.com/spigotmc/spigot-api/blob/master/README.md Instructions to compile the Spigot API project using Maven. Maven is used to manage dependencies and build the project. ```Shell mvn clean install ``` -------------------------------- ### Java Import Organization for Bukkit API Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Demonstrates the required organization and grouping of Java imports according to Bukkit API coding standards. Imports are alphabetized within groups, separating standard Java libraries from CraftBukkit specific imports. ```java import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.Random; import java.util.concurrent.Callable; // CraftBukkit start import java.io.UnsupportedEncodingException; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.logging.Level; import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.inventory.CraftInventoryView; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.LazyPlayerSet; import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.block.Action; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.inventory.*; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; // CraftBukkit end ``` -------------------------------- ### Multi-line CraftBukkit Comment with Reason Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Use multi-line CraftBukkit comments with a reason for complex changes. ```java // CraftBukkit start - special case dropping so we can get info from the tile entity public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { if (world.random.nextFloat() < f) { ItemStack itemstack = new ItemStack(Item.SKULL.id, 1, this.getDropData(world, i, j, k)); TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(i, j, k); if (tileentityskull.getSkullType() == 3 && tileentityskull.getExtraType() != null && tileentityskull.getExtraType().length() > 0) { itemstack.setTag(new NBTTagCompound()); itemstack.getTag().setString("SkullOwner", tileentityskull.getExtraType()); } this.b(world, i, j, k, itemstack); } } // CraftBukkit end ``` -------------------------------- ### Commit Message Guidelines and Expectations Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Defines the structure and content requirements for commit messages in the Spigot project. It details the imperative statement format, JIRA ticket referencing (e.g., BUKKIT-#), body content, line length limits, and acceptable keywords for ticket referencing. ```APIDOC Commit Message Expectations: The first line in a commit message is an imperative statement briefly explaining what the commit is achieving with an associated ticket number from our JIRA, in the form of BUKKIT-#. See the list of acceptable keywords to reference tickets with for more information on this. The body of the commit message needs to describe how the code behaves without this change, why this is a problem and how this commit addresses it. The body of the commit message should be restricted by a 78 character, plus newline, limit per line (meaning: once you hit about 78 characters, you should explicitly start a new line in the commit message). Acceptable keywords to reference tickets with: * **Fixes** BUKKIT-1 - this commit fixes the bug detailed in BUKKIT-1 * **Adds** BUKKIT-2 - this commit adds the new feature requested by BUKKIT-2 You can reference multiple tickets in a single commit message, for example: "Fixes BUKKIT-1, BUKKIT-2" or "Adds BUKKIT-1, BUKKIT-2" without closing punctuation. ## Submitting the Changes * Push your changes to a topic branch in your fork of the repository. * Submit a pull request to the relevant repository in the Bukkit organization. * Make sure your pull request meets [our expectations](#pull-request-formatting-expectations) before submitting. * No merges should be included in any pull requests. * Update your JIRA ticket to reflect that you have submitted a pull request and are ready for it to be reviewed. * Include a link to the pull request in the ticket. * Follow our [Tips to Get Your Pull Request Accepted](#tips-to-get-your-pull-request-accepted). * **Note:** The project is put under a code freeze leading up to the release of a Minecraft update in order to give the Bukkit team a static code base to work on. ### Pull Request Formatting Expectations #### Title > [PR Type] Brief summary. Fixes BUKKIT-#### > PR Type can be B for Bukkit, C for CraftBukkit, B+C for a PR in both sides > > Title Example: > [B+C] Provide an example commit for CONTRIBUTING.md. Fixes BUKKIT-1 ``` -------------------------------- ### Simple End-of-Line CraftBukkit Comment Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Use a simple end-of-line CraftBukkit comment for obvious code changes. ```java if (true || minecraftserver.getAllowNether()) { // CraftBukkit ``` -------------------------------- ### Spigot API Java Imports Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md This snippet lists common Java imports used within the Spigot API. It includes imports for concurrency, logging, collections, Bukkit core classes, and various event types, essential for Spigot plugin development. ```java import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.logging.Level; import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.inventory.CraftInventoryView; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.LazyPlayerSet; import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.block.Action; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.inventory.*; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; // CraftBukkit end ``` -------------------------------- ### End-of-Line CraftBukkit Comment with Reason Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Include a reason in an end-of-line CraftBukkit comment for important or hard-to-discern changes. ```java public int fireTicks; // CraftBukkit - private -> public ``` -------------------------------- ### Multi-line CraftBukkit Comment without Reason Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Employ multi-line CraftBukkit comments without a specific reason when the change is straightforward. ```java // CraftBukkit start BlockIgniteEvent event = new BlockIgniteEvent(this.cworld.getBlockAt(i, j, k), BlockIgniteEvent.IgniteCause.LIGHTNING, null); world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { world.setTypeIdUpdate(i, j, k, Block.FIRE.id); } // CraftBukkit end ``` -------------------------------- ### Commenting Out Removed Code Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Shows the practice of commenting out removed code blocks instead of deleting them entirely, as per the Minimal Diff policy. This aids in tracking changes and understanding the original code structure. ```java // CraftBukkit start - special case dropping so we can get info from the tile entity public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { if (world.random.nextFloat() < f) { ItemStack itemstack = new ItemStack(Item.SKULL.id, 1, this.getDropData(world, i, j, k)); TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(i, j, k); if (tileentityskull.getSkullType() == 3 && tileentityskull.getExtraType() != null && tileentityskull.getExtraType().length() > 0) { itemstack.setTag(new NBTTagCompound()); itemstack.getTag().setString("SkullOwner", tileentityskull.getExtraType()); } this.b(world, i, j, k, itemstack); } } // CraftBukkit end public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { if (entityhuman.abilities.canInstantlyBuild) { l |= 8; world.setData(i, j, k, l, 4); } super.a(world, i, j, k, l, entityhuman); } public void remove(World world, int i, int j, int k, int l, int i1) { if (!world.isStatic) { /* CraftBukkit start - drop item in code above, not here if ((i1 & 8) == 0) { ItemStack itemstack = new ItemStack(Item.SKULL.id, 1, this.getDropData(world, i, j, k)); TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(i, j, k); if (tileentityskull.getSkullType() == 3 && tileentityskull.getExtraType() != null && tileentityskull.getExtraType().length() > 0) { itemstack.setTag(new NBTTagCompound()); itemstack.getTag().setString("SkullOwner", tileentityskull.getExtraType()); } this.b(world, i, j, k, itemstack); } // CraftBukkit end */ super.remove(world, i, j, k, l, i1); } } ``` -------------------------------- ### CraftBukkit Comment on New Line Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Place a CraftBukkit comment on a new line above the change if it improves readability. ```java // CraftBukkit if (!isEffect && !world.isStatic && world.difficulty >= 2 && world.areChunksLoaded(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) { ``` -------------------------------- ### Indented Multi-line CraftBukkit Comment Source: https://github.com/spigotmc/spigot-api/blob/master/CONTRIBUTING.md Ensure CraftBukkit comments maintain the same indentation level as the code block they refer to. ```java if (j == 1) { // CraftBukkit start - store a reference ItemStack itemstack4 = playerinventory.getCarried(); if (itemstack4.count > 0) { entityhuman.drop(itemstack4.a(1)); } if (itemstack4.count == 0) { // CraftBukkit end playerinventory.setCarried((ItemStack) null); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.