From 2c0f8094c0c614a6d93bf4f63413d915ae53c8d1 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Tue, 24 May 2022 13:33:20 +0200 Subject: [PATCH] Reduced confusion for config items --- .../java/net/Indyuce/mmocore/util/item/ConfigItem.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/util/item/ConfigItem.java b/src/main/java/net/Indyuce/mmocore/util/item/ConfigItem.java index f778f7b6..50693c73 100644 --- a/src/main/java/net/Indyuce/mmocore/util/item/ConfigItem.java +++ b/src/main/java/net/Indyuce/mmocore/util/item/ConfigItem.java @@ -1,11 +1,13 @@ package net.Indyuce.mmocore.util.item; +import io.lumine.mythic.lib.UtilityMethods; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import javax.annotation.Nullable; import java.util.List; +import java.util.Objects; public class ConfigItem { private final String name, id, texture; @@ -15,10 +17,12 @@ public class ConfigItem { private final boolean unbreakable; public ConfigItem(ConfigurationSection config) { - id = config.getName(); + id = UtilityMethods.enumName(config.getName()); name = config.getString("name"); lore = config.getStringList("lore"); - material = Material.valueOf(config.getString("item")); + String itemFormat = Objects.requireNonNull(config.getString("item"), "Could not find item material"); + Validate.isTrue(!itemFormat.contains(":"), "Invalid custom model data format, please use 'custom-model-data: X' instead"); + material = Material.valueOf(UtilityMethods.enumName(itemFormat)); Validate.notNull(name, "Name cannot be null"); Validate.notNull(lore, "Lore can be empty but not null");