mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 12:46:11 +01:00
Added death detection for the flag thief. Also now detecting max score reached by capturing a flag. Changed the look of the team flags. CTF will be awesome. Too bad I can do anything about players dropping the flag.
This commit is contained in:
parent
82367f22e6
commit
ce625ee4b1
@ -604,7 +604,7 @@ public class War extends JavaPlugin {
|
||||
// /deletezone
|
||||
else if(command.equals("deletezone")) {
|
||||
if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
player.sendMessage(this.str("Usage: /deletewarzone. " +
|
||||
player.sendMessage(this.str("Usage: /deletezone. " +
|
||||
"Deletes the warzone. " +
|
||||
"Must be in the warzone (try /zones and /zone). "));
|
||||
} else {
|
||||
|
@ -131,7 +131,7 @@ public class WarBlockListener extends BlockListener {
|
||||
t.teamcast(war.str("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn."));
|
||||
}
|
||||
}
|
||||
player.sendMessage(war.str("You have team " + lostFlagTeam + "'s flag. Reach your team spawn to capture it!"));
|
||||
player.sendMessage(war.str("You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn to capture it!"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -201,23 +201,20 @@ public class WarPlayerListener extends PlayerListener {
|
||||
WarHub hub = war.getWarHub();
|
||||
if(hub != null && hub.getVolume().contains(playerLoc)) {
|
||||
Warzone zone = hub.getDestinationWarzoneForLocation(playerLoc);
|
||||
//synchronized(player) {
|
||||
if(zone != null) {
|
||||
enteredGate = true;
|
||||
event.setFrom(zone.getTeleport());
|
||||
player.teleportTo(zone.getTeleport());
|
||||
//
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(war.str("Welcome to warzone " + zone.getName() + "."));
|
||||
return;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
if(locZone != null && locZone.getLobby() != null
|
||||
&& locZone.getLobby().isLeavingZone(playerLoc)) { // already in a team and in warzone, leaving
|
||||
enteredGate = true;
|
||||
// same as leave, except using event.setFrom and cancelling even .. don't ask me, see NetServerHandler code
|
||||
// same as leave
|
||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||
if(playerTeam != null) {
|
||||
event.setFrom(playerWarzone.getTeleport());
|
||||
@ -245,8 +242,11 @@ public class WarPlayerListener extends PlayerListener {
|
||||
&& playerWarzone.nearAnyOwnedMonument(playerLoc, team)
|
||||
&& player.getHealth() < 20
|
||||
&& random.nextInt(42) == 3 ) { // one chance out of many of getting healed
|
||||
player.setHealth(20);
|
||||
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!"));
|
||||
int currentHp = player.getHealth();
|
||||
int newHp = currentHp + 5;
|
||||
if(newHp > 20) newHp = 20;
|
||||
player.setHealth(newHp);
|
||||
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain health!"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -254,17 +254,29 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if(playerWarzone.isFlagThief(player.getName())
|
||||
&& (team.getSpawnVolume().contains(player.getLocation())
|
||||
|| (team.getFlagVolume() != null && team.getFlagVolume().contains(player.getLocation())))) {
|
||||
// flags can be captured at own spawn or own flag pole
|
||||
team.setPoints(team.getPoints() + 1);
|
||||
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
|
||||
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
|
||||
victim.initializeTeamFlag();
|
||||
for(Team t : playerWarzone.getTeams()) {
|
||||
t.teamcast(war.str(player.getName() + " captured team " + victim.getName()
|
||||
+ "'s flag. Team " + team.getName() + " scores one point." ));
|
||||
synchronized(playerWarzone) {
|
||||
// flags can be captured at own spawn or own flag pole
|
||||
team.addPoint();
|
||||
if(team.getPoints() >= playerWarzone.getScoreCap()) {
|
||||
handleScoreCapReached(player, team.getName(), playerWarzone);
|
||||
event.setFrom(playerWarzone.getTeleport());
|
||||
player.teleportTo(playerWarzone.getTeleport());
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
// added a point
|
||||
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
|
||||
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
|
||||
victim.initializeTeamFlag();
|
||||
for(Team t : playerWarzone.getTeams()) {
|
||||
t.teamcast(war.str(player.getName() + " captured team " + victim.getName()
|
||||
+ "'s flag. Team " + team.getName() + " scores one point." ));
|
||||
}
|
||||
playerWarzone.respawnPlayer(event, team, player);
|
||||
team.resetSign();
|
||||
playerWarzone.getLobby().resetTeamGateSign(team);
|
||||
}
|
||||
playerWarzone.removeThief(player.getName());
|
||||
}
|
||||
playerWarzone.respawnPlayer(team, player);
|
||||
playerWarzone.removeThief(player.getName());
|
||||
}
|
||||
} else if (locZone != null && locZone.getLobby() != null
|
||||
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||
@ -338,30 +350,11 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
if(!scoreCapTeams.isEmpty()) {
|
||||
String winnersStr = "Score cap reached! Winning team(s): ";
|
||||
String winnersStr = "";
|
||||
for(Team winner : scoreCapTeams) {
|
||||
winnersStr += winner.getName() + " ";
|
||||
}
|
||||
winnersStr += ". Your inventory has (hopefully) been reset. The warzone is being reset... Please choose a new team.";
|
||||
// Score cap reached. Reset everything.
|
||||
for(Team t : teams) {
|
||||
t.teamcast(war.str(winnersStr));
|
||||
for(Player tp : t.getPlayers()) {
|
||||
if(tp.getName() != player.getName()) {
|
||||
tp.teleportTo(playerWarzone.getTeleport());
|
||||
}
|
||||
if(playerWarzone.hasPlayerInventory(tp.getName())){
|
||||
playerWarzone.restorePlayerInventory(tp);
|
||||
}
|
||||
}
|
||||
t.setPoints(0);
|
||||
t.getPlayers().clear(); // empty the team
|
||||
}
|
||||
if(playerWarzone.getLobby() != null) {
|
||||
playerWarzone.getLobby().getVolume().resetBlocks();
|
||||
}
|
||||
playerWarzone.getVolume().resetBlocks();
|
||||
playerWarzone.initializeZone();
|
||||
handleScoreCapReached(player, winnersStr, playerWarzone);
|
||||
scoreCapReached = true;
|
||||
} else {
|
||||
// We can keep going
|
||||
@ -374,6 +367,16 @@ public class WarPlayerListener extends PlayerListener {
|
||||
playerTeam.setRemainingTickets(playerTeam.getRemainingTickets()); // TODO get rid of this dirty workaround for the twice move-on-death bug
|
||||
}
|
||||
} else {
|
||||
if(playerWarzone.isFlagThief(player.getName())) {
|
||||
// died while carrying flag.. dropped it
|
||||
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
|
||||
victim.getFlagVolume().resetBlocks();
|
||||
victim.initializeTeamFlag();
|
||||
playerWarzone.removeThief(player.getName());
|
||||
for(Team t : playerWarzone.getTeams()) {
|
||||
t.teamcast(war.str(player.getName() + " died and dropped team " + victim.getName() + "'s flag."));
|
||||
}
|
||||
}
|
||||
playerTeam.setRemainingTickets(remaining - 1);
|
||||
}
|
||||
}
|
||||
@ -395,4 +398,28 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleScoreCapReached(Player player, String winnersStr, Warzone playerWarzone) {
|
||||
winnersStr = "Score cap reached! Winning team(s): " + winnersStr;
|
||||
winnersStr += ". Your inventory has (hopefully) been reset. The warzone is being reset... Please choose a new team.";
|
||||
// Score cap reached. Reset everything.
|
||||
for(Team t : playerWarzone.getTeams()) {
|
||||
t.teamcast(war.str(winnersStr));
|
||||
for(Player tp : t.getPlayers()) {
|
||||
if(tp.getName() != player.getName()) {
|
||||
tp.teleportTo(playerWarzone.getTeleport());
|
||||
}
|
||||
if(playerWarzone.hasPlayerInventory(tp.getName())){
|
||||
playerWarzone.restorePlayerInventory(tp);
|
||||
}
|
||||
}
|
||||
t.setPoints(0);
|
||||
t.getPlayers().clear(); // empty the team
|
||||
}
|
||||
if(playerWarzone.getLobby() != null) {
|
||||
playerWarzone.getLobby().getVolume().resetBlocks();
|
||||
}
|
||||
playerWarzone.getVolume().resetBlocks();
|
||||
playerWarzone.initializeZone();
|
||||
}
|
||||
}
|
||||
|
@ -289,8 +289,8 @@ public class Team {
|
||||
int x = teamFlag.getBlockX();
|
||||
int y = teamFlag.getBlockY();
|
||||
int z = teamFlag.getBlockZ();
|
||||
this.flagVolume.setCornerOne(warzone.getWorld().getBlockAt(x-2, y-1, z-2));
|
||||
this.flagVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+2, y+5, z+2));
|
||||
this.flagVolume.setCornerOne(warzone.getWorld().getBlockAt(x-1, y-1, z-1));
|
||||
this.flagVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+1, y+3, z+1));
|
||||
}
|
||||
|
||||
public void initializeTeamFlag() {
|
||||
@ -307,36 +307,17 @@ public class Team {
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
|
||||
// outer ring
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
|
||||
|
||||
// flag post
|
||||
warzone.getWorld().getBlockAt(x, y, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y, z-1).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x, y+1, z-1).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x, y+2, z-1).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x, y+2, z).setType(material);
|
||||
warzone.getWorld().getBlockAt(x, y+1, z).setType(material);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user