9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-29 03:39:08 +00:00

Allow using just material, fix error if not providing model

This commit is contained in:
SamB440
2022-06-05 21:15:10 +01:00
parent 75e821772d
commit 6c83e59e34

View File

@@ -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<Material> 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.");