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.

This commit is contained in:
taoneill 2011-02-23 12:40:37 -05:00
parent 01b86036dd
commit b775997046
7 changed files with 46 additions and 41 deletions

View File

@ -6,6 +6,5 @@
<classpathentry combineaccessrules="false" kind="src" path="/bukkit"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/Permissions.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/craftbukkit"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/minecraft_server.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -15,9 +15,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sourceforge.metrics.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>net.sourceforge.metrics.nature</nature>
</natures>
</projectDescription>

View File

@ -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);

View File

@ -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) {
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 {

View File

@ -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,8 +106,9 @@ public class WarPlayerListener extends PlayerListener {
event.setCancelled(true);
} else {
ItemDrop item = event.getItemDrop();
ItemStack itemStack = item.getItemStack();
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.");
@ -118,6 +118,7 @@ public class WarPlayerListener extends PlayerListener {
}
}
}
}
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
@ -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;
// }
// }
//
//}
}
}

View File

@ -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

View File

@ -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