diff options
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftSign.java | 22 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 22 |
2 files changed, 37 insertions, 7 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java index 16471009..77717d5b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -35,16 +35,24 @@ public class CraftSign extends CraftBlockState implements Sign { boolean result = super.update(force, applyPhysics); if (result) { - for(int i = 0; i < 4; i++) { - if(lines[i] != null) { - sign.lines[i] = lines[i]; - } else { - sign.lines[i] = ""; - } - } + sign.lines = sanitizeLines(lines); sign.update(); } return result; } + + public static String[] sanitizeLines(String[] lines) { + String[] astring = new String[4]; + + for (int i = 0; i < 4; i++) { + if (i < lines.length && lines[i] != null) { + astring[i] = lines[i]; + } else { + astring[i] = ""; + } + } + + return TileEntitySign.sanitizeLines(astring); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 4c193709..17c16dc6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -31,6 +31,7 @@ import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.conversations.Conversation; import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.conversations.ManuallyAbandonedConversationCanceller; +import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.craftbukkit.conversations.ConversationTracker; import org.bukkit.craftbukkit.CraftEffect; import org.bukkit.craftbukkit.CraftOfflinePlayer; @@ -369,6 +370,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } @Override + public void sendSignChange(Location loc, String[] lines) { + if (getHandle().playerConnection == null) { + return; + } + + if (lines == null) { + lines = new String[4]; + } + + Validate.notNull(loc, "Location can not be null"); + if (lines.length < 4) { + throw new IllegalArgumentException("Must have at least 4 lines"); + } + + // Limit to 15 chars per line and set null lines to blank + String[] astring = CraftSign.sanitizeLines(lines); + + getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateSign(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), astring)); + } + + @Override public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) { if (getHandle().playerConnection == null) return false; |