Removed usage of Material.

This commit is contained in:
zml2008 2011-12-31 17:57:09 -08:00
parent 525bd199b2
commit b30f7fe9c7
6 changed files with 129 additions and 111 deletions

View File

@ -21,9 +21,10 @@
import java.util.List; import java.util.List;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.ItemID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -110,7 +111,7 @@ public static Player matchSinglePlayer(Server server, String name) {
public static void dropSign(Block block) { public static void dropSign(Block block) {
block.setTypeId(0); block.setTypeId(0);
block.getWorld().dropItemNaturally(block.getLocation(), 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.setX(x + 0.5);
loc.setY(y); loc.setY(y);
loc.setZ(z + 0.5); 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); world.getBlockAt(x,0,z).setTypeId(20);
loc.setY(2); loc.setY(2);
} }

View File

@ -24,7 +24,6 @@
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -53,6 +52,7 @@
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemType; import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent; import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent;
import com.sk89q.worldguard.blacklist.events.BlockPlaceBlacklistEvent; 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 // Cake are damaged and not broken when they are eaten, so we must
// handle them a bit separately // handle them a bit separately
if (blockDamaged.getType() == Material.CAKE_BLOCK) { if (blockDamaged.getTypeId() == BlockID.CAKE_BLOCK) {
if (!plugin.getGlobalRegionManager().canBuild(player, blockDamaged)) { if (!plugin.getGlobalRegionManager().canBuild(player, blockDamaged)) {
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!"); player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
event.setCancelled(true); 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)) { if (wcfg.isAdjacentChestProtected(event.getBlock(), player)) {
player.sendMessage(ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for."); player.sendMessage(ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for.");
event.setCancelled(true); event.setCancelled(true);
@ -616,7 +616,7 @@ public void onSignChange(SignChangeEvent event) {
return; return;
} }
if (event.getBlock().getType() != Material.SIGN_POST) { if (event.getBlock().getTypeId() != BlockID.SIGN_POST) {
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "The [Lock] sign must be a sign post, not a wall sign."); + "The [Lock] sign must be a sign post, not a wall sign.");
@ -634,10 +634,10 @@ public void onSignChange(SignChangeEvent event) {
return; 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 if (below == BlockID.TNT || below == BlockID.SAND
|| below == Material.GRAVEL || below == Material.SIGN_POST) { || below == BlockID.GRAVEL || below == BlockID.SIGN_POST) {
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "That is not a safe block that you're putting this sign on."); + "That is not a safe block that you're putting this sign on.");
@ -711,9 +711,9 @@ public void onBlockForm(BlockFormEvent event) {
return; return;
} }
Material type = event.getNewState().getType(); int type = event.getNewState().getTypeId();
if (type == Material.ICE) { if (type == BlockID.ICE) {
if (wcfg.disableIceFormation) { if (wcfg.disableIceFormation) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -725,7 +725,7 @@ public void onBlockForm(BlockFormEvent event) {
} }
} }
if (type == Material.SNOW) { if (type == BlockID.SNOW) {
if (wcfg.disableSnowFormation) { if (wcfg.disableSnowFormation) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -754,9 +754,9 @@ public void onBlockSpread(BlockSpreadEvent event) {
return; 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) { if (wcfg.disableMushroomSpread) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -768,7 +768,7 @@ public void onBlockSpread(BlockSpreadEvent event) {
} }
} }
if (fromType == Material.GRASS) { if (fromType == BlockID.GRASS) {
if (wcfg.disableGrassGrowth) { if (wcfg.disableGrassGrowth) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -792,9 +792,9 @@ public void onBlockFade(BlockFadeEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); 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) { if (wcfg.disableIceMelting) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -806,7 +806,7 @@ public void onBlockFade(BlockFadeEvent event) {
} }
} }
if (type == Material.SNOW) { if (type == BlockID.SNOW) {
if (wcfg.disableSnowMelting) { if (wcfg.disableSnowMelting) {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -23,9 +23,9 @@
import java.util.Set; import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.sk89q.worldedit.blocks.BlockID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
@ -147,7 +147,7 @@ public void onEntityInteract(EntityInteractEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(entity.getWorld()); WorldConfiguration wcfg = cfg.get(entity.getWorld());
if (block.getType() == Material.SOIL) { if (block.getTypeId() == BlockID.SOIL) {
if (entity instanceof Creature && wcfg.disableCreatureCropTrampling) { if (entity instanceof Creature && wcfg.disableCreatureCropTrampling) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -476,8 +476,8 @@ public void onEntityDamage(EntityDamageEvent event) {
} }
if (type == DamageCause.DROWNING && wcfg.pumpkinScuba if (type == DamageCause.DROWNING && wcfg.pumpkinScuba
&& (player.getInventory().getHelmet().getType() == Material.PUMPKIN && (player.getInventory().getHelmet().getTypeId() == BlockID.PUMPKIN
|| player.getInventory().getHelmet().getType() == Material.JACK_O_LANTERN)) { || player.getInventory().getHelmet().getTypeId() == BlockID.JACKOLANTERN)) {
player.setRemainingAir(player.getMaximumAir()); player.setRemainingAir(player.getMaximumAir());
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -24,9 +24,10 @@
import java.util.Set; import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.ItemID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -419,7 +420,7 @@ private void handleBlockLeftClick(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
Material type = block.getType(); int type = block.getTypeId();
World world = player.getWorld(); World world = player.getWorld();
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
@ -431,11 +432,11 @@ private void handleBlockLeftClick(PlayerInteractEvent event) {
ApplicableRegionSet set = mgr.getApplicableRegions(pt); ApplicableRegionSet set = mgr.getApplicableRegions(pt);
LocalPlayer localPlayer = plugin.wrapPlayer(player); LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (type == Material.STONE_BUTTON if (type == BlockID.STONE_BUTTON
|| type == Material.LEVER || type == BlockID.LEVER
|| type == Material.WOODEN_DOOR || type == BlockID.WOODEN_DOOR
|| type == Material.TRAP_DOOR || type == BlockID.TRAP_DOOR
|| type == Material.NOTE_BLOCK) { || type == BlockID.NOTE_BLOCK) {
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.allows(DefaultFlag.USE) && !set.allows(DefaultFlag.USE)
&& !set.canBuild(localPlayer)) { && !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) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.canBuild(localPlayer)) { && !set.canBuild(localPlayer)) {
event.setUseInteractedBlock(Result.DENY); 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() != null) {
if (!wcfg.getBlacklist().check( if (!wcfg.getBlacklist().check(
new BlockBreakBlacklistEvent(plugin.wrapPlayer(player), new BlockBreakBlacklistEvent(plugin.wrapPlayer(player),
@ -513,7 +514,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
World world = block.getWorld(); World world = block.getWorld();
Material type = block.getType(); int type = block.getTypeId();
Player player = event.getPlayer(); Player player = event.getPlayer();
ItemStack item = player.getItemInHand(); ItemStack item = player.getItemInHand();
@ -521,14 +522,14 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
WorldConfiguration wcfg = cfg.get(world); WorldConfiguration wcfg = cfg.get(world);
// Infinite stack removal // Infinite stack removal
if ((type == Material.CHEST if ((type == BlockID.CHEST
|| type == Material.JUKEBOX || type == BlockID.JUKEBOX
|| type == Material.DISPENSER || type == BlockID.DISPENSER
|| type == Material.FURNACE || type == BlockID.FURNACE
|| type == Material.BURNING_FURNACE || type == BlockID.BURNING_FURNACE
|| type == Material.BREWING_STAND || type == BlockID.BREWING_STAND
|| type == Material.ENCHANTMENT_TABLE || type == BlockID.ENCHANTMENT_TABLE
|| type == Material.CAULDRON) || type == BlockID.CAULDRON)
&& wcfg.removeInfiniteStacks && wcfg.removeInfiniteStacks
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) { && !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
for (int slot = 0; slot < 40; slot++) { for (int slot = 0; slot < 40; slot++) {
@ -568,7 +569,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
return; return;
} }
if (item.getType() == Material.TNT) { if (item.getTypeId() == BlockID.TNT) {
Block placedOn = block.getRelative(event.getBlockFace()); Block placedOn = block.getRelative(event.getBlockFace());
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !plugin.getGlobalRegionManager().allows( && !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() != null
&& item.getData().getData() == 15 // bonemeal && item.getData().getData() == 15 // bonemeal
&& type == Material.GRASS) { && type == BlockID.GRASS) {
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.canBuild(localPlayer)) { && !set.canBuild(localPlayer)) {
event.setCancelled(true); 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) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.allows(DefaultFlag.SLEEP)) { && !set.allows(DefaultFlag.SLEEP)) {
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to use that bed."); 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 if (type == BlockID.CHEST
|| type == Material.JUKEBOX //stores the (arguably) most valuable item || type == BlockID.JUKEBOX //stores the (arguably) most valuable item
|| type == Material.DISPENSER || type == BlockID.DISPENSER
|| type == Material.FURNACE || type == BlockID.FURNACE
|| type == Material.BURNING_FURNACE || type == BlockID.BURNING_FURNACE
|| type == Material.BREWING_STAND) { || type == BlockID.BREWING_STAND) {
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.allows(DefaultFlag.CHEST_ACCESS) && !set.allows(DefaultFlag.CHEST_ACCESS)
&& !set.canBuild(localPlayer)) { && !set.canBuild(localPlayer)) {
@ -615,23 +616,23 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
} }
} }
if (type == Material.LEVER if (type == BlockID.LEVER
|| type == Material.STONE_BUTTON || type == BlockID.STONE_BUTTON
|| type == Material.NOTE_BLOCK || type == BlockID.NOTE_BLOCK
|| type == Material.DIODE_BLOCK_OFF || type == BlockID.REDSTONE_REPEATER_OFF
|| type == Material.DIODE_BLOCK_ON || type == BlockID.REDSTONE_REPEATER_ON
|| type == Material.WOODEN_DOOR || type == BlockID.WOODEN_DOOR
|| type == Material.TRAP_DOOR || type == BlockID.TRAP_DOOR
|| type == Material.FENCE_GATE || type == BlockID.FENCE_GATE
|| type == Material.JUKEBOX //stores the (arguably) most valuable item || type == BlockID.JUKEBOX //stores the (arguably) most valuable item
|| type == Material.DISPENSER || type == BlockID.DISPENSER
|| type == Material.FURNACE || type == BlockID.FURNACE
|| type == Material.BURNING_FURNACE || type == BlockID.BURNING_FURNACE
|| type == Material.WORKBENCH || type == BlockID.WORKBENCH
|| type == Material.BREWING_STAND || type == BlockID.BREWING_STAND
|| type == Material.ENCHANTMENT_TABLE || type == BlockID.ENCHANTMENT_TABLE
|| type == Material.CAULDRON || type == BlockID.CAULDRON
|| type == Material.DRAGON_EGG) { || type == BlockID.DRAGON_EGG) {
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.allows(DefaultFlag.USE) && !set.allows(DefaultFlag.USE)
&& !set.canBuild(localPlayer)) { && !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) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.canBuild(localPlayer)) { && !set.canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!"); 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) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.canBuild(localPlayer) && !set.canBuild(localPlayer)
&& !set.allows(DefaultFlag.PLACE_VEHICLE)) { && !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) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.canBuild(localPlayer) && !set.canBuild(localPlayer)
&& !set.allows(DefaultFlag.PLACE_VEHICLE)) { && !set.allows(DefaultFlag.PLACE_VEHICLE)) {
@ -676,13 +677,13 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
} }
if (wcfg.getBlacklist() != null) { if (wcfg.getBlacklist() != null) {
if(type != Material.CHEST if(type != BlockID.CHEST
&& type != Material.DISPENSER && type != BlockID.DISPENSER
&& type != Material.FURNACE && type != BlockID.FURNACE
&& type != Material.BURNING_FURNACE && type != BlockID.BURNING_FURNACE
&& type != Material.BREWING_STAND && type != BlockID.BREWING_STAND
&& type != Material.ENCHANTMENT_TABLE && type != BlockID.ENCHANTMENT_TABLE
&& type != Material.CAULDRON) { && type != BlockID.CAULDRON) {
if (!wcfg.getBlacklist().check( if (!wcfg.getBlacklist().check(
new ItemUseBlacklistEvent(plugin.wrapPlayer(player), toVector(block), new ItemUseBlacklistEvent(plugin.wrapPlayer(player), toVector(block),
item.getTypeId()), false, false)) { item.getTypeId()), false, false)) {
@ -701,7 +702,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
} }
// Workaround for http://leaky.bukkit.org/issues/1034 // Workaround for http://leaky.bukkit.org/issues/1034
if (item.getType() == Material.TNT) { if (item.getTypeId() == BlockID.TNT) {
Block placedOn = block.getRelative(event.getBlockFace()); Block placedOn = block.getRelative(event.getBlockFace());
if (!wcfg.getBlacklist().check( if (!wcfg.getBlacklist().check(
new BlockPlaceBlacklistEvent(plugin.wrapPlayer(player), toVector(placedOn), new BlockPlaceBlacklistEvent(plugin.wrapPlayer(player), toVector(placedOn),
@ -713,12 +714,12 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
} }
} }
if ((type == Material.CHEST if ((type == BlockID.CHEST
|| type == Material.DISPENSER || type == BlockID.DISPENSER
|| type == Material.FURNACE || type == BlockID.FURNACE
|| type == Material.BURNING_FURNACE || type == BlockID.BURNING_FURNACE
|| type == Material.ENCHANTMENT_TABLE || type == BlockID.ENCHANTMENT_TABLE
|| type == Material.BREWING_STAND)) { || type == BlockID.BREWING_STAND)) {
if (wcfg.isChestProtected(block, player)) { if (wcfg.isChestProtected(block, player)) {
player.sendMessage(ChatColor.DARK_RED + "The chest is protected."); 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 /*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(); BlockState block = blockClicked.getState();
if (((Sign)block).getLine(0).equalsIgnoreCase("[WorldGuard]") if (((Sign)block).getLine(0).equalsIgnoreCase("[WorldGuard]")
@ -784,17 +785,17 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
* @param event * @param event
*/ */
private void handlePhysicalInteract(PlayerInteractEvent event) { private void handlePhysicalInteract(PlayerInteractEvent event) {
if (event.isCancelled() == true) return; if (event.isCancelled()) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getClickedBlock(); //not actually clicked but whatever Block block = event.getClickedBlock(); //not actually clicked but whatever
Material type = block.getType(); int type = block.getTypeId();
World world = player.getWorld(); World world = player.getWorld();
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(world); WorldConfiguration wcfg = cfg.get(world);
if (block.getType() == Material.SOIL && wcfg.disablePlayerCropTrampling) { if (block.getTypeId() == BlockID.SOIL && wcfg.disablePlayerCropTrampling) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -805,7 +806,7 @@ private void handlePhysicalInteract(PlayerInteractEvent event) {
ApplicableRegionSet set = mgr.getApplicableRegions(pt); ApplicableRegionSet set = mgr.getApplicableRegions(pt);
LocalPlayer localPlayer = plugin.wrapPlayer(player); 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) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.allows(DefaultFlag.USE) && !set.allows(DefaultFlag.USE)
&& !set.canBuild(localPlayer)) { && !set.canBuild(localPlayer)) {
@ -851,7 +852,7 @@ public void onPlayerItem(PlayerItemEvent event) {
if (wcfg.useRegions && !event.isBlock() && block != null) { if (wcfg.useRegions && !event.isBlock() && block != null) {
Vector pt = toVector(block.getRelative(event.getBlockFace())); 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); pt = pt.subtract(0, 1, 0);
} }
@ -943,7 +944,7 @@ public void onPlayerBucketFill(PlayerBucketFillEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(world); 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))) { 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."); player.sendMessage(ChatColor.DARK_RED + "You don't have permission to use this in this area.");
event.setCancelled(true); event.setCancelled(true);

View File

@ -62,6 +62,15 @@ public interface ChestProtection {
* @param material * @param material
* @return * @return
*/ */
@Deprecated
public boolean isChest(Material material); public boolean isChest(Material material);
/**
* Returns whether a material is a chest.
*
* @param type
* @return
*/
public boolean isChest(int type);
} }

View File

@ -19,6 +19,7 @@
package com.sk89q.worldguard.chest; package com.sk89q.worldguard.chest;
import com.sk89q.worldedit.blocks.BlockID;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -33,10 +34,10 @@
public class SignChestProtection implements ChestProtection { public class SignChestProtection implements ChestProtection {
public boolean isProtected(Block block, Player player) { public boolean isProtected(Block block, Player player) {
if (isChest(block.getType())) { if (isChest(block.getTypeId())) {
Block below = block.getRelative(0, -1, 0); Block below = block.getRelative(0, -1, 0);
return isProtectedSignAround(below, player); return isProtectedSignAround(below, player);
} else if (block.getType() == Material.SIGN_POST) { } else if (block.getTypeId() == BlockID.SIGN_POST) {
return isProtectedSignAndChestBinary(block, player); return isProtectedSignAndChestBinary(block, player);
} else { } else {
Block above = block.getRelative(0, 1, 0); Block above = block.getRelative(0, 1, 0);
@ -56,23 +57,23 @@ private boolean isProtectedSignAround(Block searchBlock, Player player) {
side = searchBlock; side = searchBlock;
res = isProtectedSign(side, player); 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); side = searchBlock.getRelative(-1, 0, 0);
res = isProtectedSignAndChest(side, player); 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); side = searchBlock.getRelative(1, 0, 0);
res = isProtectedSignAndChest(side, player); 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); side = searchBlock.getRelative(0, 0, -1);
res = isProtectedSignAndChest(side, player); 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); side = searchBlock.getRelative(0, 0, 1);
res = isProtectedSignAndChest(side, player); res = isProtectedSignAndChest(side, player);
if (res != null && res == true) return res; if (res != null && res == Boolean.TRUE) return res;
return false; return false;
} }
@ -106,7 +107,7 @@ private Boolean isProtectedSign(Block block, Player player) {
} }
private Boolean isProtectedSignAndChest(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 null;
} }
return isProtectedSign(block, player); return isProtectedSign(block, player);
@ -114,7 +115,7 @@ private Boolean isProtectedSignAndChest(Block block, Player player) {
private boolean isProtectedSignAndChestBinary(Block block, Player player) { private boolean isProtectedSignAndChestBinary(Block block, Player player) {
Boolean res = isProtectedSignAndChest(block, player); Boolean res = isProtectedSignAndChest(block, player);
if (res == null || res == false) { if (res == null || res == Boolean.FALSE) {
return false; return false;
} }
return true; return true;
@ -126,31 +127,37 @@ public boolean isAdjacentChestProtected(Block searchBlock, Player player) {
side = searchBlock; side = searchBlock;
res = isProtected(side, player); 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); side = searchBlock.getRelative(-1, 0, 0);
res = isProtected(side, player); 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); side = searchBlock.getRelative(1, 0, 0);
res = isProtected(side, player); 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); side = searchBlock.getRelative(0, 0, -1);
res = isProtected(side, player); 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); side = searchBlock.getRelative(0, 0, 1);
res = isProtected(side, player); res = isProtected(side, player);
if (res != null && res == true) return res; if (res != null && res == Boolean.TRUE) return res;
return false; return false;
} }
@Deprecated
public boolean isChest(Material material) { public boolean isChest(Material material) {
return material == Material.CHEST return isChest(material.getId());
|| material == Material.DISPENSER }
|| material == Material.FURNACE
|| material == Material.BURNING_FURNACE; @Override
public boolean isChest(int type) {
return type == BlockID.CHEST
|| type == BlockID.DISPENSER
|| type == BlockID.FURNACE
|| type == BlockID.BURNING_FURNACE;
} }
} }