mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 12:46:11 +01:00
Added { } around single returns too
This commit is contained in:
parent
88b2e5051d
commit
1d9dcb8a00
@ -1207,7 +1207,9 @@ public class War extends JavaPlugin {
|
||||
public Team getPlayerTeam(String playerName) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
Team team = warzone.getPlayerTeam(playerName);
|
||||
if (team != null) return team;
|
||||
if (team != null) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1215,7 +1217,9 @@ public class War extends JavaPlugin {
|
||||
public Warzone getPlayerTeamWarzone(String playerName) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
Team team = warzone.getPlayerTeam(playerName);
|
||||
if (team != null) return warzone;
|
||||
if (team != null) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1227,7 +1231,9 @@ public class War extends JavaPlugin {
|
||||
public Warzone warzone(Location location) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (location.getWorld().getName().equals(warzone.getWorld().getName())
|
||||
&& warzone.getVolume() != null && warzone.getVolume().contains(location)) return warzone;
|
||||
&& warzone.getVolume() != null && warzone.getVolume().contains(location)) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1235,19 +1241,22 @@ public class War extends JavaPlugin {
|
||||
public boolean inAnyWarzone(Location location) {
|
||||
Block locBlock = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
Warzone currentZone = this.warzone(location);
|
||||
if (currentZone == null)
|
||||
if (currentZone == null) {
|
||||
return false;
|
||||
else if (currentZone.getVolume().isWallBlock(locBlock))
|
||||
} else if (currentZone.getVolume().isWallBlock(locBlock))
|
||||
{
|
||||
return false; // wall block doesnt count. this lets people in at the lobby side wall because wall gates overlap with the zone.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean inWarzone(String warzoneName, Location location) {
|
||||
Warzone currentZone = this.warzone(location);
|
||||
if (currentZone == null)
|
||||
if (currentZone == null) {
|
||||
return false;
|
||||
else if (warzoneName.toLowerCase().equals(currentZone.getName().toLowerCase()))
|
||||
} else if (warzoneName.toLowerCase().equals(currentZone.getName().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1287,21 +1296,24 @@ public class War extends JavaPlugin {
|
||||
// the only way to find a zone that has only one corner
|
||||
public Warzone findWarzone(String warzoneName) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (warzone.getName().toLowerCase().equals(warzoneName.toLowerCase()))
|
||||
if (warzone.getName().toLowerCase().equals(warzoneName.toLowerCase())) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
for (Warzone warzone : this.incompleteZones) {
|
||||
if (warzone.getName().equals(warzoneName))
|
||||
if (warzone.getName().equals(warzoneName)) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Warzone matchWarzone(String warzoneSubString) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (warzone.getName().toLowerCase().startsWith(warzoneSubString.toLowerCase()))
|
||||
if (warzone.getName().toLowerCase().startsWith(warzoneSubString.toLowerCase())) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1342,8 +1354,9 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public String getWandBearerZone(Player player) {
|
||||
if (this.isWandBearer(player))
|
||||
if (this.isWandBearer(player)) {
|
||||
return this.wandBearers.get(player.getName());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -1387,7 +1400,9 @@ public class War extends JavaPlugin {
|
||||
|
||||
public Warzone zoneOfZoneWallAtProximity(Location location) {
|
||||
for (Warzone zone : this.warzones) {
|
||||
if (zone.getWorld() == location.getWorld() && zone.isNearWall(location)) return zone;
|
||||
if (zone.getWorld() == location.getWorld() && zone.isNearWall(location)) {
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1399,22 +1414,26 @@ public class War extends JavaPlugin {
|
||||
public boolean canPlayWar(Player player) {
|
||||
if (War.permissionHandler != null
|
||||
&& (War.permissionHandler.has(player, "war.player")
|
||||
|| War.permissionHandler.has(player, "War.player")))
|
||||
|| War.permissionHandler.has(player, "War.player"))) {
|
||||
return true;
|
||||
if (War.permissionHandler == null)
|
||||
}
|
||||
if (War.permissionHandler == null) {
|
||||
// w/o Permissions, everyone can play
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canWarp(Player player) {
|
||||
if (War.permissionHandler != null
|
||||
&& (War.permissionHandler.has(player, "war.warp")
|
||||
|| War.permissionHandler.has(player, "War.warp")))
|
||||
|| War.permissionHandler.has(player, "War.warp"))) {
|
||||
return true;
|
||||
if (War.permissionHandler == null)
|
||||
}
|
||||
if (War.permissionHandler == null) {
|
||||
// w/o Permissions, everyone can warp
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1422,44 +1441,53 @@ public class War extends JavaPlugin {
|
||||
if (this.isBuildInZonesOnly()) {
|
||||
if (War.permissionHandler != null
|
||||
&& (War.permissionHandler.has(player, "war.build")
|
||||
|| War.permissionHandler.has(player, "War.build")))
|
||||
|| War.permissionHandler.has(player, "War.build"))) {
|
||||
return true;
|
||||
}
|
||||
// w/o Permissions, if buildInZonesOnly, no one can build outside the zone except Zonemakers
|
||||
return this.isZoneMaker(player);
|
||||
} else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPvpOutsideZones(Player player) {
|
||||
if (this.isPvpInZonesOnly()) {
|
||||
if (War.permissionHandler != null
|
||||
&& (War.permissionHandler.has(player, "war.pvp")
|
||||
|| War.permissionHandler.has(player, "War.pvp")))
|
||||
|| War.permissionHandler.has(player, "War.pvp"))) {
|
||||
return true;
|
||||
}
|
||||
// w/o Permissions, if pvpInZoneOnly, no one can pvp outside the zone
|
||||
return false;
|
||||
} else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isZoneMaker(Player player) {
|
||||
for (String disguised : this.zoneMakersImpersonatingPlayers) {
|
||||
if (disguised.equals(player.getName())) return false;
|
||||
if (disguised.equals(player.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (String zoneMaker : this.zoneMakerNames) {
|
||||
if (zoneMaker.equals(player.getName())) return true;
|
||||
if (zoneMaker.equals(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ( War.permissionHandler != null
|
||||
&& (
|
||||
War.permissionHandler.has(player, "war.*")
|
||||
|| War.permissionHandler.has(player, "War.*")
|
||||
)
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return player.isOp();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getDefaultAutoAssignOnly() {
|
||||
|
||||
@ -1482,24 +1510,27 @@ public class War extends JavaPlugin {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (warzone.getLobby() != null
|
||||
&& warzone.getLobby().getVolume() != null
|
||||
&& warzone.getLobby().getVolume().contains(location))
|
||||
&& warzone.getLobby().getVolume().contains(location)) {
|
||||
return warzone.getLobby();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean inAnyWarzoneLobby(Location location) {
|
||||
if (this.lobby(location) == null)
|
||||
if (this.lobby(location) == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean inWarzoneLobby(String warzoneName, Location location) {
|
||||
ZoneLobby currentLobby = this.lobby(location);
|
||||
if (currentLobby == null)
|
||||
if (currentLobby == null) {
|
||||
return false;
|
||||
else if (warzoneName.toLowerCase().equals(currentLobby.getZone().getName().toLowerCase()))
|
||||
} else if (warzoneName.toLowerCase().equals(currentLobby.getZone().getName().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -102,14 +102,16 @@ public class Monument {
|
||||
int diffX = Math.abs(playerX - x);
|
||||
int diffY = Math.abs(playerY - y);
|
||||
int diffZ = Math.abs(playerZ - z);
|
||||
if (diffX < 6 && diffY < 6 && diffZ < 6)
|
||||
if (diffX < 6 && diffY < 6 && diffZ < 6) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOwner(Team team) {
|
||||
if (team == this.ownerTeam)
|
||||
if (team == this.ownerTeam) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -548,9 +548,10 @@ public class Team {
|
||||
int flagZ = this.teamFlag.getBlockZ();
|
||||
if (block.getX() == flagX
|
||||
&& block.getY() == flagY
|
||||
&& block.getZ() == flagZ)
|
||||
&& block.getZ() == flagZ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,10 @@ public class TeamKinds {
|
||||
public static TeamKind teamKindFromString(String str) {
|
||||
String lowered = str.toLowerCase();
|
||||
for (TeamKind kind : TeamKinds.getTeamkinds()) {
|
||||
if (kind.getDefaultName().startsWith(lowered))
|
||||
if (kind.getDefaultName().startsWith(lowered)) {
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,9 @@ public class Warzone {
|
||||
}
|
||||
|
||||
public boolean ready() {
|
||||
if (this.volume.hasTwoCorners() && !this.volume.tooSmall() && !this.volume.tooBig()) return true;
|
||||
if (this.volume.hasTwoCorners() && !this.volume.tooSmall() && !this.volume.tooBig()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,10 +99,11 @@ public class Warzone {
|
||||
public Team getPlayerTeam(String playerName) {
|
||||
for (Team team : this.teams) {
|
||||
for (Player player : team.getPlayers()) {
|
||||
if (player.getName().equals(playerName))
|
||||
if (player.getName().equals(playerName)) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -276,9 +279,10 @@ public class Warzone {
|
||||
int x = monument.getLocation().getBlockX();
|
||||
int y = monument.getLocation().getBlockY() + 1;
|
||||
int z = monument.getLocation().getBlockZ();
|
||||
if (x == block.getX() && y == block.getY() && z == block.getZ())
|
||||
if (x == block.getX() && y == block.getY() && z == block.getZ()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -287,17 +291,19 @@ public class Warzone {
|
||||
int x = monument.getLocation().getBlockX();
|
||||
int y = monument.getLocation().getBlockY() + 1;
|
||||
int z = monument.getLocation().getBlockZ();
|
||||
if (x == block.getX() && y == block.getY() && z == block.getZ())
|
||||
if (x == block.getX() && y == block.getY() && z == block.getZ()) {
|
||||
return monument;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean nearAnyOwnedMonument(Location to, Team team) {
|
||||
for (Monument monument : this.monuments) {
|
||||
if (monument.isNear(to) && monument.isOwner(team))
|
||||
if (monument.isNear(to) && monument.isOwner(team)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -392,42 +398,49 @@ public class Warzone {
|
||||
}
|
||||
|
||||
public InventoryStash getPlayerInventory(String playerName) {
|
||||
if (this.inventories.containsKey(playerName)) return this.inventories.get(playerName);
|
||||
if (this.inventories.containsKey(playerName)) {
|
||||
return this.inventories.get(playerName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasMonument(String monumentName) {
|
||||
for (Monument monument: this.monuments) {
|
||||
if (monument.getName().equals(monumentName))
|
||||
if (monument.getName().equals(monumentName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Monument getMonument(String monumentName) {
|
||||
for (Monument monument: this.monuments) {
|
||||
if (monument.getName().startsWith(monumentName))
|
||||
if (monument.getName().startsWith(monumentName)) {
|
||||
return monument;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isImportantBlock(Block block) {
|
||||
if (this.ready()) {
|
||||
for (Monument m : this.monuments) {
|
||||
if (m.getVolume().contains(block))
|
||||
if (m.getVolume().contains(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (Team t : this.teams) {
|
||||
if (t.getSpawnVolume().contains(block))
|
||||
if (t.getSpawnVolume().contains(block)) {
|
||||
return true;
|
||||
else if (t.getFlagVolume() != null
|
||||
&& t.getFlagVolume().contains(block))
|
||||
} else if (t.getFlagVolume() != null
|
||||
&& t.getFlagVolume().contains(block)) {
|
||||
return true;
|
||||
}
|
||||
if (this.volume.isWallBlock(block))
|
||||
}
|
||||
if (this.volume.isWallBlock(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -450,9 +463,10 @@ public class Warzone {
|
||||
|
||||
public Team getTeamByKind(TeamKind kind) {
|
||||
for (Team t : this.teams) {
|
||||
if (t.getKind() == kind)
|
||||
if (t.getKind() == kind) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -462,39 +476,41 @@ public class Warzone {
|
||||
&& latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX()
|
||||
&& latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX()
|
||||
&& latestPlayerLocation.getBlockY() >= this.volume.getMinY()
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY())
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
return true; // near east wall
|
||||
else if (Math.abs(this.volume.getSoutheastX() - latestPlayerLocation.getBlockX()) < this.minSafeDistanceFromWall
|
||||
} else if (Math.abs(this.volume.getSoutheastX() - latestPlayerLocation.getBlockX()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockZ() <= this.volume.getNorthwestZ()
|
||||
&& latestPlayerLocation.getBlockZ() >= this.volume.getSoutheastZ()
|
||||
&& latestPlayerLocation.getBlockY() >= this.volume.getMinY()
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY())
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
return true; // near south wall
|
||||
else if (Math.abs(this.volume.getNorthwestX() - latestPlayerLocation.getBlockX()) < this.minSafeDistanceFromWall
|
||||
} else if (Math.abs(this.volume.getNorthwestX() - latestPlayerLocation.getBlockX()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockZ() <= this.volume.getNorthwestZ()
|
||||
&& latestPlayerLocation.getBlockZ() >= this.volume.getSoutheastZ()
|
||||
&& latestPlayerLocation.getBlockY() >= this.volume.getMinY()
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY())
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
return true; // near north wall
|
||||
else if (Math.abs(this.volume.getNorthwestZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall
|
||||
} else if (Math.abs(this.volume.getNorthwestZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX()
|
||||
&& latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX()
|
||||
&& latestPlayerLocation.getBlockY() >= this.volume.getMinY()
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY())
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
return true; // near west wall
|
||||
else if (Math.abs(this.volume.getMaxY() - latestPlayerLocation.getBlockY()) < this.minSafeDistanceFromWall
|
||||
} else if (Math.abs(this.volume.getMaxY() - latestPlayerLocation.getBlockY()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockX() <= this.volume.getMaxX()
|
||||
&& latestPlayerLocation.getBlockX() >= this.volume.getMinX()
|
||||
&& latestPlayerLocation.getBlockZ() <= this.volume.getMaxZ()
|
||||
&& latestPlayerLocation.getBlockZ() >= this.volume.getMinZ())
|
||||
&& latestPlayerLocation.getBlockZ() >= this.volume.getMinZ()) {
|
||||
return true; // near up wall
|
||||
else if (Math.abs(this.volume.getMinY() - latestPlayerLocation.getBlockY()) < this.minSafeDistanceFromWall
|
||||
} else if (Math.abs(this.volume.getMinY() - latestPlayerLocation.getBlockY()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockX() <= this.volume.getMaxX()
|
||||
&& latestPlayerLocation.getBlockX() >= this.volume.getMinX()
|
||||
&& latestPlayerLocation.getBlockZ() <= this.volume.getMaxZ()
|
||||
&& latestPlayerLocation.getBlockZ() >= this.volume.getMinZ())
|
||||
{
|
||||
return true; // near down wall
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -623,9 +639,10 @@ public class Warzone {
|
||||
|
||||
public ZoneWallGuard getPlayerZoneWallGuard(String name, BlockFace wall) {
|
||||
for (ZoneWallGuard guard : this.zoneWallGuards) {
|
||||
if (guard.getPlayer().getName().equals(name) && wall == guard.getWall())
|
||||
if (guard.getPlayer().getName().equals(name) && wall == guard.getWall()) {
|
||||
return guard;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -883,17 +900,19 @@ public class Warzone {
|
||||
public boolean isEnemyTeamFlagBlock(Team playerTeam, Block block) {
|
||||
for (Team team : this.teams) {
|
||||
if (!team.getName().equals(playerTeam.getName())
|
||||
&& team.isTeamFlagBlock(block))
|
||||
&& team.isTeamFlagBlock(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Team getTeamForFlagBlock(Block block) {
|
||||
for (Team team : this.teams) {
|
||||
if (team.isTeamFlagBlock(block))
|
||||
if (team.isTeamFlagBlock(block)) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -902,7 +921,9 @@ public class Warzone {
|
||||
}
|
||||
|
||||
public boolean isFlagThief(String suspect) {
|
||||
if (this.flagThieves.containsKey(suspect)) return true;
|
||||
if (this.flagThieves.containsKey(suspect)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -920,9 +941,10 @@ public class Warzone {
|
||||
|
||||
public boolean isTeamFlagStolen(Team team) {
|
||||
for (String playerKey : this.flagThieves.keySet()) {
|
||||
if (this.flagThieves.get(playerKey).getName().equals(team.getName()))
|
||||
if (this.flagThieves.get(playerKey).getName().equals(team.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1000,8 +1022,9 @@ public class Warzone {
|
||||
}
|
||||
|
||||
public boolean isDeadMan(String playerName) {
|
||||
if (this.deadMenInventories.containsKey(playerName))
|
||||
if (this.deadMenInventories.containsKey(playerName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -544,9 +544,10 @@ public class ZoneLobby {
|
||||
if (info != null) {
|
||||
if (location.getBlockX() == info.getX()
|
||||
&& location.getBlockY() == info.getY()
|
||||
&& location.getBlockZ() == info.getZ())
|
||||
&& location.getBlockZ() == info.getZ()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -554,8 +555,9 @@ public class ZoneLobby {
|
||||
if (this.autoAssignGate != null
|
||||
&& (location.getBlockX() == this.autoAssignGate.getX()
|
||||
&& location.getBlockY() == this.autoAssignGate.getY()
|
||||
&& location.getBlockZ() == this.autoAssignGate.getZ()) )
|
||||
&& location.getBlockZ() == this.autoAssignGate.getZ()) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -576,8 +578,9 @@ public class ZoneLobby {
|
||||
if (this.warHubLinkGate != null
|
||||
&& location.getBlockX() == this.warHubLinkGate.getX()
|
||||
&& location.getBlockY() == this.warHubLinkGate.getY()
|
||||
&& location.getBlockZ() == this.warHubLinkGate.getZ())
|
||||
&& location.getBlockZ() == this.warHubLinkGate.getZ()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -585,13 +588,15 @@ public class ZoneLobby {
|
||||
if (blockWall == this.wall) {
|
||||
for (String teamName: this.teamGateBlocks.keySet()) {
|
||||
BlockInfo gateInfo = this.teamGateBlocks.get(teamName);
|
||||
if (this.isPartOfGate(BlockInfo.getBlock(this.warzone.getWorld(), gateInfo), block))
|
||||
if (this.isPartOfGate(BlockInfo.getBlock(this.warzone.getWorld(), gateInfo), block)) {
|
||||
return true;
|
||||
}
|
||||
if (this.autoAssignGate != null && this.isPartOfGate(BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate), block))
|
||||
}
|
||||
if (this.autoAssignGate != null && this.isPartOfGate(BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate), block)) {
|
||||
// auto assign
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -753,12 +758,16 @@ public class ZoneLobby {
|
||||
right = BlockFace.NORTH;
|
||||
}
|
||||
if (this.autoAssignGate != null){
|
||||
if (this.leaving(location, BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate), inside, left, right)) return true;
|
||||
if (this.leaving(location, BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate), inside, left, right)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (String teamName : this.teamGateBlocks.keySet()) {
|
||||
|
||||
BlockInfo info = this.teamGateBlocks.get(teamName);
|
||||
if (this.leaving(location, BlockInfo.getBlock(this.warzone.getWorld(), info), inside, left, right)) return true;
|
||||
if (this.leaving(location, BlockInfo.getBlock(this.warzone.getWorld(), info), inside, left, right)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -775,8 +784,9 @@ public class ZoneLobby {
|
||||
gateExitVolume.setCornerOne(out.getFace(left).getFace(BlockFace.DOWN));
|
||||
gateExitVolume.setCornerTwo(gate.getFace(right, 1).getFace(BlockFace.UP, 3));
|
||||
|
||||
if (gateExitVolume.contains(location))
|
||||
if (gateExitVolume.contains(location)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 1 block thick arrow like detection grid:
|
||||
// Block out = gate.getFace(inside);
|
||||
|
@ -162,8 +162,9 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to "" or empty.
|
||||
*/
|
||||
public String getString(String key) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return this.getProperty(key);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
@ -179,8 +180,9 @@ public final class PropertiesFile {
|
||||
* @return java.lang.String Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public String getString(String key, String value) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return this.getProperty(key);
|
||||
}
|
||||
|
||||
this.setString(key, value);
|
||||
return value;
|
||||
@ -206,8 +208,9 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0
|
||||
*/
|
||||
public int getInt(String key) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Integer.parseInt(this.getProperty(key));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -221,8 +224,9 @@ public final class PropertiesFile {
|
||||
* @return <code>Integer</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public int getInt(String key, int value) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Integer.parseInt(this.getProperty(key));
|
||||
}
|
||||
|
||||
this.setInt(key, value);
|
||||
return value;
|
||||
@ -250,8 +254,9 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0.0
|
||||
*/
|
||||
public double getDouble(String key) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Double.parseDouble(this.getProperty(key));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -265,8 +270,9 @@ public final class PropertiesFile {
|
||||
* @return <code>Double</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public double getDouble(String key, double value) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Double.parseDouble(this.getProperty(key));
|
||||
}
|
||||
|
||||
this.setDouble(key, value);
|
||||
return value;
|
||||
@ -293,8 +299,9 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0L
|
||||
*/
|
||||
public long getLong(String key) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Long.parseLong(this.getProperty(key));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -308,8 +315,9 @@ public final class PropertiesFile {
|
||||
* @return <code>Long</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public long getLong(String key, long value) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Long.parseLong(this.getProperty(key));
|
||||
}
|
||||
|
||||
this.setLong(key, value);
|
||||
return value;
|
||||
@ -336,8 +344,9 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to false
|
||||
*/
|
||||
public boolean getBoolean(String key) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Boolean.parseBoolean(this.getProperty(key));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -351,8 +360,9 @@ public final class PropertiesFile {
|
||||
* @return <code>Boolean</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public boolean getBoolean(String key, boolean value) {
|
||||
if (this.containsKey(key))
|
||||
if (this.containsKey(key)) {
|
||||
return Boolean.parseBoolean(this.getProperty(key));
|
||||
}
|
||||
|
||||
this.setBoolean(key, value);
|
||||
return value;
|
||||
|
@ -130,18 +130,19 @@ public class ChatFixUtil {
|
||||
*/
|
||||
public static String thisMsgWouldCrashClient(String str) {
|
||||
// There would always be crash if we end with deg or deg+'anychar'
|
||||
if (str.length() >= 1 && str.charAt(str.length() - 1) == ChatFixUtil.deg)
|
||||
if (str.length() >= 1 && str.charAt(str.length() - 1) == ChatFixUtil.deg) {
|
||||
return "Crash: The str ends with deg.";
|
||||
else if (str.length() >= 2 && str.charAt(str.length() - 2) == ChatFixUtil.deg)
|
||||
} else if (str.length() >= 2 && str.charAt(str.length() - 2) == ChatFixUtil.deg) {
|
||||
return "Crash: The str ends with deg+'anychar'.";
|
||||
}
|
||||
|
||||
int displayedChars = 0;
|
||||
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
if (c == ChatFixUtil.deg && displayedChars == ChatFixUtil.lineLength)
|
||||
if (c == ChatFixUtil.deg && displayedChars == ChatFixUtil.lineLength) {
|
||||
return "Crash: Deg as fiftyforth \"displayed\" char";
|
||||
else if (c == ChatFixUtil.deg) {
|
||||
} else if (c == ChatFixUtil.deg) {
|
||||
i++; // this and next: they are not displayed... skip them...
|
||||
} else {
|
||||
displayedChars += 1;
|
||||
|
@ -42,7 +42,9 @@ public class VerticalVolume extends Volume{
|
||||
if (this.getMinZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX())
|
||||
{
|
||||
return true; // east wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -50,7 +52,9 @@ public class VerticalVolume extends Volume{
|
||||
if (this.getMaxX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ())
|
||||
{
|
||||
return true; // south wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,7 +62,9 @@ public class VerticalVolume extends Volume{
|
||||
if (this.getMinX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ())
|
||||
{
|
||||
return true; // north wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,7 +72,9 @@ public class VerticalVolume extends Volume{
|
||||
if (this.getMaxZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX())
|
||||
{
|
||||
return true; // west wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -327,17 +327,23 @@ public class Volume {
|
||||
}
|
||||
|
||||
public BlockInfo getMinXBlock() {
|
||||
if (this.cornerOne.getX() < this.cornerTwo.getX()) return this.cornerOne;
|
||||
if (this.cornerOne.getX() < this.cornerTwo.getX()) {
|
||||
return this.cornerOne;
|
||||
}
|
||||
return this.cornerTwo;
|
||||
}
|
||||
|
||||
public BlockInfo getMinYBlock() {
|
||||
if (this.cornerOne.getY() < this.cornerTwo.getY()) return this.cornerOne;
|
||||
if (this.cornerOne.getY() < this.cornerTwo.getY()) {
|
||||
return this.cornerOne;
|
||||
}
|
||||
return this.cornerTwo;
|
||||
}
|
||||
|
||||
public BlockInfo getMinZBlock() {
|
||||
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) return this.cornerOne;
|
||||
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) {
|
||||
return this.cornerOne;
|
||||
}
|
||||
return this.cornerTwo;
|
||||
}
|
||||
|
||||
@ -354,17 +360,23 @@ public class Volume {
|
||||
}
|
||||
|
||||
public BlockInfo getMaxXBlock() {
|
||||
if (this.cornerOne.getX() < this.cornerTwo.getX()) return this.cornerTwo;
|
||||
if (this.cornerOne.getX() < this.cornerTwo.getX()) {
|
||||
return this.cornerTwo;
|
||||
}
|
||||
return this.cornerOne;
|
||||
}
|
||||
|
||||
public BlockInfo getMaxYBlock() {
|
||||
if (this.cornerOne.getY() < this.cornerTwo.getY()) return this.cornerTwo;
|
||||
if (this.cornerOne.getY() < this.cornerTwo.getY()) {
|
||||
return this.cornerTwo;
|
||||
}
|
||||
return this.cornerOne;
|
||||
}
|
||||
|
||||
public BlockInfo getMaxZBlock() {
|
||||
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) return this.cornerTwo;
|
||||
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) {
|
||||
return this.cornerTwo;
|
||||
}
|
||||
return this.cornerOne;
|
||||
}
|
||||
|
||||
|
@ -73,21 +73,23 @@ public class ZoneVolume extends Volume {
|
||||
if (this.getCornerTwo() == null) {
|
||||
// northwest defaults to corner 1
|
||||
super.setCornerOne(topBlock);
|
||||
} else if (this.getCornerTwo().getX() <= block.getX() || this.getCornerTwo().getZ() >= block.getZ())
|
||||
} else if (this.getCornerTwo().getX() <= block.getX() || this.getCornerTwo().getZ() >= block.getZ()) {
|
||||
throw new NotNorthwestException();
|
||||
else {
|
||||
} else {
|
||||
// corner 2 already set, but we're sure we're located at the northwest of it
|
||||
super.setCornerOne(topBlock);
|
||||
}
|
||||
} else if (this.getCornerTwo() == null){
|
||||
// corner 1 already exists, set northwest as corner 2 (only if it's at the northwest of corner 1)
|
||||
if (this.getCornerOne().getX() <= block.getX() || this.getCornerOne().getZ() >= block.getZ())
|
||||
if (this.getCornerOne().getX() <= block.getX() || this.getCornerOne().getZ() >= block.getZ()) {
|
||||
throw new NotNorthwestException();
|
||||
}
|
||||
super.setCornerTwo(topBlock);
|
||||
} else {
|
||||
// both corners already set: we are resizing (only if the new block is northwest relative to the southeasternmost block)
|
||||
if (this.getSoutheastX() <= block.getX() || this.getSoutheastZ() >= block.getZ())
|
||||
if (this.getSoutheastX() <= block.getX() || this.getSoutheastZ() >= block.getZ()) {
|
||||
throw new NotNorthwestException();
|
||||
}
|
||||
BlockInfo minXBlock = this.getMinXBlock(); // north means min X
|
||||
minXBlock.setX(block.getX()); // mutating, argh!
|
||||
BlockInfo maxZBlock = this.getMaxZBlock(); // west means max Z
|
||||
@ -105,18 +107,20 @@ public class ZoneVolume extends Volume {
|
||||
}
|
||||
|
||||
public int getNorthwestX() {
|
||||
if (!this.hasTwoCorners())
|
||||
if (!this.hasTwoCorners()) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return this.getMinX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getNorthwestZ() {
|
||||
if (!this.hasTwoCorners())
|
||||
if (!this.hasTwoCorners()) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return this.getMaxZ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSoutheast(Block block) throws NotSoutheastException, TooSmallException, TooBigException {
|
||||
// southeast defaults to bottom block
|
||||
@ -128,21 +132,23 @@ public class ZoneVolume extends Volume {
|
||||
if (this.getCornerOne() == null) {
|
||||
// southeast defaults to corner 2
|
||||
super.setCornerTwo(bottomBlock);
|
||||
} else if (this.getCornerOne().getX() >= block.getX() || this.getCornerOne().getZ() <= block.getZ())
|
||||
} else if (this.getCornerOne().getX() >= block.getX() || this.getCornerOne().getZ() <= block.getZ()) {
|
||||
throw new NotSoutheastException();
|
||||
else {
|
||||
} else {
|
||||
// corner 1 already set, but we're sure we're located at the southeast of it
|
||||
super.setCornerTwo(bottomBlock);
|
||||
}
|
||||
} else if (this.getCornerOne() == null){
|
||||
// corner 2 already exists, set northwest as corner 1 (only if it's at the southeast of corner 2)
|
||||
if (this.getCornerTwo().getX() >= block.getX() || this.getCornerTwo().getZ() <= block.getZ())
|
||||
if (this.getCornerTwo().getX() >= block.getX() || this.getCornerTwo().getZ() <= block.getZ()) {
|
||||
throw new NotSoutheastException();
|
||||
}
|
||||
super.setCornerOne(bottomBlock);
|
||||
} else {
|
||||
// both corners already set: we are resizing (only if the new block is southeast relative to the northwesternmost block)
|
||||
if (this.getNorthwestX() >= block.getX() || this.getNorthwestZ() <= block.getZ())
|
||||
if (this.getNorthwestX() >= block.getX() || this.getNorthwestZ() <= block.getZ()) {
|
||||
throw new NotSoutheastException();
|
||||
}
|
||||
BlockInfo maxXBlock = this.getMaxXBlock(); // south means max X
|
||||
maxXBlock.setX(block.getX()); // mutating, argh!
|
||||
BlockInfo minZBlock = this.getMinZBlock(); // east means min Z
|
||||
@ -161,25 +167,28 @@ public class ZoneVolume extends Volume {
|
||||
}
|
||||
|
||||
public int getSoutheastX() {
|
||||
if (!this.hasTwoCorners())
|
||||
if (!this.hasTwoCorners()) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return this.getMaxX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getSoutheastZ() {
|
||||
if (!this.hasTwoCorners())
|
||||
if (!this.hasTwoCorners()) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return this.getMinZ();
|
||||
}
|
||||
}
|
||||
|
||||
public int getCenterY() {
|
||||
if (!this.hasTwoCorners())
|
||||
if (!this.hasTwoCorners()) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return this.getMinY() + (this.getMaxY() - this.getMinY())/2;
|
||||
}
|
||||
}
|
||||
|
||||
public void setZoneCornerOne(Block block) throws TooSmallException, TooBigException {
|
||||
BlockInfo oldCornerOne = this.getCornerOne();
|
||||
@ -208,14 +217,18 @@ public class ZoneVolume extends Volume {
|
||||
public boolean tooSmall() {
|
||||
if (this.hasTwoCorners() && ((this.getMaxX() - this.getMinX() < 10)
|
||||
|| (this.getMaxY() - this.getMinY() < 10)
|
||||
|| (this.getMaxZ() - this.getMinZ() < 10))) return true;
|
||||
|| (this.getMaxZ() - this.getMinZ() < 10))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean tooBig() {
|
||||
if (this.hasTwoCorners() && ((this.getMaxX() - this.getMinX() > 750)
|
||||
|| (this.getMaxY() - this.getMinY() > 750)
|
||||
|| (this.getMaxZ() - this.getMinZ() > 750))) return true;
|
||||
|| (this.getMaxZ() - this.getMinZ() > 750))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -224,31 +237,35 @@ public class ZoneVolume extends Volume {
|
||||
for (Team team : this.zone.getTeams()) {
|
||||
if (team.getTeamSpawn() != null) {
|
||||
if (!this.isInside(team.getSpawnVolume().getCornerOne())
|
||||
|| !this.isInside(team.getSpawnVolume().getCornerTwo()))
|
||||
|| !this.isInside(team.getSpawnVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (team.getTeamFlag() != null) {
|
||||
if (!this.isInside(team.getFlagVolume().getCornerOne())
|
||||
|| !this.isInside(team.getFlagVolume().getCornerTwo()))
|
||||
|| !this.isInside(team.getFlagVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check monuments
|
||||
for (Monument monument : this.zone.getMonuments()) {
|
||||
if (monument.getVolume() != null) {
|
||||
if (!this.isInside(monument.getVolume().getCornerOne())
|
||||
|| !this.isInside(monument.getVolume().getCornerTwo()))
|
||||
|| !this.isInside(monument.getVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInside(BlockInfo info) {
|
||||
if (info.getX() <= this.getMaxX() && info.getX() >= this.getMinX() &&
|
||||
info.getY() <= this.getMaxY() && info.getY() >= this.getMinY() &&
|
||||
info.getZ() <= this.getMaxZ() && info.getZ() >= this.getMinZ())
|
||||
info.getZ() <= this.getMaxZ() && info.getZ() >= this.getMinZ()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -264,7 +281,9 @@ public class ZoneVolume extends Volume {
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
return true; // east wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -274,7 +293,9 @@ public class ZoneVolume extends Volume {
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
return true; // south wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -284,7 +305,9 @@ public class ZoneVolume extends Volume {
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
return true; // north wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -294,7 +317,9 @@ public class ZoneVolume extends Volume {
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
return true; // west wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -304,7 +329,9 @@ public class ZoneVolume extends Volume {
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getZ() <= this.getMaxZ())
|
||||
{
|
||||
return true; // top wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -314,7 +341,9 @@ public class ZoneVolume extends Volume {
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getZ() <= this.getMaxZ())
|
||||
{
|
||||
return true; // bottom wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user