Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
c0936a71bd
Upstream has released updates that appear 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: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
115 Zeilen
6.4 KiB
Diff
115 Zeilen
6.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/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
index 77da7a3b51c500ff251f776acc85a752a99fb356..2d11a67bdc82088abf0b3ca134f352f155c8eb1f 100644
|
|
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
@@ -15,6 +15,8 @@ import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.server.MinecraftServer;
|
|
+import net.minecraft.nbt.CompoundTag;
|
|
+import net.minecraft.network.chat.Component;
|
|
import net.minecraft.server.level.ChunkHolder;
|
|
import net.minecraft.server.level.ChunkMap;
|
|
import net.minecraft.server.level.DistanceManager;
|
|
@@ -534,6 +536,21 @@ public final class MCUtil {
|
|
}
|
|
}
|
|
|
|
+ @Nullable
|
|
+ public static Component getBaseComponentFromNbt(String key, CompoundTag compound) {
|
|
+ if (!compound.contains(key)) {
|
|
+ return null;
|
|
+ }
|
|
+ String string = compound.getString(key);
|
|
+ try {
|
|
+ return Component.Serializer.fromJson(string);
|
|
+ } catch (com.google.gson.JsonParseException e) {
|
|
+ org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage());
|
|
+ }
|
|
+
|
|
+ return null;
|
|
+ }
|
|
+
|
|
public static ChunkStatus getChunkStatus(ChunkHolder chunk) {
|
|
return chunk.getChunkHolderStatus();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
|
index 7f1efe0d9bc059a86166e8e3c5ef4ad23217f6a7..9c7b7434ccd64668eb5d7bb61d03a9cb4105ea6e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
|
@@ -72,7 +72,7 @@ public abstract class BaseCommandBlock implements CommandSource {
|
|
this.command = nbt.getString("Command");
|
|
this.successCount = nbt.getInt("SuccessCount");
|
|
if (nbt.contains("CustomName", 8)) {
|
|
- this.setName(Component.Serializer.fromJson(nbt.getString("CustomName")));
|
|
+ this.setName(io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt)); // Paper - Catch ParseException
|
|
}
|
|
|
|
if (nbt.contains("TrackOutput", 1)) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
|
|
index 6b983e3e867bdd8cdffaf4575bbf67ad96b57ec7..66e2137f9379e885294f2b9f67f7e35296792770 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
|
|
@@ -98,7 +98,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
|
|
public void load(CompoundTag nbt) {
|
|
super.load(nbt);
|
|
if (nbt.contains("CustomName", 8)) {
|
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
|
}
|
|
|
|
this.itemPatterns = nbt.getList("Patterns", 10);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
|
index e85022b31f2bc2783e88f5ba4c5173ac8a096c96..f1acd19432877a833f0d4339f9de4830a0f7b890 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
|
@@ -31,7 +31,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
|
|
super.load(nbt);
|
|
this.lockKey = LockCode.fromTag(nbt);
|
|
if (nbt.contains("CustomName", 8)) {
|
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
index 8b79df496e1fad57e8c5c0aa97d0d84ab0deed1e..154e4652a93b50e9b26c93531a4e854601ed75e1 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
@@ -367,7 +367,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
|
this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available
|
|
// CraftBukkit end
|
|
if (nbt.contains("CustomName", 8)) {
|
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
|
}
|
|
|
|
this.lockKey = LockCode.fromTag(nbt);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
|
index 3a8bdb788b07b0a8cda3d4b872ede52ca9a005c4..65e1381bb2d10bd212463feb602c60f8fdb9ade1 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
|
@@ -42,7 +42,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable
|
|
public void load(CompoundTag nbt) {
|
|
super.load(nbt);
|
|
if (nbt.contains("CustomName", 8)) {
|
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
|
}
|
|
|
|
}
|