Fix issue when users could not select non-block items as icons for challenges and levels. (#190)

This commit is contained in:
BONNe 2019-09-28 20:09:21 +03:00
parent 29a5057535
commit 0c47f811dc
2 changed files with 31 additions and 2 deletions

View File

@ -42,7 +42,7 @@
<!-- Revision variable removes warning about dynamic version --> <!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision> <revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. --> <!-- This allows to change between versions and snapshots. -->
<build.version>0.8.0</build.version> <build.version>0.9.0</build.version>
<build.number>-LOCAL</build.number> <build.number>-LOCAL</build.number>
</properties> </properties>

View File

@ -28,7 +28,36 @@ public class SelectBlocksGUI
public SelectBlocksGUI(User user, boolean singleSelect, BiConsumer<Boolean, Set<Material>> consumer) public SelectBlocksGUI(User user, boolean singleSelect, BiConsumer<Boolean, Set<Material>> 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<Material> 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);
} }