From 4dfe31db16571df82434d623164c94d25a217d9c Mon Sep 17 00:00:00 2001 From: theone1000 Date: Mon, 7 Oct 2019 21:26:59 -0600 Subject: [PATCH] Changed stackableMaterials field to an EnumSet for better performance. Likewise, the getStackableMaterials() method had to have it's return type changed. --- src/main/java/com/songoda/skyblock/listeners/Interact.java | 2 +- .../com/songoda/skyblock/stackable/StackableManager.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java index 2aa4395c..eac79954 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Interact.java +++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java @@ -141,7 +141,7 @@ public class Interact implements Listener { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (stackableManager != null - && stackableManager.getStackableMaterials().contains(event.getMaterial()) + && stackableManager.isStackableMaterial(event.getMaterial()) && event.getClickedBlock().getType() == event.getMaterial() && !player.isSneaking() && islandManager.hasPermission(player, block.getLocation(), "Place") && (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission") || player.hasPermission("fabledskyblock.stackable"))) { diff --git a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java index 9418526a..4f4bb160 100644 --- a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java +++ b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java @@ -15,7 +15,7 @@ public class StackableManager { //ToDO: Should pobably be a GUI for this private final SkyBlock skyblock; - private List stackableMaterials = new ArrayList<>(); + private Set stackableMaterials = EnumSet.noneOf(Material.class); private Map stacks = new HashMap<>(); public StackableManager(SkyBlock skyblock) { @@ -66,8 +66,8 @@ public class StackableManager { stackableMaterials.clear(); } - public List getStackableMaterials() { - return Collections.unmodifiableList(stackableMaterials); + public Set getStackableMaterials() { + return Collections.unmodifiableSet(stackableMaterials); } public boolean isStackableMaterial(Material material) {