mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
e7f3ca4505
Allows us much greater control over the Spigot portion of the code and makes us more "proper" Credit to @Dmck2b for originally passing the idea along a while back
34 lines
No EOL
1.6 KiB
Diff
34 lines
No EOL
1.6 KiB
Diff
From 0000000000000000000000000000000000000000 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
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
|
@@ -0,0 +0,0 @@ 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);
|
|
}
|
|
@@ -0,0 +0,0 @@ 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();
|
|
}
|
|
--
|