geforkt von Mirrors/Paper
SPIGOT-4292: Ignore itemstacks with invalid enchants
Dieser Commit ist enthalten in:
Ursprung
bfb9131494
Commit
82f4b3b1d9
@ -299,7 +299,10 @@ public final class CraftItemStack extends ItemStack {
|
||||
String id = ((NBTTagCompound) list.get(i)).getString(ENCHANTMENTS_ID.NBT);
|
||||
int level = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
|
||||
|
||||
result.put(Enchantment.getByKey(CraftNamespacedKey.fromString(id)), level);
|
||||
Enchantment enchant = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(id));
|
||||
if (enchant != null) {
|
||||
result.put(enchant, level);
|
||||
}
|
||||
}
|
||||
|
||||
return result.build();
|
||||
|
@ -381,7 +381,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
String id = ((NBTTagCompound) ench.get(i)).getString(ENCHANTMENTS_ID.NBT);
|
||||
int level = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
|
||||
|
||||
Enchantment enchant = Enchantment.getByKey(CraftNamespacedKey.fromString(id));
|
||||
Enchantment enchant = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(id));
|
||||
if (enchant != null) {
|
||||
enchantments.put(enchant, level);
|
||||
}
|
||||
|
@ -8,6 +8,11 @@ public final class CraftNamespacedKey {
|
||||
public CraftNamespacedKey() {
|
||||
}
|
||||
|
||||
public static NamespacedKey fromStringOrNull(String string) {
|
||||
MinecraftKey minecraft = MinecraftKey.a(string);
|
||||
return (minecraft == null) ? null : fromMinecraft(minecraft);
|
||||
}
|
||||
|
||||
public static NamespacedKey fromString(String string) {
|
||||
return fromMinecraft(new MinecraftKey(string));
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren