mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Add SIGNS and SPAWNER to MaterialUtil
This commit is contained in:
parent
3db3a272d5
commit
814e5a643e
2 changed files with 11 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue