mirror of
https://github.com/taoneill/war.git
synced 2025-01-07 16:27:44 +01:00
Moved War out of Parameter but into a kind of Singleton
This commit is contained in:
parent
57f81479fe
commit
e9193565f3
@ -33,17 +33,17 @@ import com.tommytony.war.utils.*;
|
|||||||
/**
|
/**
|
||||||
* Main class of War
|
* Main class of War
|
||||||
*
|
*
|
||||||
* @author tommytony, Tim Düsterhus
|
* @author tommytony, Tim Düsterhus
|
||||||
* @package bukkit.tommytony.war
|
* @package bukkit.tommytony.war
|
||||||
*/
|
*/
|
||||||
public class War extends JavaPlugin {
|
public class War extends JavaPlugin {
|
||||||
public static PermissionHandler permissionHandler;
|
public static PermissionHandler permissionHandler;
|
||||||
public static War war;
|
public static War war;
|
||||||
|
|
||||||
// general
|
// general
|
||||||
private WarPlayerListener playerListener = new WarPlayerListener(this);
|
private WarPlayerListener playerListener = new WarPlayerListener();
|
||||||
private WarEntityListener entityListener = new WarEntityListener(this);
|
private WarEntityListener entityListener = new WarEntityListener();
|
||||||
private WarBlockListener blockListener = new WarBlockListener(this);
|
private WarBlockListener blockListener = new WarBlockListener();
|
||||||
private Logger log;
|
private Logger log;
|
||||||
private PluginDescriptionFile desc = null;
|
private PluginDescriptionFile desc = null;
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
@ -134,7 +134,7 @@ public class War extends JavaPlugin {
|
|||||||
this.getDefaultLoadout().put(4, new ItemStack(Material.STONE_SPADE, 1, (byte) 8));
|
this.getDefaultLoadout().put(4, new ItemStack(Material.STONE_SPADE, 1, (byte) 8));
|
||||||
this.getDefaultReward().put(0, new ItemStack(Material.CAKE, 1));
|
this.getDefaultReward().put(0, new ItemStack(Material.CAKE, 1));
|
||||||
|
|
||||||
WarMapper.load(this);
|
WarMapper.load();
|
||||||
this.log("War v" + this.desc.getVersion() + " is on.", Level.INFO);
|
this.log("War v" + this.desc.getVersion() + " is on.", Level.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ public class War extends JavaPlugin {
|
|||||||
this.getZoneMakersImpersonatingPlayers().remove(player.getName());
|
this.getZoneMakersImpersonatingPlayers().remove(player.getName());
|
||||||
this.msg(player, "You are back as a zone maker.");
|
this.msg(player, "You are back as a zone maker.");
|
||||||
}
|
}
|
||||||
WarMapper.save(this);
|
WarMapper.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performZonemakerAsZonemaker(Player player, String[] arguments) {
|
public void performZonemakerAsZonemaker(Player player, String[] arguments) {
|
||||||
@ -342,7 +342,7 @@ public class War extends JavaPlugin {
|
|||||||
this.msg(player, "You are now impersonating a regular player. Type /zonemaker again to toggle back to war maker mode.");
|
this.msg(player, "You are now impersonating a regular player. Type /zonemaker again to toggle back to war maker mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
WarMapper.save(this);
|
WarMapper.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ public class War extends JavaPlugin {
|
|||||||
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 {
|
} else {
|
||||||
if (this.updateFromNamedParams(player, arguments)) {
|
if (this.updateFromNamedParams(player, arguments)) {
|
||||||
WarMapper.save(this);
|
WarMapper.save();
|
||||||
this.msg(player, "War config saved.");
|
this.msg(player, "War config saved.");
|
||||||
} else {
|
} else {
|
||||||
this.badMsg(player, "Failed to read named parameters.");
|
this.badMsg(player, "Failed to read named parameters.");
|
||||||
@ -376,7 +376,7 @@ public class War extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
this.badMsg(player, "No War hub to delete.");
|
this.badMsg(player, "No War hub to delete.");
|
||||||
}
|
}
|
||||||
WarMapper.save(this);
|
WarMapper.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performSetWarhub(Player player) {
|
public void performSetWarhub(Player player) {
|
||||||
@ -388,7 +388,7 @@ public class War extends JavaPlugin {
|
|||||||
this.warHub.initialize();
|
this.warHub.initialize();
|
||||||
this.msg(player, "War hub moved.");
|
this.msg(player, "War hub moved.");
|
||||||
} else {
|
} else {
|
||||||
this.warHub = new WarHub(this, player.getLocation());
|
this.warHub = new WarHub(player.getLocation());
|
||||||
this.warHub.initialize();
|
this.warHub.initialize();
|
||||||
for (Warzone zone : this.warzones) {
|
for (Warzone zone : this.warzones) {
|
||||||
if (zone.getLobby() != null) {
|
if (zone.getLobby() != null) {
|
||||||
@ -398,7 +398,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
this.msg(player, "War hub created.");
|
this.msg(player, "War hub created.");
|
||||||
}
|
}
|
||||||
WarMapper.save(this);
|
WarMapper.save();
|
||||||
} else {
|
} else {
|
||||||
this.badMsg(player, "No warzones yet.");
|
this.badMsg(player, "No warzones yet.");
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ public class War extends JavaPlugin {
|
|||||||
if (monument != null) {
|
if (monument != null) {
|
||||||
monument.getVolume().resetBlocks();
|
monument.getVolume().resetBlocks();
|
||||||
warzone.getMonuments().remove(monument);
|
warzone.getMonuments().remove(monument);
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
this.msg(player, "Monument " + monument.getName() + " removed.");
|
this.msg(player, "Monument " + monument.getName() + " removed.");
|
||||||
} else {
|
} else {
|
||||||
this.badMsg(player, "No such monument.");
|
this.badMsg(player, "No such monument.");
|
||||||
@ -442,11 +442,11 @@ public class War extends JavaPlugin {
|
|||||||
this.msg(player, "Monument " + monument.getName() + " was moved.");
|
this.msg(player, "Monument " + monument.getName() + " was moved.");
|
||||||
} else {
|
} else {
|
||||||
// create a new monument
|
// create a new monument
|
||||||
Monument monument = new Monument(arguments[0], this, warzone, player.getLocation());
|
Monument monument = new Monument(arguments[0], warzone, player.getLocation());
|
||||||
warzone.getMonuments().add(monument);
|
warzone.getMonuments().add(monument);
|
||||||
this.msg(player, "Monument " + monument.getName() + " created.");
|
this.msg(player, "Monument " + monument.getName() + " created.");
|
||||||
}
|
}
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ public class War extends JavaPlugin {
|
|||||||
// warzone.addZoneOutline(warzone.getLobby().getWall());
|
// warzone.addZoneOutline(warzone.getLobby().getWall());
|
||||||
warzone.getLobby().initialize();
|
warzone.getLobby().initialize();
|
||||||
}
|
}
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
this.msg(player, "Team " + team.getName() + " removed.");
|
this.msg(player, "Team " + team.getName() + " removed.");
|
||||||
} else {
|
} else {
|
||||||
this.badMsg(player, "No such team.");
|
this.badMsg(player, "No such team.");
|
||||||
@ -499,7 +499,7 @@ public class War extends JavaPlugin {
|
|||||||
Location playerLoc = 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.");
|
this.msg(player, "Team " + team.getName() + " flag added here.");
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
} else {
|
} else {
|
||||||
// relocate flag
|
// relocate flag
|
||||||
team.getFlagVolume().resetBlocks();
|
team.getFlagVolume().resetBlocks();
|
||||||
@ -507,7 +507,7 @@ public class War extends JavaPlugin {
|
|||||||
Location playerLoc = 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.");
|
this.msg(player, "Team " + team.getName() + " flag moved.");
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -525,7 +525,7 @@ public class War extends JavaPlugin {
|
|||||||
this.msg(player, "Team " + existingTeam.getName() + " spawn relocated.");
|
this.msg(player, "Team " + existingTeam.getName() + " spawn relocated.");
|
||||||
} else {
|
} else {
|
||||||
// new team (use default TeamKind name for now)
|
// new team (use default TeamKind name for now)
|
||||||
Team newTeam = new Team(teamKind.getDefaultName(), teamKind, player.getLocation(), this, warzone);
|
Team newTeam = new Team(teamKind.getDefaultName(), teamKind, player.getLocation(), warzone);
|
||||||
newTeam.setRemainingLives(warzone.getLifePool());
|
newTeam.setRemainingLives(warzone.getLifePool());
|
||||||
warzone.getTeams().add(newTeam);
|
warzone.getTeams().add(newTeam);
|
||||||
if (warzone.getLobby() != null) {
|
if (warzone.getLobby() != null) {
|
||||||
@ -538,7 +538,7 @@ public class War extends JavaPlugin {
|
|||||||
this.msg(player, "Team " + newTeam.getName() + " created with spawn here.");
|
this.msg(player, "Team " + newTeam.getName() + " created with spawn here.");
|
||||||
}
|
}
|
||||||
|
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,8 +589,8 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
warzone.getVolume().resetBlocks();
|
warzone.getVolume().resetBlocks();
|
||||||
this.getWarzones().remove(warzone);
|
this.getWarzones().remove(warzone);
|
||||||
WarMapper.save(this);
|
WarMapper.save();
|
||||||
WarzoneMapper.delete(this, warzone.getName());
|
WarzoneMapper.delete(warzone.getName());
|
||||||
if (this.warHub != null) { // warhub has to change
|
if (this.warHub != null) { // warhub has to change
|
||||||
this.warHub.getVolume().resetBlocks();
|
this.warHub.getVolume().resetBlocks();
|
||||||
this.warHub.initialize();
|
this.warHub.initialize();
|
||||||
@ -644,7 +644,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
if (this.updateZoneFromNamedParams(warzone, player, arguments)) {
|
if (this.updateZoneFromNamedParams(warzone, player, arguments)) {
|
||||||
this.msg(player, "Saving config and resetting warzone " + warzone.getName() + ".");
|
this.msg(player, "Saving config and resetting warzone " + warzone.getName() + ".");
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
warzone.getVolume().resetBlocks();
|
warzone.getVolume().resetBlocks();
|
||||||
if (lobby != null) {
|
if (lobby != null) {
|
||||||
lobby.getVolume().resetBlocks();
|
lobby.getVolume().resetBlocks();
|
||||||
@ -678,7 +678,7 @@ public class War extends JavaPlugin {
|
|||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
// changed settings: must reinitialize with new settings
|
// changed settings: must reinitialize with new settings
|
||||||
this.updateZoneFromNamedParams(warzone, player, arguments);
|
this.updateZoneFromNamedParams(warzone, player, arguments);
|
||||||
WarzoneMapper.save(this, warzone, true);
|
WarzoneMapper.save(warzone, true);
|
||||||
warzone.getVolume().resetBlocks();
|
warzone.getVolume().resetBlocks();
|
||||||
if (lobby != null) {
|
if (lobby != null) {
|
||||||
lobby.getVolume().resetBlocks();
|
lobby.getVolume().resetBlocks();
|
||||||
@ -735,7 +735,7 @@ public class War extends JavaPlugin {
|
|||||||
this.msg(player, "Warzone lobby moved to " + wallStr + " side of zone.");
|
this.msg(player, "Warzone lobby moved to " + wallStr + " side of zone.");
|
||||||
} else {
|
} else {
|
||||||
// new lobby
|
// new lobby
|
||||||
lobby = new ZoneLobby(this, warzone, wall);
|
lobby = new ZoneLobby(warzone, wall);
|
||||||
warzone.setLobby(lobby);
|
warzone.setLobby(lobby);
|
||||||
lobby.initialize();
|
lobby.initialize();
|
||||||
if (this.warHub != null) { // warhub has to change
|
if (this.warHub != null) { // warhub has to change
|
||||||
@ -744,7 +744,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
this.msg(player, "Warzone lobby created on " + wallStr + "side of zone.");
|
this.msg(player, "Warzone lobby created on " + wallStr + "side of zone.");
|
||||||
}
|
}
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
} else {
|
} else {
|
||||||
// Not in a warzone: set the lobby position to where the player is standing
|
// Not in a warzone: set the lobby position to where the player is standing
|
||||||
Warzone warzone = this.matchWarzone(arguments[0]);
|
Warzone warzone = this.matchWarzone(arguments[0]);
|
||||||
@ -761,7 +761,7 @@ public class War extends JavaPlugin {
|
|||||||
this.msg(player, "Warzone lobby moved to your location.");
|
this.msg(player, "Warzone lobby moved to your location.");
|
||||||
} else {
|
} else {
|
||||||
// new lobby
|
// new lobby
|
||||||
lobby = new ZoneLobby(this, warzone, player.getLocation());
|
lobby = new ZoneLobby(warzone, player.getLocation());
|
||||||
warzone.setLobby(lobby);
|
warzone.setLobby(lobby);
|
||||||
lobby.initialize();
|
lobby.initialize();
|
||||||
if (this.warHub != null) { // warhub has to change
|
if (this.warHub != null) { // warhub has to change
|
||||||
@ -770,7 +770,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
this.msg(player, "Warzone lobby moved to your location.");
|
this.msg(player, "Warzone lobby moved to your location.");
|
||||||
}
|
}
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -784,7 +784,7 @@ public class War extends JavaPlugin {
|
|||||||
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 {
|
} else {
|
||||||
ZoneSetter setter = new ZoneSetter(this, player, arguments[0]);
|
ZoneSetter setter = new ZoneSetter(player, arguments[0]);
|
||||||
if (arguments[1].equals("northwest") || arguments[1].equals("nw")) {
|
if (arguments[1].equals("northwest") || arguments[1].equals("nw")) {
|
||||||
setter.placeNorthwest();
|
setter.placeNorthwest();
|
||||||
} else if (arguments[1].equals("southeast") || arguments[1].equals("se")) {
|
} else if (arguments[1].equals("southeast") || arguments[1].equals("se")) {
|
||||||
@ -1155,7 +1155,7 @@ public class War extends JavaPlugin {
|
|||||||
this.badMsg(player, "Can't set rally point. No such warzone.");
|
this.badMsg(player, "Can't set rally point. No such warzone.");
|
||||||
} else {
|
} else {
|
||||||
zone.setRallyPoint(player.getLocation());
|
zone.setRallyPoint(player.getLocation());
|
||||||
WarzoneMapper.save(this, zone, false);
|
WarzoneMapper.save(zone, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,26 +18,20 @@ import com.tommytony.war.Team;
|
|||||||
import com.tommytony.war.Warzone;
|
import com.tommytony.war.Warzone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WarBlockListener extends BlockListener {
|
public class WarBlockListener extends BlockListener {
|
||||||
|
|
||||||
private War war;
|
|
||||||
|
|
||||||
public WarBlockListener(War war) {
|
|
||||||
this.war = war;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (player != null && block != null) {
|
if (player != null && block != null) {
|
||||||
Team team = this.war.getPlayerTeam(player.getName());
|
Team team = War.war.getPlayerTeam(player.getName());
|
||||||
Warzone zone = this.war.warzone(player.getLocation());
|
Warzone zone = War.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);
|
Monument monument = zone.getMonumentFromCenterBlock(block);
|
||||||
if (monument != null && !monument.hasOwner()) {
|
if (monument != null && !monument.hasOwner()) {
|
||||||
@ -49,49 +43,49 @@ public class WarBlockListener extends BlockListener {
|
|||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
return; // important otherwise cancelled down a few line by isImportantblock
|
return; // important otherwise cancelled down a few line by isImportantblock
|
||||||
} else {
|
} else {
|
||||||
this.war.badMsg(player, "You can't capture a monument without a block of your team's material. Get one from your team spawn.");
|
War.war.badMsg(player, "You can't capture a monument without a block of your team's material. Get one from your team spawn.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean isZoneMaker = this.war.isZoneMaker(player);
|
boolean isZoneMaker = War.war.isZoneMaker(player);
|
||||||
if (zone != null && zone.isImportantBlock(block) && (!isZoneMaker || (isZoneMaker && team != null))) {
|
if (zone != null && zone.isImportantBlock(block) && (!isZoneMaker || (isZoneMaker && team != null))) {
|
||||||
this.war.badMsg(player, "Can't build here.");
|
War.war.badMsg(player, "Can't build here.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// protect warzone lobbies
|
// protect warzone lobbies
|
||||||
for (Warzone wz : this.war.getWarzones()) {
|
for (Warzone wz : War.war.getWarzones()) {
|
||||||
if (wz.getLobby() != null && wz.getLobby().getVolume() != null && wz.getLobby().getVolume().contains(block)) {
|
if (wz.getLobby() != null && wz.getLobby().getVolume() != null && wz.getLobby().getVolume().contains(block)) {
|
||||||
this.war.badMsg(player, "Can't build here.");
|
War.war.badMsg(player, "Can't build here.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// protect the hub
|
// protect the hub
|
||||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(block)) {
|
if (War.war.getWarHub() != null && War.war.getWarHub().getVolume().contains(block)) {
|
||||||
this.war.badMsg(player, "Can't build here.");
|
War.war.badMsg(player, "Can't build here.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildInZonesOnly
|
// buildInZonesOnly
|
||||||
if (zone == null && this.war.isBuildInZonesOnly() && !this.war.canBuildOutsideZone(player)) {
|
if (zone == null && War.war.isBuildInZonesOnly() && !War.war.canBuildOutsideZone(player)) {
|
||||||
this.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't place a block of your team's color
|
// 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.");
|
War.war.badMsg(player, "You can only use your team's blocks to capture monuments.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (team != null && zone != null && zone.isFlagThief(player.getName())) {
|
if (team != null && zone != null && zone.isFlagThief(player.getName())) {
|
||||||
// a flag thief can't drop his flag
|
// a flag thief can't drop his flag
|
||||||
this.war.badMsg(player, "Can't drop the flag. What are you doing? Run!");
|
War.war.badMsg(player, "Can't drop the flag. What are you doing? Run!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -99,7 +93,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
// unbreakableZoneBlocks
|
// 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)
|
// 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!");
|
War.war.badMsg(player, "The blocks in this zone are unbreakable - this also means you can't build!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +103,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (player != null && block != null) {
|
if (player != null && block != null) {
|
||||||
@ -119,13 +113,13 @@ public class WarBlockListener extends BlockListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleBreakOrDamage(Player player, Block block, Cancellable event) {
|
private void handleBreakOrDamage(Player player, Block block, Cancellable event) {
|
||||||
Warzone warzone = this.war.warzone(player.getLocation());
|
Warzone warzone = War.war.warzone(player.getLocation());
|
||||||
Team team = this.war.getPlayerTeam(player.getName());
|
Team team = War.war.getPlayerTeam(player.getName());
|
||||||
boolean isZoneMaker = this.war.isZoneMaker(player);
|
boolean isZoneMaker = War.war.isZoneMaker(player);
|
||||||
|
|
||||||
if (warzone != null && team == null && !isZoneMaker) {
|
if (warzone != null && team == null && !isZoneMaker) {
|
||||||
// can't actually destroy blocks in a warzone if not part of a team
|
// can't actually destroy blocks in a warzone if not part of a team
|
||||||
this.war.badMsg(player, "Can't destroy part of a warzone if you're not in a team.");
|
War.war.badMsg(player, "Can't destroy part of a warzone if you're not in a team.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
} else if (team != null && block != null && warzone != null && warzone.isMonumentCenterBlock(block)) {
|
} else if (team != null && block != null && warzone != null && warzone.isMonumentCenterBlock(block)) {
|
||||||
@ -145,7 +139,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
if (team != null && team.getSpawnVolume().contains(block)) {
|
if (team != null && team.getSpawnVolume().contains(block)) {
|
||||||
ItemStack teamKindBlock = new ItemStack(team.getKind().getMaterial(), team.getKind().getData());
|
ItemStack teamKindBlock = new ItemStack(team.getKind().getMaterial(), team.getKind().getData());
|
||||||
if (player.getInventory().contains(teamKindBlock)) {
|
if (player.getInventory().contains(teamKindBlock)) {
|
||||||
this.war.badMsg(player, "You already have a " + team.getName() + " block.");
|
War.war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -156,7 +150,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
} else if (team != null && warzone.isEnemyTeamFlagBlock(team, block)) {
|
} else if (team != null && warzone.isEnemyTeamFlagBlock(team, block)) {
|
||||||
if (warzone.isFlagThief(player.getName())) {
|
if (warzone.isFlagThief(player.getName())) {
|
||||||
// detect audacious thieves
|
// detect audacious thieves
|
||||||
this.war.badMsg(player, "You can only steal one flag at a time!");
|
War.war.badMsg(player, "You can only steal one flag at a time!");
|
||||||
} else {
|
} else {
|
||||||
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
|
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
|
||||||
if (lostFlagTeam.getPlayers().size() != 0) {
|
if (lostFlagTeam.getPlayers().size() != 0) {
|
||||||
@ -174,15 +168,15 @@ public class WarBlockListener extends BlockListener {
|
|||||||
+ " from reaching team " + team.getName() + "'s spawn or flag.");
|
+ " from reaching team " + team.getName() + "'s spawn or flag.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
|
War.war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
|
||||||
} else {
|
} else {
|
||||||
this.war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since no players are on that team.");
|
War.war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since no players are on that team.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
} else if (!warzone.isMonumentCenterBlock(block)) {
|
} else if (!warzone.isMonumentCenterBlock(block)) {
|
||||||
this.war.badMsg(player, "Can't destroy this.");
|
War.war.badMsg(player, "Can't destroy this.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -190,9 +184,9 @@ public class WarBlockListener extends BlockListener {
|
|||||||
|
|
||||||
// protect warzone lobbies
|
// protect warzone lobbies
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
for (Warzone zone : this.war.getWarzones()) {
|
for (Warzone zone : War.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.");
|
War.war.badMsg(player, "Can't destroy this.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -200,16 +194,16 @@ public class WarBlockListener extends BlockListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// protect the hub
|
// protect the hub
|
||||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(block)) {
|
if (War.war.getWarHub() != null && War.war.getWarHub().getVolume().contains(block)) {
|
||||||
this.war.badMsg(player, "Can't destroy this.");
|
War.war.badMsg(player, "Can't destroy this.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildInZonesOnly
|
// buildInZonesOnly
|
||||||
Warzone blockZone = this.war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
|
Warzone blockZone = War.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 && War.war.isBuildInZonesOnly() && !War.war.canBuildOutsideZone(player)) {
|
||||||
this.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -217,7 +211,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
// unbreakableZoneBlocks
|
// 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
|
// 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!");
|
War.war.badMsg(player, "The blocks in this zone are unbreakable!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import org.bukkit.event.entity.EntityCombustEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
import org.bukkit.event.entity.EntityListener;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
@ -32,17 +31,6 @@ import com.tommytony.war.Warzone;
|
|||||||
*/
|
*/
|
||||||
public class WarEntityListener extends EntityListener {
|
public class WarEntityListener extends EntityListener {
|
||||||
|
|
||||||
/**
|
|
||||||
* Instance of war
|
|
||||||
*
|
|
||||||
* @var War
|
|
||||||
*/
|
|
||||||
private final War war;
|
|
||||||
|
|
||||||
public WarEntityListener(War war) {
|
|
||||||
this.war = war;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles PVP-Damage
|
* Handles PVP-Damage
|
||||||
*
|
*
|
||||||
@ -56,21 +44,21 @@ public class WarEntityListener extends EntityListener {
|
|||||||
// only let adversaries (same warzone, different team) attack each other
|
// only let adversaries (same warzone, different team) attack each other
|
||||||
Player a = (Player) attacker;
|
Player a = (Player) attacker;
|
||||||
Player d = (Player) defender;
|
Player d = (Player) defender;
|
||||||
Warzone attackerWarzone = this.war.getPlayerTeamWarzone(a.getName());
|
Warzone attackerWarzone = War.war.getPlayerTeamWarzone(a.getName());
|
||||||
Team attackerTeam = this.war.getPlayerTeam(a.getName());
|
Team attackerTeam = War.war.getPlayerTeam(a.getName());
|
||||||
Warzone defenderWarzone = this.war.getPlayerTeamWarzone(d.getName());
|
Warzone defenderWarzone = War.war.getPlayerTeamWarzone(d.getName());
|
||||||
Team defenderTeam = this.war.getPlayerTeam(d.getName());
|
Team defenderTeam = War.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
|
// Make sure one of the players isn't in the spawn
|
||||||
if (defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
|
if (defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
|
||||||
if (!defenderWarzone.isFlagThief(d.getName())) { // thiefs can always be attacked
|
if (!defenderWarzone.isFlagThief(d.getName())) { // thiefs can always be attacked
|
||||||
this.war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
|
War.war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (attackerTeam.getSpawnVolume().contains(a.getLocation()) && !attackerTeam.getSpawnVolume().contains(d.getLocation())) {
|
} else if (attackerTeam.getSpawnVolume().contains(a.getLocation()) && !attackerTeam.getSpawnVolume().contains(d.getLocation())) {
|
||||||
// only let a player inside spawn attack an enemy player if that player enters the spawn
|
// only let a player inside spawn attack an enemy player if that player enters the spawn
|
||||||
if (!attackerWarzone.isFlagThief(a.getName())) { // thiefs can always attack
|
if (!attackerWarzone.isFlagThief(a.getName())) { // thiefs can always attack
|
||||||
this.war.badMsg(a, "Can't attack a player from inside your spawn.");
|
War.war.badMsg(a, "Can't attack a player from inside your spawn.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,30 +77,30 @@ public class WarEntityListener extends EntityListener {
|
|||||||
} 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
|
// same team, but not same person
|
||||||
if (attackerWarzone.getFriendlyFire()) {
|
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
|
War.war.badMsg(a, "Friendly fire is on! Please, don't hurt your teammates."); // if ff is on, let the attack go through
|
||||||
} else {
|
} else {
|
||||||
this.war.badMsg(a, "Your attack missed! Your target is on your team.");
|
War.war.badMsg(a, "Your attack missed! Your target is on your team.");
|
||||||
event.setCancelled(true); // ff is off
|
event.setCancelled(true); // ff is off
|
||||||
}
|
}
|
||||||
} else if (attackerTeam == null && defenderTeam == null && this.war.canPvpOutsideZones(a)) {
|
} else if (attackerTeam == null && defenderTeam == null && War.war.canPvpOutsideZones(a)) {
|
||||||
// let normal PVP through is its not turned off or if you have perms
|
// let normal PVP through is its not turned off or if you have perms
|
||||||
} else if (attackerTeam == null && defenderTeam == null && !this.war.canPvpOutsideZones(a)) {
|
} else if (attackerTeam == null && defenderTeam == null && !War.war.canPvpOutsideZones(a)) {
|
||||||
if (!this.war.isDisablePvpMessage()) {
|
if (!War.war.isDisablePvpMessage()) {
|
||||||
this.war.badMsg(a, "You need the 'war.pvp' permission to attack players outside warzones.");
|
War.war.badMsg(a, "You need the 'war.pvp' permission to attack players outside warzones.");
|
||||||
}
|
}
|
||||||
event.setCancelled(true); // global pvp is off
|
event.setCancelled(true); // global pvp is off
|
||||||
} else {
|
} else {
|
||||||
this.war.badMsg(a, "Your attack missed!");
|
War.war.badMsg(a, "Your attack missed!");
|
||||||
if (attackerTeam == null) {
|
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.");
|
War.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) {
|
} else if (defenderTeam == null) {
|
||||||
this.war.badMsg(a, "Your target is not in a team.");
|
War.war.badMsg(a, "Your target is not in a team.");
|
||||||
} else if (attacker != null && defender != null && attacker.getEntityId() == defender.getEntityId()) {
|
} else if (attacker != null && defender != null && attacker.getEntityId() == defender.getEntityId()) {
|
||||||
// You just hit yourself, probably with a bouncing arrow
|
// You just hit yourself, probably with a bouncing arrow
|
||||||
} else if (attackerTeam == defenderTeam) {
|
} else if (attackerTeam == defenderTeam) {
|
||||||
this.war.badMsg(a, "Your target is on your team.");
|
War.war.badMsg(a, "Your target is on your team.");
|
||||||
} else if (attackerWarzone != defenderWarzone) {
|
} else if (attackerWarzone != defenderWarzone) {
|
||||||
this.war.badMsg(a, "Your target is playing in another warzone.");
|
War.war.badMsg(a, "Your target is playing in another warzone.");
|
||||||
}
|
}
|
||||||
event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
|
event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
|
||||||
}
|
}
|
||||||
@ -121,15 +109,15 @@ public class WarEntityListener extends EntityListener {
|
|||||||
// attacked by dispenser arrow most probably
|
// attacked by dispenser arrow most probably
|
||||||
// Detect death, prevent it and respawn the player
|
// Detect death, prevent it and respawn the player
|
||||||
Player d = (Player) defender;
|
Player d = (Player) defender;
|
||||||
Warzone defenderWarzone = this.war.getPlayerTeamWarzone(d.getName());
|
Warzone defenderWarzone = War.war.getPlayerTeamWarzone(d.getName());
|
||||||
if (d != null && defenderWarzone != null && event.getDamage() >= d.getHealth()) {
|
if (d != null && defenderWarzone != null && event.getDamage() >= d.getHealth()) {
|
||||||
String deathMessage = "";
|
String deathMessage = "";
|
||||||
if (event instanceof EntityDamageByProjectileEvent)
|
if (event instanceof EntityDamageByProjectileEvent)
|
||||||
deathMessage = "A dispenser killed " + this.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName();
|
deathMessage = "A dispenser killed " + War.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName();
|
||||||
else if (event.getDamager() instanceof CraftTNTPrimed)
|
else if (event.getDamager() instanceof CraftTNTPrimed)
|
||||||
deathMessage = this.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " exploded";
|
deathMessage = War.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " exploded";
|
||||||
else
|
else
|
||||||
deathMessage = this.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " died";
|
deathMessage = War.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " died";
|
||||||
for (Team team : defenderWarzone.getTeams()) {
|
for (Team team : defenderWarzone.getTeams()) {
|
||||||
team.teamcast(deathMessage);
|
team.teamcast(deathMessage);
|
||||||
}
|
}
|
||||||
@ -144,23 +132,23 @@ public class WarEntityListener extends EntityListener {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
// protect zones elements, lobbies and warhub from creepers
|
// protect zones elements, lobbies and warhub from creepers
|
||||||
List<Block> explodedBlocks = event.blockList();
|
List<Block> explodedBlocks = event.blockList();
|
||||||
for (Block block : explodedBlocks) {
|
for (Block block : explodedBlocks) {
|
||||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(block)) {
|
if (War.war.getWarHub() != null && War.war.getWarHub().getVolume().contains(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
this.war.log("Explosion prevented at warhub.", Level.INFO);
|
War.war.log("Explosion prevented at warhub.", Level.INFO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Warzone zone : this.war.getWarzones()) {
|
for (Warzone zone : War.war.getWarzones()) {
|
||||||
if (zone.isImportantBlock(block)) {
|
if (zone.isImportantBlock(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
this.war.log("Explosion prevented in zone " + zone.getName() + ".", Level.INFO);
|
War.war.log("Explosion prevented in zone " + zone.getName() + ".", Level.INFO);
|
||||||
return;
|
return;
|
||||||
} else if (zone.getLobby() != null && zone.getLobby().getVolume().contains(block)) {
|
} else if (zone.getLobby() != null && zone.getLobby().getVolume().contains(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
this.war.log("Explosion prevented at zone " + zone.getName() + " lobby.", Level.INFO);
|
War.war.log("Explosion prevented at zone " + zone.getName() + " lobby.", Level.INFO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,10 +161,10 @@ public class WarEntityListener extends EntityListener {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
// prevent godmode
|
// prevent godmode
|
||||||
if (entity instanceof Player && this.war.getPlayerTeamWarzone(((Player) entity).getName()) != null) {
|
if (entity instanceof Player && War.war.getPlayerTeamWarzone(((Player) entity).getName()) != null) {
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,10 +175,10 @@ public class WarEntityListener extends EntityListener {
|
|||||||
// Detect death, prevent it and respawn the player
|
// Detect death, prevent it and respawn the player
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||||
if (zone != null && event.getDamage() >= player.getHealth()) {
|
if (zone != null && event.getDamage() >= player.getHealth()) {
|
||||||
String deathMessage = "";
|
String deathMessage = "";
|
||||||
deathMessage = this.war.getPlayerTeam(player.getName()).getKind().getColor() + player.getDisplayName() + ChatColor.WHITE + " died";
|
deathMessage = War.war.getPlayerTeam(player.getName()).getKind().getColor() + player.getDisplayName() + ChatColor.WHITE + " died";
|
||||||
for (Team team : zone.getTeams()) {
|
for (Team team : zone.getTeams()) {
|
||||||
team.teamcast(deathMessage);
|
team.teamcast(deathMessage);
|
||||||
}
|
}
|
||||||
@ -204,11 +192,11 @@ public class WarEntityListener extends EntityListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCombust(EntityCombustEvent event) {
|
public void onEntityCombust(EntityCombustEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
Team team = this.war.getPlayerTeam(player.getName());
|
Team team = War.war.getPlayerTeam(player.getName());
|
||||||
if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
|
if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
|
||||||
// smother out the fire that didn't burn out when you respawned
|
// smother out the fire that didn't burn out when you respawned
|
||||||
// Stop fire (upcast, watch out!)
|
// Stop fire (upcast, watch out!)
|
||||||
@ -227,9 +215,9 @@ public class WarEntityListener extends EntityListener {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Location location = event.getLocation();
|
Location location = event.getLocation();
|
||||||
Warzone zone = this.war.warzone(location);
|
Warzone zone = War.war.warzone(location);
|
||||||
if (zone != null && zone.isNoCreatures()) {
|
if (zone != null && zone.isNoCreatures()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
// war.logInfo("Prevented " + event.getMobType().getName() + " from spawning in zone " + zone.getName());
|
// war.logInfo("Prevented " + event.getMobType().getName() + " from spawning in zone " + zone.getName());
|
||||||
@ -242,12 +230,12 @@ public class WarEntityListener extends EntityListener {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||||
if (this.war.isLoaded() && event.getRegainReason() == RegainReason.REGEN) {
|
if (War.war.isLoaded() && event.getRegainReason() == RegainReason.REGEN) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
Warzone zone = this.war.warzone(location);
|
Warzone zone = War.war.warzone(location);
|
||||||
if (zone != null) {
|
if (zone != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package bukkit.tommytony.war;
|
package bukkit.tommytony.war;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -30,48 +28,41 @@ import com.tommytony.war.ZoneLobby;
|
|||||||
import com.tommytony.war.ZoneSetter;
|
import com.tommytony.war.ZoneSetter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author tommytony, Tim Düsterhus
|
||||||
* @author tommytony
|
* @package bukkit.tommytony.war
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WarPlayerListener extends PlayerListener {
|
public class WarPlayerListener extends PlayerListener {
|
||||||
|
|
||||||
private final War war;
|
private java.util.Random random = new java.util.Random();
|
||||||
private Random random = null;
|
|
||||||
|
|
||||||
public WarPlayerListener(War war) {
|
|
||||||
this.war = war;
|
|
||||||
this.random = new Random();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Team team = this.war.getPlayerTeam(player.getName());
|
Team team = War.war.getPlayerTeam(player.getName());
|
||||||
if (team != null) {
|
if (team != null) {
|
||||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||||
if (zone != null) {
|
if (zone != null) {
|
||||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.war.isWandBearer(player)) {
|
if (War.war.isWandBearer(player)) {
|
||||||
this.war.removeWandBearer(player);
|
War.war.removeWandBearer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Team team = this.war.getPlayerTeam(player.getName());
|
Team team = War.war.getPlayerTeam(player.getName());
|
||||||
if (team != null) {
|
if (team != null) {
|
||||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||||
|
|
||||||
if (zone.isFlagThief(player.getName())) {
|
if (zone.isFlagThief(player.getName())) {
|
||||||
// a flag thief can't drop his flag
|
// a flag thief can't drop his flag
|
||||||
this.war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
|
War.war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -80,25 +71,25 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
ItemStack itemStack = item.getItemStack();
|
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
|
// Can't drop your team's kind block
|
||||||
this.war.badMsg(player, "Can't drop " + team.getName() + " block blocks.");
|
War.war.badMsg(player, "Can't drop " + team.getName() + " block blocks.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zone.isNearWall(player.getLocation()) && itemStack != null) {
|
if (zone.isNearWall(player.getLocation()) && itemStack != null) {
|
||||||
this.war.badMsg(player, "Can't drop items near the zone border!");
|
War.war.badMsg(player, "Can't drop items near the zone border!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.war.isWandBearer(player)) {
|
if (War.war.isWandBearer(player)) {
|
||||||
Item item = event.getItemDrop();
|
Item item = event.getItemDrop();
|
||||||
if (item.getItemStack().getType() == Material.WOOD_SWORD) {
|
if (item.getItemStack().getType() == Material.WOOD_SWORD) {
|
||||||
String zoneName = this.war.getWandBearerZone(player);
|
String zoneName = War.war.getWandBearerZone(player);
|
||||||
this.war.removeWandBearer(player);
|
War.war.removeWandBearer(player);
|
||||||
this.war.msg(player, "You dropped the zone " + zoneName + " wand.");
|
War.war.msg(player, "You dropped the zone " + zoneName + " wand.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,11 +97,11 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Team team = this.war.getPlayerTeam(player.getName());
|
Team team = War.war.getPlayerTeam(player.getName());
|
||||||
if (team != null) {
|
if (team != null) {
|
||||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||||
|
|
||||||
if (zone.isFlagThief(player.getName())) {
|
if (zone.isFlagThief(player.getName())) {
|
||||||
// a flag thief can't pick up anything
|
// a flag thief can't pick up anything
|
||||||
@ -136,10 +127,10 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInventoryOpen(PlayerInventoryEvent event) {
|
public void onInventoryOpen(PlayerInventoryEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Inventory inventory = event.getInventory();
|
Inventory inventory = event.getInventory();
|
||||||
Team team = this.war.getPlayerTeam(player.getName());
|
Team team = War.war.getPlayerTeam(player.getName());
|
||||||
if (team != null && inventory instanceof PlayerInventory) {
|
if (team != null && inventory instanceof PlayerInventory) {
|
||||||
// make sure the player doesn't have too many precious blocks
|
// make sure the player doesn't have too many precious blocks
|
||||||
// or illegal armor (i.e. armor not found in loadout)
|
// or illegal armor (i.e. armor not found in loadout)
|
||||||
@ -148,7 +139,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
if (playerInv.contains(teamKindBlock, 2)) {
|
if (playerInv.contains(teamKindBlock, 2)) {
|
||||||
playerInv.remove(teamKindBlock);
|
playerInv.remove(teamKindBlock);
|
||||||
playerInv.addItem(teamKindBlock);
|
playerInv.addItem(teamKindBlock);
|
||||||
this.war.badMsg(player, "All that " + team.getName() + " must have been heavy!");
|
War.war.badMsg(player, "All that " + team.getName() + " must have been heavy!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,21 +147,21 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Team talkingPlayerTeam = this.war.getPlayerTeam(player.getName());
|
Team talkingPlayerTeam = War.war.getPlayerTeam(player.getName());
|
||||||
if (talkingPlayerTeam != null) {
|
if (talkingPlayerTeam != null) {
|
||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
String[] split = msg.split(" ");
|
String[] split = msg.split(" ");
|
||||||
if (!this.war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) {
|
if (!War.war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) {
|
||||||
String command = split[0].substring(1);
|
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")) {
|
||||||
for (String whiteCommand : this.war.getCommandWhitelist()) {
|
for (String whiteCommand : War.war.getCommandWhitelist()) {
|
||||||
if (whiteCommand.equals(command)) {
|
if (whiteCommand.equals(command)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.war.badMsg(player, "Can't use anything but War commands (e.g. /leave, /warhub) while you're playing in a warzone.");
|
War.war.badMsg(player, "Can't use anything but War commands (e.g. /leave, /warhub) while you're playing in a warzone.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,19 +171,19 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String reason = event.getReason();
|
String reason = event.getReason();
|
||||||
if (reason.contains("moved") || reason.contains("too quickly") || reason.contains("Hacking")) {
|
if (reason.contains("moved") || reason.contains("too quickly") || reason.contains("Hacking")) {
|
||||||
boolean inWarzone = this.war.inAnyWarzone(player.getLocation());
|
boolean inWarzone = War.war.inAnyWarzone(player.getLocation());
|
||||||
boolean inLobby = this.war.inAnyWarzone(player.getLocation());
|
boolean inLobby = War.war.inAnyWarzone(player.getLocation());
|
||||||
boolean inWarhub = false;
|
boolean inWarhub = false;
|
||||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(player.getLocation())) {
|
if (War.war.getWarHub() != null && War.war.getWarHub().getVolume().contains(player.getLocation())) {
|
||||||
inWarhub = true;
|
inWarhub = true;
|
||||||
}
|
}
|
||||||
if (inWarzone || inLobby || inWarhub) {
|
if (inWarzone || inLobby || inWarhub) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
this.war.log("Prevented " + player.getName() + " from getting kicked.", java.util.logging.Level.WARNING);
|
War.war.log("Prevented " + player.getName() + " from getting kicked.", java.util.logging.Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,13 +191,13 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.getItemInHand().getType() == Material.WOOD_SWORD && this.war.isWandBearer(player)) {
|
if (player.getItemInHand().getType() == Material.WOOD_SWORD && War.war.isWandBearer(player)) {
|
||||||
String zoneName = this.war.getWandBearerZone(player);
|
String zoneName = War.war.getWandBearerZone(player);
|
||||||
ZoneSetter setter = new ZoneSetter(this.war, player, zoneName);
|
ZoneSetter setter = new ZoneSetter(player, zoneName);
|
||||||
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
|
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||||
this.war.badMsg(player, "Too far.");
|
War.war.badMsg(player, "Too far.");
|
||||||
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
setter.placeCorner1(event.getClickedBlock());
|
setter.placeCorner1(event.getClickedBlock());
|
||||||
event.setUseItemInHand(Result.ALLOW);
|
event.setUseItemInHand(Result.ALLOW);
|
||||||
@ -220,25 +211,25 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (this.war.isLoaded()) {
|
if (War.war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location playerLoc = event.getFrom(); // same as player.getLoc. Don't call again we need same result.
|
Location playerLoc = event.getFrom(); // same as player.getLoc. Don't call again we need same result.
|
||||||
Warzone locZone = null;
|
Warzone locZone = null;
|
||||||
ZoneLobby locLobby = null;
|
ZoneLobby locLobby = null;
|
||||||
locZone = this.war.warzone(playerLoc);
|
locZone = War.war.warzone(playerLoc);
|
||||||
locLobby = this.war.lobby(playerLoc);
|
locLobby = War.war.lobby(playerLoc);
|
||||||
boolean canPlay = this.war.canPlayWar(player);
|
boolean canPlay = War.war.canPlayWar(player);
|
||||||
boolean isMaker = this.war.isZoneMaker(player);
|
boolean isMaker = War.war.isZoneMaker(player);
|
||||||
|
|
||||||
// Zone walls
|
// Zone walls
|
||||||
Team currentTeam = this.war.getPlayerTeam(player.getName());
|
Team currentTeam = War.war.getPlayerTeam(player.getName());
|
||||||
Warzone playerWarzone = this.war.getPlayerTeamWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
Warzone playerWarzone = War.war.getPlayerTeamWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
||||||
boolean protecting = false;
|
boolean protecting = false;
|
||||||
if (currentTeam != null) {
|
if (currentTeam != null) {
|
||||||
// Warzone nearbyZone = war.zoneOfZoneWallAtProximity(playerLoc);
|
// Warzone nearbyZone = war.zoneOfZoneWallAtProximity(playerLoc);
|
||||||
protecting = playerWarzone.protectZoneWallAgainstPlayer(player);
|
protecting = playerWarzone.protectZoneWallAgainstPlayer(player);
|
||||||
} else {
|
} else {
|
||||||
Warzone nearbyZone = this.war.zoneOfZoneWallAtProximity(playerLoc);
|
Warzone nearbyZone = War.war.zoneOfZoneWallAtProximity(playerLoc);
|
||||||
if (nearbyZone != null && !isMaker) {
|
if (nearbyZone != null && !isMaker) {
|
||||||
protecting = nearbyZone.protectZoneWallAgainstPlayer(player);
|
protecting = nearbyZone.protectZoneWallAgainstPlayer(player);
|
||||||
}
|
}
|
||||||
@ -247,7 +238,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
if (!protecting) {
|
if (!protecting) {
|
||||||
// zone makers still need to delete their walls
|
// zone makers still need to delete their walls
|
||||||
// make sure to delete any wall guards as you leave
|
// make sure to delete any wall guards as you leave
|
||||||
for (Warzone zone : this.war.getWarzones()) {
|
for (Warzone zone : War.war.getWarzones()) {
|
||||||
zone.dropZoneWallGuardIfAny(player);
|
zone.dropZoneWallGuardIfAny(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,7 +246,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
// Warzone lobby gates
|
// Warzone lobby gates
|
||||||
if (locLobby != null) {
|
if (locLobby != null) {
|
||||||
Warzone zone = locLobby.getZone();
|
Warzone zone = locLobby.getZone();
|
||||||
Team oldTeam = this.war.getPlayerTeam(player.getName());
|
Team oldTeam = War.war.getPlayerTeam(player.getName());
|
||||||
boolean isAutoAssignGate = false;
|
boolean isAutoAssignGate = false;
|
||||||
if (oldTeam == null && canPlay) { // trying to counter spammy player move
|
if (oldTeam == null && canPlay) { // trying to counter spammy player move
|
||||||
isAutoAssignGate = zone.getLobby().isAutoAssignGate(playerLoc);
|
isAutoAssignGate = zone.getLobby().isAutoAssignGate(playerLoc);
|
||||||
@ -271,13 +262,13 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
if (noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
if (noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
||||||
zone.autoAssign(player);
|
zone.autoAssign(player);
|
||||||
|
|
||||||
if (this.war.getWarHub() != null) {
|
if (War.war.getWarHub() != null) {
|
||||||
this.war.getWarHub().resetZoneSign(zone);
|
War.war.getWarHub().resetZoneSign(zone);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
// player.teleport(zone.getTeleport());
|
// player.teleport(zone.getTeleport());
|
||||||
this.war.badMsg(player, "All teams are full.");
|
War.war.badMsg(player, "All teams are full.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -292,28 +283,28 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
} else if (team.getPlayers().size() < zone.getTeamCap()) {
|
} else if (team.getPlayers().size() < zone.getTeamCap()) {
|
||||||
team.addPlayer(player);
|
team.addPlayer(player);
|
||||||
team.resetSign();
|
team.resetSign();
|
||||||
if (this.war.getWarHub() != null) {
|
if (War.war.getWarHub() != null) {
|
||||||
this.war.getWarHub().resetZoneSign(zone);
|
War.war.getWarHub().resetZoneSign(zone);
|
||||||
}
|
}
|
||||||
zone.keepPlayerInventory(player);
|
zone.keepPlayerInventory(player);
|
||||||
this.war.msg(player, "Your inventory is in storage until you /leave.");
|
War.war.msg(player, "Your inventory is in storage until you /leave.");
|
||||||
zone.respawnPlayer(event, team, player);
|
zone.respawnPlayer(event, team, player);
|
||||||
for (Team t : zone.getTeams()) {
|
for (Team t : zone.getTeams()) {
|
||||||
t.teamcast("" + player.getName() + " joined team " + team.getName() + ".");
|
t.teamcast("" + player.getName() + " joined team " + team.getName() + ".");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
this.war.badMsg(player, "Team " + team.getName() + " is full.");
|
War.war.badMsg(player, "Team " + team.getName() + " is full.");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc) && !this.war.getWarHub().getVolume().contains(player.getLocation())) {
|
if (War.war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc) && !War.war.getWarHub().getVolume().contains(player.getLocation())) {
|
||||||
this.dropFromOldTeamIfAny(player);
|
this.dropFromOldTeamIfAny(player);
|
||||||
event.setTo(this.war.getWarHub().getLocation());
|
event.setTo(War.war.getWarHub().getLocation());
|
||||||
// player.teleport(war.getWarHub().getLocation());
|
// player.teleport(war.getWarHub().getLocation());
|
||||||
this.war.msg(player, "Welcome to the War hub.");
|
War.war.msg(player, "Welcome to the War hub.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,19 +312,19 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Warhub zone gates
|
// Warhub zone gates
|
||||||
WarHub hub = this.war.getWarHub();
|
WarHub hub = War.war.getWarHub();
|
||||||
if (hub != null && hub.getVolume().contains(player.getLocation())) {
|
if (hub != null && hub.getVolume().contains(player.getLocation())) {
|
||||||
Warzone zone = hub.getDestinationWarzoneForLocation(playerLoc);
|
Warzone zone = hub.getDestinationWarzoneForLocation(playerLoc);
|
||||||
if (zone != null && zone.getTeleport() != null) {
|
if (zone != null && zone.getTeleport() != null) {
|
||||||
event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
// player.teleport(zone.getTeleport());
|
// player.teleport(zone.getTeleport());
|
||||||
this.war.msg(player, "Welcome to warzone " + zone.getName() + ".");
|
War.war.msg(player, "Welcome to warzone " + zone.getName() + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isLeaving = playerWarzone != null && playerWarzone.getLobby().isLeavingZone(playerLoc);
|
boolean isLeaving = playerWarzone != null && playerWarzone.getLobby().isLeavingZone(playerLoc);
|
||||||
Team playerTeam = this.war.getPlayerTeam(player.getName());
|
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||||
if (isLeaving) { // already in a team and in warzone, leaving
|
if (isLeaving) { // already in a team and in warzone, leaving
|
||||||
// same as leave
|
// same as leave
|
||||||
if (playerTeam != null) {
|
if (playerTeam != null) {
|
||||||
@ -348,7 +339,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
if (playerWarzone != null) {
|
if (playerWarzone != null) {
|
||||||
// Player belongs to a warzone team but is outside: he snuck out or is at spawn and died
|
// 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.");
|
War.war.badMsg(player, "Use /leave to exit the zone.");
|
||||||
event.setTo(playerTeam.getTeamSpawn());
|
event.setTo(playerTeam.getTeamSpawn());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -374,14 +365,14 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
} else {
|
} else {
|
||||||
heartNum = ((newHp - currentHp - 1) / 2) + ".5 ";
|
heartNum = ((newHp - currentHp - 1) / 2) + ".5 ";
|
||||||
}
|
}
|
||||||
this.war.msg(player, "Your dance pleases the monument's voodoo. You gain " + heartNum + "heart" + isS + "!");
|
War.war.msg(player, "Your dance pleases the monument's voodoo. You gain " + heartNum + "heart" + isS + "!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flag capture
|
// 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)) {
|
if (playerWarzone.isTeamFlagStolen(playerTeam)) {
|
||||||
this.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
|
War.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
|
||||||
} else {
|
} else {
|
||||||
synchronized (playerWarzone) {
|
synchronized (playerWarzone) {
|
||||||
// flags can be captured at own spawn or own flag pole
|
// flags can be captured at own spawn or own flag pole
|
||||||
@ -399,7 +390,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
|
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
|
||||||
victim.initializeTeamFlag();
|
victim.initializeTeamFlag();
|
||||||
for (Team t : playerWarzone.getTeams()) {
|
for (Team t : playerWarzone.getTeams()) {
|
||||||
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
|
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
|
||||||
+ " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
|
+ " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
|
||||||
}
|
}
|
||||||
playerWarzone.respawnPlayer(event, playerTeam, player);
|
playerWarzone.respawnPlayer(event, playerTeam, player);
|
||||||
@ -413,10 +404,10 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
} 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
|
// player is not in any team, but inside warzone boundaries, get him out
|
||||||
Warzone zone = this.war.warzone(playerLoc);
|
Warzone zone = War.war.warzone(playerLoc);
|
||||||
event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
// player.teleport(zone.getTeleport());
|
// player.teleport(zone.getTeleport());
|
||||||
this.war.badMsg(player, "You can't be inside a warzone without a team.");
|
War.war.badMsg(player, "You can't be inside a warzone without a team.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,25 +415,25 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
private void handleDisabledZone(PlayerMoveEvent event, Player player, Warzone zone) {
|
private void handleDisabledZone(PlayerMoveEvent event, Player player, Warzone zone) {
|
||||||
if (zone.getLobby() != null) {
|
if (zone.getLobby() != null) {
|
||||||
this.war.badMsg(player, "This warzone is disabled.");
|
War.war.badMsg(player, "This warzone is disabled.");
|
||||||
event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dropFromOldTeamIfAny(Player player) {
|
private void dropFromOldTeamIfAny(Player player) {
|
||||||
// drop from old team if any
|
// drop from old team if any
|
||||||
Team previousTeam = this.war.getPlayerTeam(player.getName());
|
Team previousTeam = War.war.getPlayerTeam(player.getName());
|
||||||
if (previousTeam != null) {
|
if (previousTeam != null) {
|
||||||
if (!previousTeam.removePlayer(player.getName())) {
|
if (!previousTeam.removePlayer(player.getName())) {
|
||||||
this.war.log("Could not remove player " + player.getName() + " from team " + previousTeam.getName(), java.util.logging.Level.WARNING);
|
War.war.log("Could not remove player " + player.getName() + " from team " + previousTeam.getName(), java.util.logging.Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAllTeamsMsg(Player player) {
|
public String getAllTeamsMsg(Player player) {
|
||||||
String teamsMessage = "Teams: ";
|
String teamsMessage = "Teams: ";
|
||||||
Warzone warzone = this.war.warzone(player.getLocation());
|
Warzone warzone = War.war.warzone(player.getLocation());
|
||||||
ZoneLobby lobby = this.war.lobby(player.getLocation());
|
ZoneLobby lobby = War.war.lobby(player.getLocation());
|
||||||
if (warzone == null && lobby != null) {
|
if (warzone == null && lobby != null) {
|
||||||
warzone = lobby.getZone();
|
warzone = lobby.getZone();
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,14 +5,12 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
|
||||||
|
|
||||||
import com.tommytony.war.volumes.Volume;
|
import com.tommytony.war.volumes.Volume;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Monument {
|
public class Monument {
|
||||||
private Location location;
|
private Location location;
|
||||||
@ -22,11 +20,11 @@ public class Monument {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private Warzone warzone;
|
private Warzone warzone;
|
||||||
|
|
||||||
public Monument(String name, War war, Warzone warzone, Location location) {
|
public Monument(String name, Warzone warzone, Location location) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.warzone = warzone;
|
this.warzone = warzone;
|
||||||
this.volume = new Volume(name, war, warzone.getWorld());
|
this.volume = new Volume(name, warzone.getWorld());
|
||||||
this.setLocation(location);
|
this.setLocation(location);
|
||||||
|
|
||||||
this.addMonumentBlocks();
|
this.addMonumentBlocks();
|
||||||
|
@ -30,14 +30,12 @@ public class Team {
|
|||||||
private Volume flagVolume;
|
private Volume flagVolume;
|
||||||
private final Warzone warzone;
|
private final Warzone warzone;
|
||||||
private TeamKind kind;
|
private TeamKind kind;
|
||||||
private War war;
|
|
||||||
|
|
||||||
public Team(String name, TeamKind kind, Location teamSpawn, War war, Warzone warzone) {
|
public Team(String name, TeamKind kind, Location teamSpawn, Warzone warzone) {
|
||||||
this.warzone = warzone;
|
this.warzone = warzone;
|
||||||
this.setName(name);
|
this.setName(name);
|
||||||
this.teamSpawn = teamSpawn;
|
this.teamSpawn = teamSpawn;
|
||||||
this.war = war;
|
this.setSpawnVolume(new Volume(name, warzone.getWorld()));
|
||||||
this.setSpawnVolume(new Volume(name, war, warzone.getWorld()));
|
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.setFlagVolume(null); // no flag at the start
|
this.setFlagVolume(null); // no flag at the start
|
||||||
}
|
}
|
||||||
@ -298,7 +296,7 @@ public class Team {
|
|||||||
lines[3] = this.remainingLives + "/" + this.warzone.getLifePool() + " lives left";
|
lines[3] = this.remainingLives + "/" + this.warzone.getLifePool() + " lives left";
|
||||||
}
|
}
|
||||||
|
|
||||||
SignHelper.setToSign(this.war, signBlock, (byte) signData, lines);
|
SignHelper.setToSign(War.war, signBlock, (byte) signData, lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +331,7 @@ public class Team {
|
|||||||
|
|
||||||
public void teamcast(String message) {
|
public void teamcast(String message) {
|
||||||
for (Player player : this.players) {
|
for (Player player : this.players) {
|
||||||
this.war.msg(player, message);
|
War.war.msg(player, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +416,7 @@ public class Team {
|
|||||||
|
|
||||||
private void setFlagVolume() {
|
private void setFlagVolume() {
|
||||||
if (this.flagVolume == null) {
|
if (this.flagVolume == null) {
|
||||||
this.flagVolume = new Volume(this.getName() + "flag", this.war, this.warzone.getWorld());
|
this.flagVolume = new Volume(this.getName() + "flag", this.warzone.getWorld());
|
||||||
}
|
}
|
||||||
if (this.flagVolume.isSaved()) {
|
if (this.flagVolume.isSaved()) {
|
||||||
this.flagVolume.resetBlocks();
|
this.flagVolume.resetBlocks();
|
||||||
|
@ -20,16 +20,14 @@ import com.tommytony.war.volumes.Volume;
|
|||||||
* @package com.tommytony.war
|
* @package com.tommytony.war
|
||||||
*/
|
*/
|
||||||
public class WarHub {
|
public class WarHub {
|
||||||
private final War war;
|
|
||||||
private Location location;
|
private Location location;
|
||||||
private Volume volume;
|
private Volume volume;
|
||||||
private Map<String, Block> zoneGateBlocks = new HashMap<String, Block>();
|
private Map<String, Block> zoneGateBlocks = new HashMap<String, Block>();
|
||||||
private BlockFace orientation;
|
private BlockFace orientation;
|
||||||
|
|
||||||
public WarHub(War war, Location location, String hubOrientation) {
|
public WarHub(Location location, String hubOrientation) {
|
||||||
this.war = war;
|
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.volume = new Volume("warhub", war, location.getWorld());
|
this.volume = new Volume("warhub", location.getWorld());
|
||||||
if (hubOrientation.equals("south")) {
|
if (hubOrientation.equals("south")) {
|
||||||
this.setOrientation(BlockFace.SOUTH);
|
this.setOrientation(BlockFace.SOUTH);
|
||||||
} else if (hubOrientation.equals("north")) {
|
} else if (hubOrientation.equals("north")) {
|
||||||
@ -43,10 +41,9 @@ public class WarHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use when creating from player location (with yaw)
|
// Use when creating from player location (with yaw)
|
||||||
public WarHub(War war, Location location) {
|
public WarHub(Location location) {
|
||||||
this.war = war;
|
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.volume = new Volume("warhub", war, location.getWorld());
|
this.volume = new Volume("warhub", location.getWorld());
|
||||||
|
|
||||||
setLocation(location);
|
setLocation(location);
|
||||||
}
|
}
|
||||||
@ -87,7 +84,7 @@ public class WarHub {
|
|||||||
for (String zoneName : this.zoneGateBlocks.keySet()) {
|
for (String zoneName : this.zoneGateBlocks.keySet()) {
|
||||||
Block gate = this.zoneGateBlocks.get(zoneName);
|
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);
|
zone = War.war.findWarzone(zoneName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return zone;
|
return zone;
|
||||||
@ -97,12 +94,12 @@ public class WarHub {
|
|||||||
// for now, draw the wall of gates to the west
|
// for now, draw the wall of gates to the west
|
||||||
this.zoneGateBlocks.clear();
|
this.zoneGateBlocks.clear();
|
||||||
int disabled = 0;
|
int disabled = 0;
|
||||||
for (Warzone zone : this.war.getWarzones()) {
|
for (Warzone zone : War.war.getWarzones()) {
|
||||||
if (zone.isDisabled()) {
|
if (zone.isDisabled()) {
|
||||||
disabled++;
|
disabled++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int noOfWarzones = this.war.getWarzones().size() - disabled;
|
int noOfWarzones = War.war.getWarzones().size() - disabled;
|
||||||
if (noOfWarzones > 0) {
|
if (noOfWarzones > 0) {
|
||||||
int hubWidth = noOfWarzones * 4 + 2;
|
int hubWidth = noOfWarzones * 4 + 2;
|
||||||
int halfHubWidth = hubWidth / 2;
|
int halfHubWidth = hubWidth / 2;
|
||||||
@ -149,7 +146,7 @@ public class WarHub {
|
|||||||
// draw gates
|
// draw gates
|
||||||
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getFace(BlockFace.UP).getFace(front, hubDepth).getFace(right, 2);
|
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getFace(BlockFace.UP).getFace(front, hubDepth).getFace(right, 2);
|
||||||
|
|
||||||
for (Warzone zone : this.war.getWarzones()) { // gonna use the index to find it again
|
for (Warzone zone : War.war.getWarzones()) { // gonna use the index to find it again
|
||||||
if (!zone.isDisabled()) {
|
if (!zone.isDisabled()) {
|
||||||
this.zoneGateBlocks.put(zone.getName(), currentGateBlock);
|
this.zoneGateBlocks.put(zone.getName(), currentGateBlock);
|
||||||
currentGateBlock.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE);
|
currentGateBlock.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE);
|
||||||
@ -175,10 +172,10 @@ public class WarHub {
|
|||||||
lines[1] = "(/warhub)";
|
lines[1] = "(/warhub)";
|
||||||
lines[2] = "Pick your";
|
lines[2] = "Pick your";
|
||||||
lines[3] = "battle!";
|
lines[3] = "battle!";
|
||||||
SignHelper.setToSign(this.war, signBlock, data, lines);
|
SignHelper.setToSign(War.war, signBlock, data, lines);
|
||||||
|
|
||||||
// Warzone signs
|
// Warzone signs
|
||||||
for (Warzone zone : this.war.getWarzones()) {
|
for (Warzone zone : War.war.getWarzones()) {
|
||||||
if (!zone.isDisabled() && zone.ready()) {
|
if (!zone.isDisabled() && zone.ready()) {
|
||||||
this.resetZoneSign(zone);
|
this.resetZoneSign(zone);
|
||||||
}
|
}
|
||||||
@ -232,7 +229,7 @@ public class WarHub {
|
|||||||
lines[1] = zone.getName();
|
lines[1] = zone.getName();
|
||||||
lines[2] = zonePlayers + "/" + zoneCap + " players";
|
lines[2] = zonePlayers + "/" + zoneCap + " players";
|
||||||
lines[3] = zone.getTeams().size() + " teams";
|
lines[3] = zone.getTeams().size() + " teams";
|
||||||
SignHelper.setToSign(this.war, block, data, lines);
|
SignHelper.setToSign(War.war, block, data, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVolume(Volume vol) {
|
public void setVolume(Volume vol) {
|
||||||
|
@ -27,8 +27,8 @@ import com.tommytony.war.volumes.ZoneVolume;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
* @package com.tommytony.war
|
||||||
*/
|
*/
|
||||||
public class Warzone {
|
public class Warzone {
|
||||||
private String name;
|
private String name;
|
||||||
@ -51,7 +51,6 @@ public class Warzone {
|
|||||||
private World world;
|
private World world;
|
||||||
private final int minSafeDistanceFromWall = 6;
|
private final int minSafeDistanceFromWall = 6;
|
||||||
private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>();
|
private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>();
|
||||||
private War war;
|
|
||||||
private ZoneLobby lobby;
|
private ZoneLobby lobby;
|
||||||
private boolean autoAssignOnly;
|
private boolean autoAssignOnly;
|
||||||
private boolean blockHeads;
|
private boolean blockHeads;
|
||||||
@ -67,25 +66,24 @@ public class Warzone {
|
|||||||
private HashMap<String, InventoryStash> deadMenInventories = new HashMap<String, InventoryStash>();
|
private HashMap<String, InventoryStash> deadMenInventories = new HashMap<String, InventoryStash>();
|
||||||
private Location rallyPoint;
|
private Location rallyPoint;
|
||||||
|
|
||||||
public Warzone(War war, World world, String name) {
|
public Warzone(World world, String name) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.war = war;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.friendlyFire = war.getDefaultFriendlyFire();
|
this.friendlyFire = War.war.getDefaultFriendlyFire();
|
||||||
this.setLifePool(war.getDefaultLifepool());
|
this.setLifePool(War.war.getDefaultLifepool());
|
||||||
this.setLoadout(war.getDefaultLoadout());
|
this.setLoadout(War.war.getDefaultLoadout());
|
||||||
this.setAutoAssignOnly(war.getDefaultAutoAssignOnly());
|
this.setAutoAssignOnly(War.war.getDefaultAutoAssignOnly());
|
||||||
this.teamCap = war.getDefaultTeamCap();
|
this.teamCap = War.war.getDefaultTeamCap();
|
||||||
this.scoreCap = war.getDefaultScoreCap();
|
this.scoreCap = War.war.getDefaultScoreCap();
|
||||||
this.monumentHeal = war.getDefaultMonumentHeal();
|
this.monumentHeal = War.war.getDefaultMonumentHeal();
|
||||||
this.setBlockHeads(war.isDefaultBlockHeads());
|
this.setBlockHeads(War.war.isDefaultBlockHeads());
|
||||||
this.setDropLootOnDeath(war.isDefaultDropLootOnDeath());
|
this.setDropLootOnDeath(War.war.isDefaultDropLootOnDeath());
|
||||||
this.setUnbreakableZoneBlocks(war.isDefaultUnbreakableZoneBlocks());
|
this.setUnbreakableZoneBlocks(War.war.isDefaultUnbreakableZoneBlocks());
|
||||||
this.setNoCreatures(war.getDefaultNoCreatures());
|
this.setNoCreatures(War.war.getDefaultNoCreatures());
|
||||||
this.setResetOnEmpty(war.isDefaultResetOnEmpty());
|
this.setResetOnEmpty(War.war.isDefaultResetOnEmpty());
|
||||||
this.setResetOnLoad(war.isDefaultResetOnLoad());
|
this.setResetOnLoad(War.war.isDefaultResetOnLoad());
|
||||||
this.setResetOnUnload(war.isDefaultResetOnUnload());
|
this.setResetOnUnload(War.war.isDefaultResetOnUnload());
|
||||||
this.volume = new ZoneVolume(name, war, this.getWorld(), this);
|
this.volume = new ZoneVolume(name, this.getWorld(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ready() {
|
public boolean ready() {
|
||||||
@ -188,12 +186,12 @@ public class Warzone {
|
|||||||
|
|
||||||
public void initializeZoneAsJob(Player respawnExempted) {
|
public void initializeZoneAsJob(Player respawnExempted) {
|
||||||
InitZoneJob job = new InitZoneJob(this, respawnExempted);
|
InitZoneJob job = new InitZoneJob(this, respawnExempted);
|
||||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, job);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeZoneAsJob() {
|
public void initializeZoneAsJob() {
|
||||||
InitZoneJob job = new InitZoneJob(this);
|
InitZoneJob job = new InitZoneJob(this);
|
||||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, job);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initZone() {
|
private void initZone() {
|
||||||
@ -235,7 +233,7 @@ public class Warzone {
|
|||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
|
|
||||||
LoadoutResetJob job = new LoadoutResetJob(this, team, player);
|
LoadoutResetJob job = new LoadoutResetJob(this, team, player);
|
||||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, job);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetInventory(Team team, Player player) {
|
public void resetInventory(Team team, Player player) {
|
||||||
@ -581,7 +579,7 @@ public class Warzone {
|
|||||||
guard.updatePlayerPosition(player.getLocation());
|
guard.updatePlayerPosition(player.getLocation());
|
||||||
} else {
|
} else {
|
||||||
// new guard
|
// new guard
|
||||||
guard = new ZoneWallGuard(player, this.war, this, wall);
|
guard = new ZoneWallGuard(player, War.war, this, wall);
|
||||||
this.zoneWallGuards.add(guard);
|
this.zoneWallGuards.add(guard);
|
||||||
}
|
}
|
||||||
protecting = true;
|
protecting = true;
|
||||||
@ -639,7 +637,7 @@ public class Warzone {
|
|||||||
if (!this.hasPlayerInventory(player.getName())) {
|
if (!this.hasPlayerInventory(player.getName())) {
|
||||||
this.keepPlayerInventory(player);
|
this.keepPlayerInventory(player);
|
||||||
}
|
}
|
||||||
this.war.msg(player, "Your inventory is in storage until you /leave.");
|
War.war.msg(player, "Your inventory is in storage until you /leave.");
|
||||||
this.respawnPlayer(lowestNoOfPlayers, player);
|
this.respawnPlayer(lowestNoOfPlayers, player);
|
||||||
for (Team team : this.teams) {
|
for (Team team : this.teams) {
|
||||||
team.teamcast("" + player.getName() + " joined team " + lowestNoOfPlayers.getName() + ".");
|
team.teamcast("" + player.getName() + " joined team " + lowestNoOfPlayers.getName() + ".");
|
||||||
@ -673,10 +671,11 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleDeath(Player player) {
|
public void handleDeath(Player player) {
|
||||||
Team playerTeam = this.war.getPlayerTeam(player.getName());
|
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||||
Warzone playerWarzone = this.war.getPlayerTeamWarzone(player.getName());
|
Warzone playerWarzone = War.war.getPlayerTeamWarzone(player.getName());
|
||||||
if (playerTeam != null && playerWarzone != null) {
|
if (playerTeam != null && playerWarzone != null) {
|
||||||
// teleport to team spawn upon death
|
// teleport to team spawn upon death
|
||||||
|
|
||||||
playerWarzone.respawnPlayer(playerTeam, player);
|
playerWarzone.respawnPlayer(playerTeam, player);
|
||||||
int remaining = playerTeam.getRemainingLifes();
|
int remaining = playerTeam.getRemainingLifes();
|
||||||
if (remaining == 0) { // your death caused your team to lose
|
if (remaining == 0) { // your death caused your team to lose
|
||||||
@ -748,7 +747,7 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
playerTeam.resetSign();
|
playerTeam.resetSign();
|
||||||
Plugin heroicDeath = this.war.getServer().getPluginManager().getPlugin("HeroicDeath");
|
Plugin heroicDeath = War.war.getServer().getPluginManager().getPlugin("HeroicDeath");
|
||||||
if (heroicDeath != null) {
|
if (heroicDeath != null) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -766,7 +765,7 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handlePlayerLeave(Player player, boolean removeFromTeam) {
|
private void handlePlayerLeave(Player player, boolean removeFromTeam) {
|
||||||
Team playerTeam = this.war.getPlayerTeam(player.getName());
|
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||||
if (playerTeam != null) {
|
if (playerTeam != null) {
|
||||||
if (removeFromTeam) {
|
if (removeFromTeam) {
|
||||||
playerTeam.removePlayer(player.getName());
|
playerTeam.removePlayer(player.getName());
|
||||||
@ -794,9 +793,9 @@ public class Warzone {
|
|||||||
player.setFireTicks(0);
|
player.setFireTicks(0);
|
||||||
player.setRemainingAir(300);
|
player.setRemainingAir(300);
|
||||||
|
|
||||||
this.war.msg(player, "Left the zone. Your inventory has been restored.");
|
War.war.msg(player, "Left the zone. Your inventory has been restored.");
|
||||||
if (this.war.getWarHub() != null) {
|
if (War.war.getWarHub() != null) {
|
||||||
this.war.getWarHub().resetZoneSign(this);
|
War.war.getWarHub().resetZoneSign(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean zoneEmpty = true;
|
boolean zoneEmpty = true;
|
||||||
@ -814,7 +813,7 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
this.getVolume().resetBlocksAsJob();
|
this.getVolume().resetBlocksAsJob();
|
||||||
this.initializeZoneAsJob();
|
this.initializeZoneAsJob();
|
||||||
this.war.log("Last player left warzone " + this.getName() + ". Warzone blocks resetting automatically...", Level.INFO);
|
War.war.log("Last player left warzone " + this.getName() + ". Warzone blocks resetting automatically...", Level.INFO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -874,15 +873,15 @@ public class Warzone {
|
|||||||
winnersStr += ". Resetting warzone and your inventory...";
|
winnersStr += ". Resetting warzone and your inventory...";
|
||||||
// Score cap reached. Reset everything.
|
// Score cap reached. Reset everything.
|
||||||
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
|
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
|
||||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, job);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||||
if (this.getLobby() != null) {
|
if (this.getLobby() != null) {
|
||||||
this.getLobby().getVolume().resetBlocksAsJob();
|
this.getLobby().getVolume().resetBlocksAsJob();
|
||||||
}
|
}
|
||||||
this.getVolume().resetBlocksAsJob();
|
this.getVolume().resetBlocksAsJob();
|
||||||
this.initializeZoneAsJob(player);
|
this.initializeZoneAsJob(player);
|
||||||
if (this.war.getWarHub() != null) {
|
if (War.war.getWarHub() != null) {
|
||||||
// TODO: test if warhub sign give the correct info despite the jobs
|
// TODO: test if warhub sign give the correct info despite the jobs
|
||||||
this.war.getWarHub().resetZoneSign(this);
|
War.war.getWarHub().resetZoneSign(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,7 +968,7 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unload() {
|
public void unload() {
|
||||||
this.war.log("Unloading zone " + this.getName() + "...", Level.INFO);
|
War.war.log("Unloading zone " + this.getName() + "...", Level.INFO);
|
||||||
for (Team team : this.getTeams()) {
|
for (Team team : this.getTeams()) {
|
||||||
for (Player player : team.getPlayers()) {
|
for (Player player : team.getPlayers()) {
|
||||||
this.handlePlayerLeave(player, this.getTeleport(), false);
|
this.handlePlayerLeave(player, this.getTeleport(), false);
|
||||||
|
@ -22,7 +22,6 @@ import com.tommytony.war.volumes.ZoneVolume;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ZoneLobby {
|
public class ZoneLobby {
|
||||||
private final War war;
|
|
||||||
private final Warzone warzone;
|
private final Warzone warzone;
|
||||||
private BlockFace wall;
|
private BlockFace wall;
|
||||||
private Volume volume;
|
private Volume volume;
|
||||||
@ -47,8 +46,7 @@ public class ZoneLobby {
|
|||||||
* @param wall
|
* @param wall
|
||||||
* On which wall of the warzone will the lobby be stuck to at mid-weight
|
* On which wall of the warzone will the lobby be stuck to at mid-weight
|
||||||
*/
|
*/
|
||||||
public ZoneLobby(War war, Warzone warzone, BlockFace wall) {
|
public ZoneLobby(Warzone warzone, BlockFace wall) {
|
||||||
this.war = war;
|
|
||||||
this.warzone = warzone;
|
this.warzone = warzone;
|
||||||
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
||||||
this.lobbyHalfSide = lobbyWidth / 2;
|
this.lobbyHalfSide = lobbyWidth / 2;
|
||||||
@ -66,8 +64,7 @@ public class ZoneLobby {
|
|||||||
* @param wall
|
* @param wall
|
||||||
* On which wall of the warzone will the lobby be stuck to at mid-weight
|
* On which wall of the warzone will the lobby be stuck to at mid-weight
|
||||||
*/
|
*/
|
||||||
public ZoneLobby(War war, Warzone warzone, Location playerLocation) {
|
public ZoneLobby(Warzone warzone, Location playerLocation) {
|
||||||
this.war = war;
|
|
||||||
this.warzone = warzone;
|
this.warzone = warzone;
|
||||||
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
||||||
this.lobbyHalfSide = lobbyWidth / 2;
|
this.lobbyHalfSide = lobbyWidth / 2;
|
||||||
@ -80,8 +77,7 @@ public class ZoneLobby {
|
|||||||
/**
|
/**
|
||||||
* 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) {
|
public ZoneLobby(Warzone warzone, BlockFace wall, Volume volume) {
|
||||||
this.war = war;
|
|
||||||
this.warzone = warzone;
|
this.warzone = warzone;
|
||||||
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
||||||
this.lobbyHalfSide = lobbyWidth / 2;
|
this.lobbyHalfSide = lobbyWidth / 2;
|
||||||
@ -226,7 +222,7 @@ public class ZoneLobby {
|
|||||||
private void createVolumeOrReset() {
|
private void createVolumeOrReset() {
|
||||||
if (this.volume == null) {
|
if (this.volume == null) {
|
||||||
// no previous wall
|
// no previous wall
|
||||||
this.volume = new Volume("lobby", this.war, this.warzone.getWorld());
|
this.volume = new Volume("lobby", this.warzone.getWorld());
|
||||||
} else if (this.volume.isSaved()) {
|
} else if (this.volume.isSaved()) {
|
||||||
this.volume.resetBlocks();
|
this.volume.resetBlocks();
|
||||||
}
|
}
|
||||||
@ -259,7 +255,7 @@ public class ZoneLobby {
|
|||||||
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // beautiful
|
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // beautiful
|
||||||
|
|
||||||
// add war hub link gate
|
// add war hub link gate
|
||||||
if (this.war.getWarHub() != null) {
|
if (War.war.getWarHub() != null) {
|
||||||
Block linkGateBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.warHubLinkGate);
|
Block linkGateBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.warHubLinkGate);
|
||||||
this.placeGate(linkGateBlock, Material.OBSIDIAN);
|
this.placeGate(linkGateBlock, Material.OBSIDIAN);
|
||||||
// add warhub sign
|
// add warhub sign
|
||||||
@ -317,7 +313,7 @@ public class ZoneLobby {
|
|||||||
lines[2] = "";
|
lines[2] = "";
|
||||||
lines[3] = "Pick your team.";
|
lines[3] = "Pick your team.";
|
||||||
}
|
}
|
||||||
SignHelper.setToSign(this.war, zoneSignBlock, data, lines);
|
SignHelper.setToSign(War.war, zoneSignBlock, data, lines);
|
||||||
|
|
||||||
// lets get some light in here
|
// lets get some light in here
|
||||||
if (this.wall == BlockFace.NORTH || this.wall == BlockFace.SOUTH) {
|
if (this.wall == BlockFace.NORTH || this.wall == BlockFace.SOUTH) {
|
||||||
@ -328,7 +324,7 @@ public class ZoneLobby {
|
|||||||
BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.SOUTH, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE);
|
BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.SOUTH, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.war.log("Failed to initalize zone lobby for zone " + this.warzone.getName(), java.util.logging.Level.WARNING);
|
War.war.log("Failed to initalize zone lobby for zone " + this.warzone.getName(), java.util.logging.Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,7 +658,7 @@ public class ZoneLobby {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SignHelper.setToSign(this.war, block, data, lines);
|
SignHelper.setToSign(War.war, block, data, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLeavingZone(Location location) {
|
public boolean isLeavingZone(Location location) {
|
||||||
@ -708,7 +704,7 @@ public class ZoneLobby {
|
|||||||
// int z = location.getBlockZ();
|
// int z = location.getBlockZ();
|
||||||
//
|
//
|
||||||
// 3x4x1 deep
|
// 3x4x1 deep
|
||||||
Volume gateExitVolume = new Volume("tempGateExit", this.war, location.getWorld());
|
Volume gateExitVolume = new Volume("tempGateExit", location.getWorld());
|
||||||
Block out = gate.getFace(inside);
|
Block out = gate.getFace(inside);
|
||||||
gateExitVolume.setCornerOne(out.getFace(left).getFace(BlockFace.DOWN));
|
gateExitVolume.setCornerOne(out.getFace(left).getFace(BlockFace.DOWN));
|
||||||
gateExitVolume.setCornerTwo(gate.getFace(right, 1).getFace(BlockFace.UP, 3));
|
gateExitVolume.setCornerTwo(gate.getFace(right, 1).getFace(BlockFace.UP, 3));
|
||||||
|
@ -15,27 +15,25 @@ import bukkit.tommytony.war.War;
|
|||||||
|
|
||||||
public class ZoneSetter {
|
public class ZoneSetter {
|
||||||
|
|
||||||
private final War war;
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final String zoneName;
|
private final String zoneName;
|
||||||
|
|
||||||
public ZoneSetter(War war, Player player, String zoneName) {
|
public ZoneSetter(Player player, String zoneName) {
|
||||||
this.war = war;
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.zoneName = zoneName;
|
this.zoneName = zoneName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void placeNorthwest() {
|
public void placeNorthwest() {
|
||||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
Warzone warzone = War.war.findWarzone(this.zoneName);
|
||||||
Block northwestBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
Block northwestBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||||
StringBuilder msgString = new StringBuilder();
|
StringBuilder msgString = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
if (warzone == null) {
|
if (warzone == null) {
|
||||||
// create the warzone
|
// create the warzone
|
||||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
|
||||||
this.war.getIncompleteZones().add(warzone);
|
War.war.getIncompleteZones().add(warzone);
|
||||||
warzone.getVolume().setNorthwest(northwestBlock);
|
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() + ". ");
|
War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:" + warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
|
||||||
} else {
|
} else {
|
||||||
// change existing warzone
|
// change existing warzone
|
||||||
this.resetWarzone(warzone, msgString);
|
this.resetWarzone(warzone, msgString);
|
||||||
@ -44,7 +42,7 @@ public class ZoneSetter {
|
|||||||
}
|
}
|
||||||
this.saveIfReady(warzone, msgString);
|
this.saveIfReady(warzone, msgString);
|
||||||
} catch (NotNorthwestException e) {
|
} catch (NotNorthwestException e) {
|
||||||
this.war.badMsg(this.player, "The block you selected is not to the northwest of the existing southeasternmost block.");
|
War.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
|
warzone.initializeZone(); // was reset before changing
|
||||||
}
|
}
|
||||||
@ -62,16 +60,16 @@ public class ZoneSetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void placeSoutheast() {
|
public void placeSoutheast() {
|
||||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
Warzone warzone = War.war.findWarzone(this.zoneName);
|
||||||
Block southeastBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
Block southeastBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||||
StringBuilder msgString = new StringBuilder();
|
StringBuilder msgString = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
if (warzone == null) {
|
if (warzone == null) {
|
||||||
// create the warzone
|
// create the warzone
|
||||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
|
||||||
this.war.getIncompleteZones().add(warzone);
|
War.war.getIncompleteZones().add(warzone);
|
||||||
warzone.getVolume().setSoutheast(southeastBlock);
|
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() + ". ");
|
War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
|
||||||
} else {
|
} else {
|
||||||
// change existing warzone
|
// change existing warzone
|
||||||
this.resetWarzone(warzone, msgString);
|
this.resetWarzone(warzone, msgString);
|
||||||
@ -80,7 +78,7 @@ public class ZoneSetter {
|
|||||||
}
|
}
|
||||||
this.saveIfReady(warzone, msgString);
|
this.saveIfReady(warzone, msgString);
|
||||||
} catch (NotSoutheastException e) {
|
} catch (NotSoutheastException e) {
|
||||||
this.war.badMsg(this.player, "The block you selected is not to the southeast of the existing northwestnmost block.");
|
War.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
|
warzone.initializeZone(); // was reset before changing
|
||||||
}
|
}
|
||||||
@ -103,15 +101,15 @@ public class ZoneSetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void placeCorner1(Block corner1Block) {
|
public void placeCorner1(Block corner1Block) {
|
||||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
Warzone warzone = War.war.findWarzone(this.zoneName);
|
||||||
StringBuilder msgString = new StringBuilder();
|
StringBuilder msgString = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
if (warzone == null) {
|
if (warzone == null) {
|
||||||
// create the warzone
|
// create the warzone
|
||||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
|
||||||
this.war.getIncompleteZones().add(warzone);
|
War.war.getIncompleteZones().add(warzone);
|
||||||
warzone.getVolume().setZoneCornerOne(corner1Block);
|
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() + ". ");
|
War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 1 set to x:" + corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
|
||||||
} else {
|
} else {
|
||||||
// change existing warzone
|
// change existing warzone
|
||||||
this.resetWarzone(warzone, msgString);
|
this.resetWarzone(warzone, msgString);
|
||||||
@ -138,15 +136,15 @@ public class ZoneSetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void placeCorner2(Block corner2Block) {
|
public void placeCorner2(Block corner2Block) {
|
||||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
Warzone warzone = War.war.findWarzone(this.zoneName);
|
||||||
StringBuilder msgString = new StringBuilder();
|
StringBuilder msgString = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
if (warzone == null) {
|
if (warzone == null) {
|
||||||
// create the warzone
|
// create the warzone
|
||||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
|
||||||
this.war.getIncompleteZones().add(warzone);
|
War.war.getIncompleteZones().add(warzone);
|
||||||
warzone.getVolume().setZoneCornerTwo(corner2Block);
|
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() + ". ");
|
War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 2 set to x:" + corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
|
||||||
} else {
|
} else {
|
||||||
// change existing warzone
|
// change existing warzone
|
||||||
this.resetWarzone(warzone, msgString);
|
this.resetWarzone(warzone, msgString);
|
||||||
@ -169,7 +167,7 @@ public class ZoneSetter {
|
|||||||
|
|
||||||
private void resetWarzone(Warzone warzone, StringBuilder msgString) {
|
private void resetWarzone(Warzone warzone, StringBuilder msgString) {
|
||||||
if (warzone.getVolume().isSaved()) {
|
if (warzone.getVolume().isSaved()) {
|
||||||
this.war.msg(this.player, "Resetting " + warzone.getName() + " blocks.");
|
War.war.msg(this.player, "Resetting " + warzone.getName() + " blocks.");
|
||||||
if (warzone.getLobby() != null && warzone.getLobby().getVolume() != null) {
|
if (warzone.getLobby() != null && warzone.getLobby().getVolume() != null) {
|
||||||
warzone.getLobby().getVolume().resetBlocks();
|
warzone.getLobby().getVolume().resetBlocks();
|
||||||
}
|
}
|
||||||
@ -179,48 +177,48 @@ public class ZoneSetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleTooSmall() {
|
private void handleTooSmall() {
|
||||||
this.war.badMsg(this.player, "That would make the " + this.zoneName + " warzone too small. Sides must be at least 10 blocks and all existing structures (spawns, flags, etc) must fit inside.");
|
War.war.badMsg(this.player, "That would make the " + this.zoneName + " warzone too small. Sides must be at least 10 blocks and all existing structures (spawns, flags, etc) must fit inside.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleTooBig() {
|
private void handleTooBig() {
|
||||||
this.war.badMsg(this.player, "That would make the " + this.zoneName + " warzone too big. Sides must be less than 750 blocks.");
|
War.war.badMsg(this.player, "That would make the " + this.zoneName + " warzone too big. Sides must be less than 750 blocks.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveIfReady(Warzone warzone, StringBuilder msgString) {
|
private void saveIfReady(Warzone warzone, StringBuilder msgString) {
|
||||||
if (warzone.ready()) {
|
if (warzone.ready()) {
|
||||||
if (!this.war.getWarzones().contains(warzone)) {
|
if (!War.war.getWarzones().contains(warzone)) {
|
||||||
this.war.addWarzone(warzone);
|
War.war.addWarzone(warzone);
|
||||||
}
|
}
|
||||||
if (this.war.getIncompleteZones().contains(warzone)) {
|
if (War.war.getIncompleteZones().contains(warzone)) {
|
||||||
this.war.getIncompleteZones().remove(warzone);
|
War.war.getIncompleteZones().remove(warzone);
|
||||||
}
|
}
|
||||||
WarMapper.save(this.war);
|
WarMapper.save();
|
||||||
msgString.append("Saving new warzone blocks...");
|
msgString.append("Saving new warzone blocks...");
|
||||||
this.war.msg(this.player, msgString.toString());
|
War.war.msg(this.player, msgString.toString());
|
||||||
warzone.saveState(false); // we just changed the volume, cant reset walls
|
warzone.saveState(false); // we just changed the volume, cant reset walls
|
||||||
if (warzone.getLobby() == null) {
|
if (warzone.getLobby() == null) {
|
||||||
// Set default lobby on south side
|
// Set default lobby on south side
|
||||||
ZoneLobby lobby = new ZoneLobby(this.war, warzone, BlockFace.SOUTH);
|
ZoneLobby lobby = new ZoneLobby(warzone, BlockFace.SOUTH);
|
||||||
warzone.setLobby(lobby);
|
warzone.setLobby(lobby);
|
||||||
if (this.war.getWarHub() != null) { // warhub has to change
|
if (War.war.getWarHub() != null) { // warhub has to change
|
||||||
this.war.getWarHub().getVolume().resetBlocks();
|
War.war.getWarHub().getVolume().resetBlocks();
|
||||||
this.war.getWarHub().initialize();
|
War.war.getWarHub().initialize();
|
||||||
}
|
}
|
||||||
this.war.msg(this.player, "Default lobby created on south side of zone. Use /setzonelobby <n/s/e/w> to change its position.");
|
War.war.msg(this.player, "Default lobby created on south side of zone. Use /setzonelobby <n/s/e/w> to change its position.");
|
||||||
} // else {
|
} // else {
|
||||||
// gotta move the lobby (or dont because zone.initzon does it for you)
|
// gotta move the lobby (or dont because zone.initzon does it for you)
|
||||||
// warzone.getLobby().changeWall(warzone.getLobby().getWall());
|
// warzone.getLobby().changeWall(warzone.getLobby().getWall());
|
||||||
// }
|
// }
|
||||||
warzone.initializeZone();
|
warzone.initializeZone();
|
||||||
WarzoneMapper.save(this.war, warzone, true);
|
WarzoneMapper.save(warzone, true);
|
||||||
this.war.msg(this.player, "Warzone saved.");
|
War.war.msg(this.player, "Warzone saved.");
|
||||||
} else {
|
} else {
|
||||||
if (warzone.getVolume().getCornerOne() == null) {
|
if (warzone.getVolume().getCornerOne() == null) {
|
||||||
msgString.append("Still missing corner 1.");
|
msgString.append("Still missing corner 1.");
|
||||||
} else if (warzone.getVolume().getCornerTwo() == null) {
|
} else if (warzone.getVolume().getCornerTwo() == null) {
|
||||||
msgString.append("Still missing corner 2.");
|
msgString.append("Still missing corner 2.");
|
||||||
}
|
}
|
||||||
this.war.msg(this.player, msgString.toString());
|
War.war.msg(this.player, msgString.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,11 +14,9 @@ import com.tommytony.war.volumes.Volume;
|
|||||||
|
|
||||||
public class RestoreWarhubJob implements Runnable {
|
public class RestoreWarhubJob implements Runnable {
|
||||||
|
|
||||||
private final War war;
|
|
||||||
private final String hubStr;
|
private final String hubStr;
|
||||||
|
|
||||||
public RestoreWarhubJob(War war, String hubStr) {
|
public RestoreWarhubJob(String hubStr) {
|
||||||
this.war = war;
|
|
||||||
this.hubStr = hubStr;
|
this.hubStr = hubStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,33 +31,33 @@ public class RestoreWarhubJob implements Runnable {
|
|||||||
String hubOrientation = "west";
|
String hubOrientation = "west";
|
||||||
if (hubStrSplit.length > 3) {
|
if (hubStrSplit.length > 3) {
|
||||||
worldName = hubStrSplit[3];
|
worldName = hubStrSplit[3];
|
||||||
world = this.war.getServer().getWorld(worldName);
|
world = War.war.getServer().getWorld(worldName);
|
||||||
if(hubStrSplit.length > 4) {
|
if(hubStrSplit.length > 4) {
|
||||||
hubOrientation = hubStrSplit[4];
|
hubOrientation = hubStrSplit[4];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
worldName = "DEFAULT";
|
worldName = "DEFAULT";
|
||||||
world = this.war.getServer().getWorlds().get(0); // default to first world
|
world = War.war.getServer().getWorlds().get(0); // default to first world
|
||||||
}
|
}
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
Location hubLocation = new Location(world, hubX, hubY, hubZ);
|
Location hubLocation = new Location(world, hubX, hubY, hubZ);
|
||||||
WarHub hub = new WarHub(this.war, hubLocation, hubOrientation);
|
WarHub hub = new WarHub(hubLocation, hubOrientation);
|
||||||
this.war.setWarHub(hub);
|
War.war.setWarHub(hub);
|
||||||
Volume vol = VolumeMapper.loadVolume("warhub", "", this.war, world);
|
Volume vol = VolumeMapper.loadVolume("warhub", "", world);
|
||||||
hub.setVolume(vol);
|
hub.setVolume(vol);
|
||||||
hub.getVolume().resetBlocks();
|
hub.getVolume().resetBlocks();
|
||||||
hub.initialize();
|
hub.initialize();
|
||||||
|
|
||||||
// In the previous job started by the mapper, warzones were created, but their lobbies are missing the war hub gate (because it didn't exist yet)
|
// In the previous job started by the mapper, warzones were created, but their lobbies are missing the war hub gate (because it didn't exist yet)
|
||||||
for (Warzone zone : this.war.getWarzones()) {
|
for (Warzone zone : War.war.getWarzones()) {
|
||||||
if (zone.getLobby() != null) {
|
if (zone.getLobby() != null) {
|
||||||
zone.getLobby().getVolume().resetBlocks();
|
zone.getLobby().getVolume().resetBlocks();
|
||||||
zone.getLobby().initialize();
|
zone.getLobby().initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.war.log("Warhub ready.", Level.INFO);
|
War.war.log("Warhub ready.", Level.INFO);
|
||||||
} else {
|
} else {
|
||||||
this.war.log("Failed to restore warhub. The specified world (name: " + worldName + ") does not exist!", Level.WARNING);
|
War.war.log("Failed to restore warhub. The specified world (name: " + worldName + ") does not exist!", Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,25 +9,23 @@ import com.tommytony.war.mappers.WarzoneMapper;
|
|||||||
|
|
||||||
public class RestoreWarzonesJob implements Runnable {
|
public class RestoreWarzonesJob implements Runnable {
|
||||||
|
|
||||||
private final War war;
|
|
||||||
private final String warzonesStr;
|
private final String warzonesStr;
|
||||||
private final boolean newWarInstall;
|
private final boolean newWarInstall;
|
||||||
|
|
||||||
public RestoreWarzonesJob(War war, String warzonesStr, boolean newWarInstall) {
|
public RestoreWarzonesJob(String warzonesStr, boolean newWarInstall) {
|
||||||
this.war = war;
|
|
||||||
this.warzonesStr = warzonesStr;
|
this.warzonesStr = warzonesStr;
|
||||||
this.newWarInstall = newWarInstall;
|
this.newWarInstall = newWarInstall;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
String[] warzoneSplit = this.warzonesStr.split(",");
|
String[] warzoneSplit = this.warzonesStr.split(",");
|
||||||
this.war.getWarzones().clear();
|
War.war.getWarzones().clear();
|
||||||
for (String warzoneName : warzoneSplit) {
|
for (String warzoneName : warzoneSplit) {
|
||||||
if (warzoneName != null && !warzoneName.equals("")) {
|
if (warzoneName != null && !warzoneName.equals("")) {
|
||||||
this.war.log("Loading zone " + warzoneName + "...", Level.INFO);
|
War.war.log("Loading zone " + warzoneName + "...", Level.INFO);
|
||||||
Warzone zone = WarzoneMapper.load(this.war, warzoneName, !this.newWarInstall);
|
Warzone zone = WarzoneMapper.load(warzoneName, !this.newWarInstall);
|
||||||
if (zone != null) { // could have failed, would've been logged already
|
if (zone != null) { // could have failed, would've been logged already
|
||||||
this.war.getWarzones().add(zone);
|
War.war.getWarzones().add(zone);
|
||||||
// zone.getVolume().loadCorners();
|
// zone.getVolume().loadCorners();
|
||||||
zone.getVolume().loadCorners();
|
zone.getVolume().loadCorners();
|
||||||
if (zone.getLobby() != null) {
|
if (zone.getLobby() != null) {
|
||||||
@ -40,8 +38,8 @@ public class RestoreWarzonesJob implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.war.getWarzones().size() > 0) {
|
if (War.war.getWarzones().size() > 0) {
|
||||||
this.war.log("Warzones ready.", Level.INFO);
|
War.war.log("Warzones ready.", Level.INFO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
package com.tommytony.war.jobs;
|
package com.tommytony.war.jobs;
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
|
||||||
|
|
||||||
import com.tommytony.war.mappers.ZoneVolumeMapper;
|
import com.tommytony.war.mappers.ZoneVolumeMapper;
|
||||||
import com.tommytony.war.volumes.Volume;
|
import com.tommytony.war.volumes.Volume;
|
||||||
|
|
||||||
public class ZoneVolumeSaveJob extends Thread {
|
public class ZoneVolumeSaveJob extends Thread {
|
||||||
private final Volume volume;
|
private final Volume volume;
|
||||||
private final String zoneName;
|
private final String zoneName;
|
||||||
private final War war;
|
|
||||||
|
|
||||||
public ZoneVolumeSaveJob(Volume volume, String zoneName, War war) {
|
public ZoneVolumeSaveJob(Volume volume, String zoneName) {
|
||||||
this.volume = volume;
|
this.volume = volume;
|
||||||
this.zoneName = zoneName;
|
this.zoneName = zoneName;
|
||||||
this.war = war;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ZoneVolumeMapper.save(this.volume, this.zoneName, this.war);
|
ZoneVolumeMapper.save(this.volume, this.zoneName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,11 +59,11 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int load(ZoneVolume volume, String zoneName, War war, World world, boolean onlyLoadCorners) {
|
public static int load(ZoneVolume volume, String zoneName, World world, boolean onlyLoadCorners) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
int noOfResetBlocks = 0;
|
int noOfResetBlocks = 0;
|
||||||
try {
|
try {
|
||||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
in = new BufferedReader(new FileReader(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
String firstLine = in.readLine();
|
String firstLine = in.readLine();
|
||||||
|
|
||||||
if (firstLine != null && !firstLine.equals("")) {
|
if (firstLine != null && !firstLine.equals("")) {
|
||||||
@ -240,7 +240,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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());
|
War.war.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();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
z++;
|
z++;
|
||||||
@ -257,15 +257,15 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
if (!deferred.isEmpty()) {
|
if (!deferred.isEmpty()) {
|
||||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, deferred, 1);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, deferred, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.log("Unexpected error caused failure to read volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Unexpected error caused failure to read volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
@ -276,7 +276,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
// scanner.close();
|
// scanner.close();
|
||||||
// scanner = null;
|
// scanner = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to close file reader for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to close file reader for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@ import com.tommytony.war.volumes.Volume;
|
|||||||
*/
|
*/
|
||||||
public class VolumeMapper {
|
public class VolumeMapper {
|
||||||
|
|
||||||
public static Volume loadVolume(String volumeName, String zoneName, War war, World world) {
|
public static Volume loadVolume(String volumeName, String zoneName, World world) {
|
||||||
Volume volume = new Volume(volumeName, war, world);
|
Volume volume = new Volume(volumeName, world);
|
||||||
VolumeMapper.load(volume, zoneName, war, world);
|
VolumeMapper.load(volume, zoneName, world);
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,13 +39,13 @@ public class VolumeMapper {
|
|||||||
// return volume;
|
// return volume;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public static void load(Volume volume, String zoneName, War war, World world) {
|
public static void load(Volume volume, String zoneName, World world) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
if (zoneName.equals("")) {
|
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.war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
||||||
} else {
|
} else {
|
||||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
in = new BufferedReader(new FileReader(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
}
|
}
|
||||||
String firstLine = in.readLine();
|
String firstLine = in.readLine();
|
||||||
if (firstLine != null && !firstLine.equals("")) {
|
if (firstLine != null && !firstLine.equals("")) {
|
||||||
@ -151,7 +151,7 @@ public class VolumeMapper {
|
|||||||
blockReads++;
|
blockReads++;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.log("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(), Level.WARNING);
|
War.war.log("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(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,31 +164,31 @@ public class VolumeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.log("Unexpected error caused failure to read volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Unexpected error caused failure to read volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to close file reader for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to close file reader for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(Volume volume, String zoneName, War war) {
|
public static void save(Volume volume, String zoneName) {
|
||||||
if (volume.hasTwoCorners()) {
|
if (volume.hasTwoCorners()) {
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
try {
|
try {
|
||||||
if (zoneName.equals("")) {
|
if (zoneName.equals("")) {
|
||||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
out = new BufferedWriter(new FileWriter(new File(War.war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||||
} else {
|
} 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.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
}
|
}
|
||||||
|
|
||||||
out.write("corner1");
|
out.write("corner1");
|
||||||
@ -260,24 +260,24 @@ public class VolumeMapper {
|
|||||||
}
|
}
|
||||||
out.newLine();
|
out.newLine();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.log("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(), Level.WARNING);
|
War.war.log("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(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.log("Unexpected error caused failure to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Unexpected error caused failure to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
try {
|
try {
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to close file writer for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to close file writer for volume " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,15 @@ import com.tommytony.war.jobs.RestoreWarzonesJob;
|
|||||||
*/
|
*/
|
||||||
public class WarMapper {
|
public class WarMapper {
|
||||||
|
|
||||||
public static void load(War war) {
|
public static void load() {
|
||||||
// war.getLogger().info("Loading war config...");
|
// war.getLogger().info("Loading war config...");
|
||||||
(war.getDataFolder()).mkdir();
|
(War.war.getDataFolder()).mkdir();
|
||||||
(new File(war.getDataFolder().getPath() + "/dat")).mkdir();
|
(new File(War.war.getDataFolder().getPath() + "/dat")).mkdir();
|
||||||
PropertiesFile warConfig = new PropertiesFile(war.getDataFolder().getPath() + "/war.txt");
|
PropertiesFile warConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/war.txt");
|
||||||
try {
|
try {
|
||||||
warConfig.load();
|
warConfig.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to load war.txt file.", Level.WARNING);
|
War.war.log("Failed to load war.txt file.", Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,93 +39,93 @@ public class WarMapper {
|
|||||||
boolean newWar = false;
|
boolean newWar = false;
|
||||||
if (!warConfig.containsKey("warzones")) {
|
if (!warConfig.containsKey("warzones")) {
|
||||||
newWar = true;
|
newWar = true;
|
||||||
WarMapper.save(war);
|
WarMapper.save();
|
||||||
war.log("war.txt settings file created.", Level.INFO);
|
War.war.log("war.txt settings file created.", Level.INFO);
|
||||||
try {
|
try {
|
||||||
warConfig.load();
|
warConfig.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to reload war.txt file after creating it.", Level.WARNING);
|
War.war.log("Failed to reload war.txt file after creating it.", Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// warzones
|
// warzones
|
||||||
String warzonesStr = warConfig.getString("warzones");
|
String warzonesStr = warConfig.getString("warzones");
|
||||||
RestoreWarzonesJob restoreWarzones = new RestoreWarzonesJob(war, warzonesStr, newWar);
|
RestoreWarzonesJob restoreWarzones = new RestoreWarzonesJob(warzonesStr, newWar);
|
||||||
if (war.getServer().getScheduler().scheduleSyncDelayedTask(war, restoreWarzones) == -1) {
|
if (War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, restoreWarzones) == -1) {
|
||||||
war.log("Failed to schedule warzone-restore job. No warzone was loaded.", Level.WARNING);
|
War.war.log("Failed to schedule warzone-restore job. No warzone was loaded.", Level.WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// zone makers
|
// zone makers
|
||||||
String[] makers = warConfig.getString("zoneMakers").split(",");
|
String[] makers = warConfig.getString("zoneMakers").split(",");
|
||||||
war.getZoneMakerNames().clear();
|
War.war.getZoneMakerNames().clear();
|
||||||
for (String makerName : makers) {
|
for (String makerName : makers) {
|
||||||
if (makerName != null && !makerName.equals("")) {
|
if (makerName != null && !makerName.equals("")) {
|
||||||
war.getZoneMakerNames().add(makerName);
|
War.war.getZoneMakerNames().add(makerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// command whitelist
|
// command whitelist
|
||||||
String[] whitelist = warConfig.getString("commandWhitelist").split(",");
|
String[] whitelist = warConfig.getString("commandWhitelist").split(",");
|
||||||
war.getCommandWhitelist().clear();
|
War.war.getCommandWhitelist().clear();
|
||||||
for (String command : whitelist) {
|
for (String command : whitelist) {
|
||||||
if (command != null && !command.equals("")) {
|
if (command != null && !command.equals("")) {
|
||||||
war.getCommandWhitelist().add(command);
|
War.war.getCommandWhitelist().add(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultLoadout
|
// defaultLoadout
|
||||||
String defaultLoadoutStr = warConfig.getString("defaultLoadout");
|
String defaultLoadoutStr = warConfig.getString("defaultLoadout");
|
||||||
String[] defaultLoadoutSplit = defaultLoadoutStr.split(";");
|
String[] defaultLoadoutSplit = defaultLoadoutStr.split(";");
|
||||||
war.getDefaultLoadout().clear();
|
War.war.getDefaultLoadout().clear();
|
||||||
for (String itemStr : defaultLoadoutSplit) {
|
for (String itemStr : defaultLoadoutSplit) {
|
||||||
if (itemStr != null && !itemStr.equals("")) {
|
if (itemStr != null && !itemStr.equals("")) {
|
||||||
String[] itemStrSplit = itemStr.split(",");
|
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);
|
War.war.getDefaultLoadout().put(Integer.parseInt(itemStrSplit[2]), item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultLifePool
|
// defaultLifePool
|
||||||
war.setDefaultLifepool(warConfig.getInt("defaultLifePool"));
|
War.war.setDefaultLifepool(warConfig.getInt("defaultLifePool"));
|
||||||
|
|
||||||
// defaultMonumentHeal
|
// defaultMonumentHeal
|
||||||
war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal"));
|
War.war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal"));
|
||||||
|
|
||||||
// defaultFriendlyFire
|
// defaultFriendlyFire
|
||||||
war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
|
War.war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
|
||||||
|
|
||||||
// defaultAutoAssignOnly
|
// defaultAutoAssignOnly
|
||||||
war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly"));
|
War.war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly"));
|
||||||
|
|
||||||
// defaultTeamCap
|
// defaultTeamCap
|
||||||
war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap"));
|
War.war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap"));
|
||||||
|
|
||||||
// defaultScoreCap
|
// defaultScoreCap
|
||||||
war.setDefaultScoreCap(warConfig.getInt("defaultScoreCap"));
|
War.war.setDefaultScoreCap(warConfig.getInt("defaultScoreCap"));
|
||||||
|
|
||||||
// pvpInZonesOnly
|
// pvpInZonesOnly
|
||||||
war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly"));
|
War.war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly"));
|
||||||
|
|
||||||
// defaultBlockHeads
|
// defaultBlockHeads
|
||||||
war.setDefaultBlockHeads(warConfig.getBoolean("defaultBlockHeads"));
|
War.war.setDefaultBlockHeads(warConfig.getBoolean("defaultBlockHeads"));
|
||||||
|
|
||||||
// buildInZonesOnly
|
// buildInZonesOnly
|
||||||
war.setBuildInZonesOnly(warConfig.getBoolean("buildInZonesOnly"));
|
War.war.setBuildInZonesOnly(warConfig.getBoolean("buildInZonesOnly"));
|
||||||
|
|
||||||
// disablePVPMessage
|
// disablePVPMessage
|
||||||
war.setDisablePvpMessage(warConfig.getBoolean("disablePvpMessage"));
|
War.war.setDisablePvpMessage(warConfig.getBoolean("disablePvpMessage"));
|
||||||
|
|
||||||
// defaultSpawnStyle
|
// defaultSpawnStyle
|
||||||
String spawnStyle = warConfig.getString("defaultspawnStyle");
|
String spawnStyle = warConfig.getString("defaultspawnStyle");
|
||||||
if (spawnStyle != null && !spawnStyle.equals("")) {
|
if (spawnStyle != null && !spawnStyle.equals("")) {
|
||||||
spawnStyle = spawnStyle.toLowerCase();
|
spawnStyle = spawnStyle.toLowerCase();
|
||||||
if (spawnStyle.equals(TeamSpawnStyles.SMALL)) {
|
if (spawnStyle.equals(TeamSpawnStyles.SMALL)) {
|
||||||
war.setDefaultSpawnStyle(spawnStyle);
|
War.war.setDefaultSpawnStyle(spawnStyle);
|
||||||
} else if (spawnStyle.equals(TeamSpawnStyles.FLAT)) {
|
} else if (spawnStyle.equals(TeamSpawnStyles.FLAT)) {
|
||||||
war.setDefaultSpawnStyle(spawnStyle);
|
War.war.setDefaultSpawnStyle(spawnStyle);
|
||||||
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)) {
|
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)) {
|
||||||
war.setDefaultSpawnStyle(spawnStyle);
|
War.war.setDefaultSpawnStyle(spawnStyle);
|
||||||
}
|
}
|
||||||
// default is already initialized to BIG (see Warzone)
|
// default is already initialized to BIG (see Warzone)
|
||||||
}
|
}
|
||||||
@ -134,73 +134,73 @@ public class WarMapper {
|
|||||||
String defaultRewardStr = warConfig.getString("defaultReward");
|
String defaultRewardStr = warConfig.getString("defaultReward");
|
||||||
if (defaultRewardStr != null && !defaultRewardStr.equals("")) {
|
if (defaultRewardStr != null && !defaultRewardStr.equals("")) {
|
||||||
String[] defaultRewardStrSplit = defaultRewardStr.split(";");
|
String[] defaultRewardStrSplit = defaultRewardStr.split(";");
|
||||||
war.getDefaultReward().clear();
|
War.war.getDefaultReward().clear();
|
||||||
for (String itemStr : defaultRewardStrSplit) {
|
for (String itemStr : defaultRewardStrSplit) {
|
||||||
if (itemStr != null && !itemStr.equals("")) {
|
if (itemStr != null && !itemStr.equals("")) {
|
||||||
String[] itemStrSplit = itemStr.split(",");
|
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);
|
War.war.getDefaultReward().put(Integer.parseInt(itemStrSplit[2]), item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultUnbreakableZoneBlocks
|
// defaultUnbreakableZoneBlocks
|
||||||
war.setDefaultUnbreakableZoneBlocks(warConfig.getBoolean("defaultUnbreakableZoneBlocks"));
|
War.war.setDefaultUnbreakableZoneBlocks(warConfig.getBoolean("defaultUnbreakableZoneBlocks"));
|
||||||
|
|
||||||
// defaultNoCreatures
|
// defaultNoCreatures
|
||||||
war.setDefaultNoCreatures(warConfig.getBoolean("defaultNoCreatures"));
|
War.war.setDefaultNoCreatures(warConfig.getBoolean("defaultNoCreatures"));
|
||||||
|
|
||||||
// defaultDropLootOnDeath
|
// defaultDropLootOnDeath
|
||||||
// war.setDefaultDropLootOnDeath(warConfig.getBoolean("defaultDropLootOnDeath"));
|
// war.setDefaultDropLootOnDeath(warConfig.getBoolean("defaultDropLootOnDeath"));
|
||||||
|
|
||||||
// defaultResetOnEmpty
|
// defaultResetOnEmpty
|
||||||
war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty"));
|
War.war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty"));
|
||||||
|
|
||||||
// defaultResetOnLoad
|
// defaultResetOnLoad
|
||||||
war.setDefaultResetOnLoad(warConfig.getBoolean("defaultResetOnLoad"));
|
War.war.setDefaultResetOnLoad(warConfig.getBoolean("defaultResetOnLoad"));
|
||||||
|
|
||||||
// defaultResetOnUnload
|
// defaultResetOnUnload
|
||||||
war.setDefaultResetOnUnload(warConfig.getBoolean("defaultResetOnUnload"));
|
War.war.setDefaultResetOnUnload(warConfig.getBoolean("defaultResetOnUnload"));
|
||||||
|
|
||||||
// warhub
|
// warhub
|
||||||
String hubStr = warConfig.getString("warhub");
|
String hubStr = warConfig.getString("warhub");
|
||||||
if (hubStr != null && !hubStr.equals("")) {
|
if (hubStr != null && !hubStr.equals("")) {
|
||||||
RestoreWarhubJob restoreWarhub = new RestoreWarhubJob(war, hubStr);
|
RestoreWarhubJob restoreWarhub = new RestoreWarhubJob(hubStr);
|
||||||
if (war.getServer().getScheduler().scheduleSyncDelayedTask(war, restoreWarhub) == -1) {
|
if (War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, restoreWarhub) == -1) {
|
||||||
war.log("Failed to schedule warhub-restore job. War hub was not loaded.", Level.WARNING);
|
War.war.log("Failed to schedule warhub-restore job. War hub was not loaded.", Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
warConfig.close();
|
warConfig.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(War war) {
|
public static void save() {
|
||||||
PropertiesFile warConfig = new PropertiesFile(war.getDataFolder().getPath() + "/war.txt");
|
PropertiesFile warConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/war.txt");
|
||||||
String warzonesStr = "";
|
String warzonesStr = "";
|
||||||
|
|
||||||
// warzones
|
// warzones
|
||||||
for (Warzone zone : war.getWarzones()) {
|
for (Warzone zone : War.war.getWarzones()) {
|
||||||
warzonesStr += zone.getName() + ",";
|
warzonesStr += zone.getName() + ",";
|
||||||
}
|
}
|
||||||
warConfig.setString("warzones", warzonesStr);
|
warConfig.setString("warzones", warzonesStr);
|
||||||
|
|
||||||
// zone makers: default is none and it means everyone can use /setzone
|
// zone makers: default is none and it means everyone can use /setzone
|
||||||
String makersStr = ""; // everyone
|
String makersStr = ""; // everyone
|
||||||
for (String name : war.getZoneMakerNames()) {
|
for (String name : War.war.getZoneMakerNames()) {
|
||||||
makersStr += name + ",";
|
makersStr += name + ",";
|
||||||
}
|
}
|
||||||
warConfig.setString("zoneMakers", makersStr);
|
warConfig.setString("zoneMakers", makersStr);
|
||||||
|
|
||||||
// whitelisted commands during a game
|
// whitelisted commands during a game
|
||||||
String commandWhitelistStr = ""; // everyone
|
String commandWhitelistStr = ""; // everyone
|
||||||
for (String command : war.getCommandWhitelist()) {
|
for (String command : War.war.getCommandWhitelist()) {
|
||||||
commandWhitelistStr += command + ",";
|
commandWhitelistStr += command + ",";
|
||||||
}
|
}
|
||||||
warConfig.setString("commandWhitelist", makersStr);
|
warConfig.setString("commandWhitelist", makersStr);
|
||||||
|
|
||||||
// defaultLoadout
|
// defaultLoadout
|
||||||
String defaultLoadoutStr = "";
|
String defaultLoadoutStr = "";
|
||||||
HashMap<Integer, ItemStack> items = war.getDefaultLoadout();
|
HashMap<Integer, ItemStack> items = War.war.getDefaultLoadout();
|
||||||
for (Integer slot : items.keySet()) {
|
for (Integer slot : items.keySet()) {
|
||||||
ItemStack item = items.get(slot);
|
ItemStack item = items.get(slot);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@ -210,41 +210,41 @@ public class WarMapper {
|
|||||||
warConfig.setString("defaultLoadout", defaultLoadoutStr);
|
warConfig.setString("defaultLoadout", defaultLoadoutStr);
|
||||||
|
|
||||||
// defaultLifepool
|
// defaultLifepool
|
||||||
warConfig.setInt("defaultLifePool", war.getDefaultLifepool());
|
warConfig.setInt("defaultLifePool", War.war.getDefaultLifepool());
|
||||||
|
|
||||||
// defaultMonumentHeal
|
// defaultMonumentHeal
|
||||||
warConfig.setInt("defaultMonumentHeal", war.getDefaultMonumentHeal());
|
warConfig.setInt("defaultMonumentHeal", War.war.getDefaultMonumentHeal());
|
||||||
|
|
||||||
// defaultFriendlyFire
|
// defaultFriendlyFire
|
||||||
warConfig.setBoolean("defaultFriendlyFire", war.getDefaultFriendlyFire());
|
warConfig.setBoolean("defaultFriendlyFire", War.war.getDefaultFriendlyFire());
|
||||||
|
|
||||||
// defaultAutoAssignOnly
|
// defaultAutoAssignOnly
|
||||||
warConfig.setBoolean("defaultAutoAssignOnly", war.getDefaultAutoAssignOnly());
|
warConfig.setBoolean("defaultAutoAssignOnly", War.war.getDefaultAutoAssignOnly());
|
||||||
|
|
||||||
// defaultTeamCap
|
// defaultTeamCap
|
||||||
warConfig.setInt("defaultTeamCap", war.getDefaultTeamCap());
|
warConfig.setInt("defaultTeamCap", War.war.getDefaultTeamCap());
|
||||||
|
|
||||||
// defaultScoreCap
|
// defaultScoreCap
|
||||||
warConfig.setInt("defaultScoreCap", war.getDefaultScoreCap());
|
warConfig.setInt("defaultScoreCap", War.war.getDefaultScoreCap());
|
||||||
|
|
||||||
// pvpInZonesOnly
|
// pvpInZonesOnly
|
||||||
warConfig.setBoolean("pvpInZonesOnly", war.isPvpInZonesOnly());
|
warConfig.setBoolean("pvpInZonesOnly", War.war.isPvpInZonesOnly());
|
||||||
|
|
||||||
// defaultBlockHeads
|
// defaultBlockHeads
|
||||||
warConfig.setBoolean("defaultBlockHeads", war.isDefaultBlockHeads());
|
warConfig.setBoolean("defaultBlockHeads", War.war.isDefaultBlockHeads());
|
||||||
|
|
||||||
// buildInZonesOnly
|
// buildInZonesOnly
|
||||||
warConfig.setBoolean("buildInZonesOnly", war.isBuildInZonesOnly());
|
warConfig.setBoolean("buildInZonesOnly", War.war.isBuildInZonesOnly());
|
||||||
|
|
||||||
// disablePVPMessage
|
// disablePVPMessage
|
||||||
warConfig.setBoolean("disablePvpMessage", war.isDisablePvpMessage());
|
warConfig.setBoolean("disablePvpMessage", War.war.isDisablePvpMessage());
|
||||||
|
|
||||||
// spawnStyle
|
// spawnStyle
|
||||||
warConfig.setString("spawnStyle", war.getDefaultSpawnStyle());
|
warConfig.setString("spawnStyle", War.war.getDefaultSpawnStyle());
|
||||||
|
|
||||||
// defaultReward
|
// defaultReward
|
||||||
String defaultRewardStr = "";
|
String defaultRewardStr = "";
|
||||||
HashMap<Integer, ItemStack> rewardItems = war.getDefaultReward();
|
HashMap<Integer, ItemStack> rewardItems = War.war.getDefaultReward();
|
||||||
for (Integer slot : rewardItems.keySet()) {
|
for (Integer slot : rewardItems.keySet()) {
|
||||||
ItemStack item = items.get(slot);
|
ItemStack item = items.get(slot);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@ -254,26 +254,26 @@ public class WarMapper {
|
|||||||
warConfig.setString("defaultReward", defaultRewardStr);
|
warConfig.setString("defaultReward", defaultRewardStr);
|
||||||
|
|
||||||
// defaultUnbreakableZoneBlocks
|
// defaultUnbreakableZoneBlocks
|
||||||
warConfig.setBoolean("defaultUnbreakableZoneBlocks", war.isDefaultUnbreakableZoneBlocks());
|
warConfig.setBoolean("defaultUnbreakableZoneBlocks", War.war.isDefaultUnbreakableZoneBlocks());
|
||||||
|
|
||||||
// defaultNoCreatures
|
// defaultNoCreatures
|
||||||
warConfig.setBoolean("defaultNoCreatures", war.isDefaultNoCreatures());
|
warConfig.setBoolean("defaultNoCreatures", War.war.isDefaultNoCreatures());
|
||||||
|
|
||||||
// defaultResetOnEmpty
|
// defaultResetOnEmpty
|
||||||
warConfig.setBoolean("defaultResetOnEmpty", war.isDefaultResetOnEmpty());
|
warConfig.setBoolean("defaultResetOnEmpty", War.war.isDefaultResetOnEmpty());
|
||||||
|
|
||||||
// defaultResetOnLoad
|
// defaultResetOnLoad
|
||||||
warConfig.setBoolean("defaultResetOnLoad", war.isDefaultResetOnLoad());
|
warConfig.setBoolean("defaultResetOnLoad", War.war.isDefaultResetOnLoad());
|
||||||
|
|
||||||
// defaultResetOnUnload
|
// defaultResetOnUnload
|
||||||
warConfig.setBoolean("defaultResetOnUnload", war.isDefaultResetOnUnload());
|
warConfig.setBoolean("defaultResetOnUnload", War.war.isDefaultResetOnUnload());
|
||||||
|
|
||||||
// defaultDropLootOnDeath
|
// defaultDropLootOnDeath
|
||||||
// warConfig.setBoolean("defaultDropLootOnDeath", war.isDefaultDropLootOnDeath());
|
// warConfig.setBoolean("defaultDropLootOnDeath", war.isDefaultDropLootOnDeath());
|
||||||
|
|
||||||
// warhub
|
// warhub
|
||||||
String hubStr = "";
|
String hubStr = "";
|
||||||
WarHub hub = war.getWarHub();
|
WarHub hub = War.war.getWarHub();
|
||||||
if (hub != null) {
|
if (hub != null) {
|
||||||
String orientationStr = "";
|
String orientationStr = "";
|
||||||
if (BlockFace.SOUTH == hub.getOrientation()) {
|
if (BlockFace.SOUTH == hub.getOrientation()) {
|
||||||
@ -287,7 +287,7 @@ public class WarMapper {
|
|||||||
}
|
}
|
||||||
hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ() + ","
|
hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ() + ","
|
||||||
+ hub.getLocation().getWorld().getName() + "," + orientationStr;
|
+ hub.getLocation().getWorld().getName() + "," + orientationStr;
|
||||||
VolumeMapper.save(hub.getVolume(), "", war);
|
VolumeMapper.save(hub.getVolume(), "");
|
||||||
}
|
}
|
||||||
warConfig.setString("warhub", hubStr);
|
warConfig.setString("warhub", hubStr);
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ import com.tommytony.war.volumes.ZoneVolume;
|
|||||||
*/
|
*/
|
||||||
public class WarzoneMapper {
|
public class WarzoneMapper {
|
||||||
|
|
||||||
public static Warzone load(War war, String name, boolean createNewVolume) {
|
public static Warzone load(String name, boolean createNewVolume) {
|
||||||
// war.getLogger().info("Loading warzone " + name + " config and blocks...");
|
// war.getLogger().info("Loading warzone " + name + " config and blocks...");
|
||||||
PropertiesFile warzoneConfig = new PropertiesFile(war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
|
PropertiesFile warzoneConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
|
||||||
try {
|
try {
|
||||||
warzoneConfig.load();
|
warzoneConfig.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.getLogger().info("Failed to load warzone-" + name + ".txt file.");
|
War.war.getLogger().info("Failed to load warzone-" + name + ".txt file.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,21 +43,21 @@ public class WarzoneMapper {
|
|||||||
String worldStr = warzoneConfig.getProperty("world");
|
String worldStr = warzoneConfig.getProperty("world");
|
||||||
World world = null;
|
World world = null;
|
||||||
if (worldStr == null || worldStr.equals("")) {
|
if (worldStr == null || worldStr.equals("")) {
|
||||||
world = war.getServer().getWorlds().get(0); // default to first world
|
world = War.war.getServer().getWorlds().get(0); // default to first world
|
||||||
} else {
|
} else {
|
||||||
world = war.getServer().getWorld(worldStr);
|
world = War.war.getServer().getWorld(worldStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
war.log("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!", Level.WARNING);
|
War.war.log("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!", Level.WARNING);
|
||||||
} else {
|
} else {
|
||||||
// Create the zone
|
// Create the zone
|
||||||
Warzone warzone = new Warzone(war, world, name);
|
Warzone warzone = new Warzone(world, name);
|
||||||
|
|
||||||
// Create file if needed
|
// Create file if needed
|
||||||
if (!warzoneConfig.containsKey("name")) {
|
if (!warzoneConfig.containsKey("name")) {
|
||||||
WarzoneMapper.save(war, warzone, false);
|
WarzoneMapper.save(warzone, false);
|
||||||
war.getLogger().info("Warzone " + name + " config file created.");
|
War.war.getLogger().info("Warzone " + name + " config file created.");
|
||||||
try {
|
try {
|
||||||
warzoneConfig.load();
|
warzoneConfig.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -93,7 +93,7 @@ public class WarzoneMapper {
|
|||||||
int yaw = Integer.parseInt(teamStrSplit[4]);
|
int yaw = Integer.parseInt(teamStrSplit[4]);
|
||||||
teamLocation.setYaw(yaw);
|
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, warzone);
|
||||||
team.setRemainingLives(warzone.getLifePool());
|
team.setRemainingLives(warzone.getLifePool());
|
||||||
warzone.getTeams().add(team);
|
warzone.getTeams().add(team);
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ public class WarzoneMapper {
|
|||||||
int monumentX = Integer.parseInt(monumentStrSplit[1]);
|
int monumentX = Integer.parseInt(monumentStrSplit[1]);
|
||||||
int monumentY = Integer.parseInt(monumentStrSplit[2]);
|
int monumentY = Integer.parseInt(monumentStrSplit[2]);
|
||||||
int monumentZ = Integer.parseInt(monumentStrSplit[3]);
|
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], warzone, new Location(world, monumentX, monumentY, monumentZ));
|
||||||
warzone.getMonuments().add(monument);
|
warzone.getMonuments().add(monument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,20 +242,20 @@ public class WarzoneMapper {
|
|||||||
warzoneConfig.close();
|
warzoneConfig.close();
|
||||||
|
|
||||||
if (createNewVolume) {
|
if (createNewVolume) {
|
||||||
ZoneVolume zoneVolume = new ZoneVolume(warzone.getName(), war, world, warzone); // VolumeMapper.loadZoneVolume(warzone.getName(), warzone.getName(), war, warzone.getWorld(), warzone);
|
ZoneVolume zoneVolume = new ZoneVolume(warzone.getName(), world, warzone); // VolumeMapper.loadZoneVolume(warzone.getName(), warzone.getName(), war, warzone.getWorld(), warzone);
|
||||||
warzone.setVolume(zoneVolume);
|
warzone.setVolume(zoneVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
// monument blocks
|
// monument blocks
|
||||||
for (Monument monument : warzone.getMonuments()) {
|
for (Monument monument : warzone.getMonuments()) {
|
||||||
monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), war, world));
|
monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), world));
|
||||||
}
|
}
|
||||||
|
|
||||||
// team spawn blocks
|
// team spawn blocks
|
||||||
for (Team team : warzone.getTeams()) {
|
for (Team team : warzone.getTeams()) {
|
||||||
team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), war, world));
|
team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), world));
|
||||||
if (team.getTeamFlag() != null) {
|
if (team.getTeamFlag() != null) {
|
||||||
team.setFlagVolume(VolumeMapper.loadVolume(team.getName() + "flag", warzone.getName(), war, world));
|
team.setFlagVolume(VolumeMapper.loadVolume(team.getName() + "flag", warzone.getName(), world));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,8 +271,8 @@ public class WarzoneMapper {
|
|||||||
} else if (lobbyStr.equals("west")) {
|
} else if (lobbyStr.equals("west")) {
|
||||||
lobbyFace = BlockFace.WEST;
|
lobbyFace = BlockFace.WEST;
|
||||||
}
|
}
|
||||||
Volume lobbyVolume = VolumeMapper.loadVolume("lobby", warzone.getName(), war, world);
|
Volume lobbyVolume = VolumeMapper.loadVolume("lobby", warzone.getName(), world);
|
||||||
ZoneLobby lobby = new ZoneLobby(war, warzone, lobbyFace, lobbyVolume);
|
ZoneLobby lobby = new ZoneLobby(warzone, lobbyFace, lobbyVolume);
|
||||||
warzone.setLobby(lobby);
|
warzone.setLobby(lobby);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,9 +281,9 @@ public class WarzoneMapper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(War war, Warzone warzone, boolean saveAllBlocks) {
|
public static void save(Warzone warzone, boolean saveAllBlocks) {
|
||||||
(new File(war.getDataFolder().getPath() + "/dat/warzone-" + warzone.getName())).mkdir();
|
(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + warzone.getName())).mkdir();
|
||||||
PropertiesFile warzoneConfig = new PropertiesFile(war.getDataFolder().getPath() + "/warzone-" + warzone.getName() + ".txt");
|
PropertiesFile warzoneConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + warzone.getName() + ".txt");
|
||||||
// war.getLogger().info("Saving warzone " + warzone.getName() + "...");
|
// war.getLogger().info("Saving warzone " + warzone.getName() + "...");
|
||||||
|
|
||||||
// name
|
// name
|
||||||
@ -446,19 +446,19 @@ public class WarzoneMapper {
|
|||||||
|
|
||||||
// monument blocks
|
// monument blocks
|
||||||
for (Monument monument : monuments) {
|
for (Monument monument : monuments) {
|
||||||
VolumeMapper.save(monument.getVolume(), warzone.getName(), war);
|
VolumeMapper.save(monument.getVolume(), warzone.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// team spawn & flag blocks
|
// team spawn & flag blocks
|
||||||
for (Team team : teams) {
|
for (Team team : teams) {
|
||||||
VolumeMapper.save(team.getSpawnVolume(), warzone.getName(), war);
|
VolumeMapper.save(team.getSpawnVolume(), warzone.getName());
|
||||||
if (team.getFlagVolume() != null) {
|
if (team.getFlagVolume() != null) {
|
||||||
VolumeMapper.save(team.getFlagVolume(), warzone.getName(), war);
|
VolumeMapper.save(team.getFlagVolume(), warzone.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warzone.getLobby() != null) {
|
if (warzone.getLobby() != null) {
|
||||||
VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName(), war);
|
VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (saveBlocks) {
|
// if (saveBlocks) {
|
||||||
@ -468,23 +468,23 @@ public class WarzoneMapper {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void delete(War war, String name) {
|
public static void delete(String name) {
|
||||||
File zoneFolder = new File(war.getDataFolder().getPath() + "/dat/warzone-" + name);
|
File zoneFolder = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name);
|
||||||
File[] files = zoneFolder.listFiles();
|
File[] files = zoneFolder.listFiles();
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
boolean deletedData = file.delete();
|
boolean deletedData = file.delete();
|
||||||
if (!deletedData) {
|
if (!deletedData) {
|
||||||
war.log("Failed to delete file " + file.getName(), Level.WARNING);
|
War.war.log("Failed to delete file " + file.getName(), Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean deletedData = zoneFolder.delete();
|
boolean deletedData = zoneFolder.delete();
|
||||||
if (!deletedData) {
|
if (!deletedData) {
|
||||||
war.log("Failed to delete folder " + zoneFolder.getName(), Level.WARNING);
|
War.war.log("Failed to delete folder " + zoneFolder.getName(), Level.WARNING);
|
||||||
}
|
}
|
||||||
File zoneFile = new File(war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
|
File zoneFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
|
||||||
deletedData = zoneFile.delete();
|
deletedData = zoneFile.delete();
|
||||||
if (!deletedData) {
|
if (!deletedData) {
|
||||||
war.log("Failed to delete file " + zoneFile.getName(), Level.WARNING);
|
War.war.log("Failed to delete file " + zoneFile.getName(), Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,26 +45,25 @@ public class ZoneVolumeMapper {
|
|||||||
*
|
*
|
||||||
* @param ZoneVolume volume Volume to load
|
* @param ZoneVolume volume Volume to load
|
||||||
* @param String zoneName Zone to load the volume from
|
* @param String zoneName Zone to load the volume from
|
||||||
* @param War war Instance of War
|
|
||||||
* @param World world The world the zone is located
|
* @param World world The world the zone is located
|
||||||
* @param boolean onlyLoadCorners Should only the corners be loaded
|
* @param boolean onlyLoadCorners Should only the corners be loaded
|
||||||
* @return integer Changed blocks
|
* @return integer Changed blocks
|
||||||
*/
|
*/
|
||||||
public static int load(ZoneVolume volume, String zoneName, War war, World world, boolean onlyLoadCorners) {
|
public static int load(ZoneVolume volume, String zoneName, World world, boolean onlyLoadCorners) {
|
||||||
File cornersFile = new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".corners");
|
File cornersFile = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".corners");
|
||||||
File blocksFile = new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".blocks");
|
File blocksFile = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".blocks");
|
||||||
File signsFile = new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".signs");
|
File signsFile = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".signs");
|
||||||
File invsFile = new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".invs");
|
File invsFile = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".invs");
|
||||||
int noOfResetBlocks = 0;
|
int noOfResetBlocks = 0;
|
||||||
if (!blocksFile.exists()) {
|
if (!blocksFile.exists()) {
|
||||||
// The post 1.6 formatted files haven't been created yet so
|
// The post 1.6 formatted files haven't been created yet so
|
||||||
// we need to use the old load.
|
// we need to use the old load.
|
||||||
noOfResetBlocks = PreDeGaulleZoneVolumeMapper.load(volume, zoneName, war, world, onlyLoadCorners);
|
noOfResetBlocks = PreDeGaulleZoneVolumeMapper.load(volume, zoneName, world, onlyLoadCorners);
|
||||||
|
|
||||||
// The new 1.6 files aren't created yet. We just reset the zone (except deferred blocks which will soon execute on main thread ),
|
// The new 1.6 files aren't created yet. We just reset the zone (except deferred blocks which will soon execute on main thread ),
|
||||||
// so let's save to the new format as soon as the zone is fully reset.
|
// so let's save to the new format as soon as the zone is fully reset.
|
||||||
ZoneVolumeMapper.saveAsJob(volume, zoneName, war, 2);
|
ZoneVolumeMapper.saveAsJob(volume, zoneName, 2);
|
||||||
war.log("Warzone " + zoneName + " file converted!", Level.INFO);
|
War.war.log("Warzone " + zoneName + " file converted!", Level.INFO);
|
||||||
|
|
||||||
return noOfResetBlocks;
|
return noOfResetBlocks;
|
||||||
} else {
|
} else {
|
||||||
@ -230,7 +229,7 @@ public class ZoneVolumeMapper {
|
|||||||
blockReads++;
|
blockReads++;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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());
|
War.war.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();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
z++;
|
z++;
|
||||||
@ -241,14 +240,14 @@ public class ZoneVolumeMapper {
|
|||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
if (!deferred.isEmpty()) {
|
if (!deferred.isEmpty()) {
|
||||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, deferred, 1);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, deferred, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
war.log("Failed to find volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to find volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to read volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@ -265,7 +264,7 @@ public class ZoneVolumeMapper {
|
|||||||
invsReader.close();
|
invsReader.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to close volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to close volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,10 +308,9 @@ public class ZoneVolumeMapper {
|
|||||||
*
|
*
|
||||||
* @param Volume volume Volume to save
|
* @param Volume volume Volume to save
|
||||||
* @param String zoneName The warzone the volume is located
|
* @param String zoneName The warzone the volume is located
|
||||||
* @param War war Instance of war
|
|
||||||
* @return integer Number of written blocks
|
* @return integer Number of written blocks
|
||||||
*/
|
*/
|
||||||
public static int save(Volume volume, String zoneName, War war) {
|
public static int save(Volume volume, String zoneName) {
|
||||||
int noOfSavedBlocks = 0;
|
int noOfSavedBlocks = 0;
|
||||||
if (volume.hasTwoCorners()) {
|
if (volume.hasTwoCorners()) {
|
||||||
BufferedWriter cornersWriter = null;
|
BufferedWriter cornersWriter = null;
|
||||||
@ -320,8 +318,8 @@ public class ZoneVolumeMapper {
|
|||||||
BufferedWriter signsWriter = null;
|
BufferedWriter signsWriter = null;
|
||||||
BufferedWriter invsWriter = null;
|
BufferedWriter invsWriter = null;
|
||||||
try {
|
try {
|
||||||
(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName)).mkdir();
|
(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName)).mkdir();
|
||||||
String path = war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName();
|
String path = War.war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName();
|
||||||
cornersWriter = new BufferedWriter(new FileWriter(new File(path + ".corners")));
|
cornersWriter = new BufferedWriter(new FileWriter(new File(path + ".corners")));
|
||||||
blocksOutput = new FileOutputStream(new File(path + ".blocks"));
|
blocksOutput = new FileOutputStream(new File(path + ".blocks"));
|
||||||
signsWriter = new BufferedWriter(new FileWriter(new File(path + ".signs")));
|
signsWriter = new BufferedWriter(new FileWriter(new File(path + ".signs")));
|
||||||
@ -433,7 +431,7 @@ public class ZoneVolumeMapper {
|
|||||||
}
|
}
|
||||||
noOfSavedBlocks++;
|
noOfSavedBlocks++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.log("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(), Level.WARNING);
|
War.war.log("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(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
z++;
|
z++;
|
||||||
@ -444,10 +442,10 @@ public class ZoneVolumeMapper {
|
|||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.log("Unexpected error caused failure to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Unexpected error caused failure to write volume file " + zoneName + " for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@ -464,7 +462,7 @@ public class ZoneVolumeMapper {
|
|||||||
invsWriter.close();
|
invsWriter.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.log("Failed to close volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to close volume file " + volume.getName() + " for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,9 +478,9 @@ public class ZoneVolumeMapper {
|
|||||||
* @param War war Instance of war
|
* @param War war Instance of war
|
||||||
* @param long tickDelay delay before beginning the task
|
* @param long tickDelay delay before beginning the task
|
||||||
*/
|
*/
|
||||||
private static void saveAsJob(ZoneVolume volume, String zoneName, War war, long tickDelay) {
|
private static void saveAsJob(ZoneVolume volume, String zoneName, long tickDelay) {
|
||||||
ZoneVolumeSaveJob job = new ZoneVolumeSaveJob(volume, zoneName, war);
|
ZoneVolumeSaveJob job = new ZoneVolumeSaveJob(volume, zoneName);
|
||||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job, tickDelay);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job, tickDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -491,12 +489,12 @@ public class ZoneVolumeMapper {
|
|||||||
* @param Volume volume volume to delete
|
* @param Volume volume volume to delete
|
||||||
* @param War war Instance of war
|
* @param War war Instance of war
|
||||||
*/
|
*/
|
||||||
public static void delete(Volume volume, War war) {
|
public static void delete(Volume volume) {
|
||||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".dat", war);
|
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".dat");
|
||||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".corners", war);
|
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".corners");
|
||||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".blocks", war);
|
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".blocks");
|
||||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".signs", war);
|
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".signs");
|
||||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".invs", war);
|
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".invs");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -505,12 +503,12 @@ public class ZoneVolumeMapper {
|
|||||||
* @param String path path of file
|
* @param String path path of file
|
||||||
* @param War war Instance of war
|
* @param War war Instance of war
|
||||||
*/
|
*/
|
||||||
private static void deleteFile(String path, War war) {
|
private static void deleteFile(String path) {
|
||||||
File volFile = new File(path);
|
File volFile = new File(path);
|
||||||
if (volFile.exists()) {
|
if (volFile.exists()) {
|
||||||
boolean deletedData = volFile.delete();
|
boolean deletedData = volFile.delete();
|
||||||
if (!deletedData) {
|
if (!deletedData) {
|
||||||
war.log("Failed to delete file " + volFile.getName(), Level.WARNING);
|
War.war.log("Failed to delete file " + volFile.getName(), Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,10 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
* @deprecated Broken, don't use.
|
||||||
* Broken, don't use.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class CenteredVolume extends Volume {
|
public class CenteredVolume extends Volume {
|
||||||
@ -20,8 +16,8 @@ public class CenteredVolume extends Volume {
|
|||||||
private int sideSize = -1;
|
private int sideSize = -1;
|
||||||
private final World world;
|
private final World world;
|
||||||
|
|
||||||
public CenteredVolume(String name, Block center, int sideSize, War war, World world) {
|
public CenteredVolume(String name, Block center, int sideSize, World world) {
|
||||||
super(name, war, world);
|
super(name, world);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.setCenter(center);
|
this.setCenter(center);
|
||||||
this.setSideSize(sideSize);
|
this.setSideSize(sideSize);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.tommytony.war.volumes;
|
package com.tommytony.war.volumes;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -8,15 +10,15 @@ import org.bukkit.block.BlockFace;
|
|||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class VerticalVolume extends Volume {
|
public class VerticalVolume extends Volume {
|
||||||
|
|
||||||
public VerticalVolume(String name, War war, World world) {
|
public VerticalVolume(String name, World world) {
|
||||||
super(name, war, world);
|
super(name, world);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +143,7 @@ public class VerticalVolume extends Volume {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.getWar().logWarn("Failed to reset wall " + wall + " in volume " + this.getName() + ". " + e.getClass().toString() + " " + e.getMessage());
|
War.war.log("Failed to reset wall " + wall + " in volume " + this.getName() + ". " + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
|
||||||
}
|
}
|
||||||
return noOfResetBlocks;
|
return noOfResetBlocks;
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,9 @@ public class Volume {
|
|||||||
private byte[][][] blockDatas = null;
|
private byte[][][] blockDatas = null;
|
||||||
private HashMap<String, String[]> signLines = new HashMap<String, String[]>();
|
private HashMap<String, String[]> signLines = new HashMap<String, String[]>();
|
||||||
private HashMap<String, List<ItemStack>> invBlockContents = new HashMap<String, List<ItemStack>>();
|
private HashMap<String, List<ItemStack>> invBlockContents = new HashMap<String, List<ItemStack>>();
|
||||||
private War war;
|
|
||||||
|
|
||||||
public Volume(String name, War war, World world) {
|
public Volume(String name, World world) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.war = war;
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +120,7 @@ public class Volume {
|
|||||||
|
|
||||||
noOfSavedBlocks++;
|
noOfSavedBlocks++;
|
||||||
} catch (Exception e) {
|
} 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());
|
War.war.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();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
z++;
|
z++;
|
||||||
@ -134,7 +132,7 @@ public class Volume {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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());
|
War.war.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();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return noOfSavedBlocks;
|
return noOfSavedBlocks;
|
||||||
@ -142,7 +140,7 @@ public class Volume {
|
|||||||
|
|
||||||
public void resetBlocksAsJob() {
|
public void resetBlocksAsJob() {
|
||||||
BlockResetJob job = new BlockResetJob(this);
|
BlockResetJob job = new BlockResetJob(this);
|
||||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, job);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int resetBlocks() {
|
public int resetBlocks() {
|
||||||
@ -270,7 +268,7 @@ public class Volume {
|
|||||||
}
|
}
|
||||||
visitedBlocks++;
|
visitedBlocks++;
|
||||||
} catch (Exception e) {
|
} 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());
|
War.war.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();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
z++;
|
z++;
|
||||||
@ -282,7 +280,7 @@ public class Volume {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.getWar().log("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(), Level.WARNING);
|
War.war.log("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(), Level.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return noOfResetBlocks;
|
return noOfResetBlocks;
|
||||||
@ -417,10 +415,6 @@ public class Volume {
|
|||||||
this.blockTypes = blockTypes;
|
this.blockTypes = blockTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public War getWar() {
|
|
||||||
return this.war;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -444,7 +438,7 @@ public class Volume {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.getWar().log("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,7 +463,7 @@ public class Volume {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.getWar().log("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +498,7 @@ public class Volume {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.getWar().log("Failed to switch block to " + newType + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
|
War.war.log("Failed to switch block to " + newType + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,6 +553,6 @@ public class Volume {
|
|||||||
this.signLines = null;
|
this.signLines = null;
|
||||||
this.invBlockContents.clear();
|
this.invBlockContents.clear();
|
||||||
this.invBlockContents = null;
|
this.invBlockContents = null;
|
||||||
this.war = null;
|
War.war = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,16 @@ public class ZoneVolume extends Volume {
|
|||||||
private Warzone zone;
|
private Warzone zone;
|
||||||
private boolean isSaved = false;
|
private boolean isSaved = false;
|
||||||
|
|
||||||
public ZoneVolume(String name, War war, World world, Warzone zone) {
|
public ZoneVolume(String name, World world, Warzone zone) {
|
||||||
super(name, war, world);
|
super(name, world);
|
||||||
this.zone = zone;
|
this.zone = zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int saveBlocks() {
|
public int saveBlocks() {
|
||||||
// Save blocks directly to disk (i.e. don't put everything in memory)
|
// Save blocks directly to disk (i.e. don't put everything in memory)
|
||||||
int saved = ZoneVolumeMapper.save(this, this.zone.getName(), this.getWar());
|
int saved = ZoneVolumeMapper.save(this, this.zone.getName());
|
||||||
this.getWar().log("Saved " + saved + " blocks in warzone " + this.zone.getName() + ".", java.util.logging.Level.INFO);
|
War.war.log("Saved " + saved + " blocks in warzone " + this.zone.getName() + ".", java.util.logging.Level.INFO);
|
||||||
this.isSaved = true;
|
this.isSaved = true;
|
||||||
return saved;
|
return saved;
|
||||||
}
|
}
|
||||||
@ -40,15 +40,15 @@ public class ZoneVolume extends Volume {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadCorners() {
|
public void loadCorners() {
|
||||||
ZoneVolumeMapper.load(this, this.zone.getName(), this.getWar(), this.getWorld(), true);
|
ZoneVolumeMapper.load(this, this.zone.getName(), this.getWorld(), true);
|
||||||
this.isSaved = true;
|
this.isSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int resetBlocks() {
|
public int resetBlocks() {
|
||||||
// Load blocks directly from disk and onto the map (i.e. no more in-memory warzone blocks)
|
// Load blocks directly from disk and onto the map (i.e. no more in-memory warzone blocks)
|
||||||
int reset = ZoneVolumeMapper.load(this, this.zone.getName(), this.getWar(), this.getWorld(), false);
|
int reset = ZoneVolumeMapper.load(this, this.zone.getName(), this.getWorld(), false);
|
||||||
this.getWar().log("Reset " + reset + " blocks in warzone " + this.zone.getName() + ".", java.util.logging.Level.INFO);
|
War.war.log("Reset " + reset + " blocks in warzone " + this.zone.getName() + ".", java.util.logging.Level.INFO);
|
||||||
this.isSaved = true;
|
this.isSaved = true;
|
||||||
return reset;
|
return reset;
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@ import org.junit.Test;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
|
||||||
|
|
||||||
import com.tommytony.war.*;
|
import com.tommytony.war.*;
|
||||||
import com.tommytony.war.volumes.*;
|
import com.tommytony.war.volumes.*;
|
||||||
|
|
||||||
@ -21,12 +19,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreatingAndNoCornersAreSet_shouldSetCorner1AtTop() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenCreatingAndNoCornersAreSet_shouldSetCorner1AtTop() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(0);
|
when(blockMock.getX()).thenReturn(0);
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -49,12 +47,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToEastOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToEastOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -83,12 +81,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToSouthOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToSouthOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -117,12 +115,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooCloseToCorner2_shouldThrowTooSmallException() throws NotNorthwestException, TooBigException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooCloseToCorner2_shouldThrowTooSmallException() throws NotNorthwestException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-5); // further south
|
when(blockMock.getX()).thenReturn(-5); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -151,12 +149,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooFarFromCorner2_shouldThrowTooBigException() throws NotNorthwestException, TooSmallException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooFarFromCorner2_shouldThrowTooBigException() throws NotNorthwestException, TooSmallException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-1000); // further south
|
when(blockMock.getX()).thenReturn(-1000); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -185,12 +183,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreatingAndCorner1AlreadySet_shouldSetCorner2AtTop() throws NotNorthwestException, TooSmallException, TooBigException{ // nw always goes to top
|
public void setNorthwest_whenCreatingAndCorner1AlreadySet_shouldSetCorner2AtTop() throws NotNorthwestException, TooSmallException, TooBigException{ // nw always goes to top
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -221,12 +219,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsEastOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsEastOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -255,12 +253,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsSouthOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsSouthOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -289,12 +287,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner1() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner1() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -328,12 +326,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner2() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner2() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -367,12 +365,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1XAndCorner2Z() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1XAndCorner2Z() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -406,12 +404,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1ZAndCorner2X() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1ZAndCorner2X() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -451,12 +449,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndNoCornersAreSet_shouldSetCorner2AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenCreatingAndNoCornersAreSet_shouldSetCorner2AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(0);
|
when(blockMock.getX()).thenReturn(0);
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -479,12 +477,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToWestOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToWestOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -513,12 +511,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToNorthOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToNorthOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -547,12 +545,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndCorner2AlreadySet_shouldSetCorner1AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{ // se always goes to bottom
|
public void setSoutheast_whenCreatingAndCorner2AlreadySet_shouldSetCorner1AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{ // se always goes to bottom
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -583,12 +581,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToWestOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToWestOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -617,12 +615,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToNorthOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToNorthOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(-64); // further north
|
when(blockMock.getX()).thenReturn(-64); // further north
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -651,12 +649,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner2() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner2() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -690,12 +688,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner1() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner1() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -729,12 +727,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1ZAndCorner2X() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1ZAndCorner2X() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
@ -768,12 +766,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1XAndCorner2Z() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1XAndCorner2Z() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
War warMock = mock(War.class);
|
|
||||||
World worldMock = mock(World.class);
|
World worldMock = mock(World.class);
|
||||||
Warzone zoneMock = mock(Warzone.class);
|
Warzone zoneMock = mock(Warzone.class);
|
||||||
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
when(zoneMock.getTeams()).thenReturn(new ArrayList<Team>());
|
||||||
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
when(zoneMock.getMonuments()).thenReturn(new ArrayList<Monument>());
|
||||||
ZoneVolume volume = new ZoneVolume("test", warMock, worldMock, zoneMock);
|
ZoneVolume volume = new ZoneVolume("test", worldMock, zoneMock);
|
||||||
Block blockMock = mock(Block.class);
|
Block blockMock = mock(Block.class);
|
||||||
when(blockMock.getX()).thenReturn(64); // further south
|
when(blockMock.getX()).thenReturn(64); // further south
|
||||||
when(blockMock.getY()).thenReturn(64); // at sea level
|
when(blockMock.getY()).thenReturn(64); // at sea level
|
||||||
|
Loading…
Reference in New Issue
Block a user