From b775997046d644f3dd1c171567fe780178dc9a37 Mon Sep 17 00:00:00 2001 From: taoneill Date: Wed, 23 Feb 2011 12:40:37 -0500 Subject: [PATCH] First v1.1 commit. Minecraft 1.3 and craftbukkit 431 fixes. Cant drop blocks and cant pickup more than one precious block. Also move to not use BLOCK_DAMAGED. Using BLOCK_BREAK instead: Grum says it's more reliable. --- war/.classpath | 1 - war/.project | 6 +++ .../main/java/bukkit/tommytony/war/War.java | 2 +- .../tommytony/war/WarBlockListener.java | 28 +++++------ .../tommytony/war/WarPlayerListener.java | 46 +++++++++---------- war/src/main/java/plugin.yml | 2 +- war/target/classes/plugin.yml | 2 +- 7 files changed, 46 insertions(+), 41 deletions(-) diff --git a/war/.classpath b/war/.classpath index 5c03e74..b9494f8 100644 --- a/war/.classpath +++ b/war/.classpath @@ -6,6 +6,5 @@ - diff --git a/war/.project b/war/.project index 0434e1d..87402b9 100644 --- a/war/.project +++ b/war/.project @@ -15,9 +15,15 @@ + + net.sourceforge.metrics.builder + + + org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature + net.sourceforge.metrics.nature diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 9980331..a1e73e8 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -125,7 +125,7 @@ public class War extends JavaPlugin { pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); - pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this); + pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this); //pm.registerEvent(Event.Type.CHUNK_UNLOADED, blockListener, Priority.Normal, this); diff --git a/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java b/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java index fbc4129..3b71e3c 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java @@ -99,22 +99,22 @@ public class WarBlockListener extends BlockListener { } } -// public void onBlockBreak(BlockBreakEvent event) { -// Player player = event.getPlayer(); -// Block block = event.getBlock(); -// if(player != null && block != null) { -// handleBreakOrDamage(player, block, event); -// } -// } - - public void onBlockDamage(BlockDamageEvent event) { - Player player = event.getPlayer(); + public void onBlockBreak(BlockBreakEvent event) { + Player player = event.getPlayer(); Block block = event.getBlock(); - if(player != null && block != null && event.getDamageLevel() == BlockDamageLevel.BROKEN) { - handleBreakOrDamage(player,block, event); - + if(player != null && block != null) { + handleBreakOrDamage(player, block, event); } } + +// public void onBlockDamage(BlockDamageEvent event) { +// Player player = event.getPlayer(); +// Block block = event.getBlock(); +// if(player != null && block != null && event.getDamageLevel() == BlockDamageLevel.BROKEN) { +// handleBreakOrDamage(player,block, event); +// +// } +// } private void handleBreakOrDamage(Player player, Block block, Cancellable event) { Warzone warzone = war.warzone(player.getLocation()); @@ -142,7 +142,7 @@ public class WarBlockListener extends BlockListener { }else if(warzone != null && warzone.isImportantBlock(block)) { if(team != null && team.getSpawnVolume().contains(block)) { if(player.getInventory().contains(team.getMaterial())) { - war.badMsg(player, "You already have a " + team.getName() + " block."); + //war.badMsg(player, "You already have a " + team.getName() + " block."); event.setCancelled(true); return; } else { diff --git a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java index 402fd91..fe075de 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java @@ -6,7 +6,6 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.entity.CraftItem; import org.bukkit.entity.Item; -import org.bukkit.entity.ItemDrop; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerEvent; @@ -107,13 +106,15 @@ public class WarPlayerListener extends PlayerListener { event.setCancelled(true); } else { - ItemDrop item = event.getItemDrop(); - ItemStack itemStack = item.getItemStack(); - if(itemStack != null && itemStack.getType().getId() == team.getMaterial().getId()) { - // Can't drop a precious block - war.badMsg(player, "Can't drop " + team.getName() + " block blocks."); - event.setCancelled(true); - return; + Item item = event.getItemDrop(); + if(item instanceof CraftItem) { + ItemStack itemStack = ((CraftItem)item).getItemStack(); + if(itemStack != null && itemStack.getType().getId() == team.getMaterial().getId()) { + // Can't drop a precious block + war.badMsg(player, "Can't drop " + team.getName() + " block blocks."); + event.setCancelled(true); + return; + } } } } @@ -128,22 +129,21 @@ public class WarPlayerListener extends PlayerListener { if(zone.isFlagThief(player.getName())) { // a flag thief can't pick up anything event.setCancelled(true); + } else { + Item item = event.getItem(); + if(item instanceof CraftItem) { + CraftItem cItem = (CraftItem)item; + ItemStack itemStack = cItem.getItemStack(); + if(itemStack != null && itemStack.getType().getId() == team.getMaterial().getId() + && player.getInventory().contains(team.getMaterial())) { + // Can't pick up a second precious block + war.badMsg(player, "You already have a " + team.getName() + " block."); + event.setCancelled(true); + return; + } + } + } -// } else { -// Item item = event.getItem(); -// if(item instanceof CraftItem) { -// CraftItem cItem = (CraftItem)item; -// ItemStack itemStack = cItem.getItemStack(); -// if(itemStack != null && itemStack.getType().getId() == team.getMaterial().getId() -// && player.getInventory().contains(team.getMaterial())) { -// // Can't pick up a second precious block -// war.badMsg(player, "You already have a " + team.getName() + " block."); -// event.setCancelled(true); -// return; -// } -// } -// - //} } } diff --git a/war/src/main/java/plugin.yml b/war/src/main/java/plugin.yml index d134cb6..0184490 100644 --- a/war/src/main/java/plugin.yml +++ b/war/src/main/java/plugin.yml @@ -1,5 +1,5 @@ name: War -version: 1.0 (Eisenhower) +version: 1.1 (Guderian) description: Lets you create TDM and CTF (warzones) for a more structured PVP experience. author: tommytony website: war.tommytony.com diff --git a/war/target/classes/plugin.yml b/war/target/classes/plugin.yml index d134cb6..0184490 100644 --- a/war/target/classes/plugin.yml +++ b/war/target/classes/plugin.yml @@ -1,5 +1,5 @@ name: War -version: 1.0 (Eisenhower) +version: 1.1 (Guderian) description: Lets you create TDM and CTF (warzones) for a more structured PVP experience. author: tommytony website: war.tommytony.com