Skip to content

Commit

Permalink
Update EssentialsX Protect with cross-version enum lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
mdcfe committed Dec 31, 2018
1 parent 78fca9a commit 6a529d6
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.earth2me.essentials.protect;

import com.earth2me.essentials.utils.EnumUtil;
import net.ess3.api.IEssentials;
import org.bukkit.Material;
import org.bukkit.block.Block;
Expand All @@ -12,8 +13,14 @@
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.world.PortalCreateEvent;

import java.util.Set;


public class EssentialsProtectBlockListener implements Listener {

private static final Set<Material> WATER_TYPES = EnumUtil.getAllMatching(Material.class, "WATER", "STATIONARY_WATER");
private static final Set<Material> LAVA_TYPES = EnumUtil.getAllMatching(Material.class, "LAVA", "STATIONARY_LAVA");

final private IProtect prot;
final private IEssentials ess;

Expand Down Expand Up @@ -57,12 +64,12 @@ public void onBlockIgnite(BlockIgniteEvent event) {
public void onBlockFromTo(final BlockFromToEvent event) {
final Block block = event.getBlock();

if (block.getType() == Material.WATER || block.getType() == Material.WATER) {
if (WATER_TYPES.contains(block.getType())) {
event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_water_flow));
return;
}

if (block.getType() == Material.LAVA || block.getType() == Material.LAVA) {
if (LAVA_TYPES.contains(block.getType())) {
event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_lava_flow));
return;
}
Expand Down

0 comments on commit 6a529d6

Please sign in to comment.