diff --git a/pom.xml b/pom.xml index b5f18c1d..fb67ad69 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bukkit bukkit - 1.20-R0.1-SNAPSHOT + 1.20.1-R0.1-SNAPSHOT jar Bukkit diff --git a/src/main/java/org/bukkit/block/data/BlockData.java b/src/main/java/org/bukkit/block/data/BlockData.java index 8bb809ec..dd286dd6 100644 --- a/src/main/java/org/bukkit/block/data/BlockData.java +++ b/src/main/java/org/bukkit/block/data/BlockData.java @@ -5,6 +5,7 @@ import org.bukkit.Server; import org.bukkit.SoundGroup; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.BlockSupport; import org.bukkit.block.BlockType; import org.bukkit.block.PistonMoveReaction; @@ -12,6 +13,7 @@ import org.bukkit.block.structure.Mirror; import org.bukkit.block.structure.StructureRotation; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemType; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -236,4 +238,14 @@ public interface BlockData extends Cloneable { * @param mirror the mirror */ void mirror(@NotNull Mirror mirror); + + /** + * Creates a new default {@link BlockState} for this type of Block, not + * bound to a location. + * + * @return a new {@link BlockState} + */ + @NotNull + @ApiStatus.Experimental + BlockState createBlockState(); } diff --git a/src/main/java/org/bukkit/entity/Enderman.java b/src/main/java/org/bukkit/entity/Enderman.java index bb325d9c..0a03dc43 100644 --- a/src/main/java/org/bukkit/entity/Enderman.java +++ b/src/main/java/org/bukkit/entity/Enderman.java @@ -2,6 +2,7 @@ package org.bukkit.entity; import org.bukkit.block.data.BlockData; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,4 +40,38 @@ public interface Enderman extends Monster { * @param blockData data to set the carried block to, or null to remove */ public void setCarriedBlock(@Nullable BlockData blockData); + + /** + * Randomly teleports the Enderman in a 64x64x64 block cuboid region. + *

+ * If the randomly selected point is in the ground, the point is moved 1 block + * down until air is found or until it goes under + * {@link org.bukkit.World#getMinHeight()}. + *

+ * This method will return false if this Enderman is not alive, or if the + * teleport location was obstructed, or if the teleport location is in water. + * + * @return true if the teleport succeeded. + */ + @ApiStatus.Experimental + public boolean teleport(); + + /** + * Randomly teleports the Enderman towards the given entity. + *

+ * The point is selected by drawing a vector between this enderman and the + * given entity. That vector's length is set to 16 blocks. + * That point is then moved within a 8x8x8 cuboid region. If the randomly + * selected point is in the ground, the point is moved 1 block down until + * air is found or until it goes under + * {@link org.bukkit.World#getMinHeight()}. + *

+ * This method will return false if this Enderman is not alive, or if the + * teleport location was obstructed, or if the teleport location is in water. + * + * @param entity The entity to teleport towards. + * @return true if the teleport succeeded. + */ + @ApiStatus.Experimental + public boolean teleportTowards(@NotNull Entity entity); } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index f5e3f43e..5a5ac318 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -21,6 +21,7 @@ import org.bukkit.advancement.AdvancementProgress; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; +import org.bukkit.block.TileState; import org.bukkit.block.data.BlockData; import org.bukkit.block.sign.Side; import org.bukkit.conversations.Conversable; @@ -629,6 +630,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM *

* If the client does not have a sign at the given location it will * display an error message to the user. + *

+ * To change all attributes of a sign, including the back Side, use + * {@link #sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)}. * * @param loc the location of the sign * @param lines the new text on the sign or null to clear it @@ -646,6 +650,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM *

* If the client does not have a sign at the given location it will * display an error message to the user. + *

+ * To change all attributes of a sign, including the back Side, use + * {@link #sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)}. * * @param loc the location of the sign * @param lines the new text on the sign or null to clear it @@ -665,6 +672,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM *

* If the client does not have a sign at the given location it will * display an error message to the user. + *

+ * To change all attributes of a sign, including the back Side, use + * {@link #sendBlockUpdate(org.bukkit.Location, org.bukkit.block.TileState)}. * * @param loc the location of the sign * @param lines the new text on the sign or null to clear it @@ -676,6 +686,26 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public void sendSignChange(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException; + /** + * Send a TileState change. This fakes a TileState change for a user at + * the given location. This will not actually change the world in any way. + * This method will use a TileState at the location's block or a faked TileState + * sent via + * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.block.data.BlockData)}. + *

+ * If the client does not have an appropriate tile at the given location it + * may display an error message to the user. + *

+ * {@link BlockData#createBlockState()} can be used to create a {@link BlockState}. + * + * @param loc the location of the sign + * @param tileState the tile state + * @throws IllegalArgumentException if location is null + * @throws IllegalArgumentException if tileState is null + */ + @ApiStatus.Experimental + public void sendBlockUpdate(@NotNull Location loc, @NotNull TileState tileState) throws IllegalArgumentException; + /** * Render a map and send it to the player in its entirety. This may be * used when streaming the map in the normal manner is not desirable. diff --git a/src/main/java/org/bukkit/event/inventory/ClickType.java b/src/main/java/org/bukkit/event/inventory/ClickType.java index 1b0b47df..fa96e8c2 100644 --- a/src/main/java/org/bukkit/event/inventory/ClickType.java +++ b/src/main/java/org/bukkit/event/inventory/ClickType.java @@ -75,7 +75,17 @@ public enum ClickType { * @return true if this ClickType represents the pressing of a key */ public boolean isKeyboardClick() { - return (this == ClickType.NUMBER_KEY) || (this == ClickType.DROP) || (this == ClickType.CONTROL_DROP); + return (this == ClickType.NUMBER_KEY) || (this == ClickType.DROP) || (this == ClickType.CONTROL_DROP) || (this == ClickType.SWAP_OFFHAND); + } + + /** + * Gets whether this ClickType represents the pressing of a mouse button + * + * @return true if this ClickType represents the pressing of a mouse button + */ + public boolean isMouseClick() { + return (this == ClickType.DOUBLE_CLICK) || (this == ClickType.LEFT) || (this == ClickType.RIGHT) || (this == ClickType.MIDDLE) + || (this == ClickType.WINDOW_BORDER_LEFT) || (this == ClickType.SHIFT_LEFT) || (this == ClickType.SHIFT_RIGHT) || (this == ClickType.WINDOW_BORDER_RIGHT); } /**