Closes gh-367. Using flint and steel on enemy spawn doesn't give you a fire block anymore. :)

This commit is contained in:
taoneill 2012-01-27 20:34:37 -05:00
parent a4a3ced0e5
commit a9c09c3f16
2 changed files with 13 additions and 5 deletions

View File

@ -159,8 +159,17 @@ public class WarBlockListener implements Listener {
private void cancelAndKeepItem(BlockPlaceEvent event) {
event.setCancelled(true);
ItemStack inHand = event.getItemInHand();
ItemStack newItemInHand = new ItemStack(inHand.getType(), inHand.getAmount(), inHand.getDurability(), inHand.getData().getData());
newItemInHand.setDurability(inHand.getDurability());
ItemStack newItemInHand = null;
if (inHand.getType() == Material.FIRE) {
// Weird bukkit/mc behavior where item in hand is reported as fire while using flint & steel.
// Just give the user his f&s back but almost broken (max durability is 8).
newItemInHand = new ItemStack(Material.FLINT_AND_STEEL, 1, (short)1);
} else {
newItemInHand = new ItemStack(inHand.getType(), inHand.getAmount(), inHand.getDurability(), inHand.getData().getData());
newItemInHand.setDurability(inHand.getDurability());
}
event.getPlayer().setItemInHand(newItemInHand);
}

View File

@ -253,16 +253,15 @@ public class WarPlayerListener implements Listener {
if (zone != null && zone.getLoadoutSelections().containsKey(player.getName())
&& zone.getLoadoutSelections().get(player.getName()).isStillInSpawn()) {
event.setUseItemInHand(Result.DENY);
War.war.badMsg(player, "Can't use items while still in spawn.");
ItemStack inHand = event.getItem();
if (inHand != null) {
ItemStack newItemInHand = new ItemStack(inHand.getType(), inHand.getAmount(), inHand.getDurability(), inHand.getData().getData());
newItemInHand.setDurability(inHand.getDurability());
event.getPlayer().setItemInHand(newItemInHand);
event.setCancelled(true);
War.war.badMsg(player, "Can't use items while still in spawn.");
}
}
}