mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Update EssentialsX Protect with cross-version enum lookups
This commit is contained in:
parent
78fca9a67a
commit
6a529d6671
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.protect;
|
package com.earth2me.essentials.protect;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.utils.EnumUtil;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -12,8 +13,14 @@ import org.bukkit.event.block.BlockFromToEvent;
|
|||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
import org.bukkit.event.world.PortalCreateEvent;
|
import org.bukkit.event.world.PortalCreateEvent;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsProtectBlockListener implements Listener {
|
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 IProtect prot;
|
||||||
final private IEssentials ess;
|
final private IEssentials ess;
|
||||||
|
|
||||||
@ -57,12 +64,12 @@ public class EssentialsProtectBlockListener implements Listener {
|
|||||||
public void onBlockFromTo(final BlockFromToEvent event) {
|
public void onBlockFromTo(final BlockFromToEvent event) {
|
||||||
final Block block = event.getBlock();
|
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));
|
event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_water_flow));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.getType() == Material.LAVA || block.getType() == Material.LAVA) {
|
if (LAVA_TYPES.contains(block.getType())) {
|
||||||
event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_lava_flow));
|
event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_lava_flow));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user