Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
1718f61bf8
Doesn't compile yet. CraftBukkit Changes: 90d6905b Repackage NMS 69cf961d Repackage patches Spigot Changes: 79d53c28 Repackage NMS
78 Zeilen
4.4 KiB
Diff
78 Zeilen
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 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/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
|
index cd7dc7d90efddb8a1bb50cd964b43d18cf9c83d1..67806eaab081e938cd99a0d74225b1b7744ff2d7 100644
|
|
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
|
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
|
@@ -514,4 +514,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/world/level/CommandBlockListenerAbstract.java b/src/main/java/net/minecraft/world/level/CommandBlockListenerAbstract.java
|
|
index 94adf4d3b3a367e2a7fa383f1da6fb3b02b35c85..0f966c5defdda58fd7d31072b625f16928cddeb7 100644
|
|
--- a/src/main/java/net/minecraft/world/level/CommandBlockListenerAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/level/CommandBlockListenerAbstract.java
|
|
@@ -72,7 +72,7 @@ public abstract class CommandBlockListenerAbstract implements ICommandListener {
|
|
this.command = nbttagcompound.getString("Command");
|
|
this.successCount = nbttagcompound.getInt("SuccessCount");
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.setName(IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName")));
|
|
+ this.setName(MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound)); // Paper - Catch ParseException
|
|
}
|
|
|
|
if (nbttagcompound.hasKeyOfType("TrackOutput", 1)) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBanner.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBanner.java
|
|
index fd8d39d04f39ea8aa389deb66ca0ddaa3e282c40..e2d3ade6565b10ebed3c001f4a1c5bbb3a7f0b12 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBanner.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBanner.java
|
|
@@ -70,7 +70,7 @@ public class TileEntityBanner extends TileEntity implements INamableTileEntity {
|
|
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
|
|
super.load(iblockdata, 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/world/level/block/entity/TileEntityContainer.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityContainer.java
|
|
index 19739ad1fb01c767288da2667a48909e4c1c36cc..5841422beb972f28fb9e9d10bcf711b2c20a4bb0 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityContainer.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityContainer.java
|
|
@@ -30,7 +30,7 @@ public abstract class TileEntityContainer extends TileEntity implements IInvento
|
|
super.load(iblockdata, nbttagcompound);
|
|
this.chestLock = ChestLock.b(nbttagcompound);
|
|
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
|
- this.customName = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
|
+ this.customName = MCUtil.getBaseComponentFromNbt("CustomName", nbttagcompound); // Paper - Catch ParseException
|
|
}
|
|
|
|
}
|