Add custom model data support for kits (#5433)

This commit is contained in:
YanisBft 2023-08-06 01:38:43 +02:00 committed by GitHub
parent 7eed853294
commit 2b993d58cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -206,6 +206,13 @@ public class MetaItemStack {
final ItemMeta meta = stack.getItemMeta();
meta.setLore(lore);
stack.setItemMeta(meta);
} else if ((split[0].equalsIgnoreCase("custom-model-data") || split[0].equalsIgnoreCase("cmd")) && hasMetaPermission(sender, "custom-model-data", false, true, ess)) {
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_14_R01)) {
final int value = split.length <= 1 ? 0 : Integer.parseInt(split[1]);
final ItemMeta meta = stack.getItemMeta();
meta.setCustomModelData(value);
stack.setItemMeta(meta);
}
} else if (split[0].equalsIgnoreCase("unbreakable") && hasMetaPermission(sender, "unbreakable", false, true, ess)) {
final boolean value = split.length <= 1 || Boolean.parseBoolean(split[1]);
setUnbreakable(ess, stack, value);

View File

@ -214,6 +214,12 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
sb.append("lore:").append(serializeLines(meta.getLore())).append(" ");
}
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_14_R01)) {
if (meta.hasCustomModelData()) {
sb.append("custom-model-data:").append(meta.getCustomModelData()).append(" ");
}
}
if (meta.hasEnchants()) {
for (final Enchantment e : meta.getEnchants().keySet()) {
sb.append(e.getName().toLowerCase()).append(":").append(meta.getEnchantLevel(e)).append(" ");