From 6c83e59e34bf5e444700f62bb7a7ec710c0f1aa9 Mon Sep 17 00:00:00 2001 From: SamB440 Date: Sun, 5 Jun 2022 21:15:10 +0100 Subject: [PATCH] Allow using just material, fix error if not providing model --- .../net/islandearth/rpgregions/gui/RegionCreateGUI.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rpgregions/src/main/java/net/islandearth/rpgregions/gui/RegionCreateGUI.java b/rpgregions/src/main/java/net/islandearth/rpgregions/gui/RegionCreateGUI.java index e073861..2d133c3 100644 --- a/rpgregions/src/main/java/net/islandearth/rpgregions/gui/RegionCreateGUI.java +++ b/rpgregions/src/main/java/net/islandearth/rpgregions/gui/RegionCreateGUI.java @@ -65,7 +65,7 @@ public class RegionCreateGUI extends RPGRegionsGUI { .withLore("&7Set the material & custom model data of the icon.", "", "&e&lClick &7to set material and icon model.") .build(); model.addItem(new GuiItem(modelItem, event -> { - new ReturnValueConversationPreset(player, "Enter the material and model, split using ':'. Example: TOTEM_OF_UNDYING:1", input -> { + new ReturnValueConversationPreset(player, "Enter the material and/or model, split using ':'. Example: TOTEM_OF_UNDYING:1", input -> { final String[] split = input.split(":"); try { final Optional materialOptional = Enums.getIfPresent(Material.class, split[0]); @@ -75,8 +75,10 @@ public class RegionCreateGUI extends RPGRegionsGUI { return; } - final int potentialModel = Integer.parseInt(split[1]); - region.setIconModel(potentialModel); + try { + final int potentialModel = Integer.parseInt(split[1]); + region.setIconModel(potentialModel); + } catch (IndexOutOfBoundsException ignored) {} region.setIcon(materialOptional.get()); } catch (NumberFormatException e) { player.sendMessage(ChatColor.RED + "'" + split[1] + "' is not a valid number.");