mirror of
https://github.com/taoneill/war.git
synced 2024-11-30 14:13:23 +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
|
// /deletezone
|
||||||
else if(command.equals("deletezone")) {
|
else if(command.equals("deletezone")) {
|
||||||
if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||||
player.sendMessage(this.str("Usage: /deletewarzone. " +
|
player.sendMessage(this.str("Usage: /deletezone. " +
|
||||||
"Deletes the warzone. " +
|
"Deletes the warzone. " +
|
||||||
"Must be in the warzone (try /zones and /zone). "));
|
"Must be in the warzone (try /zones and /zone). "));
|
||||||
} else {
|
} else {
|
||||||
|
@ -131,7 +131,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
t.teamcast(war.str("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn."));
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -201,23 +201,20 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
WarHub hub = war.getWarHub();
|
WarHub hub = war.getWarHub();
|
||||||
if(hub != null && hub.getVolume().contains(playerLoc)) {
|
if(hub != null && hub.getVolume().contains(playerLoc)) {
|
||||||
Warzone zone = hub.getDestinationWarzoneForLocation(playerLoc);
|
Warzone zone = hub.getDestinationWarzoneForLocation(playerLoc);
|
||||||
//synchronized(player) {
|
|
||||||
if(zone != null) {
|
if(zone != null) {
|
||||||
enteredGate = true;
|
enteredGate = true;
|
||||||
event.setFrom(zone.getTeleport());
|
event.setFrom(zone.getTeleport());
|
||||||
player.teleportTo(zone.getTeleport());
|
player.teleportTo(zone.getTeleport());
|
||||||
//
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(war.str("Welcome to warzone " + zone.getName() + "."));
|
player.sendMessage(war.str("Welcome to warzone " + zone.getName() + "."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(locZone != null && locZone.getLobby() != null
|
if(locZone != null && locZone.getLobby() != null
|
||||||
&& locZone.getLobby().isLeavingZone(playerLoc)) { // already in a team and in warzone, leaving
|
&& locZone.getLobby().isLeavingZone(playerLoc)) { // already in a team and in warzone, leaving
|
||||||
enteredGate = true;
|
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());
|
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||||
if(playerTeam != null) {
|
if(playerTeam != null) {
|
||||||
event.setFrom(playerWarzone.getTeleport());
|
event.setFrom(playerWarzone.getTeleport());
|
||||||
@ -245,8 +242,11 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
&& playerWarzone.nearAnyOwnedMonument(playerLoc, team)
|
&& playerWarzone.nearAnyOwnedMonument(playerLoc, team)
|
||||||
&& player.getHealth() < 20
|
&& player.getHealth() < 20
|
||||||
&& random.nextInt(42) == 3 ) { // one chance out of many of getting healed
|
&& random.nextInt(42) == 3 ) { // one chance out of many of getting healed
|
||||||
player.setHealth(20);
|
int currentHp = player.getHealth();
|
||||||
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!"));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,8 +254,16 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
if(playerWarzone.isFlagThief(player.getName())
|
if(playerWarzone.isFlagThief(player.getName())
|
||||||
&& (team.getSpawnVolume().contains(player.getLocation())
|
&& (team.getSpawnVolume().contains(player.getLocation())
|
||||||
|| (team.getFlagVolume() != null && team.getFlagVolume().contains(player.getLocation())))) {
|
|| (team.getFlagVolume() != null && team.getFlagVolume().contains(player.getLocation())))) {
|
||||||
|
synchronized(playerWarzone) {
|
||||||
// flags can be captured at own spawn or own flag pole
|
// flags can be captured at own spawn or own flag pole
|
||||||
team.setPoints(team.getPoints() + 1);
|
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());
|
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
|
||||||
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
|
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
|
||||||
victim.initializeTeamFlag();
|
victim.initializeTeamFlag();
|
||||||
@ -263,9 +271,13 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
t.teamcast(war.str(player.getName() + " captured team " + victim.getName()
|
t.teamcast(war.str(player.getName() + " captured team " + victim.getName()
|
||||||
+ "'s flag. Team " + team.getName() + " scores one point." ));
|
+ "'s flag. Team " + team.getName() + " scores one point." ));
|
||||||
}
|
}
|
||||||
playerWarzone.respawnPlayer(team, player);
|
playerWarzone.respawnPlayer(event, team, player);
|
||||||
|
team.resetSign();
|
||||||
|
playerWarzone.getLobby().resetTeamGateSign(team);
|
||||||
|
}
|
||||||
playerWarzone.removeThief(player.getName());
|
playerWarzone.removeThief(player.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (locZone != null && locZone.getLobby() != null
|
} else if (locZone != null && locZone.getLobby() != null
|
||||||
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||||
// player is not in any team, but inside warzone boundaries, get him out
|
// player is not in any team, but inside warzone boundaries, get him out
|
||||||
@ -338,30 +350,11 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!scoreCapTeams.isEmpty()) {
|
if(!scoreCapTeams.isEmpty()) {
|
||||||
String winnersStr = "Score cap reached! Winning team(s): ";
|
String winnersStr = "";
|
||||||
for(Team winner : scoreCapTeams) {
|
for(Team winner : scoreCapTeams) {
|
||||||
winnersStr += winner.getName() + " ";
|
winnersStr += winner.getName() + " ";
|
||||||
}
|
}
|
||||||
winnersStr += ". Your inventory has (hopefully) been reset. The warzone is being reset... Please choose a new team.";
|
handleScoreCapReached(player, winnersStr, playerWarzone);
|
||||||
// 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();
|
|
||||||
scoreCapReached = true;
|
scoreCapReached = true;
|
||||||
} else {
|
} else {
|
||||||
// We can keep going
|
// 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
|
playerTeam.setRemainingTickets(playerTeam.getRemainingTickets()); // TODO get rid of this dirty workaround for the twice move-on-death bug
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
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 x = teamFlag.getBlockX();
|
||||||
int y = teamFlag.getBlockY();
|
int y = teamFlag.getBlockY();
|
||||||
int z = teamFlag.getBlockZ();
|
int z = teamFlag.getBlockZ();
|
||||||
this.flagVolume.setCornerOne(warzone.getWorld().getBlockAt(x-2, y-1, z-2));
|
this.flagVolume.setCornerOne(warzone.getWorld().getBlockAt(x-1, y-1, z-1));
|
||||||
this.flagVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+2, y+5, z+2));
|
this.flagVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+1, y+3, z+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeTeamFlag() {
|
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).setType(Material.OBSIDIAN);
|
||||||
warzone.getWorld().getBlockAt(x+1, y-1, z-1).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+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, 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+1).setType(Material.OBSIDIAN);
|
||||||
warzone.getWorld().getBlockAt(x-1, y-1, z).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);
|
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
|
// 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);
|
warzone.getWorld().getBlockAt(x, y+1, z).setType(material);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user