2019-04-22 23:36:14 +02:00
|
|
|
From b44e80368f30993e543b9cd43097a5a41118e16f Mon Sep 17 00:00:00 2001
|
2018-09-24 02:10:24 +02:00
|
|
|
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
|
2019-04-22 23:36:14 +02:00
|
|
|
index e38a0d488e..a245df1dce 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -56,7 +56,7 @@ public abstract class CommandBlockListenerAbstract implements ICommandListener {
|
2018-09-24 02:10:24 +02:00
|
|
|
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
|
2019-04-22 23:36:14 +02:00
|
|
|
index c4d4775627..3d90fdb642 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2019-04-05 07:27:37 +02:00
|
|
|
@@ -1745,7 +1745,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2018-09-24 02:10:24 +02:00
|
|
|
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
|
2019-04-22 23:36:14 +02:00
|
|
|
index 0ef5ad1165..f70f5899fa 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
2018-10-05 05:18:46 +02:00
|
|
|
@@ -339,4 +339,19 @@ public final class MCUtil {
|
2018-09-24 02:10:24 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Nullable
|
|
|
|
+ public static IChatBaseComponent getBaseComponentFromNbt(String key, NBTTagCompound compound) {
|
2018-09-24 03:22:57 +02:00
|
|
|
+ if (!compound.hasKey(key)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String string = compound.getString(key);
|
2018-09-24 02:10:24 +02:00
|
|
|
+ try {
|
2018-09-24 03:22:57 +02:00
|
|
|
+ return IChatBaseComponent.ChatSerializer.jsonToComponent(string);
|
|
|
|
+ } catch (com.google.gson.JsonParseException e) {
|
|
|
|
+ org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage());
|
2018-09-24 02:10:24 +02:00
|
|
|
+ }
|
|
|
|
+
|
2018-09-24 03:22:57 +02:00
|
|
|
+ return null;
|
2018-09-24 02:10:24 +02:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityBanner.java b/src/main/java/net/minecraft/server/TileEntityBanner.java
|
2019-04-22 23:36:14 +02:00
|
|
|
index 7d9e0837d8..dfee7332ea 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- 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
|
2019-04-22 23:36:14 +02:00
|
|
|
index a106a783eb..ff8a5926e1 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- 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
|
2019-04-22 23:36:14 +02:00
|
|
|
index 2e0f782f65..77c012946a 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- 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
|
2019-04-22 23:36:14 +02:00
|
|
|
index ddd2e0eb0b..21bd156e91 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- 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
|
2019-04-22 23:36:14 +02:00
|
|
|
index bfbd35bbe5..538ca9bbb4 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -217,7 +217,7 @@ public class TileEntityFurnace extends TileEntityContainer implements IWorldInve
|
2018-09-24 02:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2019-04-22 23:36:14 +02:00
|
|
|
index 7303a6fdda..544dde4289 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -60,7 +60,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2018-09-24 02:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2019-04-22 23:36:14 +02:00
|
|
|
index fedba2e1fd..296b8dd56d 100644
|
2018-09-24 02:10:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityShulkerBox.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityShulkerBox.java
|
2018-12-08 11:09:55 +01:00
|
|
|
@@ -249,7 +249,7 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldIn
|
2018-09-24 02:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
|
|
- this.i = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
|
|
+ this.i = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
--
|
2019-03-20 01:28:15 +01:00
|
|
|
2.21.0
|
2018-09-24 02:10:24 +02:00
|
|
|
|