Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
36f34f01c0
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 Bukkit Changes: da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots 3abebc9f #492: Let Tameable extend Animals rather than Entity 941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent 4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME CraftBukkit Changes:933e9094
#664: Add methods to get/set ItemStacks in EquipmentSlots18722312
#662: Expose ItemStack and hand used in PlayerShearEntityEvent
91 Zeilen
5.1 KiB
Diff
91 Zeilen
5.1 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/CommandBlockListenerAbstract.java b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
|
index 786712297435fed5247abd577efd092bcb9c44cb..ef2a496eda45ae5ee8fe52ef09e77c2906069d2e 100644
|
|
--- a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java
|
|
@@ -59,7 +59,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/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 09bb8676c3b0b737f7ff483a54ec2f4713ba174c..8d3140871fd750bbb5d7c7f920917ae356890aeb 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1679,7 +1679,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
this.Z();
|
|
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 9d0b0c9fc3c9e5e73506a43d7195b139cbcb30cf..3342278bcd42a6d5a1793e33bc7fe4356be02451 100644
|
|
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
|
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
|
@@ -437,4 +437,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 93911a825154d04dd3f1495b1bab5a3ab2aea30b..d35604edb21441032bce87d658b76b39fea917fc 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityBanner.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityBanner.java
|
|
@@ -60,7 +60,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/TileEntityContainer.java b/src/main/java/net/minecraft/server/TileEntityContainer.java
|
|
index 473ec2cbde5b31398f57bf9ab7034139572fa666..ab6b86e4e9f99a60140187c06480cf511327a710 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityContainer.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityContainer.java
|
|
@@ -17,7 +17,7 @@ public abstract class TileEntityContainer extends TileEntity implements IInvento
|
|
super.load(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
|
|
}
|
|
|
|
}
|