mirror of
https://github.com/taoneill/war.git
synced 2025-02-02 20:51:20 +01:00
Fixed leaving zone that was glitchy. Just approaching the gates now makes you leave. Fixed lifepool decrement by one too many bug with a dirty workaround for now. Ready to release v0.3 of next short test goes well.
This commit is contained in:
parent
003b89f904
commit
3f164f60c5
@ -529,6 +529,7 @@ public class War extends JavaPlugin {
|
||||
warzone.restorePlayerInventory(p);
|
||||
player.sendMessage(this.str("You have left the warzone. Your inventory has (hopefully) been restored."));
|
||||
}
|
||||
team.getPlayers().clear();
|
||||
}
|
||||
|
||||
Warzone resetWarzone = null;
|
||||
|
@ -71,10 +71,11 @@ public class WarPlayerListener extends PlayerListener {
|
||||
// Player belongs to a warzone team but is outside: he just died! Handle death! Don't exempt the zone maker.
|
||||
if(from != null && war.warzone(player.getLocation()) == null && team != null) {
|
||||
// teleport to team spawn upon death
|
||||
|
||||
player.sendMessage(war.str("You died."));
|
||||
boolean newBattle = false;
|
||||
boolean scoreCapReached = false;
|
||||
synchronized(playerWarzone) {
|
||||
synchronized(player) {
|
||||
int remaining = team.getRemainingTickets();
|
||||
if(remaining == 0) { // your death caused your team to lose
|
||||
List<Team> teams = playerWarzone.getTeams();
|
||||
@ -104,6 +105,12 @@ public class WarPlayerListener extends PlayerListener {
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
t.setPoints(0);
|
||||
t.getPlayers().clear(); // empty the team
|
||||
}
|
||||
playerWarzone.getVolume().resetBlocks();
|
||||
@ -117,18 +124,21 @@ public class WarPlayerListener extends PlayerListener {
|
||||
playerWarzone.getVolume().resetBlocks();
|
||||
playerWarzone.initializeZone();
|
||||
newBattle = true;
|
||||
team.setRemainingTickets(team.getRemainingTickets()+1); // TODO get rid of this dirty workaround for the twice move-on-death bug
|
||||
}
|
||||
} else {
|
||||
} else if(!team.getVolume().contains(player.getLocation())){
|
||||
// only decrement points if the player is not already back at spawn
|
||||
team.setRemainingTickets(remaining - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
synchronized(player) {
|
||||
if(!newBattle && !scoreCapReached && !war.inAnyWarzone(player.getLocation())) { // only respawn him if he isnt back at zone yet
|
||||
playerWarzone.respawnPlayer(event, team, player);
|
||||
team.resetSign();
|
||||
war.info(player.getName() + " died and was tp'd back to team " + team.getName() + "'s spawn");
|
||||
} else if (scoreCapReached) {
|
||||
player.teleportTo(playerWarzone.getTeleport());
|
||||
event.setTo(playerWarzone.getTeleport());
|
||||
team.resetSign();
|
||||
war.info(player.getName() + " died and enemy team reached score cap");
|
||||
} else if (newBattle){
|
||||
@ -145,8 +155,8 @@ public class WarPlayerListener extends PlayerListener {
|
||||
player.setHealth(20);
|
||||
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!"));
|
||||
}
|
||||
} else if (war.inAnyWarzone(player.getLocation()) && !war.isZoneMaker(player.getName())) { // player is not in any team, but inside warzone boundaries, get him out
|
||||
Warzone zone = war.warzone(player.getLocation());
|
||||
} else if (war.inAnyWarzone(to) && !war.isZoneMaker(player.getName())) { // player is not in any team, but inside warzone boundaries, get him out
|
||||
Warzone zone = war.warzone(to);
|
||||
event.setTo(zone.getTeleport());
|
||||
player.sendMessage(war.str("You can't be inside a warzone without a team."));
|
||||
}
|
||||
@ -223,11 +233,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
event.setTo(war.getWarHub().getLocation());
|
||||
player.sendMessage(war.str("Welcome to the War hub."));
|
||||
}
|
||||
} else if(war.inAnyWarzone(event.getFrom())) { // already in a team and in warzone, leaving
|
||||
if(zone.getLobby().isAutoAssignGate(to)
|
||||
|| zone.getLobby().isInTeamGate(TeamMaterials.TEAMDIAMOND, to)
|
||||
|| zone.getLobby().isInTeamGate(TeamMaterials.TEAMIRON, to)
|
||||
|| zone.getLobby().isInTeamGate(TeamMaterials.TEAMGOLD, to)) {
|
||||
} else if(zone.getLobby().isLeavingZone(to)) { // already in a team and in warzone, leaving
|
||||
// same as leave, except event.setTo
|
||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||
playerTeam.removePlayer(player.getName());
|
||||
@ -236,7 +242,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
player.sendMessage(war.str("Left the zone."));
|
||||
playerWarzone.restorePlayerInventory(player);
|
||||
player.sendMessage(war.str("Your inventory has (hopefully) been restored."));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,4 +228,8 @@ public class Team {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public void setPoints(int score) {
|
||||
this.points = score;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -493,7 +493,12 @@ public class ZoneLobby {
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(rightSide).getX()
|
||||
&& block.getY() == gateBlock.getFace(rightSide).getY()
|
||||
&& block.getZ() == gateBlock.getFace(rightSide).getZ());
|
||||
&& block.getZ() == gateBlock.getFace(rightSide).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getX()
|
||||
&& block.getY() == gateBlock.getY() - 1
|
||||
&& block.getZ() == gateBlock.getZ())
|
||||
;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -573,4 +578,65 @@ public class ZoneLobby {
|
||||
state.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLeavingZone(Location location) {
|
||||
|
||||
BlockFace inside = null;
|
||||
BlockFace left = null;
|
||||
BlockFace right = null;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
inside = BlockFace.SOUTH;
|
||||
left = BlockFace.WEST;
|
||||
right = BlockFace.EAST;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
inside = BlockFace.WEST;
|
||||
left = BlockFace.NORTH;
|
||||
right = BlockFace.SOUTH;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
inside = BlockFace.NORTH;
|
||||
left = BlockFace.EAST;
|
||||
right = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
inside = BlockFace.EAST;
|
||||
left = BlockFace.SOUTH;
|
||||
right = BlockFace.NORTH;
|
||||
}
|
||||
if(autoAssignGate != null){
|
||||
if(leaving(location, autoAssignGate, inside, left, right)) return true;
|
||||
} else if(diamondGate != null){
|
||||
if(leaving(location, diamondGate, inside, left, right)) return true;
|
||||
} else if(ironGate != null){
|
||||
if(leaving(location, ironGate, inside, left, right)) return true;
|
||||
} else if(goldGate != null){
|
||||
if(leaving(location, goldGate, inside, left, right)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean leaving(Location location, Block gate, BlockFace inside,
|
||||
BlockFace left, BlockFace right) {
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
Block out = gate.getFace(inside);
|
||||
Block outL = out.getFace(left);
|
||||
Block outR = out.getFace(right);
|
||||
Block out2 = gate.getFace(inside, 2);
|
||||
Block out2L = out2.getFace(left);
|
||||
Block out2R = out2.getFace(right);
|
||||
if(out.getX() == x && out.getY() == y && out.getZ() == z) {
|
||||
return true;
|
||||
} else if(outL.getX() == x && outL.getY() == y && outL.getZ() == z) {
|
||||
return true;
|
||||
} else if(outR.getX() == x && outR.getY() == y && outR.getZ() == z) {
|
||||
return true;
|
||||
} else if(out2.getX() == x && out2.getY() == y && out2.getZ() == z) {
|
||||
return true;
|
||||
} else if(out2L.getX() == x && out2L.getY() == y && out2L.getZ() == z) {
|
||||
return true;
|
||||
} else if(out2R.getX() == x && out2R.getY() == y && out2R.getZ() == z) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user