Changed stackableMaterials field to an EnumSet for better performance. Likewise, the getStackableMaterials() method had to have it's return type changed.

This commit is contained in:
theone1000 2019-10-07 21:26:59 -06:00
parent a3ee51d1d8
commit 4dfe31db16
2 changed files with 4 additions and 4 deletions

View File

@ -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"))) {

View File

@ -15,7 +15,7 @@ public class StackableManager {
//ToDO: Should pobably be a GUI for this
private final SkyBlock skyblock;
private List<Material> stackableMaterials = new ArrayList<>();
private Set<Material> stackableMaterials = EnumSet.noneOf(Material.class);
private Map<Location, Stackable> stacks = new HashMap<>();
public StackableManager(SkyBlock skyblock) {
@ -66,8 +66,8 @@ public class StackableManager {
stackableMaterials.clear();
}
public List<Material> getStackableMaterials() {
return Collections.unmodifiableList(stackableMaterials);
public Set<Material> getStackableMaterials() {
return Collections.unmodifiableSet(stackableMaterials);
}
public boolean isStackableMaterial(Material material) {