Scissors/patches/server/0047-Fix-invalid-armor-trim-exploit.patch

30 lines
2.0 KiB
Diff
Raw Normal View History

2023-06-12 21:28:48 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Mon, 12 Jun 2023 17:32:04 -0300
Subject: [PATCH] Fix invalid armor trim exploit
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
2023-06-28 17:34:31 +00:00
index c92981aedebe934cefa1c96a0328fb91fe17acbc..2eb3705e1efdd62fa176bf4a1ec126181d083505 100644
2023-06-12 21:28:48 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
2023-06-28 17:34:31 +00:00
@@ -68,10 +68,15 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta {
CompoundTag trimCompound = tag.getCompound(TRIM.NBT);
if (trimCompound.contains(TRIM_MATERIAL.NBT, net.minecraft.nbt.Tag.TAG_STRING) && trimCompound.contains(TRIM_PATTERN.NBT, net.minecraft.nbt.Tag.TAG_STRING)) { // Paper - for now, ignore inline definitions of trim material & pattern
- TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(TRIM_MATERIAL.NBT)));
- TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(TRIM_PATTERN.NBT)));
+ // Scissors start
+ NamespacedKey trimMaterialKey = NamespacedKey.fromString(trimCompound.getString(TRIM_MATERIAL.NBT));
+ NamespacedKey trimPatternKey = NamespacedKey.fromString(trimCompound.getString(TRIM_PATTERN.NBT));
2023-06-12 21:28:48 +00:00
- this.trim = new ArmorTrim(trimMaterial, trimPattern);
2023-06-28 17:34:31 +00:00
+ TrimMaterial trimMaterial = trimMaterialKey != null ? Registry.TRIM_MATERIAL.get(trimMaterialKey) : null;
+ TrimPattern trimPattern = trimPatternKey != null ? Registry.TRIM_PATTERN.get(trimPatternKey) : null;
+
+ if (trimMaterial != null && trimPattern != null) this.trim = new ArmorTrim(trimMaterial, trimPattern);
+ // Scissors end
2023-06-12 21:28:48 +00:00
}
}
}