From b30f7fe9c7495cb27ca2e4bb5d58e8895b78e671 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Sat, 31 Dec 2011 17:57:09 -0800 Subject: [PATCH] Removed usage of Material. --- .../sk89q/worldguard/bukkit/BukkitUtil.java | 7 +- .../bukkit/WorldGuardBlockListener.java | 32 ++-- .../bukkit/WorldGuardEntityListener.java | 8 +- .../bukkit/WorldGuardPlayerListener.java | 139 +++++++++--------- .../worldguard/chest/ChestProtection.java | 9 ++ .../worldguard/chest/SignChestProtection.java | 45 +++--- 6 files changed, 129 insertions(+), 111 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java b/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java index 7dbee385..4e1a5569 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/BukkitUtil.java @@ -21,9 +21,10 @@ import java.util.List; +import com.sk89q.worldedit.blocks.BlockID; +import com.sk89q.worldedit.blocks.ItemID; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.World; import org.bukkit.block.Block; @@ -110,7 +111,7 @@ public static Player matchSinglePlayer(Server server, String name) { public static void dropSign(Block block) { block.setTypeId(0); block.getWorld().dropItemNaturally(block.getLocation(), - new ItemStack(Material.SIGN, 1)); + new ItemStack(ItemID.SIGN, 1)); } /** @@ -179,7 +180,7 @@ public static void findFreePosition(Player player) { loc.setX(x + 0.5); loc.setY(y); loc.setZ(z + 0.5); - if (y <= 2 && world.getBlockAt(x,0,z).getType() == Material.AIR) { + if (y <= 2 && world.getBlockAt(x,0,z).getTypeId() == BlockID.AIR) { world.getBlockAt(x,0,z).setTypeId(20); loc.setY(2); } diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java index c8f2d9fc..09ec3302 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java @@ -24,7 +24,6 @@ import java.util.logging.Logger; import org.bukkit.ChatColor; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -53,6 +52,7 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.ItemType; +import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent; import com.sk89q.worldguard.blacklist.events.BlockPlaceBlacklistEvent; @@ -154,7 +154,7 @@ public void onBlockDamage(BlockDamageEvent event) { // Cake are damaged and not broken when they are eaten, so we must // handle them a bit separately - if (blockDamaged.getType() == Material.CAKE_BLOCK) { + if (blockDamaged.getTypeId() == BlockID.CAKE_BLOCK) { if (!plugin.getGlobalRegionManager().canBuild(player, blockDamaged)) { player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!"); event.setCancelled(true); @@ -541,7 +541,7 @@ public void onBlockPlace(BlockPlaceEvent event) { } } - if (wcfg.signChestProtection && wcfg.getChestProtection().isChest(blockPlaced.getType())) { + if (wcfg.signChestProtection && wcfg.getChestProtection().isChest(blockPlaced.getTypeId())) { if (wcfg.isAdjacentChestProtected(event.getBlock(), player)) { player.sendMessage(ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for."); event.setCancelled(true); @@ -616,7 +616,7 @@ public void onSignChange(SignChangeEvent event) { return; } - if (event.getBlock().getType() != Material.SIGN_POST) { + if (event.getBlock().getTypeId() != BlockID.SIGN_POST) { player.sendMessage(ChatColor.RED + "The [Lock] sign must be a sign post, not a wall sign."); @@ -634,10 +634,10 @@ public void onSignChange(SignChangeEvent event) { return; } - Material below = event.getBlock().getRelative(0, -1, 0).getType(); + int below = event.getBlock().getRelative(0, -1, 0).getTypeId(); - if (below == Material.TNT || below == Material.SAND - || below == Material.GRAVEL || below == Material.SIGN_POST) { + if (below == BlockID.TNT || below == BlockID.SAND + || below == BlockID.GRAVEL || below == BlockID.SIGN_POST) { player.sendMessage(ChatColor.RED + "That is not a safe block that you're putting this sign on."); @@ -711,9 +711,9 @@ public void onBlockForm(BlockFormEvent event) { return; } - Material type = event.getNewState().getType(); + int type = event.getNewState().getTypeId(); - if (type == Material.ICE) { + if (type == BlockID.ICE) { if (wcfg.disableIceFormation) { event.setCancelled(true); return; @@ -725,7 +725,7 @@ public void onBlockForm(BlockFormEvent event) { } } - if (type == Material.SNOW) { + if (type == BlockID.SNOW) { if (wcfg.disableSnowFormation) { event.setCancelled(true); return; @@ -754,9 +754,9 @@ public void onBlockSpread(BlockSpreadEvent event) { return; } - Material fromType = event.getSource().getType(); + int fromType = event.getSource().getTypeId(); - if (fromType == Material.RED_MUSHROOM || fromType == Material.BROWN_MUSHROOM) { + if (fromType == BlockID.RED_MUSHROOM || fromType == BlockID.BROWN_MUSHROOM) { if (wcfg.disableMushroomSpread) { event.setCancelled(true); return; @@ -768,7 +768,7 @@ public void onBlockSpread(BlockSpreadEvent event) { } } - if (fromType == Material.GRASS) { + if (fromType == BlockID.GRASS) { if (wcfg.disableGrassGrowth) { event.setCancelled(true); return; @@ -792,9 +792,9 @@ public void onBlockFade(BlockFadeEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); - Material type = event.getBlock().getType(); + int type = event.getBlock().getTypeId(); - if (type == Material.ICE) { + if (type == BlockID.ICE) { if (wcfg.disableIceMelting) { event.setCancelled(true); return; @@ -806,7 +806,7 @@ public void onBlockFade(BlockFadeEvent event) { } } - if (type == Material.SNOW) { + if (type == BlockID.SNOW) { if (wcfg.disableSnowMelting) { event.setCancelled(true); return; diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java index f0b69289..2d09e9ca 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java @@ -23,9 +23,9 @@ import java.util.Set; import java.util.logging.Logger; +import com.sk89q.worldedit.blocks.BlockID; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Creature; @@ -147,7 +147,7 @@ public void onEntityInteract(EntityInteractEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(entity.getWorld()); - if (block.getType() == Material.SOIL) { + if (block.getTypeId() == BlockID.SOIL) { if (entity instanceof Creature && wcfg.disableCreatureCropTrampling) { event.setCancelled(true); } @@ -476,8 +476,8 @@ public void onEntityDamage(EntityDamageEvent event) { } if (type == DamageCause.DROWNING && wcfg.pumpkinScuba - && (player.getInventory().getHelmet().getType() == Material.PUMPKIN - || player.getInventory().getHelmet().getType() == Material.JACK_O_LANTERN)) { + && (player.getInventory().getHelmet().getTypeId() == BlockID.PUMPKIN + || player.getInventory().getHelmet().getTypeId() == BlockID.JACKOLANTERN)) { player.setRemainingAir(player.getMaximumAir()); event.setCancelled(true); return; diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java index 5dc7227a..60dfcf46 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java @@ -24,9 +24,10 @@ import java.util.Set; import java.util.logging.Logger; +import com.sk89q.worldedit.blocks.BlockID; +import com.sk89q.worldedit.blocks.ItemID; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -419,7 +420,7 @@ private void handleBlockLeftClick(PlayerInteractEvent event) { Player player = event.getPlayer(); Block block = event.getClickedBlock(); - Material type = block.getType(); + int type = block.getTypeId(); World world = player.getWorld(); ConfigurationManager cfg = plugin.getGlobalStateManager(); @@ -431,11 +432,11 @@ private void handleBlockLeftClick(PlayerInteractEvent event) { ApplicableRegionSet set = mgr.getApplicableRegions(pt); LocalPlayer localPlayer = plugin.wrapPlayer(player); - if (type == Material.STONE_BUTTON - || type == Material.LEVER - || type == Material.WOODEN_DOOR - || type == Material.TRAP_DOOR - || type == Material.NOTE_BLOCK) { + if (type == BlockID.STONE_BUTTON + || type == BlockID.LEVER + || type == BlockID.WOODEN_DOOR + || type == BlockID.TRAP_DOOR + || type == BlockID.NOTE_BLOCK) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.allows(DefaultFlag.USE) && !set.canBuild(localPlayer)) { @@ -446,7 +447,7 @@ private void handleBlockLeftClick(PlayerInteractEvent event) { } } - if (block.getRelative(event.getBlockFace()).getType() == Material.FIRE) { + if (block.getRelative(event.getBlockFace()).getTypeId() == BlockID.FIRE) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.canBuild(localPlayer)) { event.setUseInteractedBlock(Result.DENY); @@ -457,7 +458,7 @@ private void handleBlockLeftClick(PlayerInteractEvent event) { } - if (type == Material.TNT && player.getItemInHand().getType() == Material.FLINT_AND_STEEL) { + if (type == BlockID.TNT && player.getItemInHand().getTypeId() == ItemID.FLINT_AND_TINDER) { if (wcfg.getBlacklist() != null) { if (!wcfg.getBlacklist().check( new BlockBreakBlacklistEvent(plugin.wrapPlayer(player), @@ -513,7 +514,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { Block block = event.getClickedBlock(); World world = block.getWorld(); - Material type = block.getType(); + int type = block.getTypeId(); Player player = event.getPlayer(); ItemStack item = player.getItemInHand(); @@ -521,14 +522,14 @@ private void handleBlockRightClick(PlayerInteractEvent event) { WorldConfiguration wcfg = cfg.get(world); // Infinite stack removal - if ((type == Material.CHEST - || type == Material.JUKEBOX - || type == Material.DISPENSER - || type == Material.FURNACE - || type == Material.BURNING_FURNACE - || type == Material.BREWING_STAND - || type == Material.ENCHANTMENT_TABLE - || type == Material.CAULDRON) + if ((type == BlockID.CHEST + || type == BlockID.JUKEBOX + || type == BlockID.DISPENSER + || type == BlockID.FURNACE + || type == BlockID.BURNING_FURNACE + || type == BlockID.BREWING_STAND + || type == BlockID.ENCHANTMENT_TABLE + || type == BlockID.CAULDRON) && wcfg.removeInfiniteStacks && !plugin.hasPermission(player, "worldguard.override.infinite-stack")) { for (int slot = 0; slot < 40; slot++) { @@ -568,7 +569,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { return; } - if (item.getType() == Material.TNT) { + if (item.getTypeId() == BlockID.TNT) { Block placedOn = block.getRelative(event.getBlockFace()); if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !plugin.getGlobalRegionManager().allows( @@ -578,10 +579,10 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if (item.getType() == Material.INK_SACK + if (item.getTypeId() == ItemID.INK_SACK && item.getData() != null && item.getData().getData() == 15 // bonemeal - && type == Material.GRASS) { + && type == BlockID.GRASS) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.canBuild(localPlayer)) { event.setCancelled(true); @@ -589,7 +590,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if (type == Material.BED_BLOCK) { + if (type == BlockID.BED) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.allows(DefaultFlag.SLEEP)) { player.sendMessage(ChatColor.DARK_RED + "You're not allowed to use that bed."); @@ -599,12 +600,12 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if (type == Material.CHEST - || type == Material.JUKEBOX //stores the (arguably) most valuable item - || type == Material.DISPENSER - || type == Material.FURNACE - || type == Material.BURNING_FURNACE - || type == Material.BREWING_STAND) { + if (type == BlockID.CHEST + || type == BlockID.JUKEBOX //stores the (arguably) most valuable item + || type == BlockID.DISPENSER + || type == BlockID.FURNACE + || type == BlockID.BURNING_FURNACE + || type == BlockID.BREWING_STAND) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.allows(DefaultFlag.CHEST_ACCESS) && !set.canBuild(localPlayer)) { @@ -615,23 +616,23 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if (type == Material.LEVER - || type == Material.STONE_BUTTON - || type == Material.NOTE_BLOCK - || type == Material.DIODE_BLOCK_OFF - || type == Material.DIODE_BLOCK_ON - || type == Material.WOODEN_DOOR - || type == Material.TRAP_DOOR - || type == Material.FENCE_GATE - || type == Material.JUKEBOX //stores the (arguably) most valuable item - || type == Material.DISPENSER - || type == Material.FURNACE - || type == Material.BURNING_FURNACE - || type == Material.WORKBENCH - || type == Material.BREWING_STAND - || type == Material.ENCHANTMENT_TABLE - || type == Material.CAULDRON - || type == Material.DRAGON_EGG) { + if (type == BlockID.LEVER + || type == BlockID.STONE_BUTTON + || type == BlockID.NOTE_BLOCK + || type == BlockID.REDSTONE_REPEATER_OFF + || type == BlockID.REDSTONE_REPEATER_ON + || type == BlockID.WOODEN_DOOR + || type == BlockID.TRAP_DOOR + || type == BlockID.FENCE_GATE + || type == BlockID.JUKEBOX //stores the (arguably) most valuable item + || type == BlockID.DISPENSER + || type == BlockID.FURNACE + || type == BlockID.BURNING_FURNACE + || type == BlockID.WORKBENCH + || type == BlockID.BREWING_STAND + || type == BlockID.ENCHANTMENT_TABLE + || type == BlockID.CAULDRON + || type == BlockID.DRAGON_EGG) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.allows(DefaultFlag.USE) && !set.canBuild(localPlayer)) { @@ -642,7 +643,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if (type == Material.CAKE_BLOCK) { + if (type == BlockID.CAKE_BLOCK) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.canBuild(localPlayer)) { player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!"); @@ -652,7 +653,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if (BlockType.isRailBlock(type.getId()) && item.getType() == Material.MINECART) { + if (BlockType.isRailBlock(type) && item.getTypeId() == ItemID.MINECART) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.canBuild(localPlayer) && !set.allows(DefaultFlag.PLACE_VEHICLE)) { @@ -663,7 +664,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if (item.getType() == Material.BOAT) { + if (item.getTypeId() == ItemID.WOOD_BOAT) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.canBuild(localPlayer) && !set.allows(DefaultFlag.PLACE_VEHICLE)) { @@ -676,13 +677,13 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } if (wcfg.getBlacklist() != null) { - if(type != Material.CHEST - && type != Material.DISPENSER - && type != Material.FURNACE - && type != Material.BURNING_FURNACE - && type != Material.BREWING_STAND - && type != Material.ENCHANTMENT_TABLE - && type != Material.CAULDRON) { + if(type != BlockID.CHEST + && type != BlockID.DISPENSER + && type != BlockID.FURNACE + && type != BlockID.BURNING_FURNACE + && type != BlockID.BREWING_STAND + && type != BlockID.ENCHANTMENT_TABLE + && type != BlockID.CAULDRON) { if (!wcfg.getBlacklist().check( new ItemUseBlacklistEvent(plugin.wrapPlayer(player), toVector(block), item.getTypeId()), false, false)) { @@ -701,7 +702,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } // Workaround for http://leaky.bukkit.org/issues/1034 - if (item.getType() == Material.TNT) { + if (item.getTypeId() == BlockID.TNT) { Block placedOn = block.getRelative(event.getBlockFace()); if (!wcfg.getBlacklist().check( new BlockPlaceBlacklistEvent(plugin.wrapPlayer(player), toVector(placedOn), @@ -713,12 +714,12 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } } - if ((type == Material.CHEST - || type == Material.DISPENSER - || type == Material.FURNACE - || type == Material.BURNING_FURNACE - || type == Material.ENCHANTMENT_TABLE - || type == Material.BREWING_STAND)) { + if ((type == BlockID.CHEST + || type == BlockID.DISPENSER + || type == BlockID.FURNACE + || type == BlockID.BURNING_FURNACE + || type == BlockID.ENCHANTMENT_TABLE + || type == BlockID.BREWING_STAND)) { if (wcfg.isChestProtected(block, player)) { player.sendMessage(ChatColor.DARK_RED + "The chest is protected."); @@ -729,7 +730,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { } /*if (wcfg.useRegions && wcfg.useiConomy && cfg.getiConomy() != null - && (type == Material.SIGN_POST || type == Material.SIGN || type == Material.WALL_SIGN)) { + && (type == BlockID.SIGN_POST || type == ItemID.SIGN || type == BlockID.WALL_SIGN)) { BlockState block = blockClicked.getState(); if (((Sign)block).getLine(0).equalsIgnoreCase("[WorldGuard]") @@ -784,17 +785,17 @@ private void handleBlockRightClick(PlayerInteractEvent event) { * @param event */ private void handlePhysicalInteract(PlayerInteractEvent event) { - if (event.isCancelled() == true) return; + if (event.isCancelled()) return; Player player = event.getPlayer(); Block block = event.getClickedBlock(); //not actually clicked but whatever - Material type = block.getType(); + int type = block.getTypeId(); World world = player.getWorld(); ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(world); - if (block.getType() == Material.SOIL && wcfg.disablePlayerCropTrampling) { + if (block.getTypeId() == BlockID.SOIL && wcfg.disablePlayerCropTrampling) { event.setCancelled(true); return; } @@ -805,7 +806,7 @@ private void handlePhysicalInteract(PlayerInteractEvent event) { ApplicableRegionSet set = mgr.getApplicableRegions(pt); LocalPlayer localPlayer = plugin.wrapPlayer(player); - if (type == Material.STONE_PLATE || type == Material.WOOD_PLATE) { + if (type == BlockID.STONE_PRESSURE_PLATE || type == BlockID.WOODEN_PRESSURE_PLATE) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.allows(DefaultFlag.USE) && !set.canBuild(localPlayer)) { @@ -851,7 +852,7 @@ public void onPlayerItem(PlayerItemEvent event) { if (wcfg.useRegions && !event.isBlock() && block != null) { Vector pt = toVector(block.getRelative(event.getBlockFace())); - if (block.getType() == Material.WALL_SIGN) { + if (block.getTypeId() == BlockID.WALL_SIGN) { pt = pt.subtract(0, 1, 0); } @@ -943,7 +944,7 @@ public void onPlayerBucketFill(PlayerBucketFillEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(world); - if (event.getItemStack().getType() == Material.MILK_BUCKET) { + if (event.getItemStack().getTypeId() == ItemID.MILK_BUCKET) { if (!plugin.getGlobalRegionManager().allows(DefaultFlag.USE, player.getLocation().add(0, 1, 0))) { player.sendMessage(ChatColor.DARK_RED + "You don't have permission to use this in this area."); event.setCancelled(true); diff --git a/src/main/java/com/sk89q/worldguard/chest/ChestProtection.java b/src/main/java/com/sk89q/worldguard/chest/ChestProtection.java index 98246f28..7011ef71 100644 --- a/src/main/java/com/sk89q/worldguard/chest/ChestProtection.java +++ b/src/main/java/com/sk89q/worldguard/chest/ChestProtection.java @@ -62,6 +62,15 @@ public interface ChestProtection { * @param material * @return */ + @Deprecated public boolean isChest(Material material); + /** + * Returns whether a material is a chest. + * + * @param type + * @return + */ + public boolean isChest(int type); + } \ No newline at end of file diff --git a/src/main/java/com/sk89q/worldguard/chest/SignChestProtection.java b/src/main/java/com/sk89q/worldguard/chest/SignChestProtection.java index eebad59e..b6f2cc03 100644 --- a/src/main/java/com/sk89q/worldguard/chest/SignChestProtection.java +++ b/src/main/java/com/sk89q/worldguard/chest/SignChestProtection.java @@ -19,6 +19,7 @@ package com.sk89q.worldguard.chest; +import com.sk89q.worldedit.blocks.BlockID; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -33,10 +34,10 @@ public class SignChestProtection implements ChestProtection { public boolean isProtected(Block block, Player player) { - if (isChest(block.getType())) { + if (isChest(block.getTypeId())) { Block below = block.getRelative(0, -1, 0); return isProtectedSignAround(below, player); - } else if (block.getType() == Material.SIGN_POST) { + } else if (block.getTypeId() == BlockID.SIGN_POST) { return isProtectedSignAndChestBinary(block, player); } else { Block above = block.getRelative(0, 1, 0); @@ -56,23 +57,23 @@ private boolean isProtectedSignAround(Block searchBlock, Player player) { side = searchBlock; res = isProtectedSign(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(-1, 0, 0); res = isProtectedSignAndChest(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(1, 0, 0); res = isProtectedSignAndChest(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(0, 0, -1); res = isProtectedSignAndChest(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(0, 0, 1); res = isProtectedSignAndChest(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; return false; } @@ -106,7 +107,7 @@ private Boolean isProtectedSign(Block block, Player player) { } private Boolean isProtectedSignAndChest(Block block, Player player) { - if (!isChest(block.getRelative(0, 1, 0).getType())) { + if (!isChest(block.getRelative(0, 1, 0).getTypeId())) { return null; } return isProtectedSign(block, player); @@ -114,7 +115,7 @@ private Boolean isProtectedSignAndChest(Block block, Player player) { private boolean isProtectedSignAndChestBinary(Block block, Player player) { Boolean res = isProtectedSignAndChest(block, player); - if (res == null || res == false) { + if (res == null || res == Boolean.FALSE) { return false; } return true; @@ -126,31 +127,37 @@ public boolean isAdjacentChestProtected(Block searchBlock, Player player) { side = searchBlock; res = isProtected(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(-1, 0, 0); res = isProtected(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(1, 0, 0); res = isProtected(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(0, 0, -1); res = isProtected(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; side = searchBlock.getRelative(0, 0, 1); res = isProtected(side, player); - if (res != null && res == true) return res; + if (res != null && res == Boolean.TRUE) return res; return false; } - + + @Deprecated public boolean isChest(Material material) { - return material == Material.CHEST - || material == Material.DISPENSER - || material == Material.FURNACE - || material == Material.BURNING_FURNACE; + return isChest(material.getId()); + } + + @Override + public boolean isChest(int type) { + return type == BlockID.CHEST + || type == BlockID.DISPENSER + || type == BlockID.FURNACE + || type == BlockID.BURNING_FURNACE; } }