13
0
geforkt von Mirrors/Paper

SPIGOT-4292: Ignore itemstacks with invalid enchants

Dieser Commit ist enthalten in:
md_5 2018-08-20 12:49:31 +10:00
Ursprung bfb9131494
Commit 82f4b3b1d9
3 geänderte Dateien mit 10 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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();

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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));
}