mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 07:48:53 +01:00
0976d52bbd
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Please note that this build includes changes to meet upstreams requirements for nullability annotations. While we aim for a level of accuracy, these might not be 100% correct, if there are any issues, please speak to us on discord, or open an issue on the tracker to discuss. Bukkit Changes: 9a6a1de3 Remove nullability annotations from enum constructors 3f0591ea SPIGOT-2540: Add nullability annotations to entire Bukkit API CraftBukkit Changes:8d8475fc
SPIGOT-4666: Force parameter in HumanEntity#sleep8b1588e2
Fix ExplosionPrimeEvent#setFire not working with EnderCrystals39a287b7
Don't ignore newlines in PlayerListHeader/Footer Spigot Changes: cf694d87 Add nullability annotations
158 lines
8.3 KiB
Diff
158 lines
8.3 KiB
Diff
From a474fdc7768a5473ece227a6c037f4a2b552c01d Mon Sep 17 00:00:00 2001
|
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
Date: Sat, 22 Sep 2018 15:56:59 -0400
|
|
Subject: [PATCH] Catch JsonParseException in Entity and TE names
|
|
|
|
As a result, data that no longer parses correctly will not crash the server
|
|
instead just logging the exception and continuing (and in most cases should
|
|
fix the data)
|
|
|
|
Player data is fixed pretty much immediately but some block data (like
|
|
Shulkers) may need to be changed in order for it to re-save properly
|
|
|
|
No more crashing though.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
|
index e38a0d488..a245df1dc 100644
|
|
--- a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
|
@@ -56,7 +56,7 @@ public abstract class CommandBlockListenerAbstract implements ICommandListener {
|
|
this.g = nbttagcompound.getString("Command");
|
|
this.d = nbttagcompound.getInt("SuccessCount");
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.h = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.h = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
if (nbttagcompound.hasKeyOfType("TrackOutput", 1)) {
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index acd89649c..49ddb9715 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1742,7 +1742,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
|
this.setYawPitch(this.yaw, this.pitch);
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.setCustomName(IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName")));
|
|
+ this.setCustomName(MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound)); // Paper - Catch ParseException
|
|
}
|
|
|
|
this.setCustomNameVisible(nbttagcompound.getBoolean("CustomNameVisible"));
|
|
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
|
index 0ef5ad116..f70f5899f 100644
|
|
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
|
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
|
@@ -339,4 +339,19 @@ public final class MCUtil {
|
|
return null;
|
|
}
|
|
}
|
|
+
|
|
+ @Nullable
|
|
+ public static IChatBaseComponent getBaseComponentFromNbt(String key, NBTTagCompound compound) {
|
|
+ if (!compound.hasKey(key)) {
|
|
+ return null;
|
|
+ }
|
|
+ String string = compound.getString(key);
|
|
+ try {
|
|
+ return IChatBaseComponent.ChatSerializer.jsonToComponent(string);
|
|
+ } catch (com.google.gson.JsonParseException e) {
|
|
+ org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage());
|
|
+ }
|
|
+
|
|
+ return null;
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityBanner.java b/src/main/java/net/minecraft/server/TileEntityBanner.java
|
|
index 7d9e0837d..dfee7332e 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityBanner.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityBanner.java
|
|
@@ -74,7 +74,7 @@ public class TileEntityBanner extends TileEntity implements INamableTileEntity {
|
|
public void load(NBTTagCompound nbttagcompound) {
|
|
super.load(nbttagcompound);
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.a = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.a = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
if (this.hasWorld()) {
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityBrewingStand.java b/src/main/java/net/minecraft/server/TileEntityBrewingStand.java
|
|
index a106a783e..ff8a5926e 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityBrewingStand.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityBrewingStand.java
|
|
@@ -236,7 +236,7 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorl
|
|
ContainerUtil.b(nbttagcompound, this.items);
|
|
this.brewTime = nbttagcompound.getShort("BrewTime");
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.k = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.k = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
this.fuelLevel = nbttagcompound.getByte("Fuel");
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
index 2e0f782f6..77c012946 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
|
|
@@ -83,7 +83,7 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic
|
|
}
|
|
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.i = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.i = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityDispenser.java b/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
|
index ddd2e0eb0..21bd156e9 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
|
@@ -107,7 +107,7 @@ public class TileEntityDispenser extends TileEntityLootable {
|
|
}
|
|
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.i = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.i = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
index bfbd35bbe..538ca9bbb 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
@@ -217,7 +217,7 @@ public class TileEntityFurnace extends TileEntityContainer implements IWorldInve
|
|
}
|
|
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.l = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.l = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
// Paper start - cook speed API
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
index 7303a6fdd..544dde428 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
@@ -60,7 +60,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
}
|
|
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.setCustomName(IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName")));
|
|
+ this.setCustomName(MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound)); // Paper - Catch ParseException
|
|
}
|
|
|
|
this.f = nbttagcompound.getInt("TransferCooldown");
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityShulkerBox.java b/src/main/java/net/minecraft/server/TileEntityShulkerBox.java
|
|
index fedba2e1f..296b8dd56 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityShulkerBox.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityShulkerBox.java
|
|
@@ -249,7 +249,7 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldIn
|
|
}
|
|
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.i = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.i = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
}
|
|
--
|
|
2.21.0
|
|
|