diff options
Diffstat (limited to 'CraftBukkit-Patches/0020-Prevent-NPE-in-CraftSign.patch')
-rw-r--r-- | CraftBukkit-Patches/0020-Prevent-NPE-in-CraftSign.patch | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/CraftBukkit-Patches/0020-Prevent-NPE-in-CraftSign.patch b/CraftBukkit-Patches/0020-Prevent-NPE-in-CraftSign.patch new file mode 100644 index 0000000000..af762a88fc --- /dev/null +++ b/CraftBukkit-Patches/0020-Prevent-NPE-in-CraftSign.patch @@ -0,0 +1,36 @@ +From 698f2c000fd05d342681ad20420f54e2d281b201 Mon Sep 17 00:00:00 2001 +From: md_5 <[email protected]> +Date: Mon, 18 Mar 2013 20:01:44 +1100 +Subject: [PATCH] Prevent NPE in CraftSign + +This commit prevents the constructor of CraftSign throwing an NPE when it cannot get the sign tile entity. Instead it will fallback to a 4 empty lined sign, and not try to do anything to those lines on .update(). + +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +index 77717d5..1533dd4 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +@@ -14,6 +14,12 @@ public class CraftSign extends CraftBlockState implements Sign { + + CraftWorld world = (CraftWorld) block.getWorld(); + sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ()); ++ // Spigot start ++ if (sign == null) { ++ lines = new String[]{"", "", "", ""}; ++ return; ++ } ++ // Spigot end + lines = new String[sign.lines.length]; + System.arraycopy(sign.lines, 0, lines, 0, lines.length); + } +@@ -34,7 +40,7 @@ public class CraftSign extends CraftBlockState implements Sign { + public boolean update(boolean force, boolean applyPhysics) { + boolean result = super.update(force, applyPhysics); + +- if (result) { ++ if (result && sign != null) { // Spigot, add null check + sign.lines = sanitizeLines(lines); + sign.update(); + } +-- +1.9.1 + |