Add SIGNS and SPAWNER to MaterialUtil

This commit is contained in:
md678685 2018-12-09 13:47:22 +00:00
parent 3db3a272d5
commit 814e5a643e
2 changed files with 11 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials;
import com.earth2me.essentials.utils.EnumUtil;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.MaterialUtil;
import net.ess3.api.IEssentials;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -29,12 +30,12 @@ public class EssentialsBlockListener implements Listener {
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
final ItemStack is = LocationUtil.convertBlockToItem(event.getBlockPlaced());
if (is == null) {
return;
}
Material MOB_SPAWNER = EnumUtil.getMaterial("SPAWNER", "MOB_SPAWNER");
if (is.getType() == MOB_SPAWNER && event.getItemInHand() != null && event.getPlayer() != null && event.getItemInHand().getType() == MOB_SPAWNER) {
if (is.getType() == MaterialUtil.SPAWNER && event.getItemInHand() != null && event.getPlayer() != null && event.getItemInHand().getType() == MaterialUtil.SPAWNER) {
final BlockState blockState = event.getBlockPlaced().getState();
if (blockState instanceof CreatureSpawner) {
final CreatureSpawner spawner = (CreatureSpawner) blockState;

View File

@ -16,6 +16,9 @@ public class MaterialUtil {
// includes TIPPED_ARROW which also has potion effects
private static final Set<Material> PLAYER_HEADS;
private static final Set<Material> POTIONS;
private static final Set<Material> SIGNS;
public static final Material SPAWNER = EnumUtil.getMaterial("MOB_SPAWNER", "SPAWNER");
static {
@ -47,6 +50,7 @@ public class MaterialUtil {
POTIONS = EnumUtil.getAllMatching(Material.class, "POTION", "SPLASH_POTION",
"LINGERING_POTION", "TIPPED_ARROW");
SIGNS = EnumUtil.getAllMatching(Material.class, "SIGN", "SIGN_POST", "WALL_SIGN");
}
public static boolean isBed(Material material) {
@ -85,6 +89,10 @@ public class MaterialUtil {
return POTIONS.contains(material);
}
public static boolean isSign(Material material) {
return SIGNS.contains(material);
}
public static boolean isSkull(Material material) {
return isPlayerHead(material, -1) || isMobHead(material, -1);
}