Bug hunting. When you get prevented from placing an item, you get item back in your hand. Actually preventing you from placing cake now. Resetting Bomb block if it gets exploded by nearby TNT. Preventing Bomb block ignition. Nerfed player-hit explosion of suicide bomber. Made spawn-hit explosion a bit bigger (same as player-hit).

This commit is contained in:
taoneill 2012-01-17 23:20:28 -05:00
parent 934292df88
commit a86683a98a
6 changed files with 58 additions and 19 deletions

View File

@ -149,6 +149,7 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.FOOD_LEVEL_CHANGE, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DEATH, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.EXPLOSION_PRIME, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_DAMAGE, this.blockListener, Priority.Normal, this);
@ -156,6 +157,8 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, this.blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, this.blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this.serverListener, Priority.Normal, this);
if (this.isSpoutServer()) {

View File

@ -79,8 +79,8 @@ public class WarBlockListener extends BlockListener {
event.setCancelled(false);
return; // important otherwise cancelled down a few line by isImportantblock
} else {
War.war.badMsg(player, "You can't capture a monument without a block of your team's material. Get one from your team spawn.");
event.setCancelled(true);
War.war.badMsg(player, "You must capture a monument with a block of your team's wool color. Get one from your team spawn.");
cancelAndKeepItem(event);
return;
}
}
@ -89,7 +89,7 @@ public class WarBlockListener extends BlockListener {
// prevent build in important parts
if (zone != null && zone.isImportantBlock(block) && (!isZoneMaker || (isZoneMaker && team != null))) {
War.war.badMsg(player, "Can't build here.");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
@ -97,7 +97,7 @@ public class WarBlockListener extends BlockListener {
for (Warzone wz : War.war.getWarzones()) {
if (wz.getLobby() != null && wz.getLobby().getVolume() != null && wz.getLobby().getVolume().contains(block)) {
War.war.badMsg(player, "Can't build here.");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
}
@ -105,7 +105,7 @@ public class WarBlockListener extends BlockListener {
// protect the hub
if (War.war.getWarHub() != null && War.war.getWarHub().getVolume().contains(block)) {
War.war.badMsg(player, "Can't build here.");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
@ -114,35 +114,35 @@ public class WarBlockListener extends BlockListener {
if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEBUILDMESSAGE)) {
War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
}
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
// can't place a block of your team's color
if (team != null && block.getType() == team.getKind().getMaterial() && block.getData() == team.getKind().getData()) {
War.war.badMsg(player, "You can only use your team's blocks to capture monuments.");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
// a flag thief can't drop his flag
if (team != null && zone != null && zone.isFlagThief(player.getName())) {
War.war.badMsg(player, "Can't drop the flag. What are you doing? Run!");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
// a bomb thief can't drop his bomb
if (team != null && zone != null && zone.isBombThief(player.getName())) {
War.war.badMsg(player, "Can't drop the bomb. What are you doing? Run for your enemy's spawn!");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
// a cake thief can't drop his cake
if (team != null && zone != null && zone.isBombThief(player.getName())) {
if (team != null && zone != null && zone.isCakeThief(player.getName())) {
War.war.badMsg(player, "Can't drop the cake. What are you doing? Run to your spawn!");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
@ -150,11 +150,17 @@ public class WarBlockListener extends BlockListener {
if (zone != null && zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE) && (!isZoneMaker || (isZoneMaker && team != null))) {
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
War.war.badMsg(player, "The blocks in this zone are unbreakable - this also means you can't build!");
event.setCancelled(true);
cancelAndKeepItem(event);
return;
}
}
private void cancelAndKeepItem(BlockPlaceEvent event) {
event.setCancelled(true);
ItemStack inHand = event.getItemInHand();
event.getPlayer().setItemInHand(new ItemStack(inHand.getType(), inHand.getAmount(), inHand.getDurability(), inHand.getData().getData()));
}
// Do not allow moving of block into or from important zones
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
Warzone zone = Warzone.getZoneByLocation(event.getBlock().getLocation());
@ -326,7 +332,8 @@ public class WarBlockListener extends BlockListener {
} else {
Bomb bomb = warzone.getBombForBlock(block);
// player just broke the bomb block: cancel to avoid drop, give player the block, set block to air
ItemStack tntBlock = new ItemStack(Material.TNT);
ItemStack tntBlock = new ItemStack(Material.TNT, 1, (short)8, (byte)8);
tntBlock.setDurability((short)8);
player.getInventory().clear();
player.getInventory().addItem(tntBlock);
warzone.addBombThief(bomb, player.getName());
@ -368,7 +375,8 @@ public class WarBlockListener extends BlockListener {
} else {
Cake cake = warzone.getCakeForBlock(block);
// player just broke the cake block: cancel to avoid drop, give player the block, set block to air
ItemStack cakeBlock = new ItemStack(Material.CAKE);
ItemStack cakeBlock = new ItemStack(Material.CAKE, 1, (short)8, (byte)8);
cakeBlock.setDurability((short)8);
player.getInventory().clear();
player.getInventory().addItem(cakeBlock);
warzone.addCakeThief(cake, player.getName());

View File

@ -22,6 +22,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
@ -165,7 +166,7 @@ public class WarEntityListener extends EntityListener {
defenderWarzone.handleDeath(d);
// blow up bomb man if attacker is close enough
defenderWarzone.getWorld().createExplosion(a.getLocation(), 4F);
defenderWarzone.getWorld().createExplosion(a.getLocation(), 2F);
// Notify everyone
for (Team t : defenderWarzone.getTeams()) {
@ -274,6 +275,13 @@ public class WarEntityListener extends EntityListener {
for (Warzone zone : War.war.getWarzones()) {
if (zone.isImportantBlock(block)) {
dontExplode.add(block);
if (zone.isBombBlock(block)) {
// tnt doesn't get reset like normal blocks, gotta schedule a later reset just for the Bomb
// structure's tnt block
DeferredBlockResetsJob job = new DeferredBlockResetsJob(block.getWorld());
job.add(new DeferredBlockReset(block.getX(), block.getY(), block.getZ(), Material.TNT.getId(), (byte)0));
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job, 10);
}
inOneZone = true;
break;
} else if (zone.getLobby() != null && zone.getLobby().getVolume().contains(block)) {
@ -329,7 +337,7 @@ public class WarEntityListener extends EntityListener {
}
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
// Changed explosion yeild following proportion of explosion prevention (makes drops less buggy too)
// Changed explosion yield following proportion of explosion prevention (makes drops less buggy too)
int explodedSize = explodedBlocks.size();
float middleYeild = (float)(explodedSize - dontExplodeSize) / (float)explodedSize;
float newYeild = middleYeild * event.getYield();
@ -507,5 +515,22 @@ public class WarEntityListener extends EntityListener {
}
}
}
@Override
public void onExplosionPrime(ExplosionPrimeEvent event) {
if (!War.war.isLoaded()) {
return;
}
Location eventLocation = event.getEntity().getLocation();
for (Warzone zone : War.war.getWarzones()) {
if (zone.isBombBlock(eventLocation.getBlock())) {
// prevent the Bomb from exploding on its pedestral
event.setCancelled(true);
return;
}
}
}
}

View File

@ -577,7 +577,7 @@ public class WarPlayerListener extends PlayerListener {
Bomb bomb = playerWarzone.getBombForThief(player.getName());
// Boom!
playerWarzone.getWorld().createExplosion(player.getLocation(), 1F);
playerWarzone.getWorld().createExplosion(player.getLocation(), 2F);
playerTeam.addPoint();

View File

@ -5,6 +5,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.material.MaterialData;
import com.tommytony.war.volumes.Volume;
@ -54,7 +55,8 @@ public class Bomb {
// block holder
this.warzone.getWorld().getBlockAt(x, y, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.TNT);
Block tntBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z);
tntBlock.setType(Material.TNT);
}
public boolean isBombBlock(Location otherLocation) {

View File

@ -54,7 +54,8 @@ public class Cake {
// block holder
this.warzone.getWorld().getBlockAt(x, y, z).setType(Material.GLASS);
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.CAKE_BLOCK);
Block cakeBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z);
cakeBlock.setType(Material.CAKE_BLOCK);
}
public boolean isCakeBlock(Location otherLocation) {