geforkt von Mirrors/Paper
Add event for player editing sign (#9300)
Addresses https://github.com/PaperMC/Paper/issues/9293
Dieser Commit ist enthalten in:
Ursprung
279c17fcdf
Commit
18fa5eef34
81
patches/api/Add-event-for-player-editing-sign.patch
Normale Datei
81
patches/api/Add-event-for-player-editing-sign.patch
Normale Datei
@ -0,0 +1,81 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: by77er <by77er@gmail.com>
|
||||
Date: Sat, 10 Jun 2023 19:06:24 -0400
|
||||
Subject: [PATCH] Add event for player editing sign
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerOpenSignEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerOpenSignEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerOpenSignEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.block.Sign;
|
||||
+import org.bukkit.block.sign.Side;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a player begins editing a sign's text.
|
||||
+ * <p>
|
||||
+ * Cancelling this event stops the sign editing menu from opening.
|
||||
+ */
|
||||
+public class PlayerOpenSignEvent extends PlayerEvent implements Cancellable {
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+ private boolean cancel = false;
|
||||
+ @NotNull private final Sign sign;
|
||||
+ @NotNull private final Side side;
|
||||
+
|
||||
+ public PlayerOpenSignEvent(@NotNull Player editor, @NotNull Sign sign, @NotNull Side side) {
|
||||
+ super(editor);
|
||||
+ this.sign = sign;
|
||||
+ this.side = side;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the sign that was clicked.
|
||||
+ *
|
||||
+ * @return {@link Sign} that was clicked
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Sign getSign() {
|
||||
+ return sign;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets which side of the sign was clicked.
|
||||
+ *
|
||||
+ * @return {@link Side} that was clicked
|
||||
+ * @see Sign#getSide(Side)
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Side getSide() {
|
||||
+ return side;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
27
patches/server/Add-event-for-player-editing-sign.patch
Normale Datei
27
patches/server/Add-event-for-player-editing-sign.patch
Normale Datei
@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: by77er <by77er@gmail.com>
|
||||
Date: Mon, 12 Jun 2023 12:56:46 -0400
|
||||
Subject: [PATCH] Add event for player editing sign
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
||||
@@ -0,0 +0,0 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
|
||||
}
|
||||
|
||||
public void openTextEdit(Player player, SignBlockEntity blockEntity, boolean front) {
|
||||
+ // Paper start
|
||||
+ org.bukkit.entity.Player bukkitPlayer = (org.bukkit.entity.Player) player.getBukkitEntity();
|
||||
+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos());
|
||||
+ org.bukkit.craftbukkit.block.CraftSign<?> bukkitSign = (org.bukkit.craftbukkit.block.CraftSign<?>) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(bukkitBlock);
|
||||
+ io.papermc.paper.event.player.PlayerOpenSignEvent event = new io.papermc.paper.event.player.PlayerOpenSignEvent(
|
||||
+ bukkitPlayer,
|
||||
+ bukkitSign,
|
||||
+ front ? org.bukkit.block.sign.Side.FRONT : org.bukkit.block.sign.Side.BACK);
|
||||
+ if (!event.callEvent()) return;
|
||||
+ // Paper end
|
||||
blockEntity.setAllowedPlayerEditor(player.getUUID());
|
||||
player.openTextEdit(blockEntity, front);
|
||||
}
|
@ -184,6 +184,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}));
|
||||
this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
|
||||
RecipeManager.LOGGER.info("Loaded {} recipes", map1.size());
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
||||
@@ -0,0 +0,0 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
ItemStack itemStack = player.getItemInHand(hand);
|
||||
Item item = itemStack.getItem();
|
||||
- Item signBlockEntity = itemStack.getItem();
|
||||
- SignApplicator var10000;
|
||||
- if (signBlockEntity instanceof SignApplicator signApplicator) {
|
||||
- var10000 = signApplicator;
|
||||
- } else {
|
||||
- var10000 = null;
|
||||
- }
|
||||
-
|
||||
- SignApplicator signApplicator2 = var10000;
|
||||
+ SignApplicator signApplicator2 = item instanceof SignApplicator signApplicator ? signApplicator : null; // Paper - decompile fixes
|
||||
boolean bl = signApplicator2 != null && player.mayBuild();
|
||||
- BlockEntity bl2 = world.getBlockEntity(pos);
|
||||
- if (bl2 instanceof SignBlockEntity signBlockEntity) {
|
||||
+ if (world.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity) { // Paper - decompile fixes
|
||||
if (!world.isClientSide) {
|
||||
boolean bl2 = signBlockEntity.isFacingFrontText(player);
|
||||
SignText signText = signBlockEntity.getText(bl2);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren