diff --git a/patches/api/0420-Add-event-for-player-editing-sign.patch b/patches/api/0420-Add-event-for-player-editing-sign.patch new file mode 100644 index 0000000000..8a4fbb67a7 --- /dev/null +++ b/patches/api/0420-Add-event-for-player-editing-sign.patch @@ -0,0 +1,81 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: by77er +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..4f81a6dbe6694d40f27445f5d17aed48ad75498a +--- /dev/null ++++ b/src/main/java/io/papermc/paper/event/player/PlayerOpenSignEvent.java +@@ -0,0 +1,69 @@ ++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. ++ *

++ * 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; ++ } ++} diff --git a/patches/server/0006-MC-Dev-fixes.patch b/patches/server/0006-MC-Dev-fixes.patch index 6a8db73c57..2af06b8e38 100644 --- a/patches/server/0006-MC-Dev-fixes.patch +++ b/patches/server/0006-MC-Dev-fixes.patch @@ -184,6 +184,31 @@ index 4d2d23ff118e9307d50ca2a5194b83450c91a752..ab6dc3449a1d3b7acf1d7bf5ac1c2422 })); 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 91bb294be2cd8ab3467a62006a5a2751e0bec4ba..5ab7df0042391cb621ed78a187dc20333e344186 100644 +--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java +@@ -76,18 +76,9 @@ 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 b445f90b70d5a74f5bdc1b081500da4742e1c093..afba733824d84d650e669eda028bf4d28cf006b4 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java diff --git a/patches/server/0980-Add-event-for-player-editing-sign.patch b/patches/server/0980-Add-event-for-player-editing-sign.patch new file mode 100644 index 0000000000..16155347a9 --- /dev/null +++ b/patches/server/0980-Add-event-for-player-editing-sign.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: by77er +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 5ab7df0042391cb621ed78a187dc20333e344186..f7fda6fb4e908869310c783e68f7ad7025840592 100644 +--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java +@@ -144,6 +144,16 @@ 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); + }