fix: 1.13+ Material Error

Signed-off-by: MiaoWoo <admin@yumc.pw>
merge/16/MERGE
MiaoWoo 2020-04-10 00:56:39 +08:00
parent c7867ed835
commit d438c9a5f1
1 changed files with 10 additions and 8 deletions

View File

@ -104,16 +104,18 @@ public class L10N {
private static String getItemType(ItemStack i) {
String name = i.getType().name();
String dura = "";
if (i.getType() == Material.MONSTER_EGG) {
try {
name = ((SpawnEgg) i.getData()).getSpawnedType().name();
} catch (NullPointerException npe) {
name = ((SpawnEggMeta) i.getItemMeta()).getSpawnedType().name();
try {
if (i.getType() == Material.MONSTER_EGG) {
try {
name = ((SpawnEgg) i.getData()).getSpawnedType().name();
} catch (NullPointerException npe) {
name = ((SpawnEggMeta) i.getItemMeta()).getSpawnedType().name();
}
}
} else {
int dur = i.getDurability();
dura = (i.getMaxStackSize() != 1 && dur != 0) ? Integer.toString(dur) : "";
} catch (Throwable ignored) {
}
int dur = i.getDurability();
dura = (i.getMaxStackSize() != 1 && dur != 0) ? Integer.toString(dur) : "";
return (name + (dura.isEmpty() ? "" : "-" + dura)).toUpperCase();
}