From 348e6c75c73376a32b2bf0cf81a549a3a93cace5 Mon Sep 17 00:00:00 2001 From: Timberjaw Date: Thu, 10 Feb 2011 18:15:59 -0800 Subject: [PATCH] Added SIGN_CHANGE event. --- .../net/minecraft/server/NetServerHandler.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index e7b7190168..c733545df4 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -19,6 +19,7 @@ import org.bukkit.event.Event.Type; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRightClickEvent; +import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerItemEvent; @@ -792,8 +793,21 @@ public class NetServerHandler extends NetHandler implements ICommandListener { j = packet130updatesign.c; TileEntitySign tileentitysign = (TileEntitySign) tileentity; + // CraftBukkit start - SIGN_CHANGE hook + Player player = server.getPlayer(this.e); + SignChangeEvent modifyEvent = new SignChangeEvent(org.bukkit.event.Event.Type.SIGN_CHANGE, (CraftBlock) player.getWorld().getBlockAt(i, k, j), server.getPlayer(this.e), packet130updatesign.d); + server.getPluginManager().callEvent(modifyEvent); + if (modifyEvent.isCancelled()) { + // Normally we would return here, but we have to update the sign with blank text if it's been cancelled + // Otherwise the client will have bad text on their sign (client shows text changes as they type) + for(int l = 0; l < 4; ++l) { + modifyEvent.setLine(l, ""); + } + } + // CraftBukkit end + for (int l = 0; l < 4; ++l) { - tileentitysign.e[l] = packet130updatesign.d[l]; + tileentitysign.e[l] = modifyEvent.getLine(l); // CraftBukkit } tileentitysign.d();