diff --git a/pom.xml b/pom.xml index 2280415..f2dd987 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 timvandijkhuizen spigot-utils - 1.2.3 + 1.2.4 SpigotUtils @@ -62,14 +62,14 @@ org.spigotmc spigot-api - 1.16.1-R0.1-SNAPSHOT + 1.17-R0.1-SNAPSHOT provided com.github.cryptomorin XSeries - 7.5.4 + 8.1.0 \ No newline at end of file diff --git a/src/nl/timvandijkhuizen/spigotutils/config/ConfigOption.java b/src/nl/timvandijkhuizen/spigotutils/config/ConfigOption.java index 5df01a7..a2d70a5 100644 --- a/src/nl/timvandijkhuizen/spigotutils/config/ConfigOption.java +++ b/src/nl/timvandijkhuizen/spigotutils/config/ConfigOption.java @@ -7,6 +7,7 @@ import com.cryptomorin.xseries.XMaterial; import nl.timvandijkhuizen.spigotutils.data.DataArguments; +import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper; import nl.timvandijkhuizen.spigotutils.menu.MenuClick; public class ConfigOption { @@ -32,7 +33,7 @@ public ConfigOption(String path, String name, Material icon, ConfigType type) } public ConfigOption(String path, String name, XMaterial icon, ConfigType type) { - this(path, name, icon.parseMaterial(true), type); + this(path, name, InventoryHelper.parseMaterial(icon), type); } /** diff --git a/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeCurrency.java b/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeCurrency.java index 670701f..7e18c7d 100644 --- a/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeCurrency.java +++ b/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeCurrency.java @@ -1,7 +1,9 @@ package nl.timvandijkhuizen.spigotutils.config.types; import java.util.Currency; +import java.util.Set; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -19,6 +21,10 @@ public class ConfigTypeCurrency implements ConfigType { + private static final Set CURRENCIES = Currency.getAvailableCurrencies().stream() // + .sorted((a, b) -> a.getDisplayName().compareTo(b.getDisplayName())) // + .collect(Collectors.toSet()); + @Override public Currency getValue(OptionConfig config, ConfigOption option) { try { @@ -55,7 +61,7 @@ public void getValueInput(OptionConfig config, ConfigOption option, Me Player player = event.getPlayer(); Currency selected = getValue(config, option); - for (Currency currency : Currency.getAvailableCurrencies()) { + for (Currency currency : CURRENCIES) { MenuItemBuilder item = new MenuItemBuilder(XMaterial.SUNFLOWER); item.setName(UI.color(currency.getDisplayName(), UI.COLOR_PRIMARY, ChatColor.BOLD)); diff --git a/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeList.java b/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeList.java index edbe19d..4b06921 100644 --- a/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeList.java +++ b/src/nl/timvandijkhuizen/spigotutils/config/types/ConfigTypeList.java @@ -19,6 +19,7 @@ import nl.timvandijkhuizen.spigotutils.config.OptionConfig; import nl.timvandijkhuizen.spigotutils.data.TypedValue; import nl.timvandijkhuizen.spigotutils.helpers.ConsoleHelper; +import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper; import nl.timvandijkhuizen.spigotutils.menu.MenuClick; import nl.timvandijkhuizen.spigotutils.menu.items.MenuItemBuilder; import nl.timvandijkhuizen.spigotutils.menu.items.MenuItems; @@ -38,7 +39,7 @@ public ConfigTypeList(Class clazz, String menuTitle, Material menuIcon) { } public ConfigTypeList(Class clazz, String menuTitle, XMaterial menuIcon) { - this(clazz, menuTitle, menuIcon.parseMaterial(true)); + this(clazz, menuTitle, InventoryHelper.parseMaterial(menuIcon)); } public ConfigTypeList(Class clazz, String menuTitle) { diff --git a/src/nl/timvandijkhuizen/spigotutils/helpers/InventoryHelper.java b/src/nl/timvandijkhuizen/spigotutils/helpers/InventoryHelper.java new file mode 100644 index 0000000..4052920 --- /dev/null +++ b/src/nl/timvandijkhuizen/spigotutils/helpers/InventoryHelper.java @@ -0,0 +1,19 @@ +package nl.timvandijkhuizen.spigotutils.helpers; + +import org.bukkit.Material; + +import com.cryptomorin.xseries.XMaterial; + +public class InventoryHelper { + + public static Material parseMaterial(XMaterial material) { + Material output = material.parseMaterial(); + + if(output != null) { + return output; + } + + return Material.BARRIER; + } + +} diff --git a/src/nl/timvandijkhuizen/spigotutils/inventory/ItemBuilder.java b/src/nl/timvandijkhuizen/spigotutils/inventory/ItemBuilder.java index 8a9d1e2..aaf0f4c 100644 --- a/src/nl/timvandijkhuizen/spigotutils/inventory/ItemBuilder.java +++ b/src/nl/timvandijkhuizen/spigotutils/inventory/ItemBuilder.java @@ -18,6 +18,8 @@ import com.cryptomorin.xseries.SkullUtils; import com.cryptomorin.xseries.XMaterial; +import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper; + public class ItemBuilder { protected ItemStack itemStack; @@ -35,7 +37,7 @@ public ItemBuilder(XMaterial material) { } public ItemBuilder(XMaterial material, int amount) { - this(material.parseMaterial(true), amount); + this(InventoryHelper.parseMaterial(material), amount); } public ItemBuilder(ItemStack itemStack) { @@ -69,7 +71,7 @@ public ItemBuilder setType(Material material) { * @return */ public ItemBuilder setType(XMaterial material) { - return setType(material.parseMaterial(true)); + return setType(InventoryHelper.parseMaterial(material)); } /** diff --git a/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItemBuilder.java b/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItemBuilder.java index f2e0cba..b081be6 100644 --- a/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItemBuilder.java +++ b/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItemBuilder.java @@ -11,6 +11,7 @@ import com.cryptomorin.xseries.XMaterial; +import nl.timvandijkhuizen.spigotutils.helpers.InventoryHelper; import nl.timvandijkhuizen.spigotutils.inventory.ItemBuilder; import nl.timvandijkhuizen.spigotutils.menu.MenuClickListener; @@ -44,7 +45,7 @@ public MenuItemBuilder(XMaterial material) { } public MenuItemBuilder(XMaterial material, int amount) { - super(material.parseMaterial(true), amount); + super(InventoryHelper.parseMaterial(material), amount); } public MenuItemBuilder(ItemStack itemStack) { diff --git a/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItems.java b/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItems.java index ecbc995..9f1b923 100644 --- a/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItems.java +++ b/src/nl/timvandijkhuizen/spigotutils/menu/items/MenuItems.java @@ -8,14 +8,14 @@ public class MenuItems { - public static final MenuItemBuilder BACK = new MenuItemBuilder(XMaterial.RED_BED.parseItem(true)).setName(UI.color("Go Back", UI.COLOR_SECONDARY, ChatColor.BOLD)); - public static final MenuItemBuilder CLOSE = new MenuItemBuilder(XMaterial.OAK_DOOR.parseItem(true)).setName(UI.color("Close", ChatColor.RED, ChatColor.BOLD)); - public static final MenuItemBuilder CANCEL = new MenuItemBuilder(XMaterial.GRAY_DYE.parseItem(true)).setName(UI.color("Cancel", ChatColor.GRAY, ChatColor.BOLD)); - public static final MenuItemBuilder SAVE = new MenuItemBuilder(XMaterial.LIME_DYE.parseItem(true)).setName(UI.color("Save", ChatColor.GREEN, ChatColor.BOLD)); - public static final MenuItemBuilder BACKGROUND = new MenuItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem(true)); + public static final MenuItemBuilder BACK = new MenuItemBuilder(XMaterial.RED_BED.parseItem()).setName(UI.color("Go Back", UI.COLOR_SECONDARY, ChatColor.BOLD)); + public static final MenuItemBuilder CLOSE = new MenuItemBuilder(XMaterial.OAK_DOOR.parseItem()).setName(UI.color("Close", ChatColor.RED, ChatColor.BOLD)); + public static final MenuItemBuilder CANCEL = new MenuItemBuilder(XMaterial.GRAY_DYE.parseItem()).setName(UI.color("Cancel", ChatColor.GRAY, ChatColor.BOLD)); + public static final MenuItemBuilder SAVE = new MenuItemBuilder(XMaterial.LIME_DYE.parseItem()).setName(UI.color("Save", ChatColor.GREEN, ChatColor.BOLD)); + public static final MenuItemBuilder BACKGROUND = new MenuItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem()); - public static final MenuItemBuilder PREVIOUS = new MenuItemBuilder(XMaterial.ARROW.parseItem(true)).setName(UI.color("Previous Page", UI.COLOR_SECONDARY, ChatColor.BOLD)); - public static final MenuItemBuilder NEXT = new MenuItemBuilder(XMaterial.ARROW.parseItem(true)).setName(UI.color("Next Page", UI.COLOR_SECONDARY, ChatColor.BOLD)); - public static final MenuItemBuilder CURRENT = new MenuItemBuilder(XMaterial.MAP.parseItem(true)); + public static final MenuItemBuilder PREVIOUS = new MenuItemBuilder(XMaterial.ARROW.parseItem()).setName(UI.color("Previous Page", UI.COLOR_SECONDARY, ChatColor.BOLD)); + public static final MenuItemBuilder NEXT = new MenuItemBuilder(XMaterial.ARROW.parseItem()).setName(UI.color("Next Page", UI.COLOR_SECONDARY, ChatColor.BOLD)); + public static final MenuItemBuilder CURRENT = new MenuItemBuilder(XMaterial.MAP.parseItem()); }