Merge branch 'master' into enums-to-registers

# Conflicts:
#	src/main/java/org/bukkit/block/data/BlockData.java
#	src/main/java/org/bukkit/entity/Player.java
This commit is contained in:
DerFrZocker 2023-06-16 20:29:17 +02:00
commit a7c1393b43
No known key found for this signature in database
GPG key ID: 713F71FFFE1DDF91
5 changed files with 89 additions and 2 deletions

View file

@ -5,7 +5,7 @@
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Bukkit</name>

View file

@ -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();
}

View file

@ -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.
* <p>
* 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()}.
* <p>
* 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 <code>entity</code>.
* <p>
* The point is selected by drawing a vector between this enderman and the
* given <code>entity</code>. 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()}.
* <p>
* 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);
}

View file

@ -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
* <p>
* If the client does not have a sign at the given location it will
* display an error message to the user.
* <p>
* 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
* <p>
* If the client does not have a sign at the given location it will
* display an error message to the user.
* <p>
* 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
* <p>
* If the client does not have a sign at the given location it will
* display an error message to the user.
* <p>
* 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)}.
* <p>
* If the client does not have an appropriate tile at the given location it
* may display an error message to the user.
* <p>
* {@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.

View file

@ -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);
}
/**