From e64ac41fe2a854a339cdc6683dfcb11043e2505d Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 6 Jan 2022 12:40:51 +0100 Subject: [PATCH] Catch more json parse errors --- ...arseException-in-Entity-and-TE-names.patch | 68 ++++++++++--------- ...48-Add-permission-for-command-blocks.patch | 4 +- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/patches/server/0268-Catch-JsonParseException-in-Entity-and-TE-names.patch b/patches/server/0268-Catch-JsonParseException-in-Entity-and-TE-names.patch index 98b477749f..12e1a6bab2 100644 --- a/patches/server/0268-Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/patches/server/0268-Catch-JsonParseException-in-Entity-and-TE-names.patch @@ -48,65 +48,67 @@ index ccdee183f02ab55723e16f41efce55dc51e96297..162aa7718488a74980843944e0d026cc return net.minecraft.server.level.ChunkMap.MAX_VIEW_DISTANCE + net.minecraft.world.level.chunk.ChunkStatus.getDistance(status); } diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -index 04a3627667498b841fbff547d1874d99cc708af4..2e6172930526efc536a214e420e690a5ea42ac3e 100644 +index 04a3627667498b841fbff547d1874d99cc708af4..5b125aa77e769983a0aee7c5f6eb6a8a146fead0 100644 --- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java +++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -@@ -12,6 +12,7 @@ import net.minecraft.commands.CommandSourceStack; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.network.chat.Component; - import net.minecraft.network.chat.TextComponent; -+import net.minecraft.server.MCUtil; - import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.util.StringUtil; -@@ -73,7 +74,7 @@ public abstract class BaseCommandBlock implements CommandSource { +@@ -73,7 +73,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(MCUtil.getBaseComponentFromNbt("CustomName", nbt)); // Paper - Catch ParseException ++ this.setName(net.minecraft.server.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 8854901b439cdeddc528e02fa5f8539869556a3c..c72ec5b38fe8a234eb31065dfa88698dfbb6c054 100644 +index 8854901b439cdeddc528e02fa5f8539869556a3c..aec30b264e2e24ea101f8b3296a93293b4c9eef4 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 -@@ -10,6 +10,7 @@ import net.minecraft.nbt.ListTag; - import net.minecraft.network.chat.Component; - import net.minecraft.network.chat.TranslatableComponent; - import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -+import net.minecraft.server.MCUtil; - import net.minecraft.world.Nameable; - import net.minecraft.world.item.BlockItem; - import net.minecraft.world.item.DyeColor; -@@ -97,7 +98,7 @@ public class BannerBlockEntity extends BlockEntity implements Nameable { +@@ -97,7 +97,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 = MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException ++ this.name = net.minecraft.server.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 cfd1e2fbc029d928daa2d9f12df393c8cf30e850..d9ed3c53187febbc6c835286d6db17b508dbf71a 100644 +index cfd1e2fbc029d928daa2d9f12df393c8cf30e850..72c4c367b3531b21f1f28601735a5250069b8713 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 -@@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.network.chat.Component; - import net.minecraft.network.chat.TranslatableComponent; -+import net.minecraft.server.MCUtil; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; - import net.minecraft.world.Container; -@@ -31,7 +32,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co +@@ -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 = MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException ++ this.name = net.minecraft.server.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 76a401bcfdacded2137142ed38d739ed65d9fae6..7c8809e679670ba0e0ea7a1e193913e45b34a97a 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 +@@ -360,7 +360,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider { + 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 = net.minecraft.server.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 b03621ebd0a94ab2dceb9006aee43fd5320094e3..424ad38b5522d9b76aa1bf726a9fe2c1e934598d 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 +@@ -43,7 +43,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 = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException } } diff --git a/patches/server/0448-Add-permission-for-command-blocks.patch b/patches/server/0448-Add-permission-for-command-blocks.patch index 83a295d0cf..441633c5d4 100644 --- a/patches/server/0448-Add-permission-for-command-blocks.patch +++ b/patches/server/0448-Add-permission-for-command-blocks.patch @@ -40,10 +40,10 @@ index f6007a34b56c80e96aa29def9c070f717b61c5ed..7975508532fc0e97b10eca88e43aefe3 } else { BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level); diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -index 2e6172930526efc536a214e420e690a5ea42ac3e..a71cd95291e593a54c66f5672554f91b0f1470fa 100644 +index 5b125aa77e769983a0aee7c5f6eb6a8a146fead0..fca57e5d1e25db6367c53ad04e49508ebf2223e7 100644 --- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java +++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -@@ -200,7 +200,7 @@ public abstract class BaseCommandBlock implements CommandSource { +@@ -199,7 +199,7 @@ public abstract class BaseCommandBlock implements CommandSource { } public InteractionResult usedBy(Player player) {