Paper/CraftBukkit-Patches/0017-Prevent-NPE-in-CraftSign.patch

28 lines
1.2 KiB
Diff
Raw Normal View History

From 6c4714ec822f04f5edd10bd57cc8db50df6d3b17 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
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
2015-03-24 21:45:15 +01:00
index 42a6f9a..43adfcc 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
2015-03-24 21:45:15 +01:00
@@ -18,6 +18,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];
2014-11-28 02:17:45 +01:00
System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length);
}
--
2015-05-09 22:23:26 +02:00
2.1.4