Fix creating and using kits on legacy versions (#2428)

* Attempt to look up legacy items in Material enum
* Use name method when serializing ItemStacks
* Make name uppercase before looking up in Material enum
This commit is contained in:
md678685 2019-02-20 12:24:07 +00:00 committed by GitHub
parent aca83bd462
commit 9e73c29b40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -64,7 +64,7 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
@Override
public String serialize(ItemStack is) {
String mat = is.getType().name();
String mat = name(is);
if (VersionUtil.getServerBukkitVersion().isLowerThanOrEqualTo(VersionUtil.v1_12_2_R01) && is.getData().getData() != 0) {
mat = mat + ":" + is.getData().getData();
}

View File

@ -150,6 +150,13 @@ public class LegacyItemDb extends AbstractItemDb {
}
}
if (itemid < 1) {
Material matFromName = EnumUtil.getMaterial(itemname.toUpperCase());
if (matFromName != null) {
itemid = matFromName.getId();
}
}
if (itemid < 1) {
throw new Exception(tl("unknownItemName", itemname));
}