From 0c47f811dccd4c6ec2132a52b6f6c032130d98d5 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sat, 28 Sep 2019 20:09:21 +0300 Subject: [PATCH] Fix issue when users could not select non-block items as icons for challenges and levels. (#190) --- pom.xml | 2 +- .../panel/util/SelectBlocksGUI.java | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 320a870..6ca353c 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ ${build.version}-SNAPSHOT - 0.8.0 + 0.9.0 -LOCAL diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java index d7c6855..2a924e4 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectBlocksGUI.java @@ -28,7 +28,36 @@ public class SelectBlocksGUI public SelectBlocksGUI(User user, boolean singleSelect, BiConsumer> consumer) { - this(user, singleSelect, new HashSet<>(), consumer); + this.consumer = consumer; + this.user = user; + this.singleSelect = singleSelect; + + // Current GUI cannot display air blocks. It crashes with null-pointer + Set excludedMaterial = new HashSet<>(); + + excludedMaterial.add(Material.AIR); + excludedMaterial.add(Material.CAVE_AIR); + excludedMaterial.add(Material.VOID_AIR); + + // Piston head and moving piston is not necessary. useless. + excludedMaterial.add(Material.PISTON_HEAD); + excludedMaterial.add(Material.MOVING_PISTON); + + // Barrier cannot be accessible to user. + excludedMaterial.add(Material.BARRIER); + + this.elements = new ArrayList<>(); + this.selectedMaterials = new HashSet<>(); + + for (Material material : Material.values()) + { + if (!material.isLegacy() && !excludedMaterial.contains(material)) + { + this.elements.add(material); + } + } + + this.build(0); }