2013-04-23 01:27:55 +00:00
From 856c80c7445ba24d8b55291fa8f7c9dae9dec58b Mon Sep 17 00:00:00 2001
2013-03-18 09:02:03 +00:00
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
2013-04-03 07:20:29 +00:00
index 1647100..43c4434 100644
2013-03-18 09:02:03 +00:00
--- 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) {
2013-03-18 09:33:22 +00:00
+ lines = new String[]{"", "", "", ""};
2013-03-18 09:02:03 +00:00
+ 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 {
2013-04-03 07:20:29 +00:00
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
2013-03-18 09:02:03 +00:00
- if (result) {
+ if (result && sign != null) { // Spigot, add null check
for(int i = 0; i < 4; i++) {
if(lines[i] != null) {
sign.lines[i] = lines[i];
--
2013-04-10 02:36:11 +00:00
1.8.2.1
2013-03-18 09:02:03 +00:00