Add getWorld method that uses adventure Key (#11199)

This commit is contained in:
kokiriglade
2024-08-19 10:41:55 +01:00
parent 5703e6c6d8
commit 9921a197e7
4 changed files with 31 additions and 8 deletions

View File

@@ -34,6 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.kyori.adventure.sound.Sound;
+import net.kyori.adventure.text.Component;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
@@ -53,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final LockableTileState state;
+ private final Player player;
+ private Component lockedMessage;
+ private Sound lockedSound;
@@ -61,9 +61,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private Result result = Result.DEFAULT;
+
+ @ApiStatus.Internal
+ public BlockLockCheckEvent(final @NotNull Block block, final @NotNull LockableTileState state, final @NotNull Player player, final @NotNull Component lockedMessage, final @NotNull Sound lockedSound) {
+ public BlockLockCheckEvent(final @NotNull Block block, final @NotNull Player player, final @NotNull Component lockedMessage, final @NotNull Sound lockedSound) {
+ super(block);
+ this.state = state;
+ this.player = player;
+ this.lockedMessage = lockedMessage;
+ this.lockedSound = lockedSound;
@@ -76,7 +75,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the snapshot block state.
+ */
+ public @NotNull LockableTileState getBlockState() {
+ return this.state;
+ final BlockState blockState = this.getBlock().getState();
+ Preconditions.checkState(blockState instanceof LockableTileState, "Block state of lock-checked block is no longer a lockable tile state!");
+ return (LockableTileState) blockState;
+ }
+
+ /**