Add getWorld method that uses adventure Key (#11199)
This commit is contained in:
@ -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;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
|
||||
@ -23,6 +23,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public static World getWorld(@NotNull NamespacedKey worldKey) {
|
||||
+ return server.getWorld(worldKey);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the world from the given Key
|
||||
+ *
|
||||
+ * @param worldKey the Key of the world to retrieve
|
||||
+ * @return a world with the given Key, or null if none exists
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public static World getWorld(@NotNull net.kyori.adventure.key.Key worldKey) {
|
||||
+ return server.getWorld(worldKey);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
@ -71,7 +82,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @return a world with the given NamespacedKey, or null if none exists
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public World getWorld(@NotNull NamespacedKey worldKey);
|
||||
+ default World getWorld(@NotNull NamespacedKey worldKey) {
|
||||
+ return getWorld((net.kyori.adventure.key.Key) worldKey);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the world from the given Key
|
||||
+ *
|
||||
+ * @param worldKey the Key of the world to retrieve
|
||||
+ * @return a world with the given Key, or null if none exists
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ World getWorld(@NotNull net.kyori.adventure.key.Key worldKey);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user