Catch more json parse errors

This commit is contained in:
Nassim Jahnke 2022-01-06 12:40:51 +01:00
parent 2d1c799f5a
commit a3e86aeb04

View file

@ -51,20 +51,12 @@ diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java --- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java +++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ public abstract class BaseCommandBlock implements CommandSource { @@ -0,0 +0,0 @@ public abstract class BaseCommandBlock implements CommandSource {
this.command = nbt.getString("Command"); this.command = nbt.getString("Command");
this.successCount = nbt.getInt("SuccessCount"); this.successCount = nbt.getInt("SuccessCount");
if (nbt.contains("CustomName", 8)) { if (nbt.contains("CustomName", 8)) {
- this.setName(Component.Serializer.fromJson(nbt.getString("CustomName"))); - 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)) { if (nbt.contains("TrackOutput", 1)) {
@ -72,20 +64,12 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEnt
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ public class BannerBlockEntity extends BlockEntity implements Nameable { @@ -0,0 +0,0 @@ public class BannerBlockEntity extends BlockEntity implements Nameable {
public void load(CompoundTag nbt) { public void load(CompoundTag nbt) {
super.load(nbt); super.load(nbt);
if (nbt.contains("CustomName", 8)) { if (nbt.contains("CustomName", 8)) {
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName")); - 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); this.itemPatterns = nbt.getList("Patterns", 10);
@ -93,20 +77,38 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerB
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co @@ -0,0 +0,0 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
super.load(nbt); super.load(nbt);
this.lockKey = LockCode.fromTag(nbt); this.lockKey = LockCode.fromTag(nbt);
if (nbt.contains("CustomName", 8)) { if (nbt.contains("CustomName", 8)) {
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName")); - 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
@@ -0,0 +0,0 @@ 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
} }
} }