Closes gh-243. Added basic kill/death messages. Colored team player names in War chatter.

This commit is contained in:
taoneill 2011-07-16 18:55:15 -04:00
parent 5a03b6c50d
commit b910d9e640
5 changed files with 25 additions and 42 deletions

View File

@ -2,6 +2,7 @@ package bukkit.tommytony.war;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -117,15 +118,6 @@ public class WarBlockListener extends BlockListener {
}
}
// 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 = this.war.warzone(player.getLocation());
Team team = this.war.getPlayerTeam(player.getName());
@ -176,9 +168,10 @@ public class WarBlockListener extends BlockListener {
block.setType(Material.AIR);
for (Team t : warzone.getTeams()) {
t.teamcast(player.getName() + " stole team " + lostFlagTeam.getName() + "'s flag.");
t.teamcast(team.getKind().getColor() + player.getName() + ChatColor.WHITE + " stole team " + lostFlagTeam.getName() + "'s flag.");
if (t.getName().equals(lostFlagTeam.getName())) {
t.teamcast("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn or flag.");
t.teamcast("Prevent " + team.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " from reaching team " + team.getName() + "'s spawn or flag.");
}
}
this.war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");

View File

@ -2,6 +2,7 @@ package bukkit.tommytony.war;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.entity.CraftPlayer;
@ -34,27 +35,6 @@ public class WarEntityListener extends EntityListener {
this.war = war;
}
@Override
public void onEntityDeath(EntityDeathEvent event) {
if (this.war.isLoaded()) {
Entity e = event.getEntity();
if (e instanceof Player) {
Player player = (Player) e;
Team team = this.war.getPlayerTeam(player.getName());
if (team != null) {
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
zone.handleDeath(player);
// if (zone.isDropLootOnDeath()) {
// war.getServer().getScheduler().scheduleAsyncDelayedTask(war,
// new LootDropperTask(player.getLocation(), event.getDrops()),
// 750);
// }
event.getDrops().clear(); // no loot
}
}
}
}
private void handlerAttackDefend(EntityDamageByEntityEvent event) {
Entity attacker = event.getDamager();
Entity defender = event.getEntity();
@ -84,10 +64,13 @@ public class WarEntityListener extends EntityListener {
// Detect death, prevent it and respawn the player
if (event.getDamage() >= d.getHealth()) {
defenderWarzone.handleDeath(d);
if (this.war.getServer().getPluginManager().getPlugin("HeroicDeath") != null) {
String killMessage = "";
killMessage = attackerTeam.getKind().getColor() + a.getDisplayName() + ChatColor.WHITE +
" killed " + defenderTeam.getKind().getColor() + d.getDisplayName();
for (Team team : defenderWarzone.getTeams()) {
team.teamcast(killMessage);
}
defenderWarzone.handleDeath(d);
event.setCancelled(true);
}
} else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
@ -175,6 +158,11 @@ public class WarEntityListener extends EntityListener {
Player player = (Player) entity;
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
if (zone != null && event.getDamage() >= player.getHealth()) {
String deathMessage = "";
deathMessage = this.war.getPlayerTeam(player.getName()).getKind().getColor() + player.getDisplayName() + ChatColor.WHITE + " died";
for (Team team : zone.getTeams()) {
team.teamcast(deathMessage);
}
zone.handleDeath(player);
event.setCancelled(true);
}

View File

@ -2,6 +2,7 @@ package bukkit.tommytony.war;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.entity.CraftItem;
@ -398,7 +399,8 @@ public class WarPlayerListener extends PlayerListener {
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
victim.initializeTeamFlag();
for (Team t : playerWarzone.getTeams()) {
t.teamcast(player.getName() + " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
}
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@ -675,7 +676,6 @@ public class Warzone {
Warzone playerWarzone = this.war.getPlayerTeamWarzone(player.getName());
if (playerTeam != null && playerWarzone != null) {
// teleport to team spawn upon death
this.war.msg(player, "You died.");
playerWarzone.respawnPlayer(playerTeam, player);
int remaining = playerTeam.getRemainingLifes();
if (remaining == 0) { // your death caused your team to lose
@ -771,7 +771,7 @@ public class Warzone {
playerTeam.removePlayer(player.getName());
}
for (Team t : this.getTeams()) {
t.teamcast(player.getName() + " left the zone.");
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE + " left the zone.");
}
playerTeam.resetSign();
if (this.isFlagThief(player.getName())) {

View File

@ -92,15 +92,15 @@ commands:
- Must be standing in warzone.
- /setteamflag <team-color>
resetzone:
description: (War) Reloads zone blocks from memory. Reloads from disk with "hard" option. Everyone back to the lobby.
description: (War) Reloads zone blocks from memory. Everyone back to the lobby.
usage:
- Must be standing in warzone or lobby.
- /resetzone, /resetzone <hard/h>
- /resetzone
deletezone:
description: (War) Deletes the zone, resets all blocks.
usage:
- Must be standing in warzone or lobby.
- /deletezone
- Must be standing in warzone or lobby, or provide name
- /deletezone, /deletezone <zone-name>
deleteteam:
description: (War) Deletes the team. Team must exist.
usage: