mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 12:46:11 +01:00
More reformatting
This commit is contained in:
parent
1d9dcb8a00
commit
2edcb2d302
@ -81,7 +81,6 @@ public class War extends JavaPlugin {
|
||||
|
||||
private WarHub warHub;
|
||||
|
||||
|
||||
public void onDisable() {
|
||||
this.unloadWar();
|
||||
}
|
||||
@ -155,8 +154,7 @@ public class War extends JavaPlugin {
|
||||
String command = cmd.getName();
|
||||
String[] arguments = null;
|
||||
// Handle both /war <command> and /<war command>. I.e. "/war zone temple" == "/zone temple"
|
||||
String helpMessage = "War is on. Please pick your battle. " +
|
||||
"Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions.";
|
||||
String helpMessage = "War is on. Please pick your battle. " + "Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions.";
|
||||
if ((command.equals("war") || command.equals("War")) && args.length > 0) {
|
||||
command = args[0];
|
||||
arguments = new String[args.length - 1];
|
||||
@ -229,20 +227,7 @@ public class War extends JavaPlugin {
|
||||
this.loadWar();
|
||||
}
|
||||
} else if (command.equals("setzone") // Not a zone maker but War command.
|
||||
|| command.equals("nextbattle")
|
||||
|| command.equals("setzonelobby")
|
||||
|| command.equals("savezone")
|
||||
|| command.equals("setzoneconfig")
|
||||
|| command.equals("resetzone")
|
||||
|| command.equals("deletezone")
|
||||
|| command.equals("setteam")
|
||||
|| command.equals("deleteteam")
|
||||
|| command.equals("setmonument")
|
||||
|| command.equals("deletemonument")
|
||||
|| command.equals("setwarhub")
|
||||
|| command.equals("deletewarhub")
|
||||
|| command.equals("setwarconfig")
|
||||
|| command.equals("unloadwar")) {
|
||||
|| command.equals("nextbattle") || command.equals("setzonelobby") || command.equals("savezone") || command.equals("setzoneconfig") || command.equals("resetzone") || command.equals("deletezone") || command.equals("setteam") || command.equals("deleteteam") || command.equals("setmonument") || command.equals("deletemonument") || command.equals("setwarhub") || command.equals("deletewarhub") || command.equals("setwarconfig") || command.equals("unloadwar")) {
|
||||
this.badMsg(player, "You can't do this if you are not a warzone maker.");
|
||||
} else if (command.equals("zonemaker") || command.equals("zm")) {
|
||||
this.performZonemakerAsPlayer(player);
|
||||
@ -251,8 +236,7 @@ public class War extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void inventoryToLoadout(Player player,
|
||||
HashMap<Integer, ItemStack> loadout) {
|
||||
private void inventoryToLoadout(Player player, HashMap<Integer, ItemStack> loadout) {
|
||||
loadout.clear();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
int i = 0;
|
||||
@ -290,9 +274,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public void performZonemakerAsZonemaker(Player player, String[] arguments) {
|
||||
if (arguments.length > 2) {
|
||||
this.badMsg(player, "Usage: /zonemaker <player-name>, /zonemaker" +
|
||||
"Elevates the player to zone maker or removes his rights. " +
|
||||
"If you are already a zonemaker, you can toggle between player and zone maker modes by using the command without arguments.");
|
||||
this.badMsg(player, "Usage: /zonemaker <player-name>, /zonemaker" + "Elevates the player to zone maker or removes his rights. " + "If you are already a zonemaker, you can toggle between player and zone maker modes by using the command without arguments.");
|
||||
} else {
|
||||
if (arguments.length == 1) {
|
||||
// make someone zonemaker or remove the right
|
||||
@ -327,8 +309,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public void performSetWarConfig(Player player, String[] arguments) {
|
||||
if (arguments.length == 0) {
|
||||
this.badMsg(player, "Usage: /setwarconfig pvpinzonesonly:on lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " +
|
||||
"Changes the server defaults for new warzones. Please give at leaset one named parameter.");
|
||||
this.badMsg(player, "Usage: /setwarconfig pvpinzonesonly:on lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " + "Changes the server defaults for new warzones. Please give at leaset one named parameter.");
|
||||
} else {
|
||||
if (this.updateFromNamedParams(player, arguments)) {
|
||||
WarMapper.save(this);
|
||||
@ -385,11 +366,8 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performDeleteMonument(Player player, String[] arguments) {
|
||||
if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation())
|
||||
&& !this.inAnyWarzoneLobby(player.getLocation()))) {
|
||||
this.badMsg(player, "Usage: /deletemonument <name>." +
|
||||
" Deletes the monument. " +
|
||||
"Must be in a warzone or lobby (try /warzones and /warzone). ");
|
||||
if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))) {
|
||||
this.badMsg(player, "Usage: /deletemonument <name>." + " Deletes the monument. " + "Must be in a warzone or lobby (try /warzones and /warzone). ");
|
||||
} else {
|
||||
String name = arguments[0];
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
@ -412,9 +390,7 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performSetMonument(Player player, String[] arguments) {
|
||||
if (!this.inAnyWarzone(player.getLocation()) || arguments.length < 1 || arguments.length > 1
|
||||
|| (arguments.length == 1 && this.warzone(player.getLocation()) != null
|
||||
&& arguments[0].equals(this.warzone(player.getLocation()).getName()))) {
|
||||
if (!this.inAnyWarzone(player.getLocation()) || arguments.length < 1 || arguments.length > 1 || (arguments.length == 1 && this.warzone(player.getLocation()) != null && arguments[0].equals(this.warzone(player.getLocation()).getName()))) {
|
||||
this.badMsg(player, "Usage: /setmonument <name>. Creates or moves a monument. Monument can't have same name as zone. Must be in warzone.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
@ -436,11 +412,8 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performDeleteTeam(Player player, String[] arguments) {
|
||||
if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation())
|
||||
&& !this.inAnyWarzoneLobby(player.getLocation()))) {
|
||||
this.badMsg(player, "Usage: /deleteteam <team-name/color>." +
|
||||
" Deletes the team and its spawn. " +
|
||||
"Must be in a warzone or lobby (try /zones and /zone). ");
|
||||
if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))) {
|
||||
this.badMsg(player, "Usage: /deleteteam <team-name/color>." + " Deletes the team and its spawn. " + "Must be in a warzone or lobby (try /zones and /zone). ");
|
||||
} else {
|
||||
String name = arguments[0];
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
@ -472,11 +445,8 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performSetTeamFlag(Player player, String[] arguments) {
|
||||
if (arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
||||
|| (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||
this.badMsg(player, "Usage: /setteamflag <team-name/color>, e.g. /setteamflag diamond. " +
|
||||
"Sets the team flag post to the current location. " +
|
||||
"Must be in a warzone (try /zones and /zone). ");
|
||||
if (arguments.length < 1 || !this.inAnyWarzone(player.getLocation()) || (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||
this.badMsg(player, "Usage: /setteamflag <team-name/color>, e.g. /setteamflag diamond. " + "Sets the team flag post to the current location. " + "Must be in a warzone (try /zones and /zone). ");
|
||||
} else {
|
||||
TeamKind kind = TeamKinds.teamKindFromString(arguments[0]);
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
@ -488,8 +458,7 @@ public class War extends JavaPlugin {
|
||||
// new team flag
|
||||
team.setTeamFlag(player.getLocation());
|
||||
Location playerLoc = player.getLocation();
|
||||
player.teleport(new Location(playerLoc.getWorld(),
|
||||
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
|
||||
player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
|
||||
this.msg(player, "Team " + team.getName() + " flag added here.");
|
||||
WarzoneMapper.save(this, warzone, false);
|
||||
} else {
|
||||
@ -497,8 +466,7 @@ public class War extends JavaPlugin {
|
||||
team.getFlagVolume().resetBlocks();
|
||||
team.setTeamFlag(player.getLocation());
|
||||
Location playerLoc = player.getLocation();
|
||||
player.teleport(new Location(playerLoc.getWorld(),
|
||||
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()+1));
|
||||
player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ() + 1));
|
||||
this.msg(player, "Team " + team.getName() + " flag moved.");
|
||||
WarzoneMapper.save(this, warzone, false);
|
||||
}
|
||||
@ -506,11 +474,8 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performSetTeam(Player player, String[] arguments) {
|
||||
if (arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
||||
|| (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||
this.badMsg(player, "Usage: /setteam <team-kind/color>, e.g. /setteam red." +
|
||||
"Sets the team spawn to the current location. " +
|
||||
"Must be in a warzone (try /zones and /zone). ");
|
||||
if (arguments.length < 1 || !this.inAnyWarzone(player.getLocation()) || (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||
this.badMsg(player, "Usage: /setteam <team-kind/color>, e.g. /setteam red." + "Sets the team spawn to the current location. " + "Must be in a warzone (try /zones and /zone). ");
|
||||
} else {
|
||||
TeamKind teamKind = TeamKinds.teamKindFromString(arguments[0]);
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
@ -540,9 +505,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public void performDeleteZone(Player player, String[] arguments) {
|
||||
if (arguments.length == 0 && !this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
this.badMsg(player, "Usage: /deletezone [warzone-name]. " +
|
||||
"Deletes the warzone. " +
|
||||
"Must be in the warzone or name must be provided (try /zones and /zone). ");
|
||||
this.badMsg(player, "Usage: /deletezone [warzone-name]. " + "Deletes the warzone. " + "Must be in the warzone or name must be provided (try /zones and /zone). ");
|
||||
} else {
|
||||
ZoneLobby lobby = null;
|
||||
Warzone warzone = null;
|
||||
@ -644,10 +607,8 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performSetZoneConfig(Player player, String[] arguments) {
|
||||
if ((!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))
|
||||
|| arguments.length == 0) {
|
||||
this.badMsg(player, "Usage: /setzoneconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " +
|
||||
"Please give at leaset one named parameter. Does not save the blocks of the warzone. Resets the zone with the new config. Must be in warzone.");
|
||||
if ((!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) || arguments.length == 0) {
|
||||
this.badMsg(player, "Usage: /setzoneconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " + "Please give at leaset one named parameter. Does not save the blocks of the warzone. Resets the zone with the new config. Must be in warzone.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
@ -678,8 +639,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public void performSaveZone(Player player, String[] arguments) {
|
||||
if (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
this.badMsg(player, "Usage: /savezone lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " +
|
||||
"All named params optional. Saves the blocks of the warzone (i.e. the current zone state will be reloaded at each battle start). Must be in warzone.");
|
||||
this.badMsg(player, "Usage: /savezone lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " + "All named params optional. Saves the blocks of the warzone (i.e. the current zone state will be reloaded at each battle start). Must be in warzone.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
@ -711,17 +671,12 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performSetZoneLobby(Player player, String[] arguments) {
|
||||
String usageStr = "Usage: When inside a warzone - /setzonelobby <north/n/east/e/south/s/west/w>." +
|
||||
"Attaches the lobby to the specified zone wall. When outside a warzone - /setzonelobby <zonename>. " +
|
||||
"Moves the lobby to your current position.";
|
||||
String usageStr = "Usage: When inside a warzone - /setzonelobby <north/n/east/e/south/s/west/w>." + "Attaches the lobby to the specified zone wall. When outside a warzone - /setzonelobby <zonename>. " + "Moves the lobby to your current position.";
|
||||
if (arguments.length < 1 || arguments.length > 1) {
|
||||
this.badMsg(player, usageStr);
|
||||
} else if (this.inAnyWarzone(player.getLocation()) || this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
// Inside a warzone: use the classic n/s/e/w mode
|
||||
if (!arguments[0].equals("north") && !arguments[0].equals("n")
|
||||
&& !arguments[0].equals("east") && !arguments[0].equals("e")
|
||||
&& !arguments[0].equals("south") && !arguments[0].equals("s")
|
||||
&& !arguments[0].equals("west") && !arguments[0].equals("w")){
|
||||
if (!arguments[0].equals("north") && !arguments[0].equals("n") && !arguments[0].equals("east") && !arguments[0].equals("e") && !arguments[0].equals("south") && !arguments[0].equals("s") && !arguments[0].equals("west") && !arguments[0].equals("w")) {
|
||||
this.badMsg(player, usageStr);
|
||||
return;
|
||||
}
|
||||
@ -796,22 +751,12 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performSetZone(Player player, String[] arguments) {
|
||||
if (arguments.length < 2 || arguments.length > 2
|
||||
|| (arguments.length == 2 && (!arguments[1].equals("southeast") && !arguments[1].equals("northwest")
|
||||
&& !arguments[1].equals("se") && !arguments[1].equals("nw")
|
||||
&& !arguments[1].equals("corner1") && !arguments[1].equals("corner2")
|
||||
&& !arguments[1].equals("c1") && !arguments[1].equals("c2")
|
||||
&& !arguments[1].equals("pos1") && !arguments[1].equals("pos2")
|
||||
&& !arguments[1].equals("wand")))) {
|
||||
if (arguments.length < 2 || arguments.length > 2 || (arguments.length == 2 && (!arguments[1].equals("southeast") && !arguments[1].equals("northwest") && !arguments[1].equals("se") && !arguments[1].equals("nw") && !arguments[1].equals("corner1") && !arguments[1].equals("corner2") && !arguments[1].equals("c1") && !arguments[1].equals("c2") && !arguments[1].equals("pos1") && !arguments[1].equals("pos2") && !arguments[1].equals("wand")))) {
|
||||
if (arguments.length == 1) {
|
||||
// we only have a zone name, default to wand mode
|
||||
this.addWandBearer(player, arguments[0]);
|
||||
} else {
|
||||
this.badMsg(player, "Usage: =<Classic mode>= /setzone <warzone-name> <'northwest'/'southeast'/'nw'/'se'> (NW defaults to top block, SE to bottom). " +
|
||||
"=<Wand Cuboid mode>= /setzone <warzone-name> wand (gives you a wooden sword to right and left click, drop to disable). " +
|
||||
"=<Wandless Cuboid mode>= /setzone <warzone-name> <'corner1'/'corner2'/'c1'/'c2'/'pos1'/'pos2'> (block where you're standing). " +
|
||||
"Set one corner, then the next. Defines the outline of the warzone, which will be reset at the start of every battle. " +
|
||||
"Saves the zone blocks if the outline is valid.");
|
||||
this.badMsg(player, "Usage: =<Classic mode>= /setzone <warzone-name> <'northwest'/'southeast'/'nw'/'se'> (NW defaults to top block, SE to bottom). " + "=<Wand Cuboid mode>= /setzone <warzone-name> wand (gives you a wooden sword to right and left click, drop to disable). " + "=<Wandless Cuboid mode>= /setzone <warzone-name> <'corner1'/'corner2'/'c1'/'c2'/'pos1'/'pos2'> (block where you're standing). " + "Set one corner, then the next. Defines the outline of the warzone, which will be reset at the start of every battle. " + "Saves the zone blocks if the outline is valid.");
|
||||
}
|
||||
} else {
|
||||
ZoneSetter setter = new ZoneSetter(this, player, arguments[0]);
|
||||
@ -861,8 +806,7 @@ public class War extends JavaPlugin {
|
||||
public void performTeam(Player player, String[] arguments) {
|
||||
Team playerTeam = this.getPlayerTeam(player.getName());
|
||||
if (playerTeam == null) {
|
||||
this.badMsg(player, "Usage: /team <message>. " +
|
||||
"Sends a message only to your teammates.");
|
||||
this.badMsg(player, "Usage: /team <message>. " + "Sends a message only to your teammates.");
|
||||
} else {
|
||||
ChatColor color = playerTeam.getKind().getColor();
|
||||
String teamMessage = color + player.getName() + ": " + ChatColor.WHITE;
|
||||
@ -875,8 +819,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public void performLeave(Player player) {
|
||||
if (!this.inAnyWarzone(player.getLocation()) || this.getPlayerTeam(player.getName()) == null) {
|
||||
this.badMsg(player, "Usage: /leave. " +
|
||||
"Must be in a team already.");
|
||||
this.badMsg(player, "Usage: /leave. " + "Must be in a team already.");
|
||||
} else {
|
||||
Warzone zone = this.getPlayerTeamWarzone(player.getName());
|
||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||
@ -884,12 +827,8 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performJoin(Player player, String[] arguments) {
|
||||
if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))
|
||||
|| (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||
this.badMsg(player, "Usage: /join <diamond/iron/gold/red/blue/green/etc.>." +
|
||||
" Teams are warzone specific." +
|
||||
" You must be inside a warzone or zone lobby to join a team." +
|
||||
" Use as an alternative to walking through the team gate.");
|
||||
if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) || (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||
this.badMsg(player, "Usage: /join <diamond/iron/gold/red/blue/green/etc.>." + " Teams are warzone specific." + " You must be inside a warzone or zone lobby to join a team." + " Use as an alternative to walking through the team gate.");
|
||||
} else {
|
||||
// drop from old team if any
|
||||
Team previousTeam = this.getPlayerTeam(player.getName());
|
||||
@ -958,8 +897,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public void performTeams(Player player) {
|
||||
if (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
this.badMsg(player, "Usage: /teams. " +
|
||||
"Must be in a warzone or zone lobby (try /war, /zones and /zone).");
|
||||
this.badMsg(player, "Usage: /teams. " + "Must be in a warzone or zone lobby (try /war, /zones and /zone).");
|
||||
} else {
|
||||
this.msg(player, "" + this.playerListener.getAllTeamsMsg(player));
|
||||
}
|
||||
@ -998,16 +936,14 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
for (Warzone warzone : this.getWarzones()) {
|
||||
|
||||
warzonesMessage += warzone.getName() + " ("
|
||||
+ warzone.getTeams().size() + " teams, ";
|
||||
warzonesMessage += warzone.getName() + " (" + warzone.getTeams().size() + " teams, ";
|
||||
int playerTotal = 0;
|
||||
for (Team team : warzone.getTeams()) {
|
||||
playerTotal += team.getPlayers().size();
|
||||
}
|
||||
warzonesMessage += playerTotal + " players) ";
|
||||
}
|
||||
this.msg(player, warzonesMessage + " Use /zone <zone-name> to " +
|
||||
"teleport to a warzone. ");
|
||||
this.msg(player, warzonesMessage + " Use /zone <zone-name> to " + "teleport to a warzone. ");
|
||||
}
|
||||
|
||||
private boolean updateZoneFromNamedParams(Warzone warzone, Player player, String[] arguments) {
|
||||
@ -1230,8 +1166,7 @@ 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)) {
|
||||
if (location.getWorld().getName().equals(warzone.getWorld().getName()) && warzone.getVolume() != null && warzone.getVolume().contains(location)) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
@ -1243,8 +1178,7 @@ public class War extends JavaPlugin {
|
||||
Warzone currentZone = this.warzone(location);
|
||||
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;
|
||||
@ -1412,9 +1346,7 @@ 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"))) {
|
||||
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.player") || War.permissionHandler.has(player, "War.player"))) {
|
||||
return true;
|
||||
}
|
||||
if (War.permissionHandler == null) {
|
||||
@ -1425,9 +1357,7 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public boolean canWarp(Player player) {
|
||||
if (War.permissionHandler != null
|
||||
&& (War.permissionHandler.has(player, "war.warp")
|
||||
|| War.permissionHandler.has(player, "War.warp"))) {
|
||||
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.warp") || War.permissionHandler.has(player, "War.warp"))) {
|
||||
return true;
|
||||
}
|
||||
if (War.permissionHandler == null) {
|
||||
@ -1439,9 +1369,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public boolean canBuildOutsideZone(Player player) {
|
||||
if (this.isBuildInZonesOnly()) {
|
||||
if (War.permissionHandler != null
|
||||
&& (War.permissionHandler.has(player, "war.build")
|
||||
|| War.permissionHandler.has(player, "War.build"))) {
|
||||
if (War.permissionHandler != null && (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
|
||||
@ -1453,9 +1381,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public boolean canPvpOutsideZones(Player player) {
|
||||
if (this.isPvpInZonesOnly()) {
|
||||
if (War.permissionHandler != null
|
||||
&& (War.permissionHandler.has(player, "war.pvp")
|
||||
|| War.permissionHandler.has(player, "War.pvp"))) {
|
||||
if (War.permissionHandler != null && (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
|
||||
@ -1477,12 +1403,7 @@ public class War extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ( War.permissionHandler != null
|
||||
&& (
|
||||
War.permissionHandler.has(player, "war.*")
|
||||
|| War.permissionHandler.has(player, "War.*")
|
||||
)
|
||||
) {
|
||||
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.*") || War.permissionHandler.has(player, "War.*"))) {
|
||||
return true;
|
||||
} else {
|
||||
return player.isOp();
|
||||
@ -1508,9 +1429,7 @@ public class War extends JavaPlugin {
|
||||
|
||||
public ZoneLobby lobby(Location location) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (warzone.getLobby() != null
|
||||
&& warzone.getLobby().getVolume() != null
|
||||
&& warzone.getLobby().getVolume().contains(location)) {
|
||||
if (warzone.getLobby() != null && warzone.getLobby().getVolume() != null && warzone.getLobby().getVolume().contains(location)) {
|
||||
return warzone.getLobby();
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,7 @@ public class WarBlockListener extends BlockListener {
|
||||
if (player != null && block != null) {
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
Warzone zone = this.war.warzone(player.getLocation());
|
||||
if (team != null && block != null && zone != null
|
||||
&& zone.isMonumentCenterBlock(block)
|
||||
&& block.getType() == team.getKind().getMaterial()
|
||||
&& block.getData() == team.getKind().getData()) {
|
||||
if (team != null && block != null && zone != null && zone.isMonumentCenterBlock(block) && block.getType() == team.getKind().getMaterial() && block.getData() == team.getKind().getData()) {
|
||||
Monument monument = zone.getMonumentFromCenterBlock(block);
|
||||
if (monument != null && !monument.hasOwner()) {
|
||||
monument.capture(team);
|
||||
@ -85,8 +82,7 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
// can't place a block of your team's color
|
||||
if (team != null && block.getType() == team.getKind().getMaterial()
|
||||
&& block.getData() == team.getKind().getData()) {
|
||||
if (team != null && block.getType() == team.getKind().getMaterial() && block.getData() == team.getKind().getData()) {
|
||||
this.war.badMsg(player, "You can only use your team's blocks to capture monuments.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -100,10 +96,7 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
// unbreakableZoneBlocks
|
||||
if (zone != null && zone.isUnbreakableZoneBlocks()
|
||||
&& (!isZoneMaker
|
||||
|| (isZoneMaker && team != null))
|
||||
) {
|
||||
if (zone != null && zone.isUnbreakableZoneBlocks() && (!isZoneMaker || (isZoneMaker && team != null))) {
|
||||
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
|
||||
this.war.badMsg(player, "The blocks in this zone are unbreakable - this also means you can't build!");
|
||||
event.setCancelled(true);
|
||||
@ -143,8 +136,7 @@ public class WarBlockListener extends BlockListener {
|
||||
this.war.badMsg(player, "Can't destroy part of a warzone if you're not in a team.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (team != null && block != null && warzone != null
|
||||
&& warzone.isMonumentCenterBlock(block)){
|
||||
} else if (team != null && block != null && warzone != null && warzone.isMonumentCenterBlock(block)) {
|
||||
Monument monument = warzone.getMonumentFromCenterBlock(block);
|
||||
if (monument.hasOwner()) {
|
||||
|
||||
@ -206,8 +198,7 @@ public class WarBlockListener extends BlockListener {
|
||||
// protect warzone lobbies
|
||||
if (block != null) {
|
||||
for (Warzone zone : this.war.getWarzones()) {
|
||||
if (zone.getLobby() != null && zone.getLobby().getVolume() != null &&
|
||||
zone.getLobby().getVolume().contains(block)) {
|
||||
if (zone.getLobby() != null && zone.getLobby().getVolume() != null && zone.getLobby().getVolume().contains(block)) {
|
||||
this.war.badMsg(player, "Can't destroy this.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -224,19 +215,14 @@ public class WarBlockListener extends BlockListener {
|
||||
|
||||
// buildInZonesOnly
|
||||
Warzone blockZone = this.war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
|
||||
if (blockZone == null
|
||||
&& this.war.isBuildInZonesOnly()
|
||||
&& !this.war.canBuildOutsideZone(player)) {
|
||||
if (blockZone == null && this.war.isBuildInZonesOnly() && !this.war.canBuildOutsideZone(player)) {
|
||||
this.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// unbreakableZoneBlocks
|
||||
if (blockZone != null && blockZone.isUnbreakableZoneBlocks()
|
||||
&& (!isZoneMaker
|
||||
|| (isZoneMaker && team != null))
|
||||
) {
|
||||
if (blockZone != null && blockZone.isUnbreakableZoneBlocks() && (!isZoneMaker || (isZoneMaker && team != null))) {
|
||||
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks
|
||||
this.war.badMsg(player, "The blocks in this zone are unbreakable!");
|
||||
event.setCancelled(true);
|
||||
|
@ -67,9 +67,7 @@ public class WarEntityListener extends EntityListener {
|
||||
Team attackerTeam = this.war.getPlayerTeam(a.getName());
|
||||
Warzone defenderWarzone = this.war.getPlayerTeamWarzone(d.getName());
|
||||
Team defenderTeam = this.war.getPlayerTeam(d.getName());
|
||||
if (attackerTeam != null && defenderTeam != null
|
||||
&& attackerTeam != defenderTeam
|
||||
&& attackerWarzone == defenderWarzone) {
|
||||
if (attackerTeam != null && defenderTeam != null && attackerTeam != defenderTeam && attackerWarzone == defenderWarzone) {
|
||||
// Make sure one of the players isn't in the spawn
|
||||
if (defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
|
||||
if (!defenderWarzone.isFlagThief(d.getName())) { // thiefs can always be attacked
|
||||
@ -92,10 +90,7 @@ public class WarEntityListener extends EntityListener {
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (attackerTeam != null && defenderTeam != null
|
||||
&& attackerTeam == defenderTeam
|
||||
&& attackerWarzone == defenderWarzone
|
||||
&& attacker.getEntityId() != defender.getEntityId()) {
|
||||
} else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
|
||||
// same team, but not same person
|
||||
if (attackerWarzone.getFriendlyFire()) {
|
||||
this.war.badMsg(a, "Friendly fire is on! Please, don't hurt your teammates."); // if ff is on, let the attack go through
|
||||
@ -113,9 +108,7 @@ public class WarEntityListener extends EntityListener {
|
||||
} else {
|
||||
this.war.badMsg(a, "Your attack missed!");
|
||||
if (attackerTeam == null) {
|
||||
this.war.badMsg(a, "You must join a team " +
|
||||
", then you'll be able to damage people " +
|
||||
"in the other teams in that warzone.");
|
||||
this.war.badMsg(a, "You must join a team " + ", then you'll be able to damage people " + "in the other teams in that warzone.");
|
||||
} else if (defenderTeam == null) {
|
||||
this.war.badMsg(a, "Your target is not in a team.");
|
||||
} else if (attacker != null && defender != null && attacker.getEntityId() == defender.getEntityId()) {
|
||||
@ -174,8 +167,7 @@ public class WarEntityListener extends EntityListener {
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent ||
|
||||
event instanceof EntityDamageByProjectileEvent) {
|
||||
if (event instanceof EntityDamageByEntityEvent || event instanceof EntityDamageByProjectileEvent) {
|
||||
this.handlerAttackDefend((EntityDamageByEntityEvent) event);
|
||||
} else {
|
||||
// Detect death (from , prevent it and respawn the player
|
||||
|
@ -1,4 +1,5 @@
|
||||
package bukkit.tommytony.war;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -27,7 +28,6 @@ import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.ZoneLobby;
|
||||
import com.tommytony.war.ZoneSetter;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tommytony
|
||||
@ -38,7 +38,6 @@ public class WarPlayerListener extends PlayerListener {
|
||||
private final War war;
|
||||
private Random random = null;
|
||||
|
||||
|
||||
public WarPlayerListener(War war) {
|
||||
this.war = war;
|
||||
this.random = new Random();
|
||||
@ -78,9 +77,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
Item item = event.getItemDrop();
|
||||
if (item != null) {
|
||||
ItemStack itemStack = item.getItemStack();
|
||||
if (itemStack != null
|
||||
&& itemStack.getType() == team.getKind().getMaterial()
|
||||
&& itemStack.getData().getData() == team.getKind().getData()) {
|
||||
if (itemStack != null && itemStack.getType() == team.getKind().getMaterial() && itemStack.getData().getData() == team.getKind().getData()) {
|
||||
// Can't drop your team's kind block
|
||||
this.war.badMsg(player, "Can't drop " + team.getName() + " block blocks.");
|
||||
event.setCancelled(true);
|
||||
@ -123,8 +120,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
CraftItem cItem = (CraftItem) item;
|
||||
if (cItem != null) {
|
||||
ItemStack itemStack = cItem.getItemStack();
|
||||
if (itemStack != null && itemStack.getType() == team.getKind().getMaterial()
|
||||
&& player.getInventory().contains(new ItemStack(team.getKind().getMaterial(), team.getKind().getData()))) {
|
||||
if (itemStack != null && itemStack.getType() == team.getKind().getMaterial() && player.getInventory().contains(new ItemStack(team.getKind().getMaterial(), team.getKind().getData()))) {
|
||||
// Can't pick up a second precious block
|
||||
// war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||
event.setCancelled(true);
|
||||
@ -167,14 +163,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
String[] split = msg.split(" ");
|
||||
if (!this.war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) {
|
||||
String command = split[0].substring(1);
|
||||
if (!command.equals("war") && !command.equals("zones") && !command.equals("warzones")
|
||||
&& !command.equals("zone") && !command.equals("warzone")
|
||||
&& !command.equals("teams")
|
||||
&& !command.equals("join")
|
||||
&& !command.equals("leave")
|
||||
&& !command.equals("team")
|
||||
&& !command.equals("warhub")
|
||||
&& !command.equals("zonemaker")) {
|
||||
if (!command.equals("war") && !command.equals("zones") && !command.equals("warzones") && !command.equals("zone") && !command.equals("warzone") && !command.equals("teams") && !command.equals("join") && !command.equals("leave") && !command.equals("team") && !command.equals("warhub") && !command.equals("zonemaker")) {
|
||||
this.war.badMsg(player, "Can't use anything but War commands (e.g. /leave, /warhub) while you're playing in a warzone.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -314,8 +303,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc)
|
||||
&& !this.war.getWarHub().getVolume().contains(player.getLocation())){
|
||||
if (this.war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc) && !this.war.getWarHub().getVolume().contains(player.getLocation())) {
|
||||
this.dropFromOldTeamIfAny(player);
|
||||
event.setTo(this.war.getWarHub().getLocation());
|
||||
// player.teleport(war.getWarHub().getLocation());
|
||||
@ -343,9 +331,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (isLeaving) { // already in a team and in warzone, leaving
|
||||
// same as leave
|
||||
if (playerTeam != null) {
|
||||
boolean atSpawnAlready = playerTeam.getTeamSpawn().getBlockX() == player.getLocation().getBlockX() &&
|
||||
playerTeam.getTeamSpawn().getBlockY() == player.getLocation().getBlockY() &&
|
||||
playerTeam.getTeamSpawn().getBlockZ() == player.getLocation().getBlockZ();
|
||||
boolean atSpawnAlready = playerTeam.getTeamSpawn().getBlockX() == player.getLocation().getBlockX() && playerTeam.getTeamSpawn().getBlockY() == player.getLocation().getBlockY() && playerTeam.getTeamSpawn().getBlockZ() == player.getLocation().getBlockZ();
|
||||
if (!atSpawnAlready) {
|
||||
playerWarzone.handlePlayerLeave(player, playerWarzone.getTeleport(), event, true);
|
||||
return;
|
||||
@ -355,19 +341,14 @@ public class WarPlayerListener extends PlayerListener {
|
||||
|
||||
if (playerWarzone != null) {
|
||||
// Player belongs to a warzone team but is outside: he snuck out or is at spawn and died
|
||||
if (locZone == null && playerTeam != null && playerWarzone.getLobby() != null
|
||||
&& !playerWarzone.getLobby().getVolume().contains(playerLoc)
|
||||
&& !isLeaving) {
|
||||
if (locZone == null && playerTeam != null && playerWarzone.getLobby() != null && !playerWarzone.getLobby().getVolume().contains(playerLoc) && !isLeaving) {
|
||||
this.war.badMsg(player, "Use /leave to exit the zone.");
|
||||
event.setTo(playerTeam.getTeamSpawn());
|
||||
return;
|
||||
}
|
||||
|
||||
// Monuments
|
||||
if (playerTeam != null
|
||||
&& playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam)
|
||||
&& player.getHealth() < 20
|
||||
&& player.getHealth() > 0 // don't heal the dead
|
||||
if (playerTeam != null && playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam) && player.getHealth() < 20 && player.getHealth() > 0 // don't heal the dead
|
||||
&& this.random.nextInt(77) == 3) { // one chance out of many of getting healed
|
||||
int currentHp = player.getHealth();
|
||||
int newHp = currentHp + locZone.getMonumentHeal();
|
||||
@ -392,9 +373,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
|
||||
// Flag capture
|
||||
if (playerWarzone.isFlagThief(player.getName())
|
||||
&& (playerTeam.getSpawnVolume().contains(player.getLocation())
|
||||
|| (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation())))) {
|
||||
if (playerWarzone.isFlagThief(player.getName()) && (playerTeam.getSpawnVolume().contains(player.getLocation()) || (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation())))) {
|
||||
if (playerWarzone.isTeamFlagStolen(playerTeam)) {
|
||||
this.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
|
||||
} else {
|
||||
@ -414,8 +393,7 @@ 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(player.getName() + " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
|
||||
}
|
||||
playerWarzone.respawnPlayer(event, playerTeam, player);
|
||||
playerTeam.resetSign();
|
||||
@ -426,8 +404,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (locZone != null && locZone.getLobby() != null
|
||||
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||
} else if (locZone != null && locZone.getLobby() != null && !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||
// player is not in any team, but inside warzone boundaries, get him out
|
||||
Warzone zone = this.war.warzone(playerLoc);
|
||||
event.setTo(zone.getTeleport());
|
||||
|
@ -380,8 +380,7 @@ public class Team {
|
||||
boolean atLeastOnePlayerOnTeam = this.players.size() != 0;
|
||||
boolean atLeastOnePlayerOnOtherTeam = false;
|
||||
for (Team team : this.warzone.getTeams()) {
|
||||
if (!team.getName().equals(this.getName())
|
||||
&& team.getPlayers().size() > 0) {
|
||||
if (!team.getName().equals(this.getName()) && team.getPlayers().size() > 0) {
|
||||
atLeastOnePlayerOnOtherTeam = true;
|
||||
}
|
||||
}
|
||||
@ -546,9 +545,7 @@ public class Team {
|
||||
int flagX = this.teamFlag.getBlockX();
|
||||
int flagY = this.teamFlag.getBlockY() + 1;
|
||||
int flagZ = this.teamFlag.getBlockZ();
|
||||
if (block.getX() == flagX
|
||||
&& block.getY() == flagY
|
||||
&& block.getZ() == flagZ) {
|
||||
if (block.getX() == flagX && block.getY() == flagY && block.getZ() == flagZ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -47,4 +47,3 @@ public class TeamKinds {
|
||||
return TeamKinds.teamKinds;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,7 @@ public class WarHub {
|
||||
Warzone zone = null;
|
||||
for (String zoneName : this.zoneGateBlocks.keySet()) {
|
||||
Block gate = this.zoneGateBlocks.get(zoneName);
|
||||
if (gate.getX() == playerLocation.getBlockX()
|
||||
&& gate.getY() == playerLocation.getBlockY()
|
||||
&& gate.getZ() == playerLocation.getBlockZ()) {
|
||||
if (gate.getX() == playerLocation.getBlockX() && gate.getY() == playerLocation.getBlockY() && gate.getZ() == playerLocation.getBlockZ()) {
|
||||
zone = this.war.findWarzone(zoneName);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package com.tommytony.war;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -154,8 +155,8 @@ public class Warzone {
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes back to the saved state of the warzone (resets only block types, not physics).
|
||||
* Also teleports all players back to their respective spawns.
|
||||
* Goes back to the saved state of the warzone (resets only block types, not physics). Also teleports all players back to their respective spawns.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void initializeZone() {
|
||||
@ -173,8 +174,7 @@ public class Warzone {
|
||||
}
|
||||
team.setRemainingLives(this.lifePool);
|
||||
team.initializeTeamSpawn();
|
||||
if (team.getTeamFlag() != null)
|
||||
{
|
||||
if (team.getTeamFlag() != null) {
|
||||
team.setTeamFlag(team.getTeamFlag());
|
||||
// team.resetSign();
|
||||
}
|
||||
@ -184,7 +184,6 @@ public class Warzone {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initializeZoneAsJob(Player respawnExempted) {
|
||||
InitZoneJob job = new InitZoneJob(this, respawnExempted);
|
||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, job);
|
||||
@ -359,8 +358,7 @@ public class Warzone {
|
||||
public void keepPlayerInventory(Player player) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
ItemStack[] contents = inventory.getContents();
|
||||
this.inventories.put(player.getName(), new InventoryStash(contents, inventory.getHelmet(), inventory.getChestplate(),
|
||||
inventory.getLeggings(), inventory.getBoots()));
|
||||
this.inventories.put(player.getName(), new InventoryStash(contents, inventory.getHelmet(), inventory.getChestplate(), inventory.getLeggings(), inventory.getBoots()));
|
||||
}
|
||||
|
||||
public void restorePlayerInventory(Player player) {
|
||||
@ -371,8 +369,7 @@ public class Warzone {
|
||||
}
|
||||
}
|
||||
|
||||
private void playerInvFromInventoryStash(PlayerInventory playerInv,
|
||||
InventoryStash originalContents) {
|
||||
private void playerInvFromInventoryStash(PlayerInventory playerInv, InventoryStash originalContents) {
|
||||
playerInv.clear();
|
||||
playerInv.clear(playerInv.getSize() + 0);
|
||||
playerInv.clear(playerInv.getSize() + 1);
|
||||
@ -432,8 +429,7 @@ public class Warzone {
|
||||
for (Team t : this.teams) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -472,42 +468,17 @@ public class Warzone {
|
||||
|
||||
public boolean isNearWall(Location latestPlayerLocation) {
|
||||
if (this.volume.hasTwoCorners()) {
|
||||
if (Math.abs(this.volume.getSoutheastZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX()
|
||||
&& latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX()
|
||||
&& latestPlayerLocation.getBlockY() >= this.volume.getMinY()
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
if (Math.abs(this.volume.getSoutheastZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX() && latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX() && latestPlayerLocation.getBlockY() >= this.volume.getMinY() && latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
return true; // near east wall
|
||||
} 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()) {
|
||||
} 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()) {
|
||||
return true; // near south wall
|
||||
} 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()) {
|
||||
} 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()) {
|
||||
return true; // near north wall
|
||||
} 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()) {
|
||||
} 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()) {
|
||||
return true; // near west wall
|
||||
} 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()) {
|
||||
} 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()) {
|
||||
return true; // near up wall
|
||||
} 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())
|
||||
{
|
||||
} 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
|
||||
}
|
||||
}
|
||||
@ -516,61 +487,37 @@ public class Warzone {
|
||||
|
||||
public List<Block> getNearestWallBlocks(Location latestPlayerLocation) {
|
||||
List<Block> nearestWallBlocks = new ArrayList<Block>();
|
||||
if (Math.abs(this.volume.getSoutheastZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX()
|
||||
&& latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX()
|
||||
&& latestPlayerLocation.getBlockY() >= this.volume.getMinY()
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
if (Math.abs(this.volume.getSoutheastZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX() && latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX() && latestPlayerLocation.getBlockY() >= this.volume.getMinY() && latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
// near east wall
|
||||
Block eastWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX() + 1, latestPlayerLocation.getBlockY() + 1, this.volume.getSoutheastZ());
|
||||
nearestWallBlocks.add(eastWallBlock);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near south wall
|
||||
Block southWallBlock = this.world.getBlockAt(this.volume.getSoutheastX(), latestPlayerLocation.getBlockY() + 1, latestPlayerLocation.getBlockZ());
|
||||
nearestWallBlocks.add(southWallBlock);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near north wall
|
||||
Block northWallBlock = this.world.getBlockAt(this.volume.getNorthwestX(), latestPlayerLocation.getBlockY() + 1, latestPlayerLocation.getBlockZ());
|
||||
nearestWallBlocks.add(northWallBlock);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near west wall
|
||||
Block westWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX(), latestPlayerLocation.getBlockY() + 1, this.volume.getNorthwestZ());
|
||||
nearestWallBlocks.add(westWallBlock);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near up wall
|
||||
Block upWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX(), this.volume.getMaxY(), latestPlayerLocation.getBlockZ());
|
||||
nearestWallBlocks.add(upWallBlock);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near down wall
|
||||
Block downWallBlock = this.world.getBlockAt(latestPlayerLocation.getBlockX(), this.volume.getMinY(), latestPlayerLocation.getBlockZ());
|
||||
nearestWallBlocks.add(downWallBlock);
|
||||
@ -581,56 +528,32 @@ public class Warzone {
|
||||
|
||||
public List<BlockFace> getNearestWalls(Location latestPlayerLocation) {
|
||||
List<BlockFace> walls = new ArrayList<BlockFace>();
|
||||
if (Math.abs(this.volume.getSoutheastZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall
|
||||
&& latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX()
|
||||
&& latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX()
|
||||
&& latestPlayerLocation.getBlockY() >= this.volume.getMinY()
|
||||
&& latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
if (Math.abs(this.volume.getSoutheastZ() - latestPlayerLocation.getBlockZ()) < this.minSafeDistanceFromWall && latestPlayerLocation.getBlockX() <= this.volume.getSoutheastX() && latestPlayerLocation.getBlockX() >= this.volume.getNorthwestX() && latestPlayerLocation.getBlockY() >= this.volume.getMinY() && latestPlayerLocation.getBlockY() <= this.volume.getMaxY()) {
|
||||
// near east wall
|
||||
walls.add(BlockFace.EAST);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near south wall
|
||||
walls.add(BlockFace.SOUTH);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near north wall
|
||||
walls.add(BlockFace.NORTH);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near west wall
|
||||
walls.add(BlockFace.WEST);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near up wall
|
||||
walls.add(BlockFace.UP);
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
// near down wall
|
||||
walls.add(BlockFace.DOWN);
|
||||
}
|
||||
@ -704,8 +627,7 @@ public class Warzone {
|
||||
public Team autoAssign(Player player) {
|
||||
Team lowestNoOfPlayers = null;
|
||||
for (Team t : this.teams) {
|
||||
if (lowestNoOfPlayers == null
|
||||
|| (lowestNoOfPlayers != null && lowestNoOfPlayers.getPlayers().size() > t.getPlayers().size())) {
|
||||
if (lowestNoOfPlayers == null || (lowestNoOfPlayers != null && lowestNoOfPlayers.getPlayers().size() > t.getPlayers().size())) {
|
||||
lowestNoOfPlayers = t;
|
||||
}
|
||||
}
|
||||
@ -760,8 +682,7 @@ public class Warzone {
|
||||
List<Team> teams = playerWarzone.getTeams();
|
||||
String scores = "";
|
||||
for (Team t : teams) {
|
||||
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: "
|
||||
+ player.getName() + " died and there were no lives left in their life pool.");
|
||||
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: " + player.getName() + " died and there were no lives left in their life pool.");
|
||||
|
||||
if (t.getPlayers().size() != 0) {
|
||||
if (!t.getName().equals(playerTeam.getName())) {
|
||||
@ -899,8 +820,7 @@ public class Warzone {
|
||||
|
||||
public boolean isEnemyTeamFlagBlock(Team playerTeam, Block block) {
|
||||
for (Team team : this.teams) {
|
||||
if (!team.getName().equals(playerTeam.getName())
|
||||
&& team.isTeamFlagBlock(block)) {
|
||||
if (!team.getName().equals(playerTeam.getName()) && team.isTeamFlagBlock(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1052,8 +972,7 @@ public class Warzone {
|
||||
}
|
||||
team.getPlayers().clear();
|
||||
}
|
||||
if (this.getLobby() != null)
|
||||
{
|
||||
if (this.getLobby() != null) {
|
||||
this.getLobby().getVolume().resetBlocks();
|
||||
this.getLobby().getVolume().finalize();
|
||||
}
|
||||
|
@ -41,9 +41,11 @@ public class ZoneLobby {
|
||||
|
||||
/**
|
||||
* Use this constructor with /setzonelobby <n/s/e/w>
|
||||
*
|
||||
* @param war
|
||||
* @param warzone
|
||||
* @param wall On which wall of the warzone will the lobby be stuck to at mid-weight
|
||||
* @param wall
|
||||
* On which wall of the warzone will the lobby be stuck to at mid-weight
|
||||
*/
|
||||
public ZoneLobby(War war, Warzone warzone, BlockFace wall) {
|
||||
this.war = war;
|
||||
@ -57,11 +59,12 @@ public class ZoneLobby {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this constructor with /setzonelobby <zonename>.
|
||||
* Makes sure the lobby is not sticking inside the zone.
|
||||
* Use this constructor with /setzonelobby <zonename>. Makes sure the lobby is not sticking inside the zone.
|
||||
*
|
||||
* @param war
|
||||
* @param warzone
|
||||
* @param wall On which wall of the warzone will the lobby be stuck to at mid-weight
|
||||
* @param wall
|
||||
* On which wall of the warzone will the lobby be stuck to at mid-weight
|
||||
*/
|
||||
public ZoneLobby(War war, Warzone warzone, Location playerLocation) {
|
||||
this.war = war;
|
||||
@ -74,11 +77,8 @@ public class ZoneLobby {
|
||||
this.setLocation(playerLocation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience ctor when loading form disk.
|
||||
* This figures out the middle wall block of the lobby from the volume instead
|
||||
* of the other way around.
|
||||
* Convenience ctor when loading form disk. This figures out the middle wall block of the lobby from the volume instead of the other way around.
|
||||
*/
|
||||
public ZoneLobby(War war, Warzone warzone, BlockFace wall, Volume volume) {
|
||||
this.war = war;
|
||||
@ -104,8 +104,8 @@ public class ZoneLobby {
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the lobby's position. Orientation is determined from the player location.
|
||||
* Creates volume or resets. Saves new lobby blocks.
|
||||
* Changes the lobby's position. Orientation is determined from the player location. Creates volume or resets. Saves new lobby blocks.
|
||||
*
|
||||
* @param playerLocation
|
||||
*/
|
||||
public void setLocation(Location playerLocation) {
|
||||
@ -151,10 +151,7 @@ public class ZoneLobby {
|
||||
this.wall = opposite; // a player facing south places a lobby that looks just like a lobby stuck to the north wall
|
||||
|
||||
this.calculateLobbyWidth();
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(playerLocation.getBlockX(),
|
||||
playerLocation.getBlockY(),
|
||||
playerLocation.getBlockZ())
|
||||
.getFace(facing, 6));
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()).getFace(facing, 6));
|
||||
|
||||
Block corner1 = null;
|
||||
Block corner2 = null;
|
||||
@ -181,8 +178,8 @@ public class ZoneLobby {
|
||||
}
|
||||
|
||||
/**
|
||||
* Classic way of creating a lobby. Lobby position goes to middle of zone wall.
|
||||
* Creates volume or resets. Saves new lobby blocks.
|
||||
* Classic way of creating a lobby. Lobby position goes to middle of zone wall. Creates volume or resets. Saves new lobby blocks.
|
||||
*
|
||||
* @param newWall
|
||||
*/
|
||||
public void setWall(BlockFace newWall) {
|
||||
@ -214,8 +211,7 @@ public class ZoneLobby {
|
||||
int y = zoneVolume.getCenterY();
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(wallCenterPos, y, z));
|
||||
corner1 = this.warzone.getWorld().getBlockAt(wallCenterPos - this.lobbyHalfSide, y - 1, z);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(wallCenterPos + this.lobbyHalfSide,
|
||||
y + 1 + this.lobbyHeight, z - this.lobbyDepth);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(wallCenterPos + this.lobbyHalfSide, y + 1 + this.lobbyHeight, z - this.lobbyDepth);
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
int wallStart = zoneVolume.getMinZ();
|
||||
int wallEnd = zoneVolume.getMaxZ();
|
||||
@ -225,8 +221,7 @@ public class ZoneLobby {
|
||||
int y = zoneVolume.getCenterY();
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(x, y, wallCenterPos));
|
||||
corner1 = this.warzone.getWorld().getBlockAt(x, y - 1, wallCenterPos - this.lobbyHalfSide);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x + this.lobbyDepth,
|
||||
y + 1 + this.lobbyHeight, wallCenterPos + this.lobbyHalfSide);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x + this.lobbyDepth, y + 1 + this.lobbyHeight, wallCenterPos + this.lobbyHalfSide);
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
int wallStart = zoneVolume.getMinX();
|
||||
int wallEnd = zoneVolume.getMaxX();
|
||||
@ -386,8 +381,7 @@ public class ZoneLobby {
|
||||
} else {
|
||||
if (doorIndex == 0) {
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock));
|
||||
}
|
||||
else if (doorIndex % 2 == 0) {
|
||||
} else if (doorIndex % 2 == 0) {
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(rightSide, doorIndex * 2)));
|
||||
} else {
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(leftSide, doorIndex * 2 + 2)));
|
||||
@ -398,8 +392,7 @@ public class ZoneLobby {
|
||||
this.warHubLinkGate = new BlockInfo(lobbyMiddleWallBlock.getFace(this.wall, 9));
|
||||
}
|
||||
|
||||
private void placeGate(Block block,
|
||||
TeamKind teamKind) {
|
||||
private void placeGate(Block block, TeamKind teamKind) {
|
||||
if (block != null) {
|
||||
BlockFace leftSide = null; // look at the zone
|
||||
BlockFace rightSide = null;
|
||||
@ -427,8 +420,7 @@ public class ZoneLobby {
|
||||
}
|
||||
}
|
||||
|
||||
private void placeGate(Block block,
|
||||
Material material) {
|
||||
private void placeGate(Block block, Material material) {
|
||||
if (block != null) {
|
||||
BlockFace leftSide = null; // look at the zone
|
||||
BlockFace rightSide = null;
|
||||
@ -542,9 +534,7 @@ public class ZoneLobby {
|
||||
public boolean isInTeamGate(Team team, Location location) {
|
||||
BlockInfo info = this.teamGateBlocks.get(team.getName());
|
||||
if (info != null) {
|
||||
if (location.getBlockX() == info.getX()
|
||||
&& location.getBlockY() == info.getY()
|
||||
&& location.getBlockZ() == info.getZ()) {
|
||||
if (location.getBlockX() == info.getX() && location.getBlockY() == info.getY() && location.getBlockZ() == info.getZ()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -552,10 +542,7 @@ public class ZoneLobby {
|
||||
}
|
||||
|
||||
public boolean isAutoAssignGate(Location location) {
|
||||
if (this.autoAssignGate != null
|
||||
&& (location.getBlockX() == this.autoAssignGate.getX()
|
||||
&& location.getBlockY() == this.autoAssignGate.getY()
|
||||
&& location.getBlockZ() == this.autoAssignGate.getZ()) ) {
|
||||
if (this.autoAssignGate != null && (location.getBlockX() == this.autoAssignGate.getX() && location.getBlockY() == this.autoAssignGate.getY() && location.getBlockZ() == this.autoAssignGate.getZ())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -569,16 +556,12 @@ public class ZoneLobby {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
|
||||
public BlockFace getWall() {
|
||||
return this.wall;
|
||||
}
|
||||
|
||||
public boolean isInWarHubLinkGate(Location location) {
|
||||
if (this.warHubLinkGate != null
|
||||
&& location.getBlockX() == this.warHubLinkGate.getX()
|
||||
&& location.getBlockY() == this.warHubLinkGate.getY()
|
||||
&& location.getBlockZ() == this.warHubLinkGate.getZ()) {
|
||||
if (this.warHubLinkGate != null && location.getBlockX() == this.warHubLinkGate.getX() && location.getBlockY() == this.warHubLinkGate.getY() && location.getBlockZ() == this.warHubLinkGate.getZ()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -617,46 +600,7 @@ public class ZoneLobby {
|
||||
leftSide = BlockFace.NORTH;
|
||||
rightSide = BlockFace.SOUTH;
|
||||
}
|
||||
return (block.getX() == gateBlock.getX()
|
||||
&& block.getY() == gateBlock.getY()
|
||||
&& block.getZ() == gateBlock.getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(BlockFace.UP).getX()
|
||||
&& block.getY() == gateBlock.getFace(BlockFace.UP).getY()
|
||||
&& block.getZ() == gateBlock.getFace(BlockFace.UP).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(leftSide).getX()
|
||||
&& block.getY() == gateBlock.getFace(leftSide).getY()
|
||||
&& block.getZ() == gateBlock.getFace(leftSide).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getX()
|
||||
&& block.getY() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getY()
|
||||
&& block.getZ() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getX()
|
||||
&& block.getY() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getY()
|
||||
&& block.getZ() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getX()
|
||||
&& block.getY() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getY()
|
||||
&& block.getZ() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getX()
|
||||
&& block.getY() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getY()
|
||||
&& block.getZ() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getX()
|
||||
&& block.getY() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getY()
|
||||
&& block.getZ() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getFace(rightSide).getX()
|
||||
&& block.getY() == gateBlock.getFace(rightSide).getY()
|
||||
&& block.getZ() == gateBlock.getFace(rightSide).getZ())
|
||||
||
|
||||
(block.getX() == gateBlock.getX()
|
||||
&& block.getY() == gateBlock.getY() - 1
|
||||
&& block.getZ() == gateBlock.getZ())
|
||||
;
|
||||
return (block.getX() == gateBlock.getX() && block.getY() == gateBlock.getY() && block.getZ() == gateBlock.getZ()) || (block.getX() == gateBlock.getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(leftSide).getX() && block.getY() == gateBlock.getFace(leftSide).getY() && block.getZ() == gateBlock.getFace(leftSide).getZ()) || (block.getX() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getX() && block.getY() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getY() && block.getZ() == gateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP).getZ()) || (block.getX() == gateBlock.getFace(rightSide).getX() && block.getY() == gateBlock.getFace(rightSide).getY() && block.getZ() == gateBlock.getFace(rightSide).getZ()) || (block.getX() == gateBlock.getX() && block.getY() == gateBlock.getY() - 1 && block.getZ() == gateBlock.getZ());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -772,8 +716,7 @@ public class ZoneLobby {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean leaving(Location location, Block gate, BlockFace inside,
|
||||
BlockFace left, BlockFace right) {
|
||||
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();
|
||||
|
@ -29,27 +29,23 @@ public class ZoneSetter {
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
Block northwestBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setNorthwest(northwestBlock);
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:"
|
||||
+ warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:" + warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setNorthwest(northwestBlock);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Northwesternmost point set to x:"
|
||||
+ warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Northwesternmost point set to x:" + warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
|
||||
}
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (NotNorthwestException e) {
|
||||
this.war.badMsg(this.player, "The block you selected is not to the northwest of the existing southeasternmost block.");
|
||||
if (warzone.getVolume().isSaved())
|
||||
{
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone(); // was reset before changing
|
||||
}
|
||||
} catch (TooSmallException e) {
|
||||
@ -69,27 +65,23 @@ public class ZoneSetter {
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
Block southeastBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setSoutheast(southeastBlock);
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:"
|
||||
+ warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setSoutheast(southeastBlock);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Southeasternmost point set to x:"
|
||||
+ warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
|
||||
}
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (NotSoutheastException e) {
|
||||
this.war.badMsg(this.player, "The block you selected is not to the southeast of the existing northwestnmost block.");
|
||||
if (warzone.getVolume().isSaved())
|
||||
{
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone(); // was reset before changing
|
||||
}
|
||||
} catch (TooSmallException e) {
|
||||
@ -113,21 +105,18 @@ public class ZoneSetter {
|
||||
public void placeCorner1(Block corner1Block) {
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setZoneCornerOne(corner1Block);
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 1 set to x:"
|
||||
+ corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 1 set to x:" + corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setZoneCornerOne(corner1Block);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 1 set to x:"
|
||||
+ corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 1 set to x:" + corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
|
||||
}
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (TooSmallException e) {
|
||||
@ -151,21 +140,18 @@ public class ZoneSetter {
|
||||
public void placeCorner2(Block corner2Block) {
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setZoneCornerTwo(corner2Block);
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 2 set to x:"
|
||||
+ corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 2 set to x:" + corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setZoneCornerTwo(corner2Block);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 2 set to x:"
|
||||
+ corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 2 set to x:" + corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
|
||||
}
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (TooSmallException e) {
|
||||
|
@ -162,8 +162,7 @@ public class ZoneWallGuard {
|
||||
private void glassify(Block block, BlockFace wall) {
|
||||
// face here means which wall we are working on
|
||||
|
||||
if ((block.getTypeId() == Material.AIR.getId() || block.getTypeId() == Material.WATER.getId()) &&
|
||||
(this.warzone.getLobby() == null || (this.warzone.getLobby() != null && !this.warzone.getLobby().blockIsAGateBlock(block, wall)))){
|
||||
if ((block.getTypeId() == Material.AIR.getId() || block.getTypeId() == Material.WATER.getId()) && (this.warzone.getLobby() == null || (this.warzone.getLobby() != null && !this.warzone.getLobby().blockIsAGateBlock(block, wall)))) {
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.warzone.getVolume().isNorthWallBlock(block)) {
|
||||
this.glassified.add(new BlockInfo(block));
|
||||
|
@ -29,7 +29,6 @@ public class DeferredBlockResetsJob implements Runnable {
|
||||
return this.deferred.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
for (DeferredBlockReset reset : this.deferred) {
|
||||
Block worldBlock = this.world.getBlockAt(reset.getX(), reset.getY(), reset.getZ());
|
||||
@ -62,9 +61,6 @@ public class DeferredBlockResetsJob implements Runnable {
|
||||
worldBlock.setData(reset.getBlockData());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.tommytony.war.volumes.BlockInfo;
|
||||
|
||||
public class ResetCursorJob implements Runnable {
|
||||
|
||||
|
||||
private final Block cornerBlock;
|
||||
private final BlockInfo[] originalCursorBlocks;
|
||||
private final boolean isSoutheast;
|
||||
|
@ -15,6 +15,7 @@ public class ZoneVolumeSaveJob extends Thread {
|
||||
this.zoneName = zoneName;
|
||||
this.war = war;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ZoneVolumeMapper.save(this.volume, this.zoneName, this.war);
|
||||
|
@ -28,8 +28,7 @@ import com.tommytony.war.volumes.Volume;
|
||||
import com.tommytony.war.volumes.ZoneVolume;
|
||||
|
||||
/**
|
||||
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since
|
||||
* the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
|
||||
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
@ -42,28 +41,24 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
for (String itemStr : itemsStrSplit) {
|
||||
String[] itemStrSplit = itemStr.split(";");
|
||||
if (itemStrSplit.length == 4) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
stack.setData(new MaterialData(stack.getTypeId(), Byte.parseByte(itemStrSplit[3])));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else if (itemStrSplit.length == 3) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else {
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1])));
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1])));
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public static int load(ZoneVolume volume, String zoneName, War war,
|
||||
World world, boolean onlyLoadCorners) {
|
||||
public static int load(ZoneVolume volume, String zoneName, War war, World world, boolean onlyLoadCorners) {
|
||||
BufferedReader in = null;
|
||||
int noOfResetBlocks = 0;
|
||||
try {
|
||||
@ -117,15 +112,8 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
diskBlockData = Byte.parseByte(blockSplit[1]);
|
||||
worldBlock = volume.getWorld().getBlockAt(x, y, z);
|
||||
worldBlockId = worldBlock.getTypeId();
|
||||
if (worldBlockId != diskBlockType ||
|
||||
(worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData ) ||
|
||||
(worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData &&
|
||||
(diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()
|
||||
|| diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId())
|
||||
)
|
||||
) {
|
||||
if (diskBlockType == Material.WALL_SIGN.getId()
|
||||
|| diskBlockType == Material.SIGN_POST.getId()) {
|
||||
if (worldBlockId != diskBlockType || (worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData) || (worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData && (diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId() || diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId()))) {
|
||||
if (diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()) {
|
||||
// Signs read
|
||||
String linesStr = "";
|
||||
if (blockSplit.length > 2) {
|
||||
@ -136,8 +124,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
|
||||
// Signs set
|
||||
// A sign post hanging on a wall south of here will
|
||||
if (diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04)
|
||||
&& i+1 != volume.getSizeX()) {
|
||||
if (diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04) && i + 1 != volume.getSizeX()) {
|
||||
deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
|
||||
} else {
|
||||
worldBlock.setType(Material.getMaterial(diskBlockType));
|
||||
@ -235,14 +222,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
} else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.STONE_BUTTON.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.LADDER.getId() && ((diskBlockData & 0x04) == 0x04))
|
||||
|| (diskBlockType == Material.RAILS.getId() && ((diskBlockData & 0x02) == 0x02)))
|
||||
&& i+1 != volume.getSizeX()){
|
||||
} else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.STONE_BUTTON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LADDER.getId() && ((diskBlockData & 0x04) == 0x04)) || (diskBlockType == Material.RAILS.getId() && ((diskBlockData & 0x02) == 0x02))) && i + 1 != volume.getSizeX()) {
|
||||
// Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol
|
||||
// Change the block itself later on:
|
||||
deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData));
|
||||
@ -259,11 +239,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". "
|
||||
+ "Blocks read: " + blockReads
|
||||
+ ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". " + "Blocks read: " + blockReads + ". Visited blocks so far:" + visitedBlocks + ". Blocks reset: " + noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
z++;
|
||||
@ -285,12 +261,10 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to read volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error caused failure to read volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Unexpected error caused failure to read volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (in != null) {
|
||||
@ -301,8 +275,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
// scanner.close();
|
||||
// scanner = null;
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -319,18 +292,25 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
if (zoneName.equals("")) {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||
} else {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
}
|
||||
|
||||
out.write("corner1"); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getZ())); out.newLine();
|
||||
out.write("corner2"); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getX())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getY())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getZ())); out.newLine();
|
||||
out.write("corner1");
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getX()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getY()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getZ()));
|
||||
out.newLine();
|
||||
out.write("corner2");
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getX()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getY()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getZ()));
|
||||
out.newLine();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
@ -381,9 +361,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
if (items != null) {
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
extra += item.getTypeId() + ";" + item.getAmount() + ";" + item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData();
|
||||
}
|
||||
@ -408,9 +386,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
if (items != null) {
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
extra += item.getTypeId() + ";" + item.getAmount() + ";" + item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData();
|
||||
}
|
||||
@ -422,11 +398,8 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
}
|
||||
noOfSavedBlocks++;
|
||||
out.newLine();
|
||||
}
|
||||
catch (Exception e) {
|
||||
war.logWarn("Unexpected error while saving a block to " +
|
||||
" file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks
|
||||
+ "Position: x:" + x + " y:" + y + " z:" + z + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error while saving a block to " + " file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks + "Position: x:" + x + " y:" + y + " z:" + z + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
z++;
|
||||
@ -437,21 +410,17 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
x++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -460,6 +429,4 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
return noOfSavedBlocks;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Used for accessing and creating .[properties] files, reads them as utf-8, saves as utf-8.
|
||||
* Internationalization is key importance especially for character codes.
|
||||
* Used for accessing and creating .[properties] files, reads them as utf-8, saves as utf-8. Internationalization is key importance especially for character codes.
|
||||
*
|
||||
* @author Nijikokun
|
||||
* @version 1.0.4, %G%
|
||||
@ -22,6 +21,7 @@ public final class PropertiesFile {
|
||||
private Properties props = new Properties();
|
||||
private FileInputStream inputStream;
|
||||
private FileOutputStream outputStream;
|
||||
|
||||
// private List<String> lines = new ArrayList<String>();
|
||||
// private Map<String, String> props = new HashMap<String, String>();
|
||||
|
||||
@ -47,8 +47,7 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* The loader for property files, it reads the file as UTF8 or converts the string into UTF8.
|
||||
* Used for simple runthrough's, loading, or reloading of the file.
|
||||
* The loader for property files, it reads the file as UTF8 or converts the string into UTF8. Used for simple runthrough's, loading, or reloading of the file.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@ -58,8 +57,7 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes out the <code>key=value</code> properties that were changed into
|
||||
* a .[properties] file in UTF8.
|
||||
* Writes out the <code>key=value</code> properties that were changed into a .[properties] file in UTF8.
|
||||
*/
|
||||
public void save() {
|
||||
try {
|
||||
@ -87,22 +85,26 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Map of all <code>key=value</code> properties in the file as <code><key (java.lang.String), value (java.lang.String)></code>
|
||||
* <br /><br />
|
||||
* Example:
|
||||
* <blockquote><pre>
|
||||
* PropertiesFile settings = new PropertiesFile("settings.properties");
|
||||
* Map<String, String> mappedSettings;
|
||||
* Returns a Map of all <code>key=value</code> properties in the file as <code><key (java.lang.String), value (java.lang.String)></code> <br />
|
||||
* <br />
|
||||
* Example: <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* PropertiesFile settings = new PropertiesFile("settings.properties");
|
||||
* Map<String, String> mappedSettings;
|
||||
*
|
||||
* try {
|
||||
* mappedSettings = settings.returnMap();
|
||||
* } catch (Exception ex) {
|
||||
* log.info("Failed mapping settings.properties");
|
||||
* log.info("Failed mapping settings.properties");
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @return <code>map</code> - Simple Map HashMap of the entire <code>key=value</code> as <code><key (java.lang.String), value (java.lang.String)></code>
|
||||
* @throws Exception If the properties file doesn't exist.
|
||||
* @throws Exception
|
||||
* If the properties file doesn't exist.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String> returnMap() throws Exception {
|
||||
@ -112,7 +114,8 @@ public final class PropertiesFile {
|
||||
/**
|
||||
* Checks to see if the .[properties] file contains the given <code>key</code>.
|
||||
*
|
||||
* @param var The key we are going to be checking the existance of.
|
||||
* @param var
|
||||
* The key we are going to be checking the existance of.
|
||||
* @return <code>Boolean</code> - True if the <code>key</code> exists, false if it cannot be found.
|
||||
*/
|
||||
public boolean containsKey(String var) {
|
||||
@ -122,7 +125,8 @@ public final class PropertiesFile {
|
||||
/**
|
||||
* Checks to see if this <code>key</code> exists in the .[properties] file.
|
||||
*
|
||||
* @param var The key we are grabbing the value of.
|
||||
* @param var
|
||||
* The key we are grabbing the value of.
|
||||
* @return <code>java.lang.String</code> - True if the <code>key</code> exists, false if it cannot be found.
|
||||
*/
|
||||
public String getProperty(String var) {
|
||||
@ -130,11 +134,11 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a key from the file if it exists.
|
||||
* This will save() which will invoke a load() on the file.
|
||||
* Remove a key from the file if it exists. This will save() which will invoke a load() on the file.
|
||||
*
|
||||
* @see #save()
|
||||
* @param var The <code>key</code> that will be removed from the file
|
||||
* @param var
|
||||
* The <code>key</code> that will be removed from the file
|
||||
*/
|
||||
public void removeKey(String var) {
|
||||
if (this.props.containsKey(var)) {
|
||||
@ -147,7 +151,8 @@ public final class PropertiesFile {
|
||||
* Checks the existance of a <code>key</code>.
|
||||
*
|
||||
* @see #containsKey(java.lang.String)
|
||||
* @param key The <code>key</code> in question of existance.
|
||||
* @param key
|
||||
* The <code>key</code> in question of existance.
|
||||
* @return <code>Boolean</code> - True for existance, false for <code>key</code> found.
|
||||
*/
|
||||
public boolean keyExists(String key) {
|
||||
@ -155,11 +160,11 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the <code>key</code> given as a <code>String</code>,
|
||||
* however we do not set a string if no <code>key</code> is found.
|
||||
* Returns the value of the <code>key</code> given as a <code>String</code>, however we do not set a string if no <code>key</code> is found.
|
||||
*
|
||||
* @see #getProperty(java.lang.String)
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to "" or empty.
|
||||
* @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)) {
|
||||
@ -170,13 +175,14 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the <code>key</code> given as a <code>String</code>.
|
||||
* If it is not found, it will invoke saving the default <code>value</code> to the properties file.
|
||||
* Returns the value of the <code>key</code> given as a <code>String</code>. If it is not found, it will invoke saving the default <code>value</code> to the properties file.
|
||||
*
|
||||
* @see #setString(java.lang.String, java.lang.String)
|
||||
* @see #getProperty(java.lang.String)
|
||||
* @param key The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @param key
|
||||
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value
|
||||
* The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @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) {
|
||||
@ -192,8 +198,10 @@ public final class PropertiesFile {
|
||||
* Save the value given as a <code>String</code> on the specified key.
|
||||
*
|
||||
* @see #save()
|
||||
* @param key The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
* @param key
|
||||
* The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value
|
||||
* The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setString(String key, String value) {
|
||||
this.props.put(key, value);
|
||||
@ -201,11 +209,11 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the <code>key</code> given in a Integer,
|
||||
* however we do not set a string if no <code>key</code> is found.
|
||||
* Returns the value of the <code>key</code> given in a Integer, however we do not set a string if no <code>key</code> is found.
|
||||
*
|
||||
* @see #getProperty(String var)
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0
|
||||
* @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)) {
|
||||
@ -219,8 +227,10 @@ public final class PropertiesFile {
|
||||
* Returns the int value of a key
|
||||
*
|
||||
* @see #setInt(String key, int value)
|
||||
* @param key The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @param key
|
||||
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value
|
||||
* The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @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) {
|
||||
@ -237,8 +247,10 @@ public final class PropertiesFile {
|
||||
* Save the value given as a <code>int</code> on the specified key.
|
||||
*
|
||||
* @see #save()
|
||||
* @param key The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
* @param key
|
||||
* The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value
|
||||
* The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setInt(String key, int value) {
|
||||
this.props.put(key, String.valueOf(value));
|
||||
@ -247,11 +259,11 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the <code>key</code> given in a Double,
|
||||
* however we do not set a string if no <code>key</code> is found.
|
||||
* Returns the value of the <code>key</code> given in a Double, however we do not set a string if no <code>key</code> is found.
|
||||
*
|
||||
* @see #getProperty(String var)
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0.0
|
||||
* @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)) {
|
||||
@ -265,8 +277,10 @@ public final class PropertiesFile {
|
||||
* Returns the double value of a key
|
||||
*
|
||||
* @see #setDouble(String key, double value)
|
||||
* @param key The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @param key
|
||||
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value
|
||||
* The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @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) {
|
||||
@ -282,8 +296,10 @@ public final class PropertiesFile {
|
||||
* Save the value given as a <code>double</code> on the specified key.
|
||||
*
|
||||
* @see #save()
|
||||
* @param key The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
* @param key
|
||||
* The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value
|
||||
* The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setDouble(String key, double value) {
|
||||
this.props.put(key, String.valueOf(value));
|
||||
@ -292,11 +308,11 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the <code>key</code> given in a Long,
|
||||
* however we do not set a string if no <code>key</code> is found.
|
||||
* Returns the value of the <code>key</code> given in a Long, however we do not set a string if no <code>key</code> is found.
|
||||
*
|
||||
* @see #getProperty(String var)
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0L
|
||||
* @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)) {
|
||||
@ -310,8 +326,10 @@ public final class PropertiesFile {
|
||||
* Returns the long value of a key
|
||||
*
|
||||
* @see #setLong(String key, long value)
|
||||
* @param key The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @param key
|
||||
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value
|
||||
* The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @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) {
|
||||
@ -327,8 +345,10 @@ public final class PropertiesFile {
|
||||
* Save the value given as a <code>long</code> on the specified key.
|
||||
*
|
||||
* @see #save()
|
||||
* @param key The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
* @param key
|
||||
* The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value
|
||||
* The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setLong(String key, long value) {
|
||||
this.props.put(key, String.valueOf(value));
|
||||
@ -337,11 +357,11 @@ public final class PropertiesFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the <code>key</code> given in a Boolean,
|
||||
* however we do not set a string if no <code>key</code> is found.
|
||||
* Returns the value of the <code>key</code> given in a Boolean, however we do not set a string if no <code>key</code> is found.
|
||||
*
|
||||
* @see #getProperty(String var)
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to false
|
||||
* @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)) {
|
||||
@ -355,8 +375,10 @@ public final class PropertiesFile {
|
||||
* Returns the boolean value of a key
|
||||
*
|
||||
* @see #setBoolean(String key, boolean value)
|
||||
* @param key The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @param key
|
||||
* The key that we will be grabbing the value from, if no value is found set and return <code>value</code>
|
||||
* @param value
|
||||
* The default value that we will be setting if no prior <code>key</code> is found.
|
||||
* @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) {
|
||||
@ -372,8 +394,10 @@ public final class PropertiesFile {
|
||||
* Save the value given as a <code>boolean</code> on the specified key.
|
||||
*
|
||||
* @see #save()
|
||||
* @param key The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
* @param key
|
||||
* The <code>key</code> that we will be addressing the <code>value</code> to.
|
||||
* @param value
|
||||
* The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setBoolean(String key, boolean value) {
|
||||
this.props.put(key, String.valueOf(value));
|
||||
|
@ -25,8 +25,7 @@ import com.tommytony.war.volumes.Volume;
|
||||
*/
|
||||
public class VolumeMapper {
|
||||
|
||||
public static Volume loadVolume(String volumeName, String zoneName,
|
||||
War war, World world) {
|
||||
public static Volume loadVolume(String volumeName, String zoneName, War war, World world) {
|
||||
Volume volume = new Volume(volumeName, war, world);
|
||||
VolumeMapper.load(volume, zoneName, war, world);
|
||||
return volume;
|
||||
@ -43,8 +42,7 @@ public class VolumeMapper {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
if (zoneName.equals("")) {
|
||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() +
|
||||
"/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
||||
} else {
|
||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
}
|
||||
@ -87,8 +85,7 @@ public class VolumeMapper {
|
||||
volume.getBlockTypes()[i][j][k] = typeID;
|
||||
volume.getBlockDatas()[i][j][k] = data;
|
||||
|
||||
if (typeID == Material.WALL_SIGN.getId()
|
||||
|| typeID == Material.SIGN_POST.getId()) {
|
||||
if (typeID == Material.WALL_SIGN.getId() || typeID == Material.SIGN_POST.getId()) {
|
||||
// Signs
|
||||
String linesStr = "";
|
||||
if (blockSplit.length > 2) {
|
||||
@ -107,21 +104,18 @@ public class VolumeMapper {
|
||||
for (String itemStr : itemsStrSplit) {
|
||||
String[] itemStrSplit = itemStr.split(";");
|
||||
if (itemStrSplit.length == 4) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
stack.setData(new MaterialData(stack.getTypeId(), Byte.parseByte(itemStrSplit[3])));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else if (itemStrSplit.length == 3) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else {
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1])));
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,21 +129,18 @@ public class VolumeMapper {
|
||||
for (String itemStr : itemsStrSplit) {
|
||||
String[] itemStrSplit = itemStr.split(";");
|
||||
if (itemStrSplit.length == 4) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
stack.setData(new MaterialData(stack.getTypeId(), Byte.parseByte(itemStrSplit[3])));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else if (itemStrSplit.length == 3) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else {
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1])));
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,9 +150,7 @@ public class VolumeMapper {
|
||||
blockReads++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error while reading block from volume " + volume.getName() +
|
||||
" file for zone " + zoneName + ". Blocks read so far: " + blockReads
|
||||
+ "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Unexpected error while reading block from volume " + volume.getName() + " file for zone " + zoneName + ". Blocks read so far: " + blockReads + "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -174,20 +163,17 @@ public class VolumeMapper {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to read volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error caused failure to read volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Unexpected error caused failure to read volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -201,18 +187,25 @@ public class VolumeMapper {
|
||||
if (zoneName.equals("")) {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||
} else {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
}
|
||||
|
||||
out.write("corner1"); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getZ())); out.newLine();
|
||||
out.write("corner2"); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getX())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getY())); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getZ())); out.newLine();
|
||||
out.write("corner1");
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getX()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getY()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getZ()));
|
||||
out.newLine();
|
||||
out.write("corner2");
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getX()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getY()));
|
||||
out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerTwo().getZ()));
|
||||
out.newLine();
|
||||
int blockWrites = 0;
|
||||
for (int i = 0; i < volume.getSizeX(); i++) {
|
||||
for (int j = 0; j < volume.getSizeY(); j++) {
|
||||
@ -221,8 +214,7 @@ public class VolumeMapper {
|
||||
int typeId = volume.getBlockTypes()[i][j][k];
|
||||
byte data = volume.getBlockDatas()[i][j][k];
|
||||
out.write(typeId + "," + data + ",");
|
||||
if (typeId == Material.WALL_SIGN.getId()
|
||||
|| typeId == Material.SIGN_POST.getId()) {
|
||||
if (typeId == Material.WALL_SIGN.getId() || typeId == Material.SIGN_POST.getId()) {
|
||||
// Signs
|
||||
String extra = "";
|
||||
String[] lines = volume.getSignLines().get("sign-" + i + "-" + j + "-" + k);
|
||||
@ -239,9 +231,7 @@ public class VolumeMapper {
|
||||
if (contents != null) {
|
||||
for (ItemStack item : contents) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
extra += item.getTypeId() + ";" + item.getAmount() + ";" + item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData();
|
||||
}
|
||||
@ -257,9 +247,7 @@ public class VolumeMapper {
|
||||
if (contents != null) {
|
||||
for (ItemStack item : contents) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
extra += item.getTypeId() + ";" + item.getAmount() + ";" + item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData();
|
||||
}
|
||||
@ -270,32 +258,25 @@ public class VolumeMapper {
|
||||
}
|
||||
}
|
||||
out.newLine();
|
||||
}
|
||||
catch (Exception e) {
|
||||
war.logWarn("Unexpected error while writing block into volume " + volume.getName() +
|
||||
" file for zone " + zoneName + ". Blocks written so far: " + blockWrites
|
||||
+ "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error while writing block into volume " + volume.getName() + " file for zone " + zoneName + ". Blocks written so far: " + blockWrites + "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -311,5 +292,4 @@ public class VolumeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package com.tommytony.war.mappers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@ -70,8 +71,7 @@ public class WarMapper {
|
||||
for (String itemStr : defaultLoadoutSplit) {
|
||||
if (itemStr != null && !itemStr.equals("")) {
|
||||
String[] itemStrSplit = itemStr.split(",");
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
war.getDefaultLoadout().put(Integer.parseInt(itemStrSplit[2]), item);
|
||||
}
|
||||
}
|
||||
@ -128,8 +128,7 @@ public class WarMapper {
|
||||
for (String itemStr : defaultRewardStrSplit) {
|
||||
if (itemStr != null && !itemStr.equals("")) {
|
||||
String[] itemStrSplit = itemStr.split(",");
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
war.getDefaultReward().put(Integer.parseInt(itemStrSplit[2]), item);
|
||||
}
|
||||
}
|
||||
@ -259,8 +258,7 @@ public class WarMapper {
|
||||
String hubStr = "";
|
||||
WarHub hub = war.getWarHub();
|
||||
if (hub != null) {
|
||||
hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ() + ","
|
||||
+ hub.getLocation().getWorld().getName();
|
||||
hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ() + "," + hub.getLocation().getWorld().getName();
|
||||
VolumeMapper.save(hub.getVolume(), "", war);
|
||||
}
|
||||
warConfig.setString("warhub", hubStr);
|
||||
|
@ -92,10 +92,7 @@ public class WarzoneMapper {
|
||||
int yaw = Integer.parseInt(teamStrSplit[4]);
|
||||
teamLocation.setYaw(yaw);
|
||||
}
|
||||
Team team = new Team(teamStrSplit[0],
|
||||
TeamKinds.teamKindFromString(teamStrSplit[0]),
|
||||
teamLocation,
|
||||
war, warzone );
|
||||
Team team = new Team(teamStrSplit[0], TeamKinds.teamKindFromString(teamStrSplit[0]), teamLocation, war, warzone);
|
||||
team.setRemainingLives(warzone.getLifePool());
|
||||
warzone.getTeams().add(team);
|
||||
}
|
||||
@ -136,8 +133,7 @@ public class WarzoneMapper {
|
||||
for (String itemStr : loadoutStrSplit) {
|
||||
if (itemStr != null && !itemStr.equals("")) {
|
||||
String[] itemStrSplit = itemStr.split(",");
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
warzone.getLoadout().put(Integer.parseInt(itemStrSplit[2]), item);
|
||||
}
|
||||
}
|
||||
@ -183,8 +179,7 @@ public class WarzoneMapper {
|
||||
for (String itemStr : rewardStrSplit) {
|
||||
if (itemStr != null && !itemStr.equals("")) {
|
||||
String[] itemStrSplit = itemStr.split(",");
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack item = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
warzone.getReward().put(Integer.parseInt(itemStrSplit[2]), item);
|
||||
}
|
||||
}
|
||||
@ -234,8 +229,7 @@ public class WarzoneMapper {
|
||||
int monumentX = Integer.parseInt(monumentStrSplit[1]);
|
||||
int monumentY = Integer.parseInt(monumentStrSplit[2]);
|
||||
int monumentZ = Integer.parseInt(monumentStrSplit[3]);
|
||||
Monument monument = new Monument(monumentStrSplit[0], war, warzone,
|
||||
new Location(world, monumentX, monumentY, monumentZ));
|
||||
Monument monument = new Monument(monumentStrSplit[0], war, warzone, new Location(world, monumentX, monumentY, monumentZ));
|
||||
warzone.getMonuments().add(monument);
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ import com.tommytony.war.volumes.Volume;
|
||||
import com.tommytony.war.volumes.ZoneVolume;
|
||||
|
||||
/**
|
||||
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since
|
||||
* the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
|
||||
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
@ -109,22 +108,14 @@ public class ZoneVolumeMapper {
|
||||
|
||||
worldBlock = volume.getWorld().getBlockAt(x, y, z);
|
||||
worldBlockId = worldBlock.getTypeId();
|
||||
if (worldBlockId != diskBlockType ||
|
||||
(worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData ) ||
|
||||
(worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData &&
|
||||
(diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()
|
||||
|| diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId())
|
||||
)
|
||||
) {
|
||||
if (diskBlockType == Material.WALL_SIGN.getId()
|
||||
|| diskBlockType == Material.SIGN_POST.getId()) {
|
||||
if (worldBlockId != diskBlockType || (worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData) || (worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData && (diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId() || diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId()))) {
|
||||
if (diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()) {
|
||||
// Signs read
|
||||
String linesStr = signsReader.readLine();
|
||||
String[] lines = linesStr.split(";;");
|
||||
|
||||
// Signs set
|
||||
if (diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04)
|
||||
&& i+1 != volume.getSizeX()) {
|
||||
if (diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04) && i + 1 != volume.getSizeX()) {
|
||||
// A sign post hanging on a wall south of here needs that block to be set first
|
||||
deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
|
||||
} else {
|
||||
@ -212,14 +203,7 @@ public class ZoneVolumeMapper {
|
||||
worldBlock.setType(Material.GLASS);
|
||||
}
|
||||
}
|
||||
} else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.STONE_BUTTON.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.LADDER.getId() && ((diskBlockData & 0x04) == 0x04))
|
||||
|| (diskBlockType == Material.RAILS.getId() && ((diskBlockData & 0x02) == 0x02)))
|
||||
&& i+1 != volume.getSizeX()){
|
||||
} else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.STONE_BUTTON.getId() && ((diskBlockData & 0x02) == 0x02)) || (diskBlockType == Material.LADDER.getId() && ((diskBlockData & 0x04) == 0x04)) || (diskBlockType == Material.RAILS.getId() && ((diskBlockData & 0x02) == 0x02))) && i + 1 != volume.getSizeX()) {
|
||||
// Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol
|
||||
// Change the block itself later on:
|
||||
deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData));
|
||||
@ -235,11 +219,7 @@ public class ZoneVolumeMapper {
|
||||
blockReads++;
|
||||
|
||||
} catch (Exception e) {
|
||||
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". "
|
||||
+ "Blocks read: " + blockReads
|
||||
+ ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". " + "Blocks read: " + blockReads + ". Visited blocks so far:" + visitedBlocks + ". Blocks reset: " + noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
z++;
|
||||
@ -254,12 +234,10 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
war.logWarn("Failed to find volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to find volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to read volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
@ -276,8 +254,7 @@ public class ZoneVolumeMapper {
|
||||
invsReader.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to close volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -292,21 +269,18 @@ public class ZoneVolumeMapper {
|
||||
for (String itemStr : itemsStrSplit) {
|
||||
String[] itemStrSplit = itemStr.split(";");
|
||||
if (itemStrSplit.length == 4) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
stack.setData(new MaterialData(stack.getTypeId(), Byte.parseByte(itemStrSplit[3])));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else if (itemStrSplit.length == 3) {
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1]));
|
||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
|
||||
short durability = (short) Integer.parseInt(itemStrSplit[2]);
|
||||
stack.setDurability(durability);
|
||||
items.add(stack);
|
||||
} else {
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||
Integer.parseInt(itemStrSplit[1])));
|
||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,14 +302,22 @@ public class ZoneVolumeMapper {
|
||||
signsWriter = new BufferedWriter(new FileWriter(new File(path + ".signs")));
|
||||
invsWriter = new BufferedWriter(new FileWriter(new File(path + ".invs")));
|
||||
|
||||
cornersWriter.write("corner1"); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getX())); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getY())); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getZ())); cornersWriter.newLine();
|
||||
cornersWriter.write("corner2"); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getX())); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getY())); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getZ())); cornersWriter.newLine();
|
||||
cornersWriter.write("corner1");
|
||||
cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getX()));
|
||||
cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getY()));
|
||||
cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getZ()));
|
||||
cornersWriter.newLine();
|
||||
cornersWriter.write("corner2");
|
||||
cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getX()));
|
||||
cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getY()));
|
||||
cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getZ()));
|
||||
cornersWriter.newLine();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
@ -387,9 +369,7 @@ public class ZoneVolumeMapper {
|
||||
if (items != null) {
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
extra += item.getTypeId() + ";" + item.getAmount() + ";" + item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData();
|
||||
}
|
||||
@ -415,9 +395,7 @@ public class ZoneVolumeMapper {
|
||||
if (items != null) {
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
extra += item.getTypeId() + ";" + item.getAmount() + ";" + item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData();
|
||||
}
|
||||
@ -429,11 +407,8 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
}
|
||||
noOfSavedBlocks++;
|
||||
}
|
||||
catch (Exception e) {
|
||||
war.logWarn("Unexpected error while saving a block to " +
|
||||
" file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks
|
||||
+ "Position: x:" + x + " y:" + y + " z:" + z + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error while saving a block to " + " file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks + "Position: x:" + x + " y:" + y + " z:" + z + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
z++;
|
||||
@ -444,15 +419,12 @@ public class ZoneVolumeMapper {
|
||||
x++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
try {
|
||||
if (cornersWriter != null) {
|
||||
cornersWriter.close();
|
||||
@ -467,8 +439,7 @@ public class ZoneVolumeMapper {
|
||||
invsWriter.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
war.logWarn("Failed to close volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -499,5 +470,4 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,62 +5,32 @@ import java.util.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* The purpose of this tool is twofold:
|
||||
* 1: Avoid client crashes due to bad color formating.
|
||||
* 2: Make color continue on word wrapping
|
||||
* The purpose of this tool is twofold: 1: Avoid client crashes due to bad color formating. 2: Make color continue on word wrapping
|
||||
*
|
||||
* In minecraft the degree sign is used as a prefix to another char to create a color.
|
||||
* For example the code for white is "\u00A7f".
|
||||
* The "\u00A7" is the unicode notation for the degree sign and the "f" means white.
|
||||
* In minecraft the degree sign is used as a prefix to another char to create a color. For example the code for white is "\u00A7f". The "\u00A7" is the unicode notation for the degree sign and the "f" means white.
|
||||
*
|
||||
* When does minecraft wrap the text? After how many chars?
|
||||
* Answer:
|
||||
* Because the font isn't monospace this differs depending on what you write.
|
||||
* However we can fit 53 "M" without wrapping and the 54th char would then wrap (be at the beginning of the next line instead)
|
||||
* As there is no broader char than "M" we can know for sure the minimum line length is 53.
|
||||
* Note that this means the number of DISPLAYED chars per row is 53.
|
||||
* A degree sign and the char after will NOT count, as they will not be displayed as chars.
|
||||
* When does minecraft wrap the text? After how many chars? Answer: Because the font isn't monospace this differs depending on what you write. However we can fit 53 "M" without wrapping and the 54th char would then wrap (be at the beginning of the next line instead) As there is no broader char than "M" we can know for sure the minimum line length is 53. Note that this means the number of DISPLAYED chars per row is 53. A degree sign and the char after will NOT count, as they will not be displayed as chars.
|
||||
*
|
||||
* Good to know: Numbers have the same font width as an M.
|
||||
*
|
||||
* When does the client crash?
|
||||
* Answer:
|
||||
* When a row ends with a degree char and optionally another sign after.
|
||||
* Another way to say the same: When a line ends with either a broken or valid color notation.
|
||||
* AND
|
||||
* The client will ALWAYS crash if the sign after the last displayed char in a row is a degree char.
|
||||
* A goofy way to explatin it:
|
||||
* For a line with only "M" and numbers, the fiftyfourth "displayed char" musn't be a degree sign.
|
||||
* When does the client crash? Answer: When a row ends with a degree char and optionally another sign after. Another way to say the same: When a line ends with either a broken or valid color notation. AND The client will ALWAYS crash if the sign after the last displayed char in a row is a degree char. A goofy way to explatin it: For a line with only "M" and numbers, the fiftyfourth "displayed char" musn't be a degree sign.
|
||||
*
|
||||
* WARNING:
|
||||
* Above is a hypothesis I have created based on what my experiments have shown.
|
||||
* I am fairly sure it is correct but please help me test it further.
|
||||
* WARNING: Above is a hypothesis I have created based on what my experiments have shown. I am fairly sure it is correct but please help me test it further.
|
||||
*/
|
||||
public class ChatFixUtil {
|
||||
public final static char deg = '\u00A7';
|
||||
public final static int lineLength = 53;
|
||||
|
||||
/**
|
||||
* This method wraps the msg for you at row lengths of 53,
|
||||
* avoids client crash scenarios and makes the previous color continue on
|
||||
* the next line.
|
||||
* This method wraps the msg for you at row lengths of 53, avoids client crash scenarios and makes the previous color continue on the next line.
|
||||
*
|
||||
* The upsides with filtering your messages through this method are:
|
||||
* - No client crashes.
|
||||
* - Line wrapping with preserved color.
|
||||
* The upsides with filtering your messages through this method are: - No client crashes. - Line wrapping with preserved color.
|
||||
*
|
||||
* The downsides are:
|
||||
* - The width of the chat window will not be used to it's fullest.
|
||||
* For example you can fit more that 53 commas (,) in a chatwindow row
|
||||
* but the line would break after 53 displayed chars.
|
||||
* The downsides are: - The width of the chat window will not be used to it's fullest. For example you can fit more that 53 commas (,) in a chatwindow row but the line would break after 53 displayed chars.
|
||||
*
|
||||
* Suggested usage:
|
||||
* NO NEED TO USE the fix method for static help pages in your plugin.
|
||||
* As the text is static you can make sure there is no client crash yourself
|
||||
* and be able to use the full line length.
|
||||
* Suggested usage: NO NEED TO USE the fix method for static help pages in your plugin. As the text is static you can make sure there is no client crash yourself and be able to use the full line length.
|
||||
*
|
||||
* DO USE in cases like where you output colored messages with playernames in your
|
||||
* plugin. As the player names have different length there is potential for client crash.
|
||||
* DO USE in cases like where you output colored messages with playernames in your plugin. As the player names have different length there is potential for client crash.
|
||||
*/
|
||||
public static ArrayList<String> fix(String msg) {
|
||||
// Make sure the end of msg is good
|
||||
@ -104,10 +74,8 @@ public class ChatFixUtil {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the ending chars as long as they are deg or deg+'anychar' or a space
|
||||
* As I see it we would never want those chars at the end of a msg.
|
||||
* Removes the ending chars as long as they are deg or deg+'anychar' or a space As I see it we would never want those chars at the end of a msg.
|
||||
*/
|
||||
protected static String cleanMsgEnding(String msg) {
|
||||
|
||||
@ -124,9 +92,7 @@ public class ChatFixUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* This test util assumes line break after 53 displayed chars.
|
||||
* The fix method above breaks like that so this method should
|
||||
* be a valid way to test if a message row would crash a client.
|
||||
* This test util assumes line break after 53 displayed chars. The fix method above breaks like that so this method should be a valid way to test if a message row would crash a client.
|
||||
*/
|
||||
public static String thisMsgWouldCrashClient(String str) {
|
||||
// There would always be crash if we end with deg or deg+'anychar'
|
||||
@ -167,6 +133,7 @@ public class ChatFixUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMessage(Player player, List<String> messages, boolean fix) {
|
||||
if (fix) {
|
||||
messages = ChatFixUtil.fix(messages);
|
||||
@ -175,12 +142,15 @@ public class ChatFixUtil {
|
||||
ChatFixUtil.sendMessage(player, message, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMessage(Player player, String message) {
|
||||
ChatFixUtil.sendMessage(player, message, true);
|
||||
}
|
||||
|
||||
public static void sendMessage(Player player, List<String> messages) {
|
||||
ChatFixUtil.sendMessage(player, messages, true);
|
||||
}
|
||||
|
||||
// ----------------------------------------------//
|
||||
// Many Players
|
||||
// ----------------------------------------------//
|
||||
@ -194,6 +164,7 @@ public class ChatFixUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMessage(Collection<Player> players, List<String> messages, boolean fix) {
|
||||
if (fix) {
|
||||
messages = ChatFixUtil.fix(messages);
|
||||
@ -203,9 +174,11 @@ public class ChatFixUtil {
|
||||
ChatFixUtil.sendMessage(players, message, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMessage(Collection<Player> players, String message) {
|
||||
ChatFixUtil.sendMessage(players, message, true);
|
||||
}
|
||||
|
||||
public static void sendMessage(Collection<Player> players, List<String> messages) {
|
||||
ChatFixUtil.sendMessage(players, messages, true);
|
||||
}
|
||||
|
@ -63,5 +63,4 @@ public class InventoryStash {
|
||||
return this.feet;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ public class BlockInfo {
|
||||
private int z;
|
||||
private int type;
|
||||
private byte data;
|
||||
|
||||
// private String[] signLines;
|
||||
|
||||
public static Block getBlock(World world, BlockInfo info) {
|
||||
return world.getBlockAt(info.getX(), info.getY(), info.getZ());
|
||||
}
|
||||
|
||||
public BlockInfo(int x, int y, int z, int type, byte data)
|
||||
{
|
||||
public BlockInfo(int x, int y, int z, int type, byte data) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
@ -28,10 +28,7 @@ public class CenteredVolume extends Volume {
|
||||
}
|
||||
|
||||
public void changeCenter(Location newCenter) {
|
||||
this.changeCenter(this.world.getBlockAt(newCenter.getBlockX(),
|
||||
newCenter.getBlockY(),
|
||||
newCenter.getBlockZ()),
|
||||
this.sideSize);
|
||||
this.changeCenter(this.world.getBlockAt(newCenter.getBlockX(), newCenter.getBlockY(), newCenter.getBlockZ()), this.sideSize);
|
||||
}
|
||||
|
||||
public void changeCenter(Block newCenter, int sideSize) {
|
||||
|
@ -4,5 +4,4 @@ public class NotNorthwestException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -5736463256274556866L;
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ public class TooBigException extends Exception {
|
||||
*/
|
||||
private static final long serialVersionUID = 61793179891881015L;
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ public class TooSmallException extends Exception {
|
||||
*/
|
||||
private static final long serialVersionUID = -1641366536434076088L;
|
||||
|
||||
|
||||
}
|
||||
|
@ -39,40 +39,28 @@ public class VerticalVolume extends Volume{
|
||||
}
|
||||
|
||||
public boolean isEastWallBlock(Block block) {
|
||||
if (this.getMinZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX())
|
||||
{
|
||||
if (this.getMinZ() == block.getZ() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX()) {
|
||||
return true; // east wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSouthWallBlock(Block block) {
|
||||
if (this.getMaxX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ())
|
||||
{
|
||||
if (this.getMaxX() == block.getX() && block.getZ() <= this.getMaxZ() && block.getZ() >= this.getMinZ()) {
|
||||
return true; // south wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNorthWallBlock(Block block) {
|
||||
if (this.getMinX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ())
|
||||
{
|
||||
if (this.getMinX() == block.getX() && block.getZ() <= this.getMaxZ() && block.getZ() >= this.getMinZ()) {
|
||||
return true; // north wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWestWallBlock(Block block) {
|
||||
if (this.getMaxZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX())
|
||||
{
|
||||
if (this.getMaxZ() == block.getZ() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX()) {
|
||||
return true; // west wall
|
||||
}
|
||||
return false;
|
||||
@ -159,12 +147,7 @@ public class VerticalVolume extends Volume{
|
||||
}
|
||||
|
||||
private boolean resetBlock(int oldBlockType, byte oldBlockData, Block currentBlock) {
|
||||
if (currentBlock.getTypeId() != oldBlockType ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() == oldBlockData &&
|
||||
(oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId())
|
||||
)
|
||||
) {
|
||||
if (currentBlock.getTypeId() != oldBlockType || (currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) || (currentBlock.getTypeId() == oldBlockType && currentBlock.getData() == oldBlockData && (oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()))) {
|
||||
currentBlock.setTypeId(oldBlockType);
|
||||
currentBlock.setData(oldBlockData);
|
||||
// if (oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
|
||||
|
@ -121,8 +121,7 @@ public class Volume {
|
||||
|
||||
noOfSavedBlocks++;
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to save block in volume " + this.getName() + ". Saved blocks so far:" + noOfSavedBlocks
|
||||
+ ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + e.getMessage());
|
||||
this.getWar().getLogger().warning("Failed to save block in volume " + this.getName() + ". Saved blocks so far:" + noOfSavedBlocks + ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
z++;
|
||||
@ -134,8 +133,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to save volume " + this.getName() + " blocks. Saved blocks:" + noOfSavedBlocks
|
||||
+ ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " "+ e.getMessage());
|
||||
this.getWar().getLogger().warning("Failed to save volume " + this.getName() + " blocks. Saved blocks:" + noOfSavedBlocks + ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return noOfSavedBlocks;
|
||||
@ -164,18 +162,10 @@ public class Volume {
|
||||
byte oldBlockData = this.getBlockDatas()[i][j][k];
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
currentBlockId = currentBlock.getTypeId();
|
||||
if (currentBlockId != oldBlockType ||
|
||||
(currentBlockId == oldBlockType && currentBlock.getData() != oldBlockData ) ||
|
||||
(currentBlockId == oldBlockType && currentBlock.getData() == oldBlockData &&
|
||||
(oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()
|
||||
|| oldBlockType == Material.CHEST.getId() || oldBlockType == Material.DISPENSER.getId())
|
||||
)
|
||||
) {
|
||||
if (oldBlockType == Material.WALL_SIGN.getId()
|
||||
|| oldBlockType == Material.SIGN_POST.getId()) {
|
||||
if (currentBlockId != oldBlockType || (currentBlockId == oldBlockType && currentBlock.getData() != oldBlockData) || (currentBlockId == oldBlockType && currentBlock.getData() == oldBlockData && (oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId() || oldBlockType == Material.CHEST.getId() || oldBlockType == Material.DISPENSER.getId()))) {
|
||||
if (oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()) {
|
||||
// Signs
|
||||
if (oldBlockType == Material.SIGN_POST.getId() && ((oldBlockData & 0x04) == 0x04)
|
||||
&& i+1 != this.getSizeX()) {
|
||||
if (oldBlockType == Material.SIGN_POST.getId() && ((oldBlockData & 0x04) == 0x04) && i + 1 != this.getSizeX()) {
|
||||
Block southBlock = currentBlock.getFace(BlockFace.SOUTH);
|
||||
int oldSouthBlockType = this.getBlockTypes()[i + 1][j][k];
|
||||
byte oldSouthBlockData = this.getBlockDatas()[i + 1][j][k];
|
||||
@ -258,14 +248,7 @@ public class Volume {
|
||||
blockAbove.setType(Material.getMaterial(oldBlockType));
|
||||
blockAbove.setData(this.getBlockDatas()[i][j + 1][k]);
|
||||
}
|
||||
} else if (((oldBlockType == Material.TORCH.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.REDSTONE_TORCH_ON.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.LEVER.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.STONE_BUTTON.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.LADDER.getId() && ((oldBlockData & 0x04) == 0x04))
|
||||
|| (oldBlockType == Material.RAILS.getId() && ((oldBlockData & 0x02) == 0x02)))
|
||||
&& i+1 != this.getSizeX()){
|
||||
} else if (((oldBlockType == Material.TORCH.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.REDSTONE_TORCH_ON.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.LEVER.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.STONE_BUTTON.getId() && ((oldBlockData & 0x02) == 0x02)) || (oldBlockType == Material.LADDER.getId() && ((oldBlockData & 0x04) == 0x04)) || (oldBlockType == Material.RAILS.getId() && ((oldBlockData & 0x02) == 0x02))) && i + 1 != this.getSizeX()) {
|
||||
// Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol
|
||||
Block southBlock = currentBlock.getFace(BlockFace.SOUTH);
|
||||
int oldSouthBlockType = this.getBlockTypes()[i + 1][j][k];
|
||||
@ -286,9 +269,7 @@ public class Volume {
|
||||
}
|
||||
visitedBlocks++;
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to reset block in volume " + this.getName() + ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
this.getWar().getLogger().warning("Failed to reset block in volume " + this.getName() + ". Visited blocks so far:" + visitedBlocks + ". Blocks reset: " + noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
z++;
|
||||
@ -300,9 +281,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to reset volume " + this.getName() + " blocks. Blocks visited: " + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z
|
||||
+ ". Current block: " + currentBlockId + ". Old block: " + oldBlockType + ". Exception: " + e.getClass().toString() + " " + e.getMessage());
|
||||
this.getWar().logWarn("Failed to reset volume " + this.getName() + " blocks. Blocks visited: " + visitedBlocks + ". Blocks reset: " + noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z + ". Current block: " + currentBlockId + ". Old block: " + oldBlockType + ". Exception: " + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return noOfResetBlocks;
|
||||
@ -317,7 +296,6 @@ public class Volume {
|
||||
this.blockDatas = data;
|
||||
}
|
||||
|
||||
|
||||
public void setCornerTwo(Block block) {
|
||||
this.cornerTwo = new BlockInfo(block);
|
||||
}
|
||||
@ -424,22 +402,14 @@ public class Volume {
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
return this.hasTwoCorners() &&
|
||||
location.getWorld().getName().equals(this.world.getName()) &&
|
||||
x <= this.getMaxX() && x >= this.getMinX() &&
|
||||
y <= this.getMaxY() && y >= this.getMinY() &&
|
||||
z <= this.getMaxZ() && z >= this.getMinZ();
|
||||
return this.hasTwoCorners() && location.getWorld().getName().equals(this.world.getName()) && x <= this.getMaxX() && x >= this.getMinX() && y <= this.getMaxY() && y >= this.getMinY() && z <= this.getMaxZ() && z >= this.getMinZ();
|
||||
}
|
||||
|
||||
public boolean contains(Block block) {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
return this.hasTwoCorners() &&
|
||||
block.getWorld().getName().equals(this.world.getName()) &&
|
||||
x <= this.getMaxX() && x >= this.getMinX() &&
|
||||
y <= this.getMaxY() && y >= this.getMinY() &&
|
||||
z <= this.getMaxZ() && z >= this.getMinZ();
|
||||
return this.hasTwoCorners() && block.getWorld().getName().equals(this.world.getName()) && x <= this.getMaxX() && x >= this.getMinX() && y <= this.getMaxY() && y >= this.getMinY() && z <= this.getMaxZ() && z >= this.getMinZ();
|
||||
}
|
||||
|
||||
public void setBlockTypes(int[][][] blockTypes) {
|
||||
@ -486,12 +456,7 @@ public class Volume {
|
||||
for (int j = 0; j < this.getSizeY(); j++) {
|
||||
int z = this.getMinZ();
|
||||
for (int k = 0; k < this.getSizeZ(); k++) {
|
||||
if ((face == BlockFace.DOWN && y == this.getMinY())
|
||||
|| (face == BlockFace.UP && y == this.getMaxY())
|
||||
|| (face == BlockFace.NORTH && x == this.getMinX())
|
||||
|| (face == BlockFace.EAST && z == this.getMinZ())
|
||||
|| (face == BlockFace.SOUTH && x == this.getMaxX())
|
||||
|| (face == BlockFace.WEST && z == this.getMaxZ())) {
|
||||
if ((face == BlockFace.DOWN && y == this.getMinY()) || (face == BlockFace.UP && y == this.getMaxY()) || (face == BlockFace.NORTH && x == this.getMinX()) || (face == BlockFace.EAST && z == this.getMinZ()) || (face == BlockFace.SOUTH && x == this.getMaxX()) || (face == BlockFace.WEST && z == this.getMaxZ())) {
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
currentBlock.setType(material);
|
||||
}
|
||||
|
@ -68,8 +68,7 @@ public class ZoneVolume extends Volume {
|
||||
BlockInfo topBlock = new BlockInfo(block.getX(), 127, block.getZ(), block.getTypeId(), block.getData());
|
||||
BlockInfo oldCornerOne = this.getCornerOne();
|
||||
BlockInfo oldCornerTwo = this.getCornerTwo();
|
||||
if (this.getCornerOne() == null)
|
||||
{
|
||||
if (this.getCornerOne() == null) {
|
||||
if (this.getCornerTwo() == null) {
|
||||
// northwest defaults to corner 1
|
||||
super.setCornerOne(topBlock);
|
||||
@ -127,8 +126,7 @@ public class ZoneVolume extends Volume {
|
||||
BlockInfo bottomBlock = new BlockInfo(block.getX(), 0, block.getZ(), block.getTypeId(), block.getData());
|
||||
BlockInfo oldCornerOne = this.getCornerOne();
|
||||
BlockInfo oldCornerTwo = this.getCornerTwo();
|
||||
if (this.getCornerTwo() == null)
|
||||
{
|
||||
if (this.getCornerTwo() == null) {
|
||||
if (this.getCornerOne() == null) {
|
||||
// southeast defaults to corner 2
|
||||
super.setCornerTwo(bottomBlock);
|
||||
@ -215,18 +213,14 @@ 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))) {
|
||||
if (this.hasTwoCorners() && ((this.getMaxX() - this.getMinX() < 10) || (this.getMaxY() - this.getMinY() < 10) || (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))) {
|
||||
if (this.hasTwoCorners() && ((this.getMaxX() - this.getMinX() > 750) || (this.getMaxY() - this.getMinY() > 750) || (this.getMaxZ() - this.getMinZ() > 750))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -236,14 +230,12 @@ public class ZoneVolume extends Volume {
|
||||
// check team spawns & flags
|
||||
for (Team team : this.zone.getTeams()) {
|
||||
if (team.getTeamSpawn() != null) {
|
||||
if (!this.isInside(team.getSpawnVolume().getCornerOne())
|
||||
|| !this.isInside(team.getSpawnVolume().getCornerTwo())) {
|
||||
if (!this.isInside(team.getSpawnVolume().getCornerOne()) || !this.isInside(team.getSpawnVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (team.getTeamFlag() != null) {
|
||||
if (!this.isInside(team.getFlagVolume().getCornerOne())
|
||||
|| !this.isInside(team.getFlagVolume().getCornerTwo())) {
|
||||
if (!this.isInside(team.getFlagVolume().getCornerOne()) || !this.isInside(team.getFlagVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -251,8 +243,7 @@ public class ZoneVolume extends Volume {
|
||||
// check monuments
|
||||
for (Monument monument : this.zone.getMonuments()) {
|
||||
if (monument.getVolume() != null) {
|
||||
if (!this.isInside(monument.getVolume().getCornerOne())
|
||||
|| !this.isInside(monument.getVolume().getCornerTwo())) {
|
||||
if (!this.isInside(monument.getVolume().getCornerOne()) || !this.isInside(monument.getVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -261,222 +252,63 @@ public class ZoneVolume extends Volume {
|
||||
}
|
||||
|
||||
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()) {
|
||||
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()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWallBlock(Block block) {
|
||||
return this.isEastWallBlock(block) || this.isNorthWallBlock(block)
|
||||
|| this.isSouthWallBlock(block) || this.isWestWallBlock(block)
|
||||
|| this.isUpWallBlock(block) || this.isDownWallBlock(block);
|
||||
return this.isEastWallBlock(block) || this.isNorthWallBlock(block) || this.isSouthWallBlock(block) || this.isWestWallBlock(block) || this.isUpWallBlock(block) || this.isDownWallBlock(block);
|
||||
}
|
||||
|
||||
public boolean isEastWallBlock(Block block) {
|
||||
if (this.getMinZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
if (this.getMinZ() == block.getZ() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX() && block.getY() >= this.getMinY() && block.getY() <= this.getMaxY()) {
|
||||
return true; // east wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSouthWallBlock(Block block) {
|
||||
if (this.getMaxX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
if (this.getMaxX() == block.getX() && block.getZ() <= this.getMaxZ() && block.getZ() >= this.getMinZ() && block.getY() >= this.getMinY() && block.getY() <= this.getMaxY()) {
|
||||
return true; // south wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNorthWallBlock(Block block) {
|
||||
if (this.getMinX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
if (this.getMinX() == block.getX() && block.getZ() <= this.getMaxZ() && block.getZ() >= this.getMinZ() && block.getY() >= this.getMinY() && block.getY() <= this.getMaxY()) {
|
||||
return true; // north wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWestWallBlock(Block block) {
|
||||
if (this.getMaxZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
{
|
||||
if (this.getMaxZ() == block.getZ() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX() && block.getY() >= this.getMinY() && block.getY() <= this.getMaxY()) {
|
||||
return true; // west wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isUpWallBlock(Block block) {
|
||||
if (this.getMaxY() == block.getY()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getZ() <= this.getMaxZ())
|
||||
{
|
||||
if (this.getMaxY() == block.getY() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX() && block.getZ() >= this.getMinZ() && block.getZ() <= this.getMaxZ()) {
|
||||
return true; // top wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDownWallBlock(Block block) {
|
||||
if (this.getMinY() == block.getY()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getZ() <= this.getMaxZ())
|
||||
{
|
||||
if (this.getMinY() == block.getY() && block.getX() <= this.getMaxX() && block.getX() >= this.getMinX() && block.getZ() >= this.getMinZ() && block.getZ() <= this.getMaxZ()) {
|
||||
return true; // bottom wall
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*public int resetWallBlocks(BlockFace wall) {
|
||||
int noOfResetBlocks = 0;
|
||||
try {
|
||||
if (hasTwoCorners() && getBlockTypes() != null) {
|
||||
if (wall == BlockFace.EAST) {
|
||||
int z = getMinZ();
|
||||
int k = 0;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
int z = getMaxZ();
|
||||
int k = getSizeZ()-1;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
} else if (wall == BlockFace.NORTH) {
|
||||
int x = getMinX();
|
||||
int i = 0;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int z = getMinZ();
|
||||
for (int k = 0; k < getSizeZ(); k++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
int x = getMaxX();
|
||||
int i = getSizeX()-1;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int z = getMinZ();
|
||||
for (int k = 0; k < getSizeZ(); k++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
} else if (wall == BlockFace.UP) {
|
||||
int x = getMinX();
|
||||
int y = getMaxY();
|
||||
int j = getSizeY()-1;
|
||||
for (int i = 0;i < getSizeX(); i++) {
|
||||
int z = getMinZ();
|
||||
for (int k = 0; k < getSizeZ(); k++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
} else if (wall == BlockFace.DOWN) {
|
||||
int x = getMinX();
|
||||
int y = getMinY();
|
||||
int j = 0;
|
||||
for (int i = 0;i < getSizeX(); i++) {
|
||||
int z = getMinZ();
|
||||
for (int k = 0; k < getSizeZ(); k++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to reset wall " + wall + " in volume " + getName() + ". " + e.getClass().toString() + " " + e.getMessage());
|
||||
}
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
|
||||
|
||||
private boolean resetBlock(int oldBlockType, byte oldBlockData, Block currentBlock) {
|
||||
if (currentBlock.getTypeId() != oldBlockType ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() == oldBlockData &&
|
||||
(oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId())
|
||||
)
|
||||
) {
|
||||
currentBlock.setTypeId(oldBlockType);
|
||||
currentBlock.setData(oldBlockData);
|
||||
// TODO: reset wall signs, chests and dispensers properly like in resetBlocks
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* public int resetWallBlocks(BlockFace wall) { int noOfResetBlocks = 0; try { if (hasTwoCorners() && getBlockTypes() != null) { if (wall == BlockFace.EAST) { int z = getMinZ(); int k = 0; int y = getMinY(); for (int j = 0; j < getSizeY(); j++) { int x = getMinX(); for (int i = 0; i < getSizeX(); i++) { int oldBlockType = getBlockTypes()[i][j][k]; byte oldBlockData = getBlockDatas()[i][j][k]; Block currentBlock = getWorld().getBlockAt(x, y, z); if (resetBlock(oldBlockType, oldBlockData, currentBlock)) { noOfResetBlocks++; } x++; } y++; } } else if (wall == BlockFace.WEST) { int z = getMaxZ(); int k = getSizeZ()-1; int y = getMinY(); for (int j = 0; j < getSizeY(); j++) { int x = getMinX(); for (int i = 0; i < getSizeX(); i++) { int oldBlockType = getBlockTypes()[i][j][k]; byte oldBlockData = getBlockDatas()[i][j][k]; Block currentBlock = getWorld().getBlockAt(x, y, z); if (resetBlock(oldBlockType, oldBlockData, currentBlock)) { noOfResetBlocks++; } x++; } y++; } } else if (wall == BlockFace.NORTH) { int x = getMinX(); int i = 0; int y = getMinY(); for (int j = 0; j < getSizeY(); j++) { int z = getMinZ(); for (int k = 0; k < getSizeZ(); k++) { int oldBlockType = getBlockTypes()[i][j][k]; byte oldBlockData = getBlockDatas()[i][j][k]; Block currentBlock = getWorld().getBlockAt(x, y, z); if (resetBlock(oldBlockType, oldBlockData, currentBlock)) { noOfResetBlocks++; } z++; } y++; } } else if (wall == BlockFace.SOUTH) { int x = getMaxX(); int i = getSizeX()-1; int y = getMinY(); for (int j = 0; j < getSizeY(); j++) { int z = getMinZ(); for (int k = 0; k < getSizeZ(); k++) { int oldBlockType = getBlockTypes()[i][j][k]; byte oldBlockData = getBlockDatas()[i][j][k]; Block currentBlock = getWorld().getBlockAt(x, y, z); if (resetBlock(oldBlockType, oldBlockData, currentBlock)) { noOfResetBlocks++; } z++; } y++; } } else if (wall == BlockFace.UP) { int x = getMinX(); int y = getMaxY(); int j = getSizeY()-1; for (int i = 0;i < getSizeX(); i++) { int z = getMinZ(); for (int k = 0; k < getSizeZ(); k++) { int oldBlockType = getBlockTypes()[i][j][k]; byte oldBlockData = getBlockDatas()[i][j][k]; Block currentBlock = getWorld().getBlockAt(x, y, z); if (resetBlock(oldBlockType, oldBlockData, currentBlock)) { noOfResetBlocks++; } z++; } x++; } } else if (wall == BlockFace.DOWN) { int x = getMinX(); int y = getMinY(); int j = 0; for (int i = 0;i < getSizeX(); i++) { int z = getMinZ(); for (int k = 0; k < getSizeZ(); k++) { int oldBlockType = getBlockTypes()[i][j][k]; byte oldBlockData = getBlockDatas()[i][j][k]; Block currentBlock = getWorld().getBlockAt(x, y, z); if (resetBlock(oldBlockType, oldBlockData, currentBlock)) { noOfResetBlocks++; } z++; } x++; } } } } catch (Exception e) { this.getWar().logWarn("Failed to reset wall " + wall + " in volume " + getName() + ". " + e.getClass().toString() + " " + e.getMessage()); } return noOfResetBlocks; }
|
||||
*
|
||||
*
|
||||
* private boolean resetBlock(int oldBlockType, byte oldBlockData, Block currentBlock) { if (currentBlock.getTypeId() != oldBlockType || (currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) || (currentBlock.getTypeId() == oldBlockType && currentBlock.getData() == oldBlockData && (oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()) ) ) { currentBlock.setTypeId(oldBlockType); currentBlock.setData(oldBlockData); // TODO: reset wall signs, chests and dispensers properly like in resetBlocks return true; } return false; }
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user