From aa4bb3d8e4221e7349cda1d0671737fd7d4065c6 Mon Sep 17 00:00:00 2001 From: BONNe Date: Mon, 20 Sep 2021 11:49:39 +0300 Subject: [PATCH] Update missing icons for blocks. Some blocks cannot be displayed in GUI's, and were leaving empty spaces. This replaces their icon with a close representative. Fixes #286 --- .../bentobox/challenges/utils/GuiUtils.java | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/utils/GuiUtils.java b/src/main/java/world/bentobox/challenges/utils/GuiUtils.java index 2e6da65..129bc21 100644 --- a/src/main/java/world/bentobox/challenges/utils/GuiUtils.java +++ b/src/main/java/world/bentobox/challenges/utils/GuiUtils.java @@ -254,12 +254,27 @@ public class GuiUtils if (material.name().contains("WALL_")) { // Materials that is attached to wall cannot be showed in GUI. But they should be in list. - itemStack = new ItemStack(Material.getMaterial(material.name().replace("WALL_", ""))); + + Material newMaterial = Material.getMaterial(material.name().replace("WALL_", "")); + itemStack = new ItemStack(Objects.requireNonNullElse(newMaterial, material)); + } + else if (material.equals(Material.POTTED_AZALEA_BUSH)) + { + return new ItemStack(Material.AZALEA); + } + else if (material.equals(Material.POTTED_FLOWERING_AZALEA_BUSH)) + { + return new ItemStack(Material.FLOWERING_AZALEA); } else if (material.name().startsWith("POTTED_")) { // Materials Potted elements cannot be in inventory. - itemStack = new ItemStack(Material.getMaterial(material.name().replace("POTTED_", ""))); + Material newMaterial = Material.getMaterial(material.name().replace("POTTED_", "")); + itemStack = new ItemStack(Objects.requireNonNullElse(newMaterial, material)); + } + else if (material.name().endsWith("CAULDRON")) + { + itemStack = new ItemStack(Material.CAULDRON); } else if (material.equals(Material.MELON_STEM) || material.equals(Material.ATTACHED_MELON_STEM)) { @@ -289,9 +304,16 @@ public class GuiUtils { itemStack = new ItemStack(Material.COCOA_BEANS); } - else if (material.equals(Material.KELP_PLANT)) + else if (material.equals(Material.CAVE_VINES) || material.equals(Material.CAVE_VINES_PLANT)) { - itemStack = new ItemStack(Material.KELP); + // Process cave vines as they are glow berries + itemStack = new ItemStack(Material.GLOW_BERRIES); + } + else if (material.name().endsWith("_PLANT")) + { + // Plants cannot be displayed in GUI's. + Material newMaterial = Material.getMaterial(material.name().replace("_PLANT", "")); + itemStack = new ItemStack(Objects.requireNonNullElse(newMaterial, material)); } else if (material.equals(Material.REDSTONE_WIRE)) { @@ -329,6 +351,26 @@ public class GuiUtils { itemStack = new ItemStack(Material.PISTON); } + else if (material.equals(Material.BAMBOO_SAPLING)) + { + itemStack = new ItemStack(Material.BAMBOO); + } + else if (material.equals(Material.SWEET_BERRY_BUSH)) + { + itemStack = new ItemStack(Material.SWEET_BERRIES); + } + else if (material.name().contains("CANDLE_CAKE")) + { + itemStack = new ItemStack(Material.CAKE); + } + else if (material.equals(Material.POWDER_SNOW)) + { + itemStack = new ItemStack(Material.POWDER_SNOW_BUCKET); + } + else if (material.equals(Material.BIG_DRIPLEAF_STEM)) + { + itemStack = new ItemStack(Material.BIG_DRIPLEAF); + } else { itemStack = new ItemStack(material);