Huge (albiet still broken) changes. - Switched to Yaml config (stupid API). - Added team-specific settings. - Reworked entire configuration architechture and mechanic. War holds the War settings, the warzones defaults and the team defaults. Warzones hold their own config items which override the War default if they please (instead of being copied). Team settings add another level of defaults (unless specified, team settings are taken from the Warzone team defaults, or if absent, from the War team defaults). - Added /teamcfg command. - No more difference between default/extra loadouts.

This commit is contained in:
taoneill 2012-01-05 01:17:02 -05:00
parent dd6beb3b82
commit 983e90ca38
52 changed files with 4090 additions and 1242 deletions

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,9 @@ import com.tommytony.war.FlagReturn;
import com.tommytony.war.Monument;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarConfig;
import com.tommytony.war.config.WarzoneConfig;
/**
*
@ -89,8 +92,8 @@ public class WarBlockListener extends BlockListener {
}
// buildInZonesOnly
if (zone == null && War.war.isBuildInZonesOnly() && !War.war.canBuildOutsideZone(player)) {
if (!War.war.isDisableBuildMessage()) {
if (zone == null && War.war.getWarConfig().getBoolean(WarConfig.BUILDINZONESONLY) && !War.war.canBuildOutsideZone(player)) {
if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEBUILDMESSAGE)) {
War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
}
event.setCancelled(true);
@ -112,7 +115,7 @@ public class WarBlockListener extends BlockListener {
}
// unbreakableZoneBlocks
if (zone != null && zone.isUnbreakableZoneBlocks() && (!isZoneMaker || (isZoneMaker && team != null))) {
if (zone != null && zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE) && (!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)
War.war.badMsg(player, "The blocks in this zone are unbreakable - this also means you can't build!");
event.setCancelled(true);
@ -169,7 +172,7 @@ public class WarBlockListener extends BlockListener {
Player player = event.getPlayer();
Block block = event.getBlock();
Warzone playerZone = Warzone.getZoneByLocation(player);
if (player != null && block != null && playerZone != null && playerZone.isInstaBreak()) {
if (player != null && block != null && playerZone != null && playerZone.getWarzoneConfig().getBoolean(WarzoneConfig.INSTABREAK)) {
Warzone blockZone = Warzone.getZoneByLocation(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
if (blockZone != null && blockZone == playerZone) {
event.setInstaBreak(true);
@ -232,8 +235,9 @@ public class WarBlockListener extends BlockListener {
block.setType(Material.AIR);
String spawnOrFlag = "spawn or flag";
if (warzone.getFlagReturn() == FlagReturn.FLAG || warzone.getFlagReturn() == FlagReturn.SPAWN) {
spawnOrFlag = warzone.getFlagReturn().toString();
if (team.getTeamConfig().getFlagReturn(TeamConfig.FLAGRETURN).equals(FlagReturn.FLAG)
|| team.getTeamConfig().getFlagReturn(TeamConfig.FLAGRETURN) == FlagReturn.SPAWN) {
spawnOrFlag = team.getTeamConfig().getFlagReturn(TeamConfig.FLAGRETURN).toString();
}
for (Team t : warzone.getTeams()) {
@ -288,8 +292,8 @@ public class WarBlockListener extends BlockListener {
// buildInZonesOnly
Warzone blockZone = Warzone.getZoneByLocation(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
if (blockZone == null && War.war.isBuildInZonesOnly() && !War.war.canBuildOutsideZone(player)) {
if (!War.war.isDisableBuildMessage()) {
if (blockZone == null && War.war.getWarConfig().getBoolean(WarConfig.BUILDINZONESONLY) && !War.war.canBuildOutsideZone(player)) {
if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEBUILDMESSAGE)) {
War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
}
event.setCancelled(true);
@ -297,7 +301,7 @@ public class WarBlockListener extends BlockListener {
}
// unbreakableZoneBlocks
if (blockZone != null && blockZone.isUnbreakableZoneBlocks() && (!isZoneMaker || (isZoneMaker && team != null))) {
if (blockZone != null && blockZone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE) && (!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
War.war.badMsg(player, "The blocks in this zone are unbreakable!");
event.setCancelled(true);

View File

@ -93,6 +93,8 @@ public class WarCommandHandler {
commandObj = new SetMonumentCommand(this, sender, arguments);
} else if (command.equals("deletemonument")) {
commandObj = new DeleteMonumentCommand(this, sender, arguments);
} else if (command.equals("setteamconfig") || command.equals("teamcfg")) {
commandObj = new SetTeamConfigCommand(this, sender, arguments);
} else if (command.equals("setzoneconfig") || command.equals("zonecfg")) {
commandObj = new SetZoneConfigCommand(this, sender, arguments);
} else if (command.equals("setwarhub")) {

View File

@ -33,6 +33,9 @@ import org.bukkit.inventory.ItemStack;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.jobs.DeferredBlockResetsJob;
import com.tommytony.war.utils.DeferredBlockReset;
@ -99,7 +102,7 @@ public class WarEntityListener extends EntityListener {
return;
}
if (!attackerWarzone.isPvpInZone()) {
if (!attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.PVPINZONE)) {
// spleef-like, non-pvp, zone
event.setCancelled(true);
return;
@ -151,7 +154,7 @@ public class WarEntityListener extends EntityListener {
}
} else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
// same team, but not same person
if (attackerWarzone.getFriendlyFire()) {
if (attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.FRIENDLYFIRE)) {
War.war.badMsg(a, "Friendly fire is on! Please, don't hurt your teammates."); // if ff is on, let the attack go through
} else {
War.war.badMsg(a, "Your attack missed! Your target is on your team.");
@ -160,7 +163,7 @@ public class WarEntityListener extends EntityListener {
} else if (attackerTeam == null && defenderTeam == null && War.war.canPvpOutsideZones(a)) {
// let normal PVP through is its not turned off or if you have perms
} else if (attackerTeam == null && defenderTeam == null && !War.war.canPvpOutsideZones(a)) {
if (!War.war.isDisablePvpMessage()) {
if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEPVPMESSAGE)) {
War.war.badMsg(a, "You need the 'war.pvp' permission to attack players outside warzones.");
}
event.setCancelled(true); // global pvp is off
@ -218,7 +221,7 @@ public class WarEntityListener extends EntityListener {
boolean explosionInAWarzone = event.getEntity() != null && Warzone.getZoneByLocation(event.getEntity().getLocation()) != null;
if (!explosionInAWarzone && War.war.isTntInZonesOnly() && event.getEntity() instanceof TNTPrimed) {
if (!explosionInAWarzone && War.war.getWarConfig().getBoolean(WarConfig.TNTINZONESONLY) && event.getEntity() instanceof TNTPrimed) {
// if tntinzonesonly:true, no tnt blows up outside zones
event.setCancelled(true);
return;
@ -394,7 +397,7 @@ public class WarEntityListener extends EntityListener {
Location location = event.getLocation();
Warzone zone = Warzone.getZoneByLocation(location);
if (zone != null && zone.isNoCreatures()) {
if (zone != null && zone.getWarzoneConfig().getBoolean(WarzoneConfig.NOCREATURES)) {
event.setCancelled(true);
}
}
@ -421,9 +424,10 @@ public class WarEntityListener extends EntityListener {
Player player = (Player) entity;
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
if (zone != null) {
Team team = Team.getTeamByPlayerName(player.getName());
if ((event.getRegainReason() == RegainReason.EATING
|| event.getRegainReason().toString() != "SATIATED" )
&& zone.isNoHunger()) {
&& team.getTeamConfig().getBoolean(TeamConfig.NOHUNGER)) {
// noHunger setting means you can't auto-heal with full hunger bar (use saturation instead to control how fast you get hungry)
event.setCancelled(true);
} else if (event.getRegainReason() == RegainReason.REGEN) {
@ -441,7 +445,8 @@ public class WarEntityListener extends EntityListener {
Player player = (Player) event.getEntity();
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
if (zone != null && zone.isNoHunger()){
Team team = Team.getTeamByPlayerName(player.getName());
if (zone != null && team.getTeamConfig().getBoolean(TeamConfig.NOHUNGER)){
event.setCancelled(true);
}
}

View File

@ -34,6 +34,8 @@ import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.ZoneSetter;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig;
/**
* @author tommytony, Tim Düsterhus
@ -75,7 +77,7 @@ public class WarPlayerListener extends PlayerListener {
// a flag thief can't drop his flag
War.war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
event.setCancelled(true);
} else if (zone.isNoDrops()) {
} else if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.NODROPS)) {
War.war.badMsg(player, "Can't drop items in this warzone.");
event.setCancelled(true);
} else {
@ -270,12 +272,12 @@ public class WarPlayerListener extends PlayerListener {
Warzone playerWarzone = Warzone.getZoneByPlayerName(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
boolean protecting = false;
if (currentTeam != null) {
if (playerWarzone.isGlassWalls()) {
if (playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.GLASSWALLS)) {
protecting = playerWarzone.protectZoneWallAgainstPlayer(player);
}
} else {
Warzone nearbyZone = War.war.zoneOfZoneWallAtProximity(playerLoc);
if (nearbyZone != null && nearbyZone.isGlassWalls() && !isMaker) {
if (nearbyZone != null && nearbyZone.getWarzoneConfig().getBoolean(WarzoneConfig.GLASSWALLS) && !isMaker) {
protecting = nearbyZone.protectZoneWallAgainstPlayer(player);
}
}
@ -296,15 +298,18 @@ public class WarPlayerListener extends PlayerListener {
if (oldTeam == null && canPlay) { // trying to counter spammy player move
isAutoAssignGate = zone.getLobby().isAutoAssignGate(playerLoc);
if (isAutoAssignGate) {
if (zone.isDisabled()) {
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
this.handleDisabledZone(event, player, zone);
} else {
this.dropFromOldTeamIfAny(player);
int noOfPlayers = 0;
int totalCap = 0;
for (Team t : zone.getTeams()) {
noOfPlayers += t.getPlayers().size();
totalCap += t.getTeamConfig().getInt(TeamConfig.MAXSCORE);
}
if (noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
if (noOfPlayers < totalCap) {
zone.autoAssign(player);
if (War.war.getWarHub() != null) {
@ -323,9 +328,9 @@ public class WarPlayerListener extends PlayerListener {
for (Team team : zone.getTeams()) {
if (zone.getLobby().isInTeamGate(team, playerLoc)) {
this.dropFromOldTeamIfAny(player);
if (zone.isDisabled()) {
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
this.handleDisabledZone(event, player, zone);
} else if (team.getPlayers().size() < zone.getTeamCap()) {
} else if (team.getPlayers().size() < team.getTeamConfig().getInt(TeamConfig.TEAMSIZE)) {
team.addPlayer(player);
team.resetSign();
if (War.war.getWarHub() != null) {
@ -433,12 +438,13 @@ public class WarPlayerListener extends PlayerListener {
if (!playerTeam.getSpawnVolume().contains(playerLoc)) {
if (!playerWarzone.isEnoughPlayers()) {
War.war.badMsg(player, "Can't leave spawn until there's a minimum of " + playerWarzone.getMinPlayers() +" player(s) on at least " + playerWarzone.getMinTeams() + " team(s).");
War.war.badMsg(player, "Can't leave spawn until there's a minimum of " + playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINPLAYERS)
+" player(s) on at least " + playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINTEAMS) + " team(s).");
event.setTo(playerTeam.getTeamSpawn());
return;
}
if (playerWarzone.isRespawning(player)) {
int rt = playerWarzone.getRespawnTimer();
int rt = playerTeam.getTeamConfig().getInt(TeamConfig.RESPAWNTIMER);
String isS = "s";
if (rt==1) isS = "";
War.war.badMsg(player, "Can't leave spawn for "+rt+" second"+isS+" after spawning!");
@ -451,7 +457,7 @@ public class WarPlayerListener extends PlayerListener {
if (playerTeam != null && playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam) && player.getHealth() < 20 && player.getHealth() > 0 // don't heal the dead
&& this.random.nextInt(7) == 3) { // one chance out of many of getting healed
int currentHp = player.getHealth();
int newHp = Math.min(20, currentHp + locZone.getMonumentHeal());
int newHp = Math.min(20, currentHp + locZone.getWarzoneConfig().getInt(WarzoneConfig.MONUMENTHEAL));
player.setHealth(newHp);
String isS = "s";
@ -473,18 +479,18 @@ public class WarPlayerListener extends PlayerListener {
boolean inSpawn = playerTeam.getSpawnVolume().contains(player.getLocation());
boolean inFlag = (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation()));
if (playerWarzone.getFlagReturn() == FlagReturn.BOTH) {
if (playerTeam.getTeamConfig().getFlagReturn(TeamConfig.FLAGRETURN).equals(FlagReturn.BOTH)) {
if (!inSpawn && !inFlag) {
return;
}
} else if (playerWarzone.getFlagReturn() == FlagReturn.SPAWN) {
} else if (playerTeam.getTeamConfig().getFlagReturn(TeamConfig.FLAGRETURN).equals(FlagReturn.SPAWN)) {
if (inFlag) {
War.war.badMsg(player, "You have to capture the enemy flag at your team's spawn.");
return;
} else if (!inSpawn) {
return;
}
} else if (playerWarzone.getFlagReturn() == FlagReturn.FLAG) {
} else if (playerTeam.getTeamConfig().getFlagReturn(TeamConfig.FLAGRETURN).equals(FlagReturn.FLAG)) {
if (inSpawn) {
War.war.badMsg(player, "You have to capture the enemy flag at your team's flag.");
return;
@ -493,13 +499,13 @@ public class WarPlayerListener extends PlayerListener {
}
}
if (playerWarzone.isTeamFlagStolen(playerTeam) && playerWarzone.isFlagMustBeHome()) {
if (playerWarzone.isTeamFlagStolen(playerTeam) && playerTeam.getTeamConfig().getBoolean(TeamConfig.FLAGMUSTBEHOME)) {
War.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
} else {
synchronized (playerWarzone) {
// flags can be captured at own spawn or own flag pole
playerTeam.addPoint();
if (playerTeam.getPoints() >= playerWarzone.getScoreCap()) {
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().getInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
@ -554,11 +560,11 @@ public class WarPlayerListener extends PlayerListener {
if (War.war.isLoaded() && event.isSneaking()) {
Warzone playerWarzone = Warzone.getZoneByLocation(event.getPlayer());
Team playerTeam = Team.getTeamByPlayerName(event.getPlayer().getName());
if (playerWarzone != null && playerTeam != null && playerWarzone.getExtraLoadouts().keySet().size() > 0 && playerTeam.getSpawnVolume().contains(event.getPlayer().getLocation())) {
if (playerWarzone != null && playerTeam != null && playerTeam.getInventories().resolveLoadouts().keySet().size() > 1 && playerTeam.getSpawnVolume().contains(event.getPlayer().getLocation())) {
if (playerWarzone.getLoadoutSelections().keySet().contains(event.getPlayer().getName())
&& playerWarzone.getLoadoutSelections().get(event.getPlayer().getName()).isStillInSpawn()) {
LoadoutSelection selection = playerWarzone.getLoadoutSelections().get(event.getPlayer().getName());
int currentIndex = (selection.getSelectedIndex() + 1) % (playerWarzone.getExtraLoadouts().keySet().size() + 1);
int currentIndex = (selection.getSelectedIndex() + 1) % (playerTeam.getInventories().resolveLoadouts().keySet().size());
selection.setSelectedIndex(currentIndex);
playerWarzone.equipPlayerLoadoutSelection(event.getPlayer(), playerTeam, false, true);

View File

@ -14,6 +14,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig;
public class WarSpoutListener extends SpoutListener {
static Plugin plugin;
@ -72,34 +73,31 @@ public class WarSpoutListener extends SpoutListener {
}
// is there even a score cap (or is it just 1 point)?
if (zone.getScoreCap()>1) {
linecounter = 0;
for (Team t : zone.getTeams()) {
// scores
line = new GenericLabel(t.getPoints()+"/"+zone.getScoreCap()+" points");
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3+teammax+15+playmax+15).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
scorelines.add(line);
linecounter++;
}
// I bet you know what is done here!
for (GenericLabel l : scorelines) {
if (GenericLabel.getStringWidth(l.getText()) > scoremax) scoremax=GenericLabel.getStringWidth(l.getText());
}
linecounter = 0;
for (Team t : zone.getTeams()) {
// scores
line = new GenericLabel(t.getPoints()+"/"+t.getTeamConfig().getInt(TeamConfig.MAXSCORE)+" points");
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3+teammax+15+playmax+15).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
scorelines.add(line);
linecounter++;
}
// I bet you know what is done here!
for (GenericLabel l : scorelines) {
if (GenericLabel.getStringWidth(l.getText()) > scoremax) scoremax=GenericLabel.getStringWidth(l.getText());
}
// and finally, lives.
if (zone.getLifePool()>1) {
linecounter = 0;
for (Team t : zone.getTeams()) {
line = new GenericLabel(t.getRemainingLifes()+"/"+zone.getLifePool()+" lives");
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3+teammax+15+playmax+15+scoremax+15).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
scorelines.add(line);
linecounter++;
}
linecounter = 0;
for (Team t : zone.getTeams()) {
line = new GenericLabel(t.getRemainingLifes()+"/"+t.getTeamConfig().getInt(TeamConfig.LIFEPOOL)+" lives");
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3+teammax+15+playmax+15+scoremax+15).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
scorelines.add(line);
linecounter++;
}
// Now to print it to the Spout players!

View File

@ -3,12 +3,12 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Monument;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Deletes a monument.
@ -55,7 +55,7 @@ public class DeleteMonumentCommand extends AbstractZoneMakerCommand {
if (monument != null) {
monument.getVolume().resetBlocks();
zone.getMonuments().remove(monument);
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
this.msg("Monument " + monument.getName() + " removed.");
} else {
this.badMsg("No such monument.");

View File

@ -3,13 +3,13 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.TeamKind;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Deletes a team.
@ -62,7 +62,7 @@ public class DeleteTeamCommand extends AbstractZoneMakerCommand {
if (zone.getLobby() != null) {
zone.getLobby().initialize();
}
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
this.msg("Team " + team.getName() + " removed.");
} else {
this.badMsg("No such team.");

View File

@ -8,7 +8,7 @@ import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneMapper;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Deletes a monument.
@ -60,7 +60,7 @@ public class DeleteTeamFlagCommand extends AbstractZoneMakerCommand {
if (teamFlagTeam != null) {
teamFlagTeam.deleteTeamFlag();
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
this.msg(teamFlagTeam.getName() + " flag removed.");
} else {
this.badMsg("No such team flag.");

View File

@ -2,15 +2,14 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import com.tommytony.war.Warzone;
import com.tommytony.war.WarHub;
import com.tommytony.war.mappers.VolumeMapper;
import com.tommytony.war.mappers.WarMapper;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.VolumeMapper;
import com.tommytony.war.mappers.WarYmlMapper;
/**
* Deletes the warhub.
*
@ -43,7 +42,7 @@ public class DeleteWarhubCommand extends AbstractWarAdminCommand {
} else {
this.badMsg("No War hub to delete.");
}
WarMapper.save();
WarYmlMapper.save();
return true;
}

View File

@ -3,15 +3,15 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Monument;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarMapper;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.mappers.WarYmlMapper;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Deletes a warzone.
@ -70,8 +70,8 @@ public class DeleteZoneCommand extends AbstractZoneMakerCommand {
}
zone.getVolume().resetBlocks();
War.war.getWarzones().remove(zone);
WarMapper.save();
WarzoneMapper.delete(zone.getName());
WarYmlMapper.save();
WarzoneYmlMapper.delete(zone.getName());
if (War.war.getWarHub() != null) { // warhub has to change
War.war.getWarHub().getVolume().resetBlocks();
War.war.getWarHub().initialize();

View File

@ -12,6 +12,8 @@ import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig;
/**
* Joins a team.
@ -91,7 +93,7 @@ public class JoinCommand extends AbstractWarCommand {
// join new team
if (zone.isDisabled()) {
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
this.msg("This warzone is disabled.");
} else {
List<Team> teams = zone.getTeams();
@ -102,7 +104,7 @@ public class JoinCommand extends AbstractWarCommand {
zone.keepPlayerState(player);
this.msg("Your inventory is in storage until you use '/war leave'.");
}
if (team.getPlayers().size() < zone.getTeamCap()) {
if (team.getPlayers().size() < team.getTeamConfig().getInt(TeamConfig.TEAMSIZE)) {
team.addPlayer(player);
team.resetSign();
zone.respawnPlayer(team, player);

View File

@ -6,15 +6,16 @@ import java.util.logging.Level;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.PropertiesFile;
import com.tommytony.war.mappers.WarMapper;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.mappers.PropertiesFile;
import com.tommytony.war.mappers.WarYmlMapper;
import com.tommytony.war.mappers.WarzoneYmlMapper;
public class RenameZoneCommand extends AbstractZoneMakerCommand {
public RenameZoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args);
@ -74,20 +75,20 @@ public class RenameZoneCommand extends AbstractZoneMakerCommand {
warzoneConfig.close();
War.war.log("Loading zone " + this.args[0] + "...", Level.INFO);
Warzone newZone = WarzoneMapper.load(this.args[0], false);
Warzone newZone = WarzoneYmlMapper.load(this.args[0], false);
War.war.getWarzones().add(newZone);
// zone.getVolume().loadCorners();
newZone.getVolume().loadCorners();
if (newZone.getLobby() != null) {
newZone.getLobby().getVolume().resetBlocks();
}
if (newZone.isResetOnLoad()) {
if (newZone.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONLOAD)) {
newZone.getVolume().resetBlocks();
}
newZone.initializeZone();
// save war config
WarMapper.save();
WarYmlMapper.save();
if (War.war.getWarHub() != null) { // warhub has to change
War.war.getWarHub().getVolume().resetBlocks();

View File

@ -8,7 +8,7 @@ import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneMapper;
import com.tommytony.war.mappers.WarzoneYmlMapper;
public class SaveZoneCommand extends AbstractZoneMakerCommand {
@ -67,7 +67,7 @@ public class SaveZoneCommand extends AbstractZoneMakerCommand {
// changed settings: must reinitialize with new settings
String namedParamResult = War.war.updateZoneFromNamedParams(zone, commandSender, this.args);
WarzoneMapper.save(zone, true);
WarzoneYmlMapper.save(zone, true);
if (this.args.length > 0) {
// the config may have changed, requiring a reset for spawn styles etc.
zone.getVolume().resetBlocks();

View File

@ -3,11 +3,11 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Monument;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Places a monument
@ -44,22 +44,20 @@ public class SetMonumentCommand extends AbstractZoneMakerCommand {
return false;
}
Warzone warzone = Warzone.getZoneByLocation(player);
if (warzone.hasMonument(this.args[0])) {
if (zone.hasMonument(this.args[0])) {
// move the existing monument
Monument monument = warzone.getMonument(this.args[0]);
Monument monument = zone.getMonument(this.args[0]);
monument.getVolume().resetBlocks();
monument.setLocation(player.getLocation());
this.msg("Monument " + monument.getName() + " was moved.");
} else {
// create a new monument
Monument monument = new Monument(this.args[0], warzone, player.getLocation());
warzone.getMonuments().add(monument);
Monument monument = new Monument(this.args[0], zone, player.getLocation());
zone.getMonuments().add(monument);
this.msg("Monument " + monument.getName() + " created.");
}
WarzoneMapper.save(warzone, false);
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
return true;
}

View File

@ -3,12 +3,13 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Places a soawn
@ -53,7 +54,7 @@ public class SetTeamCommand extends AbstractZoneMakerCommand {
} else {
// new team (use default TeamKind name for now)
Team newTeam = new Team(teamKind.toString(), teamKind, player.getLocation(), zone);
newTeam.setRemainingLives(zone.getLifePool());
newTeam.setRemainingLives(newTeam.getTeamConfig().getInt(TeamConfig.LIFEPOOL));
zone.getTeams().add(newTeam);
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
@ -64,7 +65,7 @@ public class SetTeamCommand extends AbstractZoneMakerCommand {
}
}
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
return true;
}

View File

@ -0,0 +1,146 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneYmlMapper;
public class SetTeamConfigCommand extends AbstractZoneMakerCommand {
public SetTeamConfigCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args);
}
@Override
public boolean handle() {
Warzone zone = null;
Player player = null;
CommandSender commandSender = this.getSender();
boolean isFirstParamWarzone = false;
boolean wantsToPrint = false;
if (this.args.length == 0) {
return false;
} else {
if (!this.args[0].contains(":")) {
// warzone name maybe in first place
Warzone zoneByName = Warzone.getZoneByName(this.args[0]);
if (zoneByName != null) {
zone = zoneByName;
isFirstParamWarzone = true;
} else if (this.args[0].equals("-p") || this.args[0].equals("print")) {
wantsToPrint = true;
}
}
if (this.getSender() instanceof Player) {
player = (Player) commandSender;
Warzone zoneByLoc = Warzone.getZoneByLocation(player);
ZoneLobby lobbyByLoc = ZoneLobby.getLobbyByLocation(player);
if (zoneByLoc == null && lobbyByLoc != null) {
zoneByLoc = lobbyByLoc.getZone();
}
if (zoneByLoc != null) {
zone = zoneByLoc;
}
}
if (zone == null) {
// No warzone found, whatever the mean, escape
return false;
} else if (!this.isSenderAuthorOfZone(zone)) {
return true;
}
if (isFirstParamWarzone) {
if (this.args.length == 1) {
// Only one param: the warzone name - default to usage
return false;
}
// More than one param: the arguments need to be shifted
String[] newargs = new String[this.args.length - 1];
for (int i = 1; i < this.args.length; i++) {
newargs[i - 1] = this.args[i];
}
this.args = newargs;
}
// args have been shifted if needed
Team team = null;
if (this.args.length > 0) {
// only printing
TeamKind kind = TeamKind.teamKindFromString(this.args[0]);
team = zone.getTeamByKind(kind);
if (team == null) {
// Team not found
return false;
}
// first param was team, shift again
String[] newargs = new String[this.args.length - 1];
for (int i = 1; i < this.args.length; i++) {
newargs[i - 1] = this.args[i];
}
this.args = newargs;
} else {
// No team param, show usage
return false;
}
if (this.args.length > 0 && (this.args[0].equals("-p") || this.args[0].equals("print"))) {
// only printing
if (this.args.length == 1) {
this.msg(War.war.printConfig(zone));
return true;
} else {
// first param was to print, shift again
String[] newargs = new String[this.args.length - 1];
for (int i = 1; i < this.args.length; i++) {
newargs[i - 1] = this.args[i];
}
this.args = newargs;
}
wantsToPrint = true;
}
// We have a warzone, a team and indexed-from-0 arguments, let's update
String namedParamReturn = War.war.updateTeamFromNamedParams(team, player, this.args);
if (!namedParamReturn.equals("") && !namedParamReturn.equals("PARSE-ERROR")) {
this.msg("Saving config and resetting warzone " + zone.getName() + ".");
WarzoneYmlMapper.save(zone, false);
zone.getVolume().resetBlocks();
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
}
zone.initializeZone(); // bring back team spawns etc
if (wantsToPrint) {
this.msg("Team config saved. Zone reset." + namedParamReturn + " " + War.war.printConfig(team));
} else {
this.msg("Team config saved. Zone reset." + namedParamReturn);
}
if (War.war.getWarHub() != null) { // maybe the zone was disabled/enabled
War.war.getWarHub().getVolume().resetBlocks();
War.war.getWarHub().initialize();
}
} else if (namedParamReturn.equals("PARSE-ERROR")) {
this.badMsg("Failed to read named parameter(s).");
} else {
// empty return means no param was parsed - print command usage
return false;
}
return true;
}
}
}

View File

@ -4,12 +4,12 @@ import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Places a teamflag
@ -52,7 +52,7 @@ public class SetTeamFlagCommand extends AbstractZoneMakerCommand {
Location playerLoc = player.getLocation();
player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
this.msg("Team " + team.getName() + " flag added here.");
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
} else {
// relocate flag
team.getFlagVolume().resetBlocks();
@ -60,7 +60,7 @@ public class SetTeamFlagCommand extends AbstractZoneMakerCommand {
Location playerLoc = player.getLocation();
player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ() + 1));
this.msg("Team " + team.getName() + " flag moved.");
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
}
return true;

View File

@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.mappers.WarMapper;
import com.tommytony.war.mappers.WarYmlMapper;
public class SetWarConfigCommand extends AbstractWarAdminCommand {
@ -28,7 +28,7 @@ public class SetWarConfigCommand extends AbstractWarAdminCommand {
String namedParamReturn = War.war.updateFromNamedParams(this.getSender(), this.args);
if (!namedParamReturn.equals("") && !namedParamReturn.equals("PARSE-ERROR")) {
WarMapper.save();
WarYmlMapper.save();
if (wantsToPrint) {
String config = War.war.printConfig();
this.msg("War config saved." + namedParamReturn + " " + config);

View File

@ -3,13 +3,13 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarMapper;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarYmlMapper;
/**
* Places the warhub
*
@ -50,7 +50,7 @@ public class SetWarHubCommand extends AbstractWarAdminCommand {
}
this.msg("War hub created.");
}
WarMapper.save();
WarYmlMapper.save();
} else {
this.msg("No warzones yet.");
}

View File

@ -8,7 +8,7 @@ import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneMapper;
import com.tommytony.war.mappers.WarzoneYmlMapper;
public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
@ -92,7 +92,7 @@ public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
String namedParamReturn = War.war.updateZoneFromNamedParams(zone, player, this.args);
if (!namedParamReturn.equals("") && !namedParamReturn.equals("PARSE-ERROR")) {
this.msg("Saving config and resetting warzone " + zone.getName() + ".");
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
zone.getVolume().resetBlocks();
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();

View File

@ -4,13 +4,13 @@ import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Places the zonelobby
*
@ -66,7 +66,7 @@ public class SetZoneLobbyCommand extends AbstractZoneMakerCommand {
}
this.msg("Warzone lobby moved to your location.");
}
WarzoneMapper.save(givenWarzone, false);
WarzoneYmlMapper.save(givenWarzone, false);
}
} else if (!this.isSenderAuthorOfZone(zone)) {
return true;
@ -110,7 +110,7 @@ public class SetZoneLobbyCommand extends AbstractZoneMakerCommand {
}
this.msg("Warzone lobby created on " + wallStr + "side of zone.");
}
WarzoneMapper.save(zone, false);
WarzoneYmlMapper.save(zone, false);
}
return true;

View File

@ -3,11 +3,11 @@ package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.tommytony.war.mappers.WarMapper;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.mappers.WarYmlMapper;
/**
* Makes a player zonemaker and other way round.
*
@ -71,7 +71,7 @@ public class ZoneMakerCommand extends AbstractWarCommand {
War.war.getZoneMakersImpersonatingPlayers().remove(player.getName());
this.msg("You are back as a zone maker.");
WarMapper.save();
WarYmlMapper.save();
}
return true;

View File

@ -10,9 +10,13 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarSpoutListener;
import com.tommytony.war.config.InventoryBag;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.TeamConfigBag;
import com.tommytony.war.utils.SignHelper;
import com.tommytony.war.volumes.Volume;
@ -32,9 +36,12 @@ public class Team {
private Volume flagVolume;
private final Warzone warzone;
private TeamKind kind;
private InventoryBag inventories = new InventoryBag();
private TeamConfigBag teamConfig;
public Team(String name, TeamKind kind, Location teamSpawn, Warzone warzone) {
this.warzone = warzone;
this.teamConfig = new TeamConfigBag(warzone);
this.setName(name);
this.teamSpawn = teamSpawn;
this.setSpawnVolume(new Volume(name, warzone.getWorld()));
@ -64,10 +71,10 @@ public class Team {
int y = this.teamSpawn.getBlockY();
int z = this.teamSpawn.getBlockZ();
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.INVISIBLE)) {
if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.INVISIBLE)) {
this.spawnVolume.setCornerOne(this.warzone.getWorld().getBlockAt(x, y - 1, z));
this.spawnVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x, y + 3, z));
} else if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.SMALL)) {
} else if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.SMALL)) {
this.spawnVolume.setCornerOne(this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1));
this.spawnVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x + 1, y + 3, z + 1));
} else {
@ -87,7 +94,7 @@ public class Team {
int y = this.teamSpawn.getBlockY();
int z = this.teamSpawn.getBlockZ();
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.INVISIBLE)) {
if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.INVISIBLE)) {
// nothing but glowstone
this.warzone.getWorld().getBlockAt(x, y - 1, z).setType(Material.GLOWSTONE);
} else {
@ -113,7 +120,7 @@ public class Team {
Block signBlock = null;
int signData = 0;
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.INVISIBLE)) {
if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.INVISIBLE)) {
// INVISIBLE style
signBlock = this.warzone.getWorld().getBlockAt(x, y, z);
if (yaw >= 0 && yaw < 90) {
@ -125,7 +132,7 @@ public class Team {
} else if (yaw >= 270 && yaw <= 360) {
signData = 6;
}
} else if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.SMALL)) {
} else if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.SMALL)) {
// SMALL style
if (yaw >= 0 && yaw < 90) {
signData = 10;
@ -171,7 +178,7 @@ public class Team {
signData = 10;
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.WEST, 2);
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) {
if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.BIG)) {
// rim
this.setBlock(x - 2, y, z - 1, this.kind);
this.setBlock(x - 2, y, z - 2, this.kind);
@ -203,7 +210,7 @@ public class Team {
opposite = BlockFace.SOUTH_WEST;
signData = 14;
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.NORTH, 2).getRelative(BlockFace.EAST, 2);
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) {
if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.BIG)) {
// rim
this.setBlock(x + 1, y, z - 2, this.kind);
this.setBlock(x + 2, y, z - 2, this.kind);
@ -235,7 +242,7 @@ public class Team {
opposite = BlockFace.NORTH_WEST;
signData = 2;
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.EAST, 2);
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) {
if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.BIG)) {
// rim
this.setBlock(x + 2, y, z + 1, this.kind);
this.setBlock(x + 2, y, z + 2, this.kind);
@ -267,7 +274,7 @@ public class Team {
opposite = BlockFace.NORTH_EAST;
signData = 6;
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(BlockFace.SOUTH, 2).getRelative(BlockFace.WEST, 2);
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyle.BIG)) {
if (this.getTeamConfig().getInt(TeamConfig.SPAWNSTYLE).equals(TeamSpawnStyle.BIG)) {
// rim
this.setBlock(x - 1, y, z + 2, this.kind);
this.setBlock(x - 2, y, z + 2, this.kind);
@ -300,12 +307,12 @@ public class Team {
if (signBlock != null) {
String[] lines = new String[4];
lines[0] = "Team " + this.name;
lines[1] = this.players.size() + "/" + this.warzone.getTeamCap() + " players";
lines[2] = this.points + "/" + this.warzone.getScoreCap() + " pts";
if (this.warzone.getLifePool() == -1) {
lines[1] = this.players.size() + "/" + this.getTeamConfig().getInt(TeamConfig.TEAMSIZE) + " players";
lines[2] = this.points + "/" + this.getTeamConfig().getInt(TeamConfig.MAXSCORE)+ " pts";
if (this.getTeamConfig().getInt(TeamConfig.LIFEPOOL) == -1) {
lines[3] = "unlimited lives";
} else {
lines[3] = this.remainingLives + "/" + this.warzone.getLifePool() + " lives left";
lines[3] = this.remainingLives + "/" + this.getTeamConfig().getInt(TeamConfig.LIFEPOOL) + " lives left";
}
SignHelper.setToSign(War.war, signBlock, (byte) signData, lines);
@ -542,4 +549,12 @@ public class Team {
War.war.log("Failed to delete file " + filePath, Level.WARNING);
}
}
public InventoryBag getInventories() {
return this.inventories ;
}
public TeamConfigBag getTeamConfig() {
return this.teamConfig;
}
}

View File

@ -23,6 +23,6 @@ public enum TeamSpawnStyle {
}
}
return TeamSpawnStyle.BIG;
return TeamSpawnStyle.SMALL;
}
}

View File

@ -11,6 +11,8 @@ import org.bukkit.block.BlockFace;
import bukkit.tommytony.war.War;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.utils.SignHelper;
import com.tommytony.war.volumes.BlockInfo;
import com.tommytony.war.volumes.Volume;
@ -105,7 +107,7 @@ public class WarHub {
this.zoneGateBlocks.clear();
int disabled = 0;
for (Warzone zone : War.war.getWarzones()) {
if (zone.isDisabled()) {
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
disabled++;
}
}
@ -159,7 +161,7 @@ public class WarHub {
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(front, hubDepth).getRelative(right, 2);
for (Warzone zone : War.war.getWarzones()) { // gonna use the index to find it again
if (!zone.isDisabled()) {
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
this.zoneGateBlocks.put(zone.getName(), currentGateBlock);
currentGateBlock.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE);
currentGateBlock.getRelative(left).setType(Material.OBSIDIAN);
@ -186,7 +188,7 @@ public class WarHub {
// Warzone signs
for (Warzone zone : War.war.getWarzones()) {
if (!zone.isDisabled() && zone.ready()) {
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) && zone.ready()) {
this.resetZoneSign(zone);
}
}
@ -233,7 +235,7 @@ public class WarHub {
int zonePlayers = 0;
for (Team t : zone.getTeams()) {
zonePlayers += t.getPlayers().size();
zoneCap += zone.getTeamCap();
zoneCap += t.getTeamConfig().getInt(TeamConfig.TEAMSIZE);
}
String[] lines = new String[4];
lines[0] = "Warzone";

View File

@ -26,6 +26,11 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarSpoutListener;
import com.tommytony.war.config.InventoryBag;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.TeamConfigBag;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.config.WarzoneConfigBag;
import com.tommytony.war.jobs.InitZoneJob;
import com.tommytony.war.jobs.LoadoutResetJob;
import com.tommytony.war.jobs.ScoreCapReachedJob;
@ -47,16 +52,13 @@ public class Warzone {
private final List<Player> respawn = new ArrayList<Player>();
private Location teleport;
private boolean friendlyFire = false;
private int lifePool = 7;
private HashMap<Integer, ItemStack> loadout = new HashMap<Integer, ItemStack>();
private HashMap<String, HashMap<Integer, ItemStack>> extraLoadouts = new HashMap<String, HashMap<Integer, ItemStack>>();
private int teamCap = 5;
private int scoreCap = 5;
private int monumentHeal = 5;
private FlagReturn flagReturn = FlagReturn.BOTH;
private TeamSpawnStyle spawnStyle = TeamSpawnStyle.BIG;
private HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
// private boolean friendlyFire = false;
// private int lifePool = 7;
// private int teamCap = 5;
// private int scoreCap = 5;
// private int monumentHeal = 5;
// private FlagReturn flagReturn = FlagReturn.BOTH;
// private TeamSpawnStyle spawnStyle = TeamSpawnStyle.BIG;
private HashMap<String, PlayerState> playerStates = new HashMap<String, PlayerState>();
private HashMap<String, Team> flagThieves = new HashMap<String, Team>();
@ -65,62 +67,64 @@ public class Warzone {
private final int minSafeDistanceFromWall = 6;
private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>();
private ZoneLobby lobby;
private boolean autoAssignOnly = false;
private boolean flagPointsOnly = false;
private boolean flagMustBeHome = true;
private boolean blockHeads = true;
private boolean unbreakableZoneBlocks = false;
private boolean disabled = false;
private boolean noCreatures = false;
private boolean glassWalls = true;
private boolean pvpInZone = true;
private boolean instaBreak = false;
private boolean noDrops = false;
private boolean noHunger = false;
private int respawnTimer = 0;
private int saturation = 10;
private int minPlayers = 1;
private int minTeams = 1;
// private boolean autoAssignOnly = false;
// private boolean flagPointsOnly = false;
// private boolean flagMustBeHome = true;
// private boolean blockHeads = true;
// private boolean unbreakableZoneBlocks = false;
// private boolean disabled = false;
// private boolean noCreatures = false;
// private boolean glassWalls = true;
// private boolean pvpInZone = true;
// private boolean instaBreak = false;
// private boolean noDrops = false;
// private boolean noHunger = false;
// private int respawnTimer = 0;
// private int saturation = 10;
// private int minPlayers = 1;
// private int minTeams = 1;
private boolean resetOnEmpty = false;
private boolean resetOnLoad = false;
private boolean resetOnUnload = false;
// private boolean resetOnEmpty = false;
// private boolean resetOnLoad = false;
// private boolean resetOnUnload = false;
private HashMap<String, PlayerState> deadMenInventories = new HashMap<String, PlayerState>();
private Location rallyPoint;
private final WarzoneConfigBag warzoneConfig = new WarzoneConfigBag();
private final TeamConfigBag teamDefaultConfig = new TeamConfigBag();
private InventoryBag defaultInventories = new InventoryBag();
@SuppressWarnings("unchecked")
public Warzone(World world, String name) {
this.world = world;
this.name = name;
this.friendlyFire = War.war.isDefaultFriendlyFire();
this.setLifePool(War.war.getDefaultLifepool());
this.setLoadout((HashMap<Integer, ItemStack>)War.war.getDefaultLoadout().clone());
this.extraLoadouts = (HashMap<String, HashMap<Integer, ItemStack>>)War.war.getDefaultExtraLoadouts().clone();
this.reward = (HashMap<Integer, ItemStack>)War.war.getDefaultReward().clone();
this.autoAssignOnly = War.war.isDefaultAutoAssignOnly();
this.setFlagPointsOnly(War.war.isDefaultFlagPointsOnly());
this.setFlagMustBeHome(War.war.isDefaultFlagMustBeHome());
this.teamCap = War.war.getDefaultTeamCap();
this.scoreCap = War.war.getDefaultScoreCap();
this.monumentHeal = War.war.getDefaultMonumentHeal();
this.spawnStyle = War.war.getDefaultSpawnStyle(); // don't use side-effect-full setters instead of this
this.flagReturn = War.war.getDefaultFlagReturn();
this.setBlockHeads(War.war.isDefaultBlockHeads());
this.setUnbreakableZoneBlocks(War.war.isDefaultUnbreakableZoneBlocks());
this.setNoCreatures(War.war.isDefaultNoCreatures());
this.setGlassWalls(War.war.isDefaultGlassWalls());
this.setPvpInZone(War.war.isDefaultPvpInZone());
this.setInstaBreak(War.war.isDefaultInstaBreak());
this.setNoDrops(War.war.isDefaultNoDrops());
this.setNoHunger(War.war.isDefaultNoHunger());
this.setRespawnTimer(War.war.getDefaultRespawnTimer());
this.setSaturation(War.war.getDefaultSaturation());
this.setMinPlayers(War.war.getDefaultMinPlayers());
this.setMinTeams(War.war.getDefaultMinTeams());
this.setResetOnEmpty(War.war.isDefaultResetOnEmpty());
this.setResetOnLoad(War.war.isDefaultResetOnLoad());
this.setResetOnUnload(War.war.isDefaultResetOnUnload());
// this.friendlyFire = War.war.isDefaultFriendlyFire();
// this.setLifePool(War.war.getDefaultLifepool());
// this.loadouts = (HashMap<String, HashMap<Integer, ItemStack>>)War.war.getDefaultLoadouts().clone();
// this.reward = (HashMap<Integer, ItemStack>)War.war.getDefaultReward().clone();
// this.autoAssignOnly = War.war.isDefaultAutoAssignOnly();
// this.setFlagPointsOnly(War.war.isDefaultFlagPointsOnly());
// this.setFlagMustBeHome(War.war.isDefaultFlagMustBeHome());
// this.teamCap = War.war.getDefaultTeamCap();
// this.scoreCap = War.war.getDefaultScoreCap();
// this.monumentHeal = War.war.getDefaultMonumentHeal();
// this.spawnStyle = War.war.getDefaultSpawnStyle(); // don't use side-effect-full setters instead of this
// this.flagReturn = War.war.getDefaultFlagReturn();
// this.setBlockHeads(War.war.isDefaultBlockHeads());
// this.setUnbreakableZoneBlocks(War.war.isDefaultUnbreakableZoneBlocks());
// this.setNoCreatures(War.war.isDefaultNoCreatures());
// this.setGlassWalls(War.war.isDefaultGlassWalls());
// this.setPvpInZone(War.war.isDefaultPvpInZone());
// this.setInstaBreak(War.war.isDefaultInstaBreak());
// this.setNoDrops(War.war.isDefaultNoDrops());
// this.setNoHunger(War.war.isDefaultNoHunger());
// this.setRespawnTimer(War.war.getDefaultRespawnTimer());
// this.setSaturation(War.war.getDefaultSaturation());
// this.setMinPlayers(War.war.getDefaultMinPlayers());
// this.setMinTeams(War.war.getDefaultMinTeams());
// this.setResetOnEmpty(War.war.isDefaultResetOnEmpty());
// this.setResetOnLoad(War.war.isDefaultResetOnLoad());
// this.setResetOnUnload(War.war.isDefaultResetOnUnload());
this.volume = new ZoneVolume(name, this.getWorld(), this);
}
@ -189,7 +193,8 @@ public class Warzone {
teamsMessage += "none.";
} else {
for (Team team : this.getTeams()) {
teamsMessage += team.getName() + " (" + team.getPoints() + " points, " + team.getRemainingLifes() + "/" + this.getLifePool() + " lives left. ";
teamsMessage += team.getName() + " (" + team.getPoints() + " points, " + team.getRemainingLifes() + "/"
+ team.getTeamConfig().getInt(TeamConfig.LIFEPOOL) + " lives left. ";
for (Player member : team.getPlayers()) {
teamsMessage += member.getName() + " ";
}
@ -268,7 +273,7 @@ public class Warzone {
this.respawnPlayer(team, player);
}
}
team.setRemainingLives(this.lifePool);
team.setRemainingLives(team.getTeamConfig().getInt(TeamConfig.LIFEPOOL));
team.initializeTeamSpawn();
if (team.getTeamFlag() != null) {
team.setTeamFlag(team.getTeamFlag());
@ -343,7 +348,7 @@ public class Warzone {
player.setRemainingAir(300);
player.setHealth(20);
player.setFoodLevel(20);
player.setSaturation(this.getSaturation());
player.setSaturation(team.getTeamConfig().getInt(TeamConfig.SATURATION));
player.setExhaustion(0);
player.setFireTicks(0); //this works fine here, why put it in LoudoutResetJob...? I'll keep it over there though
@ -369,7 +374,7 @@ public class Warzone {
}
final LoadoutResetJob job = new LoadoutResetJob(this, team, player, isFirstRespawn, false);
if (respawnTimer == 0 || isFirstRespawn) {
if (team.getTeamConfig().getInt(TeamConfig.RESPAWNTIMER) == 0 || isFirstRespawn) {
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
}
else {
@ -381,7 +386,7 @@ public class Warzone {
respawn.remove(player);
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
}
}, respawnTimer * 20L); // 20 ticks = 1 second
}, team.getTeamConfig().getInt(TeamConfig.RESPAWNTIMER) * 20L); // 20 ticks = 1 second
}
}
@ -407,7 +412,7 @@ public class Warzone {
}
}
}
if (this.isBlockHeads()) {
if (this.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
playerInv.setHelmet(new ItemStack(team.getKind().getMaterial(), 1, (short) 1, new Byte(team.getKind().getData())));
} else {
if (team.getKind() == TeamKind.GOLD) {
@ -459,47 +464,32 @@ public class Warzone {
return this.monuments;
}
public boolean getFriendlyFire() {
return this.friendlyFire;
}
public void setFriendlyFire(boolean ffOn) {
this.friendlyFire = ffOn;
}
public void setLoadout(HashMap<Integer, ItemStack> newLoadout) {
this.loadout.clear();
for (Integer slot : newLoadout.keySet()) {
ItemStack stack = newLoadout.get(slot);
if (stack != null) {
this.loadout.put(slot, stack);
}
}
}
public HashMap<Integer, ItemStack> getLoadout() {
return this.loadout;
}
public void setLifePool(int lifePool) {
this.lifePool = lifePool;
for (Team team : this.teams) {
team.setRemainingLives(lifePool);
}
}
public int getLifePool() {
return this.lifePool;
}
public void setMonumentHeal(int monumentHeal) {
this.monumentHeal = monumentHeal;
}
public int getMonumentHeal() {
return this.monumentHeal;
}
// public boolean getFriendlyFire() {
// return this.friendlyFire;
// }
//
// public void setFriendlyFire(boolean ffOn) {
// this.friendlyFire = ffOn;
// }
//
// public void setLifePool(int lifePool) {
// this.lifePool = lifePool;
// for (Team team : this.teams) {
// team.setRemainingLives(lifePool);
// }
// }
//
// public int getLifePool() {
// return this.lifePool;
// }
//
// public void setMonumentHeal(int monumentHeal) {
// this.monumentHeal = monumentHeal;
// }
//
// public int getMonumentHeal() {
// return this.monumentHeal;
// }
public boolean hasPlayerState(String playerName) {
return this.playerStates.containsKey(playerName);
@ -802,36 +792,36 @@ public class Warzone {
return lowestNoOfPlayers;
}
public void setTeamCap(int teamCap) {
this.teamCap = teamCap;
}
// public void setTeamCap(int teamCap) {
// this.teamCap = teamCap;
// }
//
// public int getTeamCap() {
// return this.teamCap;
// }
//
// public void setScoreCap(int scoreCap) {
// this.scoreCap = scoreCap;
// }
//
// public int getScoreCap() {
// return this.scoreCap;
// }
public int getTeamCap() {
return this.teamCap;
}
public void setScoreCap(int scoreCap) {
this.scoreCap = scoreCap;
}
public int getScoreCap() {
return this.scoreCap;
}
public void setAutoAssignOnlyAndResetLobby(boolean autoAssignOnly) {
this.autoAssignOnly = autoAssignOnly;
if (this.getLobby() != null) {
this.getLobby().setLocation(this.getTeleport());
}
}
public void setAutoAssignOnlyWithoutResettingLobby(boolean autoAssignOnly) {
this.autoAssignOnly = autoAssignOnly;
}
public boolean isAutoAssignOnly() {
return this.autoAssignOnly;
}
// public void setAutoAssignOnlyAndResetLobby(boolean autoAssignOnly) {
// this.autoAssignOnly = autoAssignOnly;
// if (this.getLobby() != null) {
// this.getLobby().setLocation(this.getTeleport());
// }
// }
//
// public void setAutoAssignOnlyWithoutResettingLobby(boolean autoAssignOnly) {
// this.autoAssignOnly = autoAssignOnly;
// }
//
// public boolean isAutoAssignOnly() {
// return this.autoAssignOnly;
// }
public void handleDeath(Player player) {
Team playerTeam = Team.getTeamByPlayerName(player.getName());
@ -847,24 +837,24 @@ public class Warzone {
for (Team t : teams) {
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: " + player.getName() + " died and there were no lives left in their life pool.");
if (t.getPlayers().size() != 0 && !this.flagPointsOnly) {
if (t.getPlayers().size() != 0 && !t.getTeamConfig().getBoolean(TeamConfig.FLAGPOINTSONLY)) {
if (!t.getName().equals(playerTeam.getName())) {
// all other teams get a point
t.addPoint();
t.resetSign();
}
scores += t.getName() + "(" + t.getPoints() + ") ";
scores += t.getName() + "(" + t.getPoints() + "/" + t.getTeamConfig().getInt(TeamConfig.MAXSCORE) + ") ";
}
}
if (!scores.equals("")) {
for (Team t : teams) {
t.teamcast("New scores - " + scores + " (/" + this.getScoreCap() + ")");
t.teamcast("New scores - " + scores);
}
}
// detect score cap
List<Team> scoreCapTeams = new ArrayList<Team>();
for (Team t : teams) {
if (t.getPoints() == playerWarzone.getScoreCap()) {
if (t.getPoints() == t.getTeamConfig().getInt(TeamConfig.MAXSCORE)) {
scoreCapTeams.add(t);
}
}
@ -976,11 +966,11 @@ public class Warzone {
break;
}
}
if (zoneEmpty && this.isResetOnEmpty()) {
if (zoneEmpty && this.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONEMPTY)) {
// reset the zone for a new game when the last player leaves
for (Team team : this.getTeams()) {
team.resetPoints();
team.setRemainingLives(this.getLifePool());
team.setRemainingLives(team.getTeamConfig().getInt(TeamConfig.LIFEPOOL));
}
this.getVolume().resetBlocksAsJob();
this.initializeZoneAsJob();
@ -1062,65 +1052,57 @@ public class Warzone {
}
}
public void setBlockHeads(boolean blockHeads) {
this.blockHeads = blockHeads;
}
// public void setBlockHeads(boolean blockHeads) {
// this.blockHeads = blockHeads;
// }
//
// public boolean isBlockHeads() {
// return this.blockHeads;
// }
public boolean isBlockHeads() {
return this.blockHeads;
}
// public void setSpawnStyle(TeamSpawnStyle spawnStyle) {
// this.spawnStyle = spawnStyle;
// for (Team team : this.teams) {
// team.setTeamSpawn(team.getTeamSpawn());
// }
// }
//
// public TeamSpawnStyle getSpawnStyle() {
// return this.spawnStyle;
// }
//
//
// public void setFlagReturn(FlagReturn flagReturn) {
// this.flagReturn = flagReturn;
// }
//
// public FlagReturn getFlagReturn() {
// return this.flagReturn;
// }
public void setSpawnStyle(TeamSpawnStyle spawnStyle) {
this.spawnStyle = spawnStyle;
for (Team team : this.teams) {
team.setTeamSpawn(team.getTeamSpawn());
}
}
public TeamSpawnStyle getSpawnStyle() {
return this.spawnStyle;
}
public void setFlagReturn(FlagReturn flagReturn) {
this.flagReturn = flagReturn;
}
public FlagReturn getFlagReturn() {
return this.flagReturn;
}
public void setReward(HashMap<Integer, ItemStack> reward) {
this.reward = reward;
}
public HashMap<Integer, ItemStack> getReward() {
return this.reward;
}
public void setUnbreakableZoneBlocks(boolean unbreakableZoneBlocks) {
this.unbreakableZoneBlocks = unbreakableZoneBlocks;
}
public boolean isUnbreakableZoneBlocks() {
return this.unbreakableZoneBlocks;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
public boolean isDisabled() {
return this.disabled;
}
public boolean isNoCreatures() {
return this.noCreatures;
}
public void setNoCreatures(boolean noCreatures) {
this.noCreatures = noCreatures;
}
// public void setUnbreakableZoneBlocks(boolean unbreakableZoneBlocks) {
// this.unbreakableZoneBlocks = unbreakableZoneBlocks;
// }
//
// public boolean isUnbreakableZoneBlocks() {
// return this.unbreakableZoneBlocks;
// }
//
// public void setDisabled(boolean disabled) {
// this.disabled = disabled;
// }
//
// public boolean isDisabled() {
// return this.disabled;
// }
//
// public boolean isNoCreatures() {
// return this.noCreatures;
// }
//
// public void setNoCreatures(boolean noCreatures) {
// this.noCreatures = noCreatures;
// }
public boolean isDeadMan(String playerName) {
if (this.deadMenInventories.containsKey(playerName)) {
@ -1157,7 +1139,7 @@ public class Warzone {
this.getLobby().getVolume().resetBlocks();
this.getLobby().getVolume().finalize();
}
if (this.isResetOnUnload()) {
if (this.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONUNLOAD)) {
this.getVolume().resetBlocks();
}
this.getVolume().finalize();
@ -1166,127 +1148,123 @@ public class Warzone {
public boolean isEnoughPlayers() {
int teamsWithEnough = 0;
for (Team team : teams) {
if (team.getPlayers().size() >= this.getMinPlayers()) {
if (team.getPlayers().size() >= this.getWarzoneConfig().getInt(WarzoneConfig.MINPLAYERS)) {
teamsWithEnough++;
}
}
if (teamsWithEnough >= this.getMinTeams()) {
if (teamsWithEnough >= this.getWarzoneConfig().getInt(WarzoneConfig.MINTEAMS)) {
return true;
}
return false;
}
public void setResetOnLoad(boolean resetOnLoad) {
this.resetOnLoad = resetOnLoad;
}
public boolean isResetOnLoad() {
return this.resetOnLoad;
}
public void setResetOnUnload(boolean resetOnUnload) {
this.resetOnUnload = resetOnUnload;
}
public boolean isResetOnUnload() {
return this.resetOnUnload;
}
public void setResetOnEmpty(boolean resetOnEmpty) {
this.resetOnEmpty = resetOnEmpty;
}
public boolean isResetOnEmpty() {
return this.resetOnEmpty;
}
public void setGlassWalls(boolean glassWalls) {
this.glassWalls = glassWalls;
}
public boolean isGlassWalls() {
return this.glassWalls;
}
// public void setResetOnLoad(boolean resetOnLoad) {
// this.resetOnLoad = resetOnLoad;
// }
//
// public boolean isResetOnLoad() {
// return this.resetOnLoad;
// }
//
// public void setResetOnUnload(boolean resetOnUnload) {
// this.resetOnUnload = resetOnUnload;
// }
//
// public boolean isResetOnUnload() {
// return this.resetOnUnload;
// }
//
// public void setResetOnEmpty(boolean resetOnEmpty) {
// this.resetOnEmpty = resetOnEmpty;
// }
//
// public boolean isResetOnEmpty() {
// return this.resetOnEmpty;
// }
//
// public void setGlassWalls(boolean glassWalls) {
// this.glassWalls = glassWalls;
// }
//
// public boolean isGlassWalls() {
// return this.glassWalls;
// }
public void setFlagPointsOnly(boolean flagPointsOnly) {
this.flagPointsOnly = flagPointsOnly;
}
public boolean isFlagPointsOnly() {
return this.flagPointsOnly;
}
public void setFlagMustBeHome(boolean flagMustBeHome) {
this.flagMustBeHome = flagMustBeHome;
}
public boolean isFlagMustBeHome() {
return this.flagMustBeHome;
}
public void setMinPlayers(int minPlayers) {
this.minPlayers = minPlayers;
}
public int getMinPlayers() {
return minPlayers;
}
public void setMinTeams(int minTeams) {
this.minTeams = minTeams;
}
public int getMinTeams() {
return minTeams;
}
public HashMap<String, HashMap<Integer, ItemStack>> getExtraLoadouts() {
return extraLoadouts;
}
// public void setFlagPointsOnly(boolean flagPointsOnly) {
// this.flagPointsOnly = flagPointsOnly;
// }
//
// public boolean isFlagPointsOnly() {
// return this.flagPointsOnly;
// }
//
// public void setFlagMustBeHome(boolean flagMustBeHome) {
// this.flagMustBeHome = flagMustBeHome;
// }
//
// public boolean isFlagMustBeHome() {
// return this.flagMustBeHome;
// }
//
// public void setMinPlayers(int minPlayers) {
// this.minPlayers = minPlayers;
// }
//
// public int getMinPlayers() {
// return minPlayers;
// }
//
// public void setMinTeams(int minTeams) {
// this.minTeams = minTeams;
// }
//
// public int getMinTeams() {
// return minTeams;
// }
public HashMap<String, LoadoutSelection> getLoadoutSelections() {
return loadoutSelections;
}
public boolean isPvpInZone() {
return pvpInZone;
}
// public boolean isPvpInZone() {
// return pvpInZone;
// }
//
// public void setPvpInZone(boolean stopPvp) {
// this.pvpInZone = stopPvp;
// }
//
// public boolean isInstaBreak() {
// return instaBreak;
// }
//
// public void setInstaBreak(boolean instaBreak) {
// this.instaBreak = instaBreak;
// }
//
// public boolean isNoDrops() {
// return noDrops;
// }
//
// public void setNoDrops(boolean noDrops) {
// this.noDrops = noDrops;
// }
public void setPvpInZone(boolean stopPvp) {
this.pvpInZone = stopPvp;
}
public boolean isInstaBreak() {
return instaBreak;
}
public void setInstaBreak(boolean instaBreak) {
this.instaBreak = instaBreak;
}
public boolean isNoDrops() {
return noDrops;
}
public void setNoDrops(boolean noDrops) {
this.noDrops = noDrops;
}
public boolean isNoHunger() {
return noHunger;
}
public void setNoHunger(boolean noHunger) {
this.noHunger = noHunger;
}
public int getSaturation() {
return this.saturation;
}
public void setSaturation(int saturation) {
this.saturation = saturation;
}
// public boolean isNoHunger() {
// return noHunger;
// }
//
// public void setNoHunger(boolean noHunger) {
// this.noHunger = noHunger;
// }
//
// public int getSaturation() {
// return this.saturation;
// }
//
// public void setSaturation(int saturation) {
// this.saturation = saturation;
// }
public boolean isAuthor(Player player) {
// if no authors, all zonemakers can edit the zone
@ -1313,35 +1291,40 @@ public class Warzone {
LoadoutSelection selection = this.getLoadoutSelections().get(player.getName());
if (selection != null && !this.isRespawning(player)) {
int currentIndex = selection.getSelectedIndex();
if (currentIndex == 0) {
this.resetInventory(playerTeam, player, this.getLoadout());
if (isFirstRespawn && this.extraLoadouts.keySet().size() > 0) {
War.war.msg(player, "Equipped default loadout (sneak to switch).");
} else if (isToggle){
War.war.msg(player, "Equipped default loadout.");
}
} else {
int i = 0;
Iterator it = this.getExtraLoadouts().entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
if (i == currentIndex - 1) {
this.resetInventory(playerTeam, player, (HashMap<Integer, ItemStack>)pairs.getValue());
if (isToggle) {
War.war.msg(player, "Equipped " + pairs.getKey() + " loadout.");
}
}
i++;
}
}
int i = 0;
Iterator it = playerTeam.getInventories().resolveLoadouts().entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
if (i == currentIndex) {
this.resetInventory(playerTeam, player, (HashMap<Integer, ItemStack>)pairs.getValue());
if (isFirstRespawn && playerTeam.getInventories().resolveLoadouts().keySet().size() > 1) {
War.war.msg(player, "Equipped " + pairs.getKey() + " loadout (sneak to switch).");
} else if (isToggle) {
War.war.msg(player, "Equipped " + pairs.getKey() + " loadout.");
}
}
i++;
}
}
}
public void setRespawnTimer(int respawnTimer) {
this.respawnTimer = respawnTimer;
// public void setRespawnTimer(int respawnTimer) {
// this.respawnTimer = respawnTimer;
// }
//
// public int getRespawnTimer() {
// return this.respawnTimer;
// }
public WarzoneConfigBag getWarzoneConfig() {
return this.warzoneConfig;
}
public TeamConfigBag getTeamDefaultConfig() {
return this.teamDefaultConfig;
}
public int getRespawnTimer() {
return this.respawnTimer;
public InventoryBag getDefaultInventories() {
return this.defaultInventories ;
}
}

View File

@ -13,6 +13,8 @@ import org.bukkit.entity.Player;
import bukkit.tommytony.war.War;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.utils.SignHelper;
import com.tommytony.war.volumes.BlockInfo;
import com.tommytony.war.volumes.Volume;
@ -246,7 +248,7 @@ public class ZoneLobby {
private void calculateLobbyWidth() {
int noOfTeams = this.warzone.getTeams().size();
if (this.warzone.isAutoAssignOnly()) {
if (this.warzone.getWarzoneConfig().getBoolean(WarzoneConfig.AUTOASSIGN)) {
noOfTeams = 1;
}
int lobbyWidth = noOfTeams * 4 + 5;
@ -365,7 +367,7 @@ public class ZoneLobby {
rightSide = BlockFace.SOUTH;
}
this.teamGateBlocks.clear();
if (this.warzone.isAutoAssignOnly()) {
if (this.warzone.getWarzoneConfig().getBoolean(WarzoneConfig.AUTOASSIGN)) {
this.autoAssignGate = new BlockInfo(lobbyMiddleWallBlock);
} else {
this.autoAssignGate = null;
@ -586,12 +588,12 @@ public class ZoneLobby {
if (gate != null) {
String[] lines = new String[4];
lines[0] = "Team " + team.getName();
lines[1] = team.getPlayers().size() + "/" + this.warzone.getTeamCap() + " players";
lines[2] = team.getPoints() + "/" + this.warzone.getScoreCap() + " pts";
if (this.warzone.getLifePool() == -1) {
lines[1] = team.getPlayers().size() + "/" + team.getTeamConfig().getInt(TeamConfig.TEAMSIZE) + " players";
lines[2] = team.getPoints() + "/" + team.getTeamConfig().getInt(TeamConfig.MAXSCORE) + " pts";
if (team.getTeamConfig().getInt(TeamConfig.LIFEPOOL) == -1) {
lines[3] = "unlimited lives";
} else {
lines[3] = team.getRemainingLifes() + "/" + this.warzone.getLifePool() + " lives left";
lines[3] = team.getRemainingLifes() + "/" + team.getTeamConfig().getInt(TeamConfig.TEAMSIZE) + " lives left";
}
this.resetGateSign(gate, lines, true);
}

View File

@ -6,8 +6,9 @@ import org.bukkit.entity.Player;
import bukkit.tommytony.war.War;
import com.tommytony.war.mappers.WarMapper;
import com.tommytony.war.mappers.WarzoneMapper;
import com.tommytony.war.config.WarConfig;
import com.tommytony.war.mappers.WarYmlMapper;
import com.tommytony.war.mappers.WarzoneYmlMapper;
import com.tommytony.war.volumes.NotNorthwestException;
import com.tommytony.war.volumes.NotSoutheastException;
import com.tommytony.war.volumes.TooBigException;
@ -28,7 +29,7 @@ public class ZoneSetter {
Block northwestBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
StringBuilder msgString = new StringBuilder();
try {
if (warzone == null && War.war.getWarzones().size() >= War.war.getMaxZones()) {
if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
// max warzones reached
War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
return;
@ -71,7 +72,7 @@ public class ZoneSetter {
Block southeastBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
StringBuilder msgString = new StringBuilder();
try {
if (warzone == null && War.war.getWarzones().size() >= War.war.getMaxZones()) {
if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
// max warzones reached
War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
return;
@ -118,7 +119,7 @@ public class ZoneSetter {
Warzone warzone = War.war.findWarzone(this.zoneName);
StringBuilder msgString = new StringBuilder();
try {
if (warzone == null && War.war.getWarzones().size() >= War.war.getMaxZones()) {
if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
// max warzones reached
War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
return;
@ -160,7 +161,7 @@ public class ZoneSetter {
Warzone warzone = War.war.findWarzone(this.zoneName);
StringBuilder msgString = new StringBuilder();
try {
if (warzone == null && War.war.getWarzones().size() >= War.war.getMaxZones()) {
if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
// max warzones reached
War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
return;
@ -229,7 +230,7 @@ public class ZoneSetter {
if (War.war.getIncompleteZones().contains(warzone)) {
War.war.getIncompleteZones().remove(warzone);
}
WarMapper.save();
WarYmlMapper.save();
msgString.append("Saving new warzone blocks...");
War.war.msg(this.player, msgString.toString());
warzone.saveState(false); // we just changed the volume, cant reset walls
@ -246,7 +247,7 @@ public class ZoneSetter {
}
warzone.initializeZone();
WarzoneMapper.save(warzone, true);
WarzoneYmlMapper.save(warzone, true);
War.war.msg(this.player, "Warzone saved.");
} else {
if (warzone.getVolume().getCornerOne() == null) {

View File

@ -0,0 +1,79 @@
package com.tommytony.war.config;
import java.util.HashMap;
import org.bukkit.inventory.ItemStack;
import bukkit.tommytony.war.War;
import com.tommytony.war.Warzone;
public class InventoryBag {
private HashMap<String, HashMap<Integer, ItemStack>> loadouts = new HashMap<String, HashMap<Integer,ItemStack>>();
private HashMap<Integer, ItemStack> reward = null;
private Warzone warzone;
public InventoryBag(Warzone warzone) {
this.warzone = warzone;
}
public InventoryBag() {
this.warzone = null;
}
public void addLoadout(String name, HashMap<Integer, ItemStack> loadout) {
this.loadouts.put(name, loadout);
}
public void removeLoadout(String name) {
this.loadouts.remove(name);
}
public boolean hasLoadouts() {
return loadouts.size() > 0;
}
public HashMap<String, HashMap<Integer, ItemStack>> getLoadouts() {
return this.loadouts;
}
public HashMap<String, HashMap<Integer, ItemStack>> resolveLoadouts() {
if (this.hasLoadouts()) {
return loadouts;
} else if (warzone != null && warzone.getDefaultInventories().hasLoadouts()) {
return warzone.getDefaultInventories().resolveLoadouts();
} else if (War.war.getDefaultInventories().hasLoadouts()) {
return War.war.getDefaultInventories().resolveLoadouts();
} else {
return new HashMap<String, HashMap<Integer, ItemStack>>();
}
}
public void setReward(HashMap<Integer, ItemStack> reward) {
this.reward = reward;
}
public boolean hasReward() {
return reward != null;
}
public HashMap<Integer, ItemStack> getReward() {
return reward;
}
public HashMap<Integer, ItemStack> resolveReward() {
if (this.hasReward()) {
return reward;
} else if (warzone != null && warzone.getDefaultInventories().hasReward()) {
return warzone.getDefaultInventories().resolveReward();
} else {
return War.war.getDefaultInventories().resolveReward();
}
}
public void clearLoadouts() {
this.loadouts.clear();
}
}

View File

@ -0,0 +1,46 @@
package com.tommytony.war.config;
import com.tommytony.war.FlagReturn;
import com.tommytony.war.TeamSpawnStyle;
public enum TeamConfig {
FLAGMUSTBEHOME (Integer.class),
FLAGPOINTSONLY (Boolean.class),
FLAGRETURN (FlagReturn.class),
LIFEPOOL (Integer.class),
MAXSCORE (Integer.class),
NOHUNGER (Boolean.class),
RESPAWNTIMER (Integer.class),
SATURATION (Integer.class),
SPAWNSTYLE (TeamSpawnStyle.class),
TEAMSIZE (Integer.class);
private final Class<?> configType;
private TeamConfig(Class<?> configType) {
this.configType = configType;
}
public Class<?> getConfigType() {
return configType;
}
public static TeamConfig teamConfigFromString(String str) {
String lowered = str.toLowerCase();
for (TeamConfig config : TeamConfig.values()) {
if (config.toString().startsWith(lowered)) {
return config;
}
}
return null;
}
public String toStringWithValue(Object value) {
return this.toString() + ":" + value.toString();
}
@Override
public String toString() {
return super.toString().toLowerCase();
}
}

View File

@ -0,0 +1,162 @@
package com.tommytony.war.config;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
import bukkit.tommytony.war.War;
import com.tommytony.war.FlagReturn;
import com.tommytony.war.TeamSpawnStyle;
import com.tommytony.war.Warzone;
public class TeamConfigBag {
private HashMap<TeamConfig, Object> bag = new HashMap<TeamConfig, Object>();
private Warzone warzone;
public TeamConfigBag(Warzone warzone) {
this.warzone = warzone;
}
public TeamConfigBag() {
this.warzone = null;
}
public boolean contains(TeamConfig config) {
return this.bag.containsKey(config);
}
public boolean isEmpty() {
return this.bag.keySet().size() == 0;
}
public void put(TeamConfig config, Object value) {
this.bag.put(config, value);
}
public Object getValue(TeamConfig config) {
if (this.contains(config)) {
return this.bag.get(config);
} else if (this.warzone != null && this.warzone.getTeamDefaultConfig().contains(config)){
// use Warzone default config
return this.warzone.getTeamDefaultConfig().getValue(config);
} else {
// use War default config
return War.war.getTeamDefaultConfig().getValue(config);
}
}
public Integer getInt(TeamConfig config) {
if (this.contains(config)) {
return (Integer)this.bag.get(config);
} else if (this.warzone != null && this.warzone.getTeamDefaultConfig().contains(config)){
// use Warzone default config
return this.warzone.getTeamDefaultConfig().getInt(config);
} else {
// use War default config
return War.war.getTeamDefaultConfig().getInt(config);
}
}
public Boolean getBoolean(TeamConfig config) {
if (this.contains(config)) {
return (Boolean)this.bag.get(config);
} else if (this.warzone != null && this.warzone.getTeamDefaultConfig().contains(config)){
// use Warzone default config
return this.warzone.getTeamDefaultConfig().getBoolean(config);
} else {
// use War default config
return War.war.getTeamDefaultConfig().getBoolean(config);
}
}
public FlagReturn getFlagReturn(TeamConfig config) {
if (this.contains(config)) {
return (FlagReturn)this.bag.get(config);
} else if (this.warzone != null && this.warzone.getTeamDefaultConfig().contains(config)){
// use Warzone default config
return this.warzone.getTeamDefaultConfig().getFlagReturn(config);
} else {
// use War default config
return War.war.getTeamDefaultConfig().getFlagReturn(config);
}
}
public TeamSpawnStyle getSpawnStyle(TeamConfig config) {
if (this.contains(config)) {
return (TeamSpawnStyle)this.bag.get(config);
} else if (this.warzone != null && this.warzone.getTeamDefaultConfig().contains(config)){
// use War default config
return this.warzone.getTeamDefaultConfig().getSpawnStyle(config);
} else {
return War.war.getTeamDefaultConfig().getSpawnStyle(config);
}
}
public void loadFrom(ConfigurationSection teamConfigSection) {
for (TeamConfig config : TeamConfig.values()) {
if (teamConfigSection.contains(config.toString())) {
if (config.getConfigType().equals(Integer.class)) {
this.put(config, teamConfigSection.getInt(config.toString()));
} else if (config.getConfigType().equals(Boolean.class)) {
this.put(config, teamConfigSection.getBoolean(config.toString()));
} else if (config.getConfigType().equals(FlagReturn.class)) {
String flagReturnStr = teamConfigSection.getString(config.toString());
FlagReturn returnMode = FlagReturn.getFromString(flagReturnStr);
if (returnMode != null) {
this.put(config, returnMode);
}
} else if (config.getConfigType().equals(TeamSpawnStyle.class)) {
String spawnStyleStr = teamConfigSection.getString(config.toString());
TeamSpawnStyle style = TeamSpawnStyle.getStyleFromString(spawnStyleStr);
if (style != null) {
this.put(config, style);
}
}
}
}
}
public void saveTo(ConfigurationSection teamConfigSection) {
for (TeamConfig config : TeamConfig.values()) {
if (this.contains(config)) {
teamConfigSection.set(config.toString(), this.bag.get(config).toString());
}
}
}
public String updateFromNamedParams(Map<String, String> namedParams) {
String returnMessage = "";
for (String namedParam : namedParams.keySet()) {
TeamConfig teamConfig = TeamConfig.teamConfigFromString(namedParam);
if (teamConfig != null) {
if (teamConfig.getConfigType().equals(Integer.class)) {
int intValue = Integer.parseInt(namedParams.get(namedParam));
this.bag.put(teamConfig, intValue);
} else if (teamConfig.getConfigType().equals(Boolean.class)) {
String onOff = namedParams.get(namedParam);
this.bag.put(teamConfig, onOff.equals("on") || onOff.equals("true"));
} else if (teamConfig.getConfigType().equals(FlagReturn.class)) {
FlagReturn flagValue = FlagReturn.getFromString(namedParams.get(namedParam));
this.bag.put(teamConfig, flagValue);
} else if (teamConfig.getConfigType().equals(TeamSpawnStyle.class)) {
TeamSpawnStyle spawnValue = TeamSpawnStyle.getStyleFromString(namedParams.get(namedParam));
this.bag.put(teamConfig, spawnValue);
}
returnMessage += teamConfig.toString() + " set to " + namedParams.get(namedParam);
} else if (namedParam.startsWith("delete")) {
String toDelete = namedParam.replace("delete", "");
teamConfig = TeamConfig.teamConfigFromString(toDelete);
// param delete (to restore inheritance)
if (teamConfig != null) {
this.bag.remove(teamConfig);
returnMessage += teamConfig.toString() + " removed";
}
}
}
return returnMessage;
}
}

View File

@ -0,0 +1,40 @@
package com.tommytony.war.config;
public enum WarConfig {
BUILDINZONESONLY (Boolean.class),
DISABLEBUILDMESSAGE (Boolean.class),
DISABLEPVPMESSAGE (Boolean.class),
MAXZONES (Integer.class),
PVPINZONESONLY (Boolean.class),
TNTINZONESONLY (Boolean.class);
private final Class<?> configType;
private WarConfig(Class<?> configType) {
this.configType = configType;
}
public Class<?> getConfigType() {
return configType;
}
public static WarConfig warConfigFromString(String str) {
String lowered = str.toLowerCase();
for (WarConfig config : WarConfig.values()) {
if (config.toString().startsWith(lowered)) {
return config;
}
}
return null;
}
public String toStringWithValue(Object value) {
return this.toString() + ":" + value.toString();
}
@Override
public String toString() {
return super.toString().toLowerCase();
}
}

View File

@ -0,0 +1,77 @@
package com.tommytony.war.config;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
public class WarConfigBag {
HashMap<WarConfig, Object> bag = new HashMap<WarConfig, Object>();
public void put(WarConfig config, Object value) {
this.bag.put(config, value);
}
public Object getValue(WarConfig config) {
if (this.bag.containsKey(config)) {
return this.bag.get(config);
} else {
return null;
}
}
public Integer getInt(WarConfig config) {
if (this.bag.containsKey(config)) {
return (Integer)this.bag.get(config);
} else {
return null;
}
}
public Boolean getBoolean(WarConfig config) {
if (this.bag.containsKey(config)) {
return (Boolean)this.bag.get(config);
} else {
return null;
}
}
public void loadFrom(ConfigurationSection warConfigSection) {
for (WarConfig config : WarConfig.values()) {
if (warConfigSection.contains(config.toString())) {
if (config.getConfigType().equals(Integer.class)) {
this.put(config, warConfigSection.getInt(config.toString()));
} else if (config.getConfigType().equals(Boolean.class)) {
this.put(config, warConfigSection.getBoolean(config.toString()));
}
}
}
}
public void saveTo(ConfigurationSection warConfigSection) {
for (WarConfig config : WarConfig.values()) {
if (this.bag.containsKey(config)) {
warConfigSection.set(config.toString(), this.bag.get(config));
}
}
}
public String updateFromNamedParams(Map<String, String> namedParams) {
String returnMessage = "";
for (String namedParam : namedParams.keySet()) {
WarConfig warConfig = WarConfig.warConfigFromString(namedParam);
if (warConfig != null) {
if (warConfig.getConfigType().equals(Integer.class)) {
int intValue = Integer.parseInt(namedParams.get(namedParam));
this.bag.put(warConfig, intValue);
} else if (warConfig.getConfigType().equals(Boolean.class)) {
String onOff = namedParams.get(namedParam);
this.bag.put(warConfig, onOff.equals("on") || onOff.equals("true"));
}
returnMessage += warConfig.toString() + " set to " + namedParams.get(namedParam);
}
}
return returnMessage;
}
}

View File

@ -0,0 +1,49 @@
package com.tommytony.war.config;
public enum WarzoneConfig {
AUTOASSIGN (Boolean.class),
BLOCKHEADS (Boolean.class),
DISABLED (Boolean.class),
FRIENDLYFIRE (Boolean.class),
GLASSWALLS (Boolean.class),
INSTABREAK (Boolean.class),
MINTEAMS (Integer.class),
MINPLAYERS (Integer.class),
MONUMENTHEAL (Integer.class),
NOCREATURES (Boolean.class),
NODROPS (Boolean.class),
PVPINZONE (Boolean.class),
RESETONEMPTY (Boolean.class),
RESETONLOAD (Boolean.class),
RESETONUNLOAD (Boolean.class),
UNBREAKABLE (Boolean.class);
private final Class<?> configType;
private WarzoneConfig(Class<?> configType) {
this.configType = configType;
}
public Class<?> getConfigType() {
return configType;
}
public static WarzoneConfig warzoneConfigFromString(String str) {
String lowered = str.toLowerCase();
for (WarzoneConfig config : WarzoneConfig.values()) {
if (config.toString().startsWith(lowered)) {
return config;
}
}
return null;
}
public String toStringWithValue(Object value) {
return this.toString() + ":" + value.toString();
}
@Override
public String toString() {
return super.toString().toLowerCase();
}
}

View File

@ -0,0 +1,97 @@
package com.tommytony.war.config;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.configuration.ConfigurationSection;
import bukkit.tommytony.war.War;
public class WarzoneConfigBag {
HashMap<WarzoneConfig, Object> bag = new HashMap<WarzoneConfig, Object>();
public void put(WarzoneConfig config, Object value) {
bag.put(config, value);
}
public boolean isEmpty() {
return bag.keySet().size() == 0;
}
public Object getValue(WarzoneConfig config) {
if (bag.containsKey(config)) {
return bag.get(config);
} else {
// use War default config
return War.war.getWarzoneDefaultConfig().getValue(config);
}
}
public Integer getInt(WarzoneConfig config) {
if (bag.containsKey(config)) {
return (Integer)bag.get(config);
} else {
// use War default config
return War.war.getWarzoneDefaultConfig().getInt(config);
}
}
public Boolean getBoolean(WarzoneConfig config) {
if (bag.containsKey(config)) {
return (Boolean)bag.get(config);
} else {
// use War default config
return War.war.getWarzoneDefaultConfig().getBoolean(config);
}
}
public void loadFrom(ConfigurationSection warzoneConfigSection) {
for (WarzoneConfig config : WarzoneConfig.values()) {
if (warzoneConfigSection.contains(config.toString())) {
if (config.getConfigType().equals(Integer.class)) {
this.put(config, warzoneConfigSection.getInt(config.toString()));
} else if (config.getConfigType().equals(Boolean.class)) {
this.put(config, warzoneConfigSection.getBoolean(config.toString()));
}
}
}
}
public void saveTo(ConfigurationSection warzoneConfigSection) {
for (WarzoneConfig config : WarzoneConfig.values()) {
if (this.bag.containsKey(config)) {
warzoneConfigSection.set(config.toString(), this.bag.get(config));
}
}
}
public String updateFromNamedParams(Map<String, String> namedParams) {
String returnMessage = "";
for (String namedParam : namedParams.keySet()) {
WarzoneConfig warzoneConfig = WarzoneConfig.warzoneConfigFromString(namedParam);
// param update
if (warzoneConfig != null) {
if (warzoneConfig.getConfigType().equals(Integer.class)) {
int intValue = Integer.parseInt(namedParams.get(namedParam));
this.bag.put(warzoneConfig, intValue);
} else if (warzoneConfig.getConfigType().equals(Boolean.class)) {
String onOff = namedParams.get(namedParam);
this.bag.put(warzoneConfig, onOff.equals("on") || onOff.equals("true"));
}
returnMessage += warzoneConfig.toString() + " set to " + namedParams.get(namedParam);
} else if (namedParam.startsWith("delete")) {
String toDelete = namedParam.replace("delete", "");
warzoneConfig = WarzoneConfig.warzoneConfigFromString(toDelete);
// param delete (to restore inheritance)
if (warzoneConfig != null) {
this.bag.remove(warzoneConfig);
returnMessage += warzoneConfig.toString() + " removed";
}
}
}
return returnMessage;
}
}

View File

@ -2,28 +2,20 @@ package com.tommytony.war.jobs;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.ContainerBlock;
import org.bukkit.block.Dispenser;
import org.bukkit.block.Furnace;
import org.bukkit.block.NoteBlock;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import bukkit.tommytony.war.War;
import com.tommytony.war.mappers.ZoneVolumeMapper;
import com.tommytony.war.utils.DeferredBlockReset;
import com.tommytony.war.volumes.Volume;

View File

@ -9,6 +9,7 @@ import org.bukkit.inventory.PlayerInventory;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.WarzoneConfig;
import bukkit.tommytony.war.War;
@ -31,7 +32,7 @@ public class HelmetProtectionTask implements Runnable {
for (Player player : team.getPlayers()) {
PlayerInventory playerInv = player.getInventory();
Material teamBlockMaterial;
if (zone.isBlockHeads()) {
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
teamBlockMaterial = team.getKind().getMaterial();
// 1) Replace missing block head
if (playerInv.getHelmet().getType() != teamBlockMaterial) {

View File

@ -5,7 +5,8 @@ import java.util.logging.Level;
import bukkit.tommytony.war.War;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarzoneMapper;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.mappers.WarzoneTxtMapper;
public class RestoreWarzonesJob implements Runnable {
@ -23,7 +24,7 @@ public class RestoreWarzonesJob implements Runnable {
for (String warzoneName : warzoneSplit) {
if (warzoneName != null && !warzoneName.equals("")) {
War.war.log("Loading zone " + warzoneName + "...", Level.INFO);
Warzone zone = WarzoneMapper.load(warzoneName, !this.newWarInstall);
Warzone zone = WarzoneTxtMapper.load(warzoneName, !this.newWarInstall);
if (zone != null) { // could have failed, would've been logged already
War.war.getWarzones().add(zone);
// zone.getVolume().loadCorners();
@ -31,7 +32,7 @@ public class RestoreWarzonesJob implements Runnable {
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
}
if (zone.isResetOnLoad()) {
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONLOAD)) {
zone.getVolume().resetBlocks();
}
zone.initializeZone();

View File

@ -0,0 +1,54 @@
package com.tommytony.war.jobs;
import java.util.logging.Level;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import bukkit.tommytony.war.War;
import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.VolumeMapper;
import com.tommytony.war.volumes.Volume;
public class RestoreYmlWarhubJob implements Runnable {
private final ConfigurationSection warhubConfig;
public RestoreYmlWarhubJob(ConfigurationSection warhubConfig) {
this.warhubConfig = warhubConfig;
}
public void run() {
int hubX = warhubConfig.getInt("x");
int hubY = warhubConfig.getInt("y");
int hubZ = warhubConfig.getInt("z");
String worldName = warhubConfig.getString("world");
String hubOrientation = warhubConfig.getString("orientation");
World world = War.war.getServer().getWorld(worldName);
if (world != null) {
Location hubLocation = new Location(world, hubX, hubY, hubZ);
WarHub hub = new WarHub(hubLocation, hubOrientation);
War.war.setWarHub(hub);
Volume vol = VolumeMapper.loadVolume("warhub", "", world);
hub.setVolume(vol);
hub.getVolume().resetBlocks();
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)
for (Warzone zone : War.war.getWarzones()) {
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
zone.getLobby().initialize();
}
}
War.war.log("Warhub ready.", Level.INFO);
} else {
War.war.log("Failed to restore warhub. The specified world (name: " + worldName + ") does not exist!", Level.WARNING);
}
}
}

View File

@ -0,0 +1,49 @@
package com.tommytony.war.jobs;
import java.util.List;
import java.util.logging.Level;
import bukkit.tommytony.war.War;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.mappers.WarzoneYmlMapper;
public class RestoreYmlWarzonesJob implements Runnable {
private final List<String> warzones;
private final boolean newWarInstall;
public RestoreYmlWarzonesJob(List<String> warzones, boolean newWarInstall) {
this.warzones = warzones;
this.newWarInstall = newWarInstall;
}
public void run() {
War.war.getWarzones().clear();
if (this.warzones != null) {
for (String warzoneName : this.warzones) {
if (warzoneName != null && !warzoneName.equals("")) {
War.war.log("Loading zone " + warzoneName + "...", Level.INFO);
Warzone zone = WarzoneYmlMapper.load(warzoneName, !this.newWarInstall);
if (zone != null) { // could have failed, would've been logged already
War.war.getWarzones().add(zone);
zone.getVolume().loadCorners();
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
}
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONLOAD)) {
zone.getVolume().resetBlocks();
}
zone.initializeZone();
}
}
}
if (War.war.getWarzones().size() > 0) {
War.war.log("Warzones ready.", Level.INFO);
}
}
}
}

View File

@ -44,8 +44,8 @@ public class ScoreCapReachedJob implements Runnable {
}
if (this.winnersStr.contains(t.getName())) {
// give reward
for (Integer slot : this.zone.getReward().keySet()) {
ItemStack item = this.zone.getReward().get(slot);
for (Integer slot : t.getInventories().resolveReward().keySet()) {
ItemStack item = t.getInventories().resolveReward().get(slot);
if (item != null) {
tp.getInventory().addItem(item);
}

View File

@ -0,0 +1,62 @@
package com.tommytony.war.mappers;
import java.util.HashMap;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
public class LoadoutTxtMapper {
public static String fromLoadoutToString(HashMap<Integer, ItemStack> loadout) {
String loadoutString = "";
for (Integer slot : loadout.keySet()) {
ItemStack item = loadout.get(slot);
if (item != null) {
loadoutString += item.getTypeId() + "," + item.getAmount() + "," + slot + "," + item.getDurability() + "," + item.getData().getData();
if (item.getEnchantments().keySet().size() > 0) {
String enchantmentsStr = "";
for (Enchantment enchantment : item.getEnchantments().keySet()) {
enchantmentsStr += enchantment.getId() + ":" + item.getEnchantments().get(enchantment) + "::";
}
loadoutString += "," + enchantmentsStr;
}
}
loadoutString += ";";
}
return loadoutString;
}
public static void fromStringToLoadout(String loadoutString, HashMap<Integer, ItemStack> destinationLoadout) {
String[] rewardStrSplit = loadoutString.split(";");
destinationLoadout.clear();
for (String itemStr : rewardStrSplit) {
if (itemStr != null && !itemStr.equals("")) {
String[] itemStrSplit = itemStr.split(",");
ItemStack item = null;
if (itemStrSplit.length == 3) {
item = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]));
} else if (itemStrSplit.length == 5) {
short durability = Short.parseShort(itemStrSplit[3]);
item = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]), durability, Byte.parseByte(itemStrSplit[4]));
item.setDurability(durability);
} else if (itemStrSplit.length == 6) {
short durability = Short.parseShort(itemStrSplit[3]);
item = new ItemStack(Integer.parseInt(itemStrSplit[0]), Integer.parseInt(itemStrSplit[1]), durability, Byte.parseByte(itemStrSplit[4]));
item.setDurability(durability);
// enchantments
String[] enchantmentsSplit = itemStrSplit[5].split("::");
for (String enchantmentStr : enchantmentsSplit) {
if (!enchantmentStr.equals("")) {
String[] enchantmentSplit = enchantmentStr.split(":");
int enchantId = Integer.parseInt(enchantmentSplit[0]);
int level = Integer.parseInt(enchantmentSplit[1]);
item.addEnchantment(Enchantment.getById(enchantId), level);
}
}
}
destinationLoadout.put(Integer.parseInt(itemStrSplit[2]), item);
}
}
}
}

View File

@ -0,0 +1,87 @@
package com.tommytony.war.mappers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
public class LoadoutYmlMapper {
public static void fromConfigToLoadouts(ConfigurationSection config, HashMap<String, HashMap<Integer, ItemStack>> loadouts) {
List<String> loadoutNames = config.getStringList("names");
loadouts.clear();
for (String name : loadoutNames) {
HashMap<Integer, ItemStack> newLoadout = new HashMap<Integer, ItemStack>();
loadouts.put(name, newLoadout);
fromConfigToLoadout(config, newLoadout, name);
}
}
public static void fromConfigToLoadout(ConfigurationSection config, HashMap<Integer, ItemStack> loadout, String loadoutName) {
List<Integer> slots = config.getIntegerList(loadoutName + ".slots");
for (Integer slot : slots) {
String prefix = loadoutName + "." + slot + ".";
int id = config.getInt(prefix + "id");
byte data = Byte.parseByte(config.getString(prefix + "data"));
int amount = config.getInt(prefix + "amount");
short durability = Short.parseShort(config.getString(prefix + "durability"));
ItemStack stack = new ItemStack(id, amount, durability, data);
stack.setDurability(durability);
if (config.contains(prefix + "enchantments")) {
List<String> enchantmentStringList = config.getStringList(prefix + "enchantments");
for (String enchantmentString : enchantmentStringList) {
String[] enchantmentStringSplit = enchantmentString.split(",");
if (enchantmentStringSplit.length == 2) {
int enchantId = Integer.parseInt(enchantmentStringSplit[0]);
int level = Integer.parseInt(enchantmentStringSplit[1]);
stack.addEnchantment(Enchantment.getById(enchantId), level);
}
}
}
}
}
public static void fromLoadoutsToConfig(HashMap<String, HashMap<Integer, ItemStack>> loadouts, ConfigurationSection config) {
config.set("names", loadouts.keySet());
for (String name : loadouts.keySet()) {
fromLoadoutToConfig(loadouts.get(name), config, name);
}
}
public static void fromLoadoutToConfig(HashMap<Integer, ItemStack> loadout, ConfigurationSection config, String loadoutName) {
//ConfigurationSection loadoutSection = config.createSection(loadoutName);
//loadoutSection.set("slots", loadout.keySet());
config.set(loadoutName + ".slots", loadout.keySet());
for (Integer slot : loadout.keySet()) {
// ConfigurationSection slotSection = loadoutSection.createSection(slot.toString());
// ItemStack stack = loadout.get(slot);
//
// slotSection.set("id", stack.getTypeId());
// slotSection.set("data", Byte.toString(stack.getData().getData()));
// slotSection.set("amount", stack.getAmount());
// slotSection.set("durability", Short.toString(stack.getDurability()));
ItemStack stack = loadout.get(slot);
String slotPrefix = loadoutName + "." + slot + ".";
config.set(slotPrefix + "id", stack.getTypeId());
config.set(slotPrefix + "data", Byte.toString(stack.getData().getData()));
config.set(slotPrefix + "amount", stack.getAmount());
config.set(slotPrefix + "durability", Short.toString(stack.getDurability()));
if (stack.getEnchantments().keySet().size() > 0) {
List<String> enchantmentStringList = new ArrayList<String>();
for (Enchantment enchantment : stack.getEnchantments().keySet()) {
int level = stack.getEnchantments().get(enchantment);
enchantmentStringList.add(enchantment.getId() + "," + level);
}
config.set(slotPrefix + "enchantments", enchantmentStringList);
}
}
}
}

View File

@ -194,7 +194,6 @@ public class VolumeMapper {
}
} else if (typeId == Material.DISPENSER.getId()) {
// Dispensers
String extra = "";
List<ItemStack> contents = volume.getInvBlockContents().get("dispenser-" + i + "-" + j + "-" + k);
if (contents != null) {
out.write(buildInventoryStringFromItemList(contents));

View File

@ -0,0 +1,461 @@
package com.tommytony.war.mappers;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.logging.Level;
import org.bukkit.inventory.ItemStack;
import bukkit.tommytony.war.War;
import com.tommytony.war.FlagReturn;
import com.tommytony.war.TeamSpawnStyle;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.jobs.RestoreWarhubJob;
import com.tommytony.war.jobs.RestoreWarzonesJob;
/**
*
* @author tommytony
*
*/
public class WarTxtMapper {
public static void load() {
load(false);
}
public static void load(boolean convertingToYml) {
(War.war.getDataFolder()).mkdir();
(new File(War.war.getDataFolder().getPath() + "/dat")).mkdir();
PropertiesFile warConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/war.txt");
try {
warConfig.load();
} catch (IOException e) {
War.war.log("Failed to load war.txt file.", Level.WARNING);
e.printStackTrace();
}
// Create file if need be
boolean newWar = false;
if (!warConfig.containsKey("warzones")) {
newWar = true;
WarTxtMapper.save();
War.war.log("war.txt settings file created.", Level.INFO);
try {
warConfig.load();
} catch (IOException e) {
War.war.log("Failed to reload war.txt file after creating it.", Level.WARNING);
e.printStackTrace();
}
}
// warzones
String warzonesStr = warConfig.getString("warzones");
if (!convertingToYml) {
// No need to load the warzones if we're about to convert them
RestoreWarzonesJob restoreWarzones = new RestoreWarzonesJob(warzonesStr, newWar);
if (War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, restoreWarzones) == -1) {
War.war.log("Failed to schedule warzone-restore job. No warzone was loaded.", Level.WARNING);
}
}
// zone makers
String[] makers = warConfig.getString("zoneMakers").split(",");
War.war.getZoneMakerNames().clear();
for (String makerName : makers) {
if (makerName != null && !makerName.equals("")) {
War.war.getZoneMakerNames().add(makerName);
}
}
// command whitelist
String[] whitelist = warConfig.getString("commandWhitelist").split(",");
War.war.getCommandWhitelist().clear();
for (String command : whitelist) {
if (command != null && !command.equals("")) {
War.war.getCommandWhitelist().add(command);
}
}
// defaultLoadout
War.war.getDefaultInventories().getLoadouts().clear();
String loadoutStr = warConfig.getString("defaultLoadout");
if (loadoutStr != null && !loadoutStr.equals("")) {
War.war.getDefaultInventories().addLoadout("default", new HashMap<Integer, ItemStack>());
LoadoutTxtMapper.fromStringToLoadout(loadoutStr, War.war.getDefaultInventories().getLoadouts().get("default"));
}
// defaultExtraLoadouts
String extraLoadoutStr = warConfig.getString("defaultExtraLoadouts");
String[] extraLoadoutsSplit = extraLoadoutStr.split(",");
for (String nameStr : extraLoadoutsSplit) {
if (nameStr != null && !nameStr.equals("")) {
War.war.getDefaultInventories().addLoadout(nameStr, new HashMap<Integer, ItemStack>());
}
}
for (String extraName : extraLoadoutsSplit) {
if (extraName != null && !extraName.equals("")) {
String loadoutString = warConfig.getString(extraName + "Loadout");
HashMap<Integer, ItemStack> loadout = War.war.getDefaultInventories().getLoadouts().get(extraName);
LoadoutTxtMapper.fromStringToLoadout(loadoutString, loadout);
}
}
// maxZones
if (warConfig.keyExists("maxZones")) {
War.war.getWarConfig().put(WarConfig.MAXZONES, warConfig.getInt("maxZones"));
}
// defaultLifePool
if (warConfig.keyExists("defaultLifePool")) {
War.war.getTeamDefaultConfig().put(TeamConfig.LIFEPOOL, warConfig.getInt("defaultLifePool"));
}
// defaultMonumentHeal
if (warConfig.keyExists("defaultMonumentHeal")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.MONUMENTHEAL, warConfig.getInt("defaultMonumentHeal"));
}
// defaultFriendlyFire
if (warConfig.keyExists("defaultFriendlyFire")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.FRIENDLYFIRE, warConfig.getBoolean("defaultFriendlyFire"));
}
// defaultAutoAssignOnly
if (warConfig.keyExists("defaultAutoAssignOnly")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.AUTOASSIGN, warConfig.getBoolean("defaultAutoAssignOnly"));
}
// defaultFlagPointsOnly
if (warConfig.keyExists("defaultFlagPointsOnly")) {
War.war.getTeamDefaultConfig().put(TeamConfig.LIFEPOOL, warConfig.getBoolean("defaultFlagPointsOnly"));
}
// defaultFlagMustBeHome
if (warConfig.keyExists("defaultFlagMustBeHome")) {
War.war.getTeamDefaultConfig().put(TeamConfig.FLAGMUSTBEHOME, warConfig.getBoolean("defaultFlagMustBeHome"));
}
// defaultTeamCap
if (warConfig.keyExists("defaultTeamCap")) {
War.war.getTeamDefaultConfig().put(TeamConfig.TEAMSIZE, warConfig.getInt("defaultTeamCap"));
}
// defaultScoreCap
if (warConfig.keyExists("defaultScoreCap")) {
War.war.getTeamDefaultConfig().put(TeamConfig.MAXSCORE, warConfig.getInt("defaultScoreCap"));
}
// defaultRespawnTimer
if (warConfig.keyExists("defaultRespawnTimer")) {
War.war.getTeamDefaultConfig().put(TeamConfig.RESPAWNTIMER, warConfig.getInt("defaultRespawnTimer"));
}
// pvpInZonesOnly
if (warConfig.keyExists("pvpInZonesOnly")) {
War.war.getWarConfig().put(WarConfig.PVPINZONESONLY, warConfig.getBoolean("pvpInZonesOnly"));
}
// defaultBlockHeads
if (warConfig.keyExists("defaultBlockHeads")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.BLOCKHEADS, warConfig.getBoolean("defaultBlockHeads"));
}
// buildInZonesOnly
if (warConfig.keyExists("buildInZonesOnly")) {
War.war.getWarConfig().put(WarConfig.BUILDINZONESONLY, warConfig.getBoolean("buildInZonesOnly"));
}
// disablePVPMessage
if (warConfig.keyExists("disablePvpMessage")) {
War.war.getWarConfig().put(WarConfig.DISABLEPVPMESSAGE, warConfig.getBoolean("disablePvpMessage"));
}
// disableBuildMessage
if (warConfig.keyExists("disableBuildMessage")) {
War.war.getWarConfig().put(WarConfig.DISABLEBUILDMESSAGE, warConfig.getBoolean("disableBuildMessage"));
}
// tntInZonesOnly
if (warConfig.keyExists("tntInZonesOnly")) {
War.war.getWarConfig().put(WarConfig.TNTINZONESONLY, warConfig.getBoolean("tntInZonesOnly"));
}
// defaultSpawnStyle
String spawnStyle = warConfig.getString("defaultspawnStyle");
if (spawnStyle != null && !spawnStyle.equals("")) {
War.war.getTeamDefaultConfig().put(TeamConfig.SPAWNSTYLE, TeamSpawnStyle.getStyleFromString(spawnStyle));
}
// defaultFlagReturn
String flagReturn = warConfig.getString("defaultFlagReturn");
if (flagReturn != null && !flagReturn.equals("")) {
War.war.getTeamDefaultConfig().put(TeamConfig.FLAGRETURN, FlagReturn.getFromString(flagReturn));
}
// defaultReward
String defaultRewardStr = warConfig.getString("defaultReward");
if (defaultRewardStr != null && !defaultRewardStr.equals("")) {
LoadoutTxtMapper.fromStringToLoadout(defaultRewardStr, War.war.getDefaultInventories().getReward());
}
// defaultUnbreakableZoneBlocks
if (warConfig.keyExists("defaultUnbreakableZoneBlocks")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.UNBREAKABLE, warConfig.getBoolean("defaultUnbreakableZoneBlocks"));
}
// defaultNoCreatures
if (warConfig.keyExists("defaultNoCreatures")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.NOCREATURES, warConfig.getBoolean("defaultNoCreatures"));
}
// defaultGlassWalls
if (warConfig.keyExists("defaultGlassWalls")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.GLASSWALLS, warConfig.getBoolean("defaultGlassWalls"));
}
// defaultPvpInZone
if (warConfig.keyExists("defaultPvpInZone")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.PVPINZONE, warConfig.getBoolean("defaultPvpInZone"));
}
// defaultInstaBreak
if (warConfig.keyExists("defaultInstaBreak")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.INSTABREAK, warConfig.getBoolean("defaultInstaBreak"));
}
// defaultNoDrops
if (warConfig.keyExists("defaultNoDrops")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.NODROPS, warConfig.getBoolean("defaultNoDrops"));
}
// defaultNoHunger
if (warConfig.keyExists("defaultNoHunger")) {
War.war.getTeamDefaultConfig().put(TeamConfig.NOHUNGER, warConfig.getBoolean("defaultNoHunger"));
}
// defaultSaturation
if (warConfig.keyExists("defaultSaturation")) {
War.war.getTeamDefaultConfig().put(TeamConfig.SATURATION, warConfig.getInt("defaultSaturation"));
}
// defaultMinPlayers
if (warConfig.keyExists("defaultMinPlayers")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.MINPLAYERS, warConfig.getInt("defaultMinPlayers"));
}
// defaultMinTeams
if (warConfig.keyExists("defaultMinTeams")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.MINTEAMS, warConfig.getInt("defaultMinTeams"));
}
// defaultResetOnEmpty
if (warConfig.keyExists("defaultResetOnEmpty")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.RESETONEMPTY, warConfig.getBoolean("defaultResetOnEmpty"));
}
// defaultResetOnLoad
if (warConfig.keyExists("defaultResetOnLoad")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.RESETONLOAD, warConfig.getBoolean("defaultResetOnLoad"));
}
// defaultResetOnUnload
if (warConfig.keyExists("defaultResetOnUnload")) {
War.war.getWarzoneDefaultConfig().put(WarzoneConfig.RESETONUNLOAD, warConfig.getBoolean("defaultResetOnUnload"));
}
// warhub
String hubStr = warConfig.getString("warhub");
if (hubStr != null && !hubStr.equals("")) {
RestoreWarhubJob restoreWarhub = new RestoreWarhubJob(hubStr);
if (War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, restoreWarhub) == -1) {
War.war.log("Failed to schedule warhub-restore job. War hub was not loaded.", Level.WARNING);
}
}
warConfig.close();
}
public static void save() {
// PropertiesFile warConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/war.txt");
// String warzonesStr = "";
War.war.log("Saving War with WarTxtMapper", Level.SEVERE);
// // warzones
// for (Warzone zone : War.war.getWarzones()) {
// warzonesStr += zone.getName() + ",";
// }
// warConfig.setString("warzones", warzonesStr);
//
// // zone makers: default is none and it means everyone can use /setzone
// String makersStr = ""; // everyone
// for (String name : War.war.getZoneMakerNames()) {
// makersStr += name + ",";
// }
// warConfig.setString("zoneMakers", makersStr);
//
// // whitelisted commands during a game
// String commandWhitelistStr = ""; // everyone
// for (String command : War.war.getCommandWhitelist()) {
// commandWhitelistStr += command + ",";
// }
// warConfig.setString("commandWhitelist", commandWhitelistStr);
//
// // defaultLoadout
// HashMap<Integer, ItemStack> items = War.war.getDefaultInventories().getLoadouts().get("default");
// warConfig.setString("defaultLoadout", LoadoutTxtMapper.fromLoadoutToString(items));
//
// // defaultExtraLoadouts
// String extraLoadoutsStr = "";
// for (String name : War.war.getDefaultInventories().getLoadouts().keySet()) {
// if (!name.equals("default")) {
// extraLoadoutsStr += name + ",";
//
// HashMap<Integer, ItemStack> loadout = War.war.getDefaultInventories().getLoadouts().get(name);
// warConfig.setString(name + "Loadout", LoadoutTxtMapper.fromLoadoutToString(loadout));
// }
// }
// warConfig.setString("defaultExtraLoadouts", extraLoadoutsStr);
//
// // maxZones
// warConfig.setInt("maxZones", War.war.getWarConfig().getInt(WarConfig.MAXZONES));
//
// // defaultLifepool
// warConfig.setInt("defaultLifePool", War.war.getDefaultLifepool());
//
// // defaultMonumentHeal
// warConfig.setInt("defaultMonumentHeal", War.war.getDefaultMonumentHeal());
//
// // defaultFriendlyFire
// warConfig.setBoolean("defaultFriendlyFire", War.war.isDefaultFriendlyFire());
//
// // defaultAutoAssignOnly
// warConfig.setBoolean("defaultAutoAssignOnly", War.war.isDefaultAutoAssignOnly());
//
// // defaultFlagPointsOnly
// warConfig.setBoolean("defaultFlagPointsOnly", War.war.isDefaultFlagPointsOnly());
//
// // defaultFlagMustBeHome
// warConfig.setBoolean("defaultFlagMustBeHome", War.war.isDefaultFlagMustBeHome());
//
// // defaultTeamCap
// warConfig.setInt("defaultTeamCap", War.war.getDefaultTeamCap());
//
// // defaultScoreCap
// warConfig.setInt("defaultScoreCap", War.war.getDefaultScoreCap());
//
// // defaultRespawnTimer
// warConfig.setInt("defaultRespawnTimer", War.war.getDefaultRespawnTimer());
//
// // pvpInZonesOnly
// warConfig.setBoolean("pvpInZonesOnly", War.war.getWarConfig().getBoolean(WarConfig.PVPINZONESONLY));
//
// // defaultBlockHeads
// warConfig.setBoolean("defaultBlockHeads", War.war.isDefaultBlockHeads());
//
// // buildInZonesOnly
// warConfig.setBoolean("buildInZonesOnly", War.war.getWarConfig().getBoolean(WarConfig.BUILDINZONESONLY));
//
// // disablePVPMessage
// warConfig.setBoolean("disablePvpMessage", War.war.getWarConfig().getBoolean(WarConfig.DISABLEPVPMESSAGE));
//
// // disableBuildMessage
// warConfig.setBoolean("disableBuildMessage", War.war.getWarConfig().getBoolean(WarConfig.DISABLEBUILDMESSAGE));
//
// // tntInZonesOnly
// warConfig.setBoolean("tntInZonesOnly", War.war.getWarConfig().getBoolean(WarConfig.TNTINZONESONLY));
//
// // spawnStyle
// warConfig.setString("spawnStyle", War.war.getDefaultSpawnStyle().toString());
//
// // flagReturn
// warConfig.setString("flagReturn", War.war.getDefaultFlagReturn().toString());
//
// // defaultReward
// String defaultRewardStr = "";
// HashMap<Integer, ItemStack> rewardItems = War.war.getDefaultInventories().getReward();
// for (Integer slot : rewardItems.keySet()) {
// ItemStack item = items.get(slot);
// if (item != null) {
// defaultRewardStr += item.getTypeId() + "," + item.getAmount() + "," + slot + ";";
// }
// }
// warConfig.setString("defaultReward", defaultRewardStr);
//
// // defaultUnbreakableZoneBlocks
// warConfig.setBoolean("defaultUnbreakableZoneBlocks", War.war.isDefaultUnbreakableZoneBlocks());
//
// // defaultNoCreatures
// warConfig.setBoolean("defaultNoCreatures", War.war.isDefaultNoCreatures());
//
// // defaultGlassWalls
// warConfig.setBoolean("defaultGlassWalls", War.war.isDefaultGlassWalls());
//
// // defaultPvpInZone
// warConfig.setBoolean("defaultPvpInZone", War.war.isDefaultPvpInZone());
//
// // defaultInstaBreak
// warConfig.setBoolean("defaultInstaBreak", War.war.isDefaultInstaBreak());
//
// // defaultNoDrops
// warConfig.setBoolean("defaultNoDrops", War.war.isDefaultNoDrops());
//
// // defaultNoHunger
// warConfig.setBoolean("defaultNoHunger", War.war.isDefaultNoHunger());
//
// // defaultSaturation
// warConfig.setInt("defaultSaturation", War.war.getDefaultSaturation());
//
// // defaultMinPlayers
// warConfig.setInt("defaultMinPlayers", War.war.getDefaultMinPlayers());
//
// // defaultMinTeams
// warConfig.setInt("defaultMinTeams", War.war.getDefaultMinTeams());
//
// // defaultResetOnEmpty
// warConfig.setBoolean("defaultResetOnEmpty", War.war.isDefaultResetOnEmpty());
//
// // defaultResetOnLoad
// warConfig.setBoolean("defaultResetOnLoad", War.war.isDefaultResetOnLoad());
//
// // defaultResetOnUnload
// warConfig.setBoolean("defaultResetOnUnload", War.war.isDefaultResetOnUnload());
//
// // warhub
// String hubStr = "";
// WarHub hub = War.war.getWarHub();
// if (hub != null) {
// String orientationStr = "";
// switch (hub.getOrientation()) {
// case SOUTH:
// orientationStr = "south";
// break;
// case EAST:
// orientationStr = "east";
// break;
// case NORTH:
// orientationStr = "north";
// break;
// case WEST:
// default:
// orientationStr = "west";
// break;
// }
// hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ() + ","
// + hub.getLocation().getWorld().getName() + "," + orientationStr;
// VolumeMapper.save(hub.getVolume(), "");
// }
// warConfig.setString("warhub", hubStr);
//
// warConfig.save();
// warConfig.close();
}
}

View File

@ -0,0 +1,178 @@
package com.tommytony.war.mappers;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import bukkit.tommytony.war.War;
import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.jobs.RestoreYmlWarhubJob;
import com.tommytony.war.jobs.RestoreYmlWarzonesJob;
public class WarYmlMapper {
public static void load() {
(War.war.getDataFolder()).mkdir();
(new File(War.war.getDataFolder().getPath() + "/dat")).mkdir();
File warTxtFile = new File(War.war.getDataFolder().getPath() + "/war.txt");
File warYmlFile = new File(War.war.getDataFolder().getPath() + "/war.yml");
boolean newWar = false;
if (warTxtFile.exists() && !warYmlFile.exists()) {
// Load both War and warzones (with delay) in old format, save War to new format immediatly
WarTxtMapper.load(true);
WarYmlMapper.save();
War.war.log("Converted war.txt to war.yml.", Level.INFO);
} else if (!warTxtFile.exists() && !warYmlFile.exists()) {
// Save defaults to disk
newWar = true;
WarYmlMapper.save();
War.war.log("war.yml settings file created.", Level.INFO);
}
YamlConfiguration warYmlConfig = YamlConfiguration.loadConfiguration(warYmlFile);
// warzones
List<String> warzones = warYmlConfig.getStringList("war.info.warzones");
RestoreYmlWarzonesJob restoreWarzones = new RestoreYmlWarzonesJob(warzones, newWar); // during conversion, this should execute just after the RestoreTxtWarzonesJob
if (War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, restoreWarzones) == -1) {
War.war.log("Failed to schedule warzone-restore job. No warzone was loaded.", Level.WARNING);
}
// zone makers
List<String> makers = warYmlConfig.getStringList("war.info.zonemakers");
War.war.getZoneMakerNames().clear();
for (String makerName : makers) {
if (makerName != null && !makerName.equals("")) {
War.war.getZoneMakerNames().add(makerName);
}
}
// command whitelist
List<String> whitelist = warYmlConfig.getStringList("war.info.commandwhitelist");
War.war.getCommandWhitelist().clear();
for (String command : whitelist) {
if (command != null && !command.equals("")) {
War.war.getCommandWhitelist().add(command);
}
}
// defaultLoadouts
ConfigurationSection loadoutsSection = warYmlConfig.getConfigurationSection("team.default.loadout");
LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, War.war.getDefaultInventories().getLoadouts());
// defaultReward
ConfigurationSection rewardsSection = warYmlConfig.getConfigurationSection("team.default.reward");
HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
War.war.getDefaultInventories().setReward(reward);
// War settings
ConfigurationSection warConfigSection = warYmlConfig.getConfigurationSection("war.config");
War.war.getWarConfig().loadFrom(warConfigSection);
// Warzone default settings
ConfigurationSection warzoneConfigSection = warYmlConfig.getConfigurationSection("warzone.default.config");
War.war.getWarzoneDefaultConfig().loadFrom(warzoneConfigSection);
// Team default settings
ConfigurationSection teamConfigSection = warYmlConfig.getConfigurationSection("team.default.config");
War.war.getTeamDefaultConfig().loadFrom(teamConfigSection);
// warhub
ConfigurationSection hubConfigSection = warYmlConfig.getConfigurationSection("war.info.warhub");
if (hubConfigSection != null) {
RestoreYmlWarhubJob restoreWarhub = new RestoreYmlWarhubJob(hubConfigSection);
if (War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, restoreWarhub) == -1) {
War.war.log("Failed to schedule warhub-restore job. War hub was not loaded.", Level.WARNING);
}
}
}
public static void save() {
YamlConfiguration warYmlConfig = new YamlConfiguration();
(new File(War.war.getDataFolder().getPath())).mkdir();
(new File(War.war.getDataFolder().getPath() + "/dat")).mkdir();
// warzones
List<String> warzones = new ArrayList<String>();
for (Warzone zone : War.war.getWarzones()) {
warzones.add(zone.getName());
}
warYmlConfig.set("war.info.warzones", warzones);
// zone makers
warYmlConfig.set("war.info.zonemakers", War.war.getZoneMakerNames());
// whitelisted commands during a game
warYmlConfig.set("war.info.commandwhitelist", War.war.getCommandWhitelist());
// defaultLoadouts
ConfigurationSection loadoutsSection = warYmlConfig.createSection("team.default.loadout");
LoadoutYmlMapper.fromLoadoutsToConfig(War.war.getDefaultInventories().getLoadouts(), loadoutsSection);
// defaultReward
ConfigurationSection rewardsSection = warYmlConfig.createSection("team.default.reward");
LoadoutYmlMapper.fromLoadoutToConfig(War.war.getDefaultInventories().getReward(), rewardsSection, "default");
// War settings
ConfigurationSection warConfigSection = warYmlConfig.createSection("war.config");
War.war.getWarConfig().saveTo(warConfigSection);
// Warzone default settings
ConfigurationSection warzoneConfigSection = warYmlConfig.createSection("warzone.default.config");
War.war.getWarzoneDefaultConfig().saveTo(warzoneConfigSection);
// Team default settings
ConfigurationSection teamConfigSection = warYmlConfig.createSection("team.default.config");
War.war.getTeamDefaultConfig().saveTo(teamConfigSection);
// warhub
WarHub hub = War.war.getWarHub();
if (hub != null) {
String orientationStr = "";
switch (hub.getOrientation()) {
case SOUTH:
orientationStr = "south";
break;
case EAST:
orientationStr = "east";
break;
case NORTH:
orientationStr = "north";
break;
case WEST:
default:
orientationStr = "west";
break;
}
ConfigurationSection hubConfigSection = warYmlConfig.createSection("war.info.warhub");
hubConfigSection.set("x", hub.getLocation().getBlockX());
hubConfigSection.set("y", hub.getLocation().getBlockY());
hubConfigSection.set("z", hub.getLocation().getBlockZ());
hubConfigSection.set("world", hub.getLocation().getWorld().getName());
hubConfigSection.set("orientation", orientationStr);
VolumeMapper.save(hub.getVolume(), "");
}
// Save to disk
File warConfigFile = new File(War.war.getDataFolder().getPath() + "/war.yml");
try {
warYmlConfig.save(warConfigFile);
} catch (IOException e) {
War.war.log("Failed to save war.yml", Level.WARNING);
e.printStackTrace();
}
}
}

View File

@ -443,7 +443,6 @@ public class WarzoneMapper {
warzoneConfig.setBoolean("friendlyFire", warzone.getFriendlyFire());
// loadout
String loadoutStr = "";
HashMap<Integer, ItemStack> items = warzone.getLoadout();
warzoneConfig.setString("loadout", fromLoadoutToString(items));
@ -494,7 +493,6 @@ public class WarzoneMapper {
warzoneConfig.setString("flagReturn", warzone.getFlagReturn().toString());
// reward
String rewardStr = "";
HashMap<Integer, ItemStack> rewardItems = warzone.getReward();
warzoneConfig.setString("reward", fromLoadoutToString(rewardItems));

View File

@ -0,0 +1,625 @@
package com.tommytony.war.mappers;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.logging.Level;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
import bukkit.tommytony.war.War;
import com.tommytony.war.FlagReturn;
import com.tommytony.war.Monument;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.TeamSpawnStyle;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.volumes.Volume;
import com.tommytony.war.volumes.ZoneVolume;
/**
*
* @author tommytony
*
*/
public class WarzoneTxtMapper {
public static Warzone load(String name, boolean createNewVolume) {
// war.getLogger().info("Loading warzone " + name + " config and blocks...");
PropertiesFile warzoneConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
try {
warzoneConfig.load();
} catch (IOException e) {
War.war.getLogger().info("Failed to load warzone-" + name + ".txt file.");
e.printStackTrace();
}
// world
String worldStr = warzoneConfig.getProperty("world");
World world = null;
if (worldStr == null || worldStr.equals("")) {
world = War.war.getServer().getWorlds().get(0); // default to first world
} else {
world = War.war.getServer().getWorld(worldStr);
}
if (world == null) {
War.war.log("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!", Level.WARNING);
} else {
// Create the zone
Warzone warzone = new Warzone(world, name);
// Create file if needed
if (!warzoneConfig.containsKey("name")) {
WarzoneTxtMapper.save(warzone, false);
War.war.getLogger().info("Warzone " + name + " config file created.");
try {
warzoneConfig.load();
} catch (IOException e) {
// war.getLogger().info("Failed to reload warzone-" + name + ".txt file after creating it.");
e.printStackTrace();
}
}
// teleport
String teleportStr = warzoneConfig.getString("teleport");
if (teleportStr != null && !teleportStr.equals("")) {
String[] teleportSplit = teleportStr.split(",");
int teleX = Integer.parseInt(teleportSplit[0]);
int teleY = Integer.parseInt(teleportSplit[1]);
int teleZ = Integer.parseInt(teleportSplit[2]);
int yaw = Integer.parseInt(teleportSplit[3]);
warzone.setTeleport(new Location(world, teleX, teleY, teleZ, yaw, 0));
}
// ff
if (warzoneConfig.containsKey("friendlyFire")) {
warzone.getWarzoneConfig().put(WarzoneConfig.FRIENDLYFIRE, warzoneConfig.getBoolean("friendlyFire"));
}
// loadout
warzone.getDefaultInventories().getLoadouts().clear();
String loadoutStr = warzoneConfig.getString("loadout");
if (loadoutStr != null && !loadoutStr.equals("")) {
warzone.getDefaultInventories().getLoadouts().put("default", new HashMap<Integer, ItemStack>());
LoadoutTxtMapper.fromStringToLoadout(loadoutStr, warzone.getDefaultInventories().getLoadouts().get("default"));
}
// extraLoadouts
String extraLoadoutStr = warzoneConfig.getString("extraLoadouts");
String[] extraLoadoutsSplit = extraLoadoutStr.split(",");
for (String nameStr : extraLoadoutsSplit) {
if (nameStr != null && !nameStr.equals("")) {
warzone.getDefaultInventories().getLoadouts().put(nameStr, new HashMap<Integer, ItemStack>());
}
}
for (String extraName : extraLoadoutsSplit) {
String loadoutString = warzoneConfig.getString(extraName + "Loadout");
HashMap<Integer, ItemStack> loadout = warzone.getDefaultInventories().getLoadouts().get(extraName);
LoadoutTxtMapper.fromStringToLoadout(loadoutString, loadout);
}
// authors
if (warzoneConfig.containsKey("author") && !warzoneConfig.getString("author").equals("")) {
for(String authorStr : warzoneConfig.getString("author").split(",")) {
if (!authorStr.equals("")) {
warzone.addAuthor(authorStr);
}
}
}
// life pool (always set after teams, so the teams' remaining lives get initialized properly by this setter)
if (warzoneConfig.containsKey("lifePool")) {
warzone.getTeamDefaultConfig().put(TeamConfig.LIFEPOOL, warzoneConfig.getInt("lifePool"));
}
// monument heal
if (warzoneConfig.containsKey("monumentHeal")) {
warzone.getWarzoneConfig().put(WarzoneConfig.MONUMENTHEAL, warzoneConfig.getInt("monumentHeal"));
}
// autoAssignOnly
if (warzoneConfig.containsKey("autoAssignOnly")) {
warzone.getWarzoneConfig().put(WarzoneConfig.AUTOASSIGN, warzoneConfig.getBoolean("autoAssignOnly"));
}
// flagPointsOnly
if (warzoneConfig.containsKey("flagPointsOnly")) {
warzone.getTeamDefaultConfig().put(TeamConfig.FLAGPOINTSONLY, warzoneConfig.getBoolean("flagPointsOnly"));
}
// flagMustBeHome
if (warzoneConfig.containsKey("flagMustBeHome")) {
warzone.getTeamDefaultConfig().put(TeamConfig.FLAGMUSTBEHOME, warzoneConfig.getBoolean("flagMustBeHome"));
}
// team cap
if (warzoneConfig.containsKey("teamCap")) {
warzone.getTeamDefaultConfig().put(TeamConfig.TEAMSIZE, warzoneConfig.getInt("teamCap"));
}
// score cap
if (warzoneConfig.containsKey("scoreCap")) {
warzone.getTeamDefaultConfig().put(TeamConfig.MAXSCORE, warzoneConfig.getInt("scoreCap"));
}
// respawn timer
if (warzoneConfig.containsKey("respawnTimer")) {
warzone.getTeamDefaultConfig().put(TeamConfig.RESPAWNTIMER, warzoneConfig.getInt("respawnTimer"));
}
// blockHeads
if (warzoneConfig.containsKey("blockHeads")) {
warzone.getWarzoneConfig().put(WarzoneConfig.BLOCKHEADS, warzoneConfig.getBoolean("blockHeads"));
}
// spawnStyle
String spawnStyle = warzoneConfig.getString("spawnStyle");
if (spawnStyle != null && !spawnStyle.equals("")) {
warzone.getTeamDefaultConfig().put(TeamConfig.SPAWNSTYLE, TeamSpawnStyle.getStyleFromString(spawnStyle));
}
// flagReturn
String flagReturn = warzoneConfig.getString("flagReturn");
if (flagReturn != null && !flagReturn.equals("")) {
warzone.getTeamDefaultConfig().put(TeamConfig.FLAGRETURN, FlagReturn.getFromString(flagReturn));
}
// reward
String rewardStr = warzoneConfig.getString("reward");
if (rewardStr != null && !rewardStr.equals("")) {
HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
LoadoutTxtMapper.fromStringToLoadout(rewardStr, reward);
warzone.getDefaultInventories().setReward(reward);
}
// unbreakableZoneBlocks
if (warzoneConfig.containsKey("unbreakableZoneBlocks")) {
warzone.getWarzoneConfig().put(WarzoneConfig.UNBREAKABLE, warzoneConfig.getBoolean("unbreakableZoneBlocks"));
}
// disabled
if (warzoneConfig.containsKey("disabled")) {
warzone.getWarzoneConfig().put(WarzoneConfig.DISABLED, warzoneConfig.getBoolean("disabled"));
}
// noCreatures
if (warzoneConfig.containsKey("noCreatures")) {
warzone.getWarzoneConfig().put(WarzoneConfig.NOCREATURES, warzoneConfig.getBoolean("noCreatures"));
}
// glassWalls
if (warzoneConfig.containsKey("glassWalls")) {
warzone.getWarzoneConfig().put(WarzoneConfig.GLASSWALLS, warzoneConfig.getBoolean("glassWalls"));
}
// pvpInZone
if (warzoneConfig.containsKey("pvpInZone")) {
warzone.getWarzoneConfig().put(WarzoneConfig.PVPINZONE, warzoneConfig.getBoolean("pvpInZone"));
}
// instaBreak
if (warzoneConfig.containsKey("instaBreak")) {
warzone.getWarzoneConfig().put(WarzoneConfig.INSTABREAK, warzoneConfig.getBoolean("instaBreak"));
}
// noDrops
if (warzoneConfig.containsKey("noDrops")) {
warzone.getWarzoneConfig().put(WarzoneConfig.NODROPS, warzoneConfig.getBoolean("noDrops"));
}
// noHunger
if (warzoneConfig.containsKey("noHunger")) {
warzone.getTeamDefaultConfig().put(TeamConfig.NOHUNGER, warzoneConfig.getBoolean("noHunger"));
}
// saturation
if (warzoneConfig.containsKey("saturation")) {
warzone.getTeamDefaultConfig().put(TeamConfig.SATURATION, warzoneConfig.getInt("saturation"));
}
// minPlayers
if (warzoneConfig.containsKey("minPlayers")) {
warzone.getWarzoneConfig().put(WarzoneConfig.MINPLAYERS, warzoneConfig.getInt("minPlayers"));
}
// minTeams
if (warzoneConfig.containsKey("minTeams")) {
warzone.getWarzoneConfig().put(WarzoneConfig.MINTEAMS, warzoneConfig.getInt("minTeams"));
}
// resetOnEmpty
if (warzoneConfig.containsKey("resetOnEmpty")) {
warzone.getWarzoneConfig().put(WarzoneConfig.RESETONEMPTY, warzoneConfig.getBoolean("resetOnEmpty"));
}
// resetOnLoad
if (warzoneConfig.containsKey("resetOnLoad")) {
warzone.getWarzoneConfig().put(WarzoneConfig.RESETONLOAD, warzoneConfig.getBoolean("resetOnLoad"));
}
// resetOnUnload
if (warzoneConfig.containsKey("resetOnUnload")) {
warzone.getWarzoneConfig().put(WarzoneConfig.RESETONUNLOAD, warzoneConfig.getBoolean("resetOnUnload"));
}
// rallyPoint
String rallyPointStr = warzoneConfig.getString("rallyPoint");
if (rallyPointStr != null && !rallyPointStr.equals("")) {
String[] rallyPointStrSplit = rallyPointStr.split(",");
int rpX = Integer.parseInt(rallyPointStrSplit[0]);
int rpY = Integer.parseInt(rallyPointStrSplit[1]);
int rpZ = Integer.parseInt(rallyPointStrSplit[2]);
Location rallyPoint = new Location(world, rpX, rpY, rpZ);
warzone.setRallyPoint(rallyPoint);
}
// monuments
String monumentsStr = warzoneConfig.getString("monuments");
if (monumentsStr != null && !monumentsStr.equals("")) {
String[] monumentsSplit = monumentsStr.split(";");
warzone.getMonuments().clear();
for (String monumentStr : monumentsSplit) {
if (monumentStr != null && !monumentStr.equals("")) {
String[] monumentStrSplit = monumentStr.split(",");
int monumentX = Integer.parseInt(monumentStrSplit[1]);
int monumentY = Integer.parseInt(monumentStrSplit[2]);
int monumentZ = Integer.parseInt(monumentStrSplit[3]);
Monument monument = new Monument(monumentStrSplit[0], warzone, new Location(world, monumentX, monumentY, monumentZ));
warzone.getMonuments().add(monument);
}
}
}
// teams
String teamsStr = warzoneConfig.getString("teams");
if (teamsStr != null && !teamsStr.equals("")) {
String[] teamsSplit = teamsStr.split(";");
warzone.getTeams().clear();
for (String teamStr : teamsSplit) {
if (teamStr != null && !teamStr.equals("")) {
String[] teamStrSplit = teamStr.split(",");
int teamX = Integer.parseInt(teamStrSplit[1]);
int teamY = Integer.parseInt(teamStrSplit[2]);
int teamZ = Integer.parseInt(teamStrSplit[3]);
Location teamLocation = new Location(world, teamX, teamY, teamZ);
if (teamStrSplit.length > 4) {
int yaw = Integer.parseInt(teamStrSplit[4]);
teamLocation.setYaw(yaw);
}
Team team = new Team(teamStrSplit[0], TeamKind.teamKindFromString(teamStrSplit[0]), teamLocation, warzone);
team.setRemainingLives(warzone.getTeamDefaultConfig().getInt(TeamConfig.LIFEPOOL));
warzone.getTeams().add(team);
}
}
}
// teamFlags
String teamFlagsStr = warzoneConfig.getString("teamFlags");
if (teamFlagsStr != null && !teamFlagsStr.equals("")) {
String[] teamFlagsSplit = teamFlagsStr.split(";");
for (String teamFlagStr : teamFlagsSplit) {
if (teamFlagStr != null && !teamFlagStr.equals("")) {
String[] teamFlagStrSplit = teamFlagStr.split(",");
Team team = warzone.getTeamByKind(TeamKind.teamKindFromString(teamFlagStrSplit[0]));
if (team != null) {
int teamFlagX = Integer.parseInt(teamFlagStrSplit[1]);
int teamFlagY = Integer.parseInt(teamFlagStrSplit[2]);
int teamFlagZ = Integer.parseInt(teamFlagStrSplit[3]);
Location teamFlagLocation = new Location(world, teamFlagX, teamFlagY, teamFlagZ);
if (teamFlagStrSplit.length > 4) {
int yaw = Integer.parseInt(teamFlagStrSplit[4]);
teamFlagLocation.setYaw(yaw);
}
team.setTeamFlag(teamFlagLocation); // this may screw things up
}
}
}
}
// lobby
String lobbyStr = warzoneConfig.getString("lobby");
warzoneConfig.close();
if (createNewVolume) {
ZoneVolume zoneVolume = new ZoneVolume(warzone.getName(), world, warzone); // VolumeMapper.loadZoneVolume(warzone.getName(), warzone.getName(), war, warzone.getWorld(), warzone);
warzone.setVolume(zoneVolume);
}
// monument blocks
for (Monument monument : warzone.getMonuments()) {
monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), world));
}
// team spawn blocks
for (Team team : warzone.getTeams()) {
team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), world));
if (team.getTeamFlag() != null) {
team.setFlagVolume(VolumeMapper.loadVolume(team.getName() + "flag", warzone.getName(), world));
}
}
// lobby
BlockFace lobbyFace = null;
if (lobbyStr != null && !lobbyStr.equals("")) {
String[] lobbyStrSplit = lobbyStr.split(",");
if (lobbyStrSplit.length > 0) {
// lobby orientation
if (lobbyStrSplit[0].equals("south")) {
lobbyFace = BlockFace.SOUTH;
} else if (lobbyStrSplit[0].equals("east")) {
lobbyFace = BlockFace.EAST;
} else if (lobbyStrSplit[0].equals("north")) {
lobbyFace = BlockFace.NORTH;
} else if (lobbyStrSplit[0].equals("west")) {
lobbyFace = BlockFace.WEST;
}
// lobby world
World lobbyWorld = world; // by default, warzone world
if (lobbyStrSplit.length > 1) {
World strWorld = War.war.getServer().getWorld(lobbyStrSplit[1]);
if (strWorld != null) {
lobbyWorld = strWorld;
}
}
// create the lobby
Volume lobbyVolume = VolumeMapper.loadVolume("lobby", warzone.getName(), lobbyWorld);
ZoneLobby lobby = new ZoneLobby(warzone, lobbyFace, lobbyVolume);
warzone.setLobby(lobby);
}
}
return warzone;
}
return null;
}
public static void save(Warzone warzone, boolean saveAllBlocks) {
War.war.log("Saving War with WarzoneTxtMapper", Level.SEVERE);
// (new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + warzone.getName())).mkdir();
// PropertiesFile warzoneConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + warzone.getName() + ".txt");
// // war.getLogger().info("Saving warzone " + warzone.getName() + "...");
//
// // name
// warzoneConfig.setString("name", warzone.getName());
//
// // world
// warzoneConfig.setString("world", warzone.getWorld().getName()); // default for now
//
// // teleport
// String teleportStr = "";
// Location tele = warzone.getTeleport();
// if (tele != null) {
// int intYaw = 0;
// if (tele.getYaw() >= 0) {
// intYaw = (int) (tele.getYaw() % 360);
// } else {
// intYaw = (int) (360 + (tele.getYaw() % 360));
// }
// teleportStr = tele.getBlockX() + "," + tele.getBlockY() + "," + tele.getBlockZ() + "," + intYaw;
// }
// warzoneConfig.setString("teleport", teleportStr);
//
// // teams
// String teamsStr = "";
// List<Team> teams = warzone.getTeams();
// for (Team team : teams) {
// Location spawn = team.getTeamSpawn();
// int intYaw = 0;
// if (spawn.getYaw() >= 0) {
// intYaw = (int) (spawn.getYaw() % 360);
// } else {
// intYaw = (int) (360 + (spawn.getYaw() % 360));
// }
// teamsStr += team.getName() + "," + spawn.getBlockX() + "," + spawn.getBlockY() + "," + spawn.getBlockZ() + "," + intYaw + ";";
// }
// warzoneConfig.setString("teams", teamsStr);
//
// // team flags
// String teamFlagsStr = "";;
// for (Team team : teams) {
// if (team.getFlagVolume() != null) {
// Location flag = team.getTeamFlag();
// int intYaw = 0;
// if (flag.getYaw() >= 0) {
// intYaw = (int) (flag.getYaw() % 360);
// } else {
// intYaw = (int) (360 + (flag.getYaw() % 360));
// }
// teamFlagsStr += team.getName() + "," + flag.getBlockX() + "," + flag.getBlockY() + "," + flag.getBlockZ() + "," + intYaw + ";";
// }
// }
// warzoneConfig.setString("teamFlags", teamFlagsStr);
//
// // ff
// warzoneConfig.setBoolean("friendlyFire", warzone.getFriendlyFire());
//
// // loadout
// HashMap<Integer, ItemStack> items = warzone.getDefaultInventories().getLoadouts().get("default");
// warzoneConfig.setString("loadout", LoadoutTxtMapper.fromLoadoutToString(items));
//
// // defaultExtraLoadouts
// String extraLoadoutsStr = "";
// for (String name : warzone.getDefaultInventories().getLoadouts().keySet()) {
// if (!name.equals("default")) {
// extraLoadoutsStr += name + ",";
//
// HashMap<Integer, ItemStack> loadout = warzone.getDefaultInventories().getLoadouts().get(name);
// warzoneConfig.setString(name + "Loadout", LoadoutTxtMapper.fromLoadoutToString(loadout));
// }
// }
// warzoneConfig.setString("extraLoadouts", extraLoadoutsStr);
//
// // authors
// warzoneConfig.setString("author", warzone.getAuthorsString());
//
// // life pool
// warzoneConfig.setInt("lifePool", warzone.getLifePool());
//
// // monument heal
// warzoneConfig.setInt("monumentHeal", warzone.getMonumentHeal());
//
// // autoAssignOnly
// warzoneConfig.setBoolean("autoAssignOnly", warzone.isAutoAssignOnly());
//
// // flagPointsOnly
// warzoneConfig.setBoolean("flagPointsOnly", warzone.isFlagPointsOnly());
//
// // flagMustBeHome
// warzoneConfig.setBoolean("flagMustBeHome", warzone.isFlagMustBeHome());
//
// // team cap
// warzoneConfig.setInt("teamCap", warzone.getTeamCap());
//
// // score cap
// warzoneConfig.setInt("scoreCap", warzone.getScoreCap());
//
// // respawn timer
// warzoneConfig.setInt("respawnTimer", warzone.getRespawnTimer());
//
// // blockHeads
// warzoneConfig.setBoolean("blockHeads", warzone.isBlockHeads());
//
// // spawnStyle
// warzoneConfig.setString("spawnStyle", warzone.getSpawnStyle().toString());
//
// // flagReturn
// warzoneConfig.setString("flagReturn", warzone.getFlagReturn().toString());
//
// // reward
// HashMap<Integer, ItemStack> rewardItems = warzone.getDefaultInventories().getReward();
// warzoneConfig.setString("reward", LoadoutTxtMapper.fromLoadoutToString(rewardItems));
//
// // unbreakableZoneBlocks
// warzoneConfig.setBoolean("unbreakableZoneBlocks", warzone.isUnbreakableZoneBlocks());
//
// // disabled
// warzoneConfig.setBoolean("disabled", warzone.isDisabled());
//
// // noCreatures
// warzoneConfig.setBoolean("noCreatures", warzone.isNoCreatures());
//
// // glassWalls
// warzoneConfig.setBoolean("glassWalls", warzone.isGlassWalls());
//
// // pvpInZone
// warzoneConfig.setBoolean("pvpInZone", warzone.isPvpInZone());
//
// // instaBreak
// warzoneConfig.setBoolean("instaBreak", warzone.isInstaBreak());
//
// // noDrops
// warzoneConfig.setBoolean("noDrops", warzone.isNoDrops());
//
// // noHunger
// warzoneConfig.setBoolean("noHunger", warzone.isNoHunger());
//
// // saturation
// warzoneConfig.setInt("saturation", warzone.getSaturation());
//
// // minPlayers
// warzoneConfig.setInt("minPlayers", warzone.getMinPlayers());
//
// // minTeams
// warzoneConfig.setInt("minTeams", warzone.getMinTeams());
//
// // resetOnEmpty
// warzoneConfig.setBoolean("resetOnEmpty", warzone.isResetOnEmpty());
//
// // resetOnLoad
// warzoneConfig.setBoolean("resetOnLoad", warzone.isResetOnLoad());
//
// // resetOnUnload
// warzoneConfig.setBoolean("resetOnUnload", warzone.isResetOnUnload());
//
// // rallyPoint
// String rpStr = "";
// Location rp = warzone.getRallyPoint();
// if (rp != null) {
// rpStr = rp.getBlockX() + "," + rp.getBlockY() + "," + rp.getBlockZ();
// }
// warzoneConfig.setString("rallyPoint", rpStr);
//
// // defaultDropLootOnDeath
// // warzoneConfig.setBoolean("dropLootOnDeath", warzone.isDropLootOnDeath());
//
// // monuments
// String monumentsStr = "";
// List<Monument> monuments = warzone.getMonuments();
// for (Monument monument : monuments) {
// Location monumentLoc = monument.getLocation();
// monumentsStr += monument.getName() + "," + monumentLoc.getBlockX() + "," + monumentLoc.getBlockY() + "," + monumentLoc.getBlockZ() + ";";
// }
// warzoneConfig.setString("monuments", monumentsStr);
//
// // lobby
// String lobbyStr = "";
// if (warzone.getLobby() != null) {
// if (BlockFace.SOUTH == warzone.getLobby().getWall()) {
// lobbyStr = "south";
// } else if (BlockFace.EAST == warzone.getLobby().getWall()) {
// lobbyStr = "east";
// } else if (BlockFace.NORTH == warzone.getLobby().getWall()) {
// lobbyStr = "north";
// } else if (BlockFace.WEST == warzone.getLobby().getWall()) {
// lobbyStr = "west";
// }
// }
// warzoneConfig.setString("lobby", lobbyStr + "," + warzone.getLobby().getVolume().getWorld().getName());
//
// warzoneConfig.save();
// warzoneConfig.close();
//
// // monument blocks
// for (Monument monument : monuments) {
// VolumeMapper.save(monument.getVolume(), warzone.getName());
// }
//
// // team spawn & flag blocks
// for (Team team : teams) {
// VolumeMapper.save(team.getSpawnVolume(), warzone.getName());
// if (team.getFlagVolume() != null) {
// VolumeMapper.save(team.getFlagVolume(), warzone.getName());
// }
// }
//
// if (warzone.getLobby() != null) {
// VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName());
// }
}
public static void delete(String name) {
File zoneFolder = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name);
File[] files = zoneFolder.listFiles();
for (File file : files) {
boolean deletedData = file.delete();
if (!deletedData) {
War.war.log("Failed to delete file " + file.getName(), Level.WARNING);
}
}
boolean deletedData = zoneFolder.delete();
if (!deletedData) {
War.war.log("Failed to delete folder " + zoneFolder.getName(), Level.WARNING);
}
File zoneFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
deletedData = zoneFile.delete();
if (!deletedData) {
War.war.log("Failed to delete file " + zoneFile.getName(), Level.WARNING);
}
}
}

View File

@ -0,0 +1,408 @@
package com.tommytony.war.mappers;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import bukkit.tommytony.war.War;
import com.tommytony.war.Monument;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.volumes.Volume;
import com.tommytony.war.volumes.ZoneVolume;
public class WarzoneYmlMapper {
public static Warzone load(String name, boolean createNewVolume) {
File warzoneTxtFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
File warzoneYmlFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".yml");
// Convert from TXT to YML if needed
if (warzoneTxtFile.exists() && !warzoneYmlFile.exists()) {
// Since we're converting, WarTxtMapper didn't load the warzones.
// We need to load the old-text-format-Warzone into memory.
Warzone zoneToConvert = WarzoneTxtMapper.load(name, false);
WarzoneYmlMapper.save(zoneToConvert, false);
War.war.log("Converted warzone-" + name + ".txt to warzone-" + name + ".yml", Level.INFO);
}
if (!warzoneYmlFile.exists()) {
War.war.log("File warzone-" + name + ".yml not found", Level.WARNING);
} else {
YamlConfiguration warzoneYmlConfig = YamlConfiguration.loadConfiguration(warzoneYmlFile);
String zoneInfoPrefix = "warzone." + name + ".info.";
// world
String worldStr = warzoneYmlConfig.getString(zoneInfoPrefix + "world");
World world = War.war.getServer().getWorld(worldStr);
// Create the zone
Warzone warzone = new Warzone(world, name);
// teleport
int teleX = warzoneYmlConfig.getInt(zoneInfoPrefix + "teleport.x");
int teleY = warzoneYmlConfig.getInt(zoneInfoPrefix + "teleport.y");
int teleZ = warzoneYmlConfig.getInt(zoneInfoPrefix + "teleport.z");
int teleYaw = warzoneYmlConfig.getInt(zoneInfoPrefix + "teleport.yaw");
warzone.setTeleport(new Location(world, teleX, teleY, teleZ, teleYaw, 0));
if (warzoneYmlConfig.contains("team.default")) {
// defaultLoadouts
ConfigurationSection loadoutsSection = warzoneYmlConfig.getConfigurationSection("team.default.loadout");
LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, warzone.getDefaultInventories().getLoadouts());
// defaultReward
ConfigurationSection rewardsSection = warzoneYmlConfig.getConfigurationSection("team.default.reward");
HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
warzone.getDefaultInventories().setReward(reward);
// Team default settings
ConfigurationSection teamConfigSection = warzoneYmlConfig.getConfigurationSection("team.default.config");
warzone.getTeamDefaultConfig().loadFrom(teamConfigSection);
}
// Warzone settings
if (warzoneYmlConfig.contains("warzone.config")) {
ConfigurationSection warzoneConfigSection = warzoneYmlConfig.getConfigurationSection("warzone.config");
warzone.getWarzoneConfig().loadFrom(warzoneConfigSection);
}
// authors
if (warzoneYmlConfig.contains(zoneInfoPrefix + "authors")) {
for(String authorStr : warzoneYmlConfig.getStringList("authors")) {
if (!authorStr.equals("")) {
warzone.addAuthor(authorStr);
}
}
}
// rallyPoint
if (warzoneYmlConfig.contains(zoneInfoPrefix + "rallypoint")) {
int rpX = warzoneYmlConfig.getInt(zoneInfoPrefix + "rallypoint.x");
int rpY = warzoneYmlConfig.getInt(zoneInfoPrefix + "rallypoint.y");
int rpZ = warzoneYmlConfig.getInt(zoneInfoPrefix + "rallypoint.z");
int rpYaw = warzoneYmlConfig.getInt(zoneInfoPrefix + "rallypoint.yaw");
Location rallyPoint = new Location(world, rpX, rpY, rpZ, rpYaw, 0);
warzone.setRallyPoint(rallyPoint);
}
// monuments
if (warzoneYmlConfig.contains(zoneInfoPrefix + "monument")) {
List<String> monunmentNames = warzoneYmlConfig.getStringList(zoneInfoPrefix + "monument.names");
for (String monumentName : monunmentNames) {
if (monumentName != null && !monumentName.equals("")) {
String monumentPrefix = zoneInfoPrefix + "monument." + monumentName + ".";
int monumentX = warzoneYmlConfig.getInt(monumentPrefix + "x");
int monumentY = warzoneYmlConfig.getInt(monumentPrefix + "y");
int monumentZ = warzoneYmlConfig.getInt(monumentPrefix + "z");
int monumentYaw = warzoneYmlConfig.getInt(monumentPrefix + "yaw");
Monument monument = new Monument(monumentName, warzone, new Location(world, monumentX, monumentY, monumentZ, monumentYaw, 0));
warzone.getMonuments().add(monument);
}
}
}
// teams
List<String> teamsNames = warzoneYmlConfig.getStringList("team.names");
for (String teamName : teamsNames) {
// team info
String teamInfoPrefix = "team." + teamName + ".info";
int teamX = warzoneYmlConfig.getInt(teamInfoPrefix + "spawn.x");
int teamY = warzoneYmlConfig.getInt(teamInfoPrefix + "spawn.y");
int teamZ = warzoneYmlConfig.getInt(teamInfoPrefix + "spawn.z");
int teamYaw = warzoneYmlConfig.getInt(teamInfoPrefix + "spawn.yaw");
Location teamLocation = new Location(world, teamX, teamY, teamZ, teamYaw, 0);
Team team = new Team(teamName, TeamKind.teamKindFromString(teamName), teamLocation, warzone);
warzone.getTeams().add(team);
if (warzoneYmlConfig.contains(teamInfoPrefix + "flag")) {
int flagX = warzoneYmlConfig.getInt(teamInfoPrefix + "flag.x");
int flagY = warzoneYmlConfig.getInt(teamInfoPrefix + "flag.y");
int flagZ = warzoneYmlConfig.getInt(teamInfoPrefix + "flag.z");
int flagYaw = warzoneYmlConfig.getInt(teamInfoPrefix + "flag.yaw");
Location flagLocation = new Location(world, flagX, flagY, flagZ, flagYaw, 0);
team.setTeamFlag(flagLocation);
}
String teamConfigPrefix = "team." + teamName + ".config";
if (warzoneYmlConfig.contains(teamConfigPrefix)) {
// team specific config
ConfigurationSection teamConfigSection = warzoneYmlConfig.getConfigurationSection(teamConfigPrefix);
team.getTeamConfig().loadFrom(teamConfigSection);
}
team.setRemainingLives(team.getTeamConfig().getInt(TeamConfig.LIFEPOOL));
String teamLoadoutPrefix = "team." + teamName + ".loadout";
if (warzoneYmlConfig.contains(teamLoadoutPrefix)) {
// team specific loadouts
ConfigurationSection loadoutsSection = warzoneYmlConfig.getConfigurationSection(teamLoadoutPrefix);
LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, team.getInventories().getLoadouts());
}
String teamRewardPrefix = "team." + teamName + ".reward";
if (warzoneYmlConfig.contains(teamRewardPrefix)) {
// team specific reward
ConfigurationSection rewardsSection = warzoneYmlConfig.getConfigurationSection(teamRewardPrefix);
HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
warzone.getDefaultInventories().setReward(reward);
}
}
if (createNewVolume) {
ZoneVolume zoneVolume = new ZoneVolume(warzone.getName(), world, warzone);
warzone.setVolume(zoneVolume);
}
// monument blocks
for (Monument monument : warzone.getMonuments()) {
monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), world));
}
// team spawn blocks
for (Team team : warzone.getTeams()) {
team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), world));
if (team.getTeamFlag() != null) {
team.setFlagVolume(VolumeMapper.loadVolume(team.getName() + "flag", warzone.getName(), world));
}
}
// lobby
String lobbyPrefix = zoneInfoPrefix + "lobby.";
// lobby orientation
String lobbyOrientation = warzoneYmlConfig.getString(lobbyPrefix + "orientation");
BlockFace lobbyFace = null;
if (lobbyOrientation.equals("south")) {
lobbyFace = BlockFace.SOUTH;
} else if (lobbyOrientation.equals("east")) {
lobbyFace = BlockFace.EAST;
} else if (lobbyOrientation.equals("north")) {
lobbyFace = BlockFace.NORTH;
} else if (lobbyOrientation.equals("west")) {
lobbyFace = BlockFace.WEST;
}
// lobby world
String lobbyWorldName = warzoneYmlConfig.getString(lobbyPrefix + "world");
World lobbyWorld = War.war.getServer().getWorld(lobbyWorldName);
// create the lobby
Volume lobbyVolume = VolumeMapper.loadVolume("lobby", warzone.getName(), lobbyWorld);
ZoneLobby lobby = new ZoneLobby(warzone, lobbyFace, lobbyVolume);
warzone.setLobby(lobby);
return warzone;
}
return null;
}
public static void save(Warzone warzone, boolean saveAllBlocks) {
YamlConfiguration warzoneYmlConfig = new YamlConfiguration();
(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + warzone.getName())).mkdir(); // create folder
String zoneInfoPrefix = "warzone." + warzone.getName() + ".info.";
// world
warzoneYmlConfig.set(zoneInfoPrefix + "world", warzone.getWorld().getName());
// teleport
ConfigurationSection teleSection = warzoneYmlConfig.createSection(zoneInfoPrefix + "teleport");
teleSection.set(zoneInfoPrefix + "teleport.x", warzone.getTeleport().getBlockX());
teleSection.set(zoneInfoPrefix + "teleport.y", warzone.getTeleport().getBlockY());
teleSection.set(zoneInfoPrefix + "teleport.z", warzone.getTeleport().getBlockZ());
teleSection.set(zoneInfoPrefix + "teleport.yaw", toIntYaw(warzone.getTeleport().getYaw()));
// teams
List<Team> teams = warzone.getTeams();
List<String> teamNames = new ArrayList<String>();
for (Team team : teams) {
String teamPrefix = "team." + team.getName() + ".";
teamNames.add(team.getName());
Location spawn = team.getTeamSpawn();
warzoneYmlConfig.set(teamPrefix + "spawn.x", spawn.getBlockX());
warzoneYmlConfig.set(teamPrefix + "spawn.y", spawn.getBlockY());
warzoneYmlConfig.set(teamPrefix + "spawn.z", spawn.getBlockZ());
warzoneYmlConfig.set(teamPrefix + "spawn.yaw", toIntYaw(spawn.getYaw()));
if (team.getTeamFlag() != null) {
Location teamFlag = team.getTeamFlag();
warzoneYmlConfig.set(teamPrefix + "flag.x", teamFlag.getBlockX());
warzoneYmlConfig.set(teamPrefix + "flag.y", teamFlag.getBlockY());
warzoneYmlConfig.set(teamPrefix + "flag.z", teamFlag.getBlockZ());
warzoneYmlConfig.set(teamPrefix + "flag.yaw", toIntYaw(teamFlag.getYaw()));
}
if (!team.getTeamConfig().isEmpty()) {
// team specific config
ConfigurationSection teamConfigSection = warzoneYmlConfig.createSection("team." + team.getName() + ".config");
team.getTeamConfig().saveTo(teamConfigSection);
}
if (team.getInventories().hasLoadouts()) {
// team specific loadouts
ConfigurationSection loadoutsSection = warzoneYmlConfig.createSection("team." + team.getName() + ".loadout");
LoadoutYmlMapper.fromLoadoutsToConfig(team.getInventories().getLoadouts(), loadoutsSection);
}
if (team.getInventories().hasReward()) {
// team specific reward
ConfigurationSection rewardsSection = warzoneYmlConfig.createSection("team." + team.getName() + ".reward");
LoadoutYmlMapper.fromLoadoutToConfig(team.getInventories().getReward(), rewardsSection, "default");
}
}
if (teamNames.size() > 0) {
warzoneYmlConfig.set("team.names", teamNames);
}
// defaultLoadouts
if (warzone.getDefaultInventories().hasLoadouts()) {
ConfigurationSection loadoutsSection = warzoneYmlConfig.createSection("team.default.loadout");
LoadoutYmlMapper.fromLoadoutsToConfig(warzone.getDefaultInventories().getLoadouts(), loadoutsSection);
}
// defaultReward
if (warzone.getDefaultInventories().hasReward()) {
ConfigurationSection rewardsSection = warzoneYmlConfig.createSection("team.default.reward");
LoadoutYmlMapper.fromLoadoutToConfig(warzone.getDefaultInventories().getReward(), rewardsSection, "default");
}
// Warzone settings
if (!warzone.getWarzoneConfig().isEmpty()) {
ConfigurationSection warzoneConfigSection = warzoneYmlConfig.createSection("warzone." + warzone.getName() + ".config");
warzone.getWarzoneConfig().saveTo(warzoneConfigSection);
}
// Team default settings
if (!warzone.getTeamDefaultConfig().isEmpty()) {
ConfigurationSection teamConfigSection = warzoneYmlConfig.createSection("team.default.config");
warzone.getTeamDefaultConfig().saveTo(teamConfigSection);
}
// authors
warzoneYmlConfig.set(zoneInfoPrefix + "authors", warzone.getAuthors());
// rallyPoint
if (warzone.getRallyPoint() != null) {
ConfigurationSection rpSection = warzoneYmlConfig.createSection(zoneInfoPrefix + "rallypoint");
rpSection.set(zoneInfoPrefix + "x", warzone.getTeleport().getBlockX());
rpSection.set(zoneInfoPrefix + "y", warzone.getTeleport().getBlockY());
rpSection.set(zoneInfoPrefix + "z", warzone.getTeleport().getBlockZ());
rpSection.set(zoneInfoPrefix + "yaw", toIntYaw(warzone.getTeleport().getYaw()));
}
// monuments
if (warzone.getMonuments().size() > 0) {
ConfigurationSection monumentSection = warzoneYmlConfig.createSection(zoneInfoPrefix + "monument");
List<String> monumentNames = new ArrayList<String>();
for (Monument monument : warzone.getMonuments()) {
monumentNames.add(monument.getName());
monumentSection.set(monument.getName() + ".x", monument.getLocation().getBlockX());
monumentSection.set(monument.getName() + ".y", monument.getLocation().getBlockX());
monumentSection.set(monument.getName() + ".z", monument.getLocation().getBlockX());
monumentSection.set(monument.getName() + ".yaw", toIntYaw(monument.getLocation().getYaw()));
}
monumentSection.set("names", monumentNames);
}
// lobby
if (warzone.getLobby() != null) {
String lobbyOrientation = "";
if (BlockFace.SOUTH == warzone.getLobby().getWall()) {
lobbyOrientation = "south";
} else if (BlockFace.EAST == warzone.getLobby().getWall()) {
lobbyOrientation = "east";
} else if (BlockFace.NORTH == warzone.getLobby().getWall()) {
lobbyOrientation = "north";
} else if (BlockFace.WEST == warzone.getLobby().getWall()) {
lobbyOrientation = "west";
}
warzoneYmlConfig.set(zoneInfoPrefix + "lobby.orientation", lobbyOrientation);
warzoneYmlConfig.set(zoneInfoPrefix + "lobby.world", warzone.getLobby().getVolume().getWorld().getName());
}
// monument blocks
for (Monument monument : warzone.getMonuments()) {
VolumeMapper.save(monument.getVolume(), warzone.getName());
}
// team spawn & flag blocks
for (Team team : teams) {
VolumeMapper.save(team.getSpawnVolume(), warzone.getName());
if (team.getFlagVolume() != null) {
VolumeMapper.save(team.getFlagVolume(), warzone.getName());
}
}
if (warzone.getLobby() != null) {
VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName());
}
// Save to disk
try {
File warzoneConfigFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + warzone.getName() + ".yml");
warzoneYmlConfig.save(warzoneConfigFile);
} catch (IOException e) {
War.war.log("Failed to save warzone-" + warzone.getName() + ".yml", Level.WARNING);
e.printStackTrace();
}
}
private static int toIntYaw(float yaw) {
int intYaw = 0;
if (yaw >= 0) {
intYaw = (int) (yaw % 360);
} else {
intYaw = (int) (360 + (yaw % 360));
}
return intYaw;
}
public static void delete(String name) {
File zoneFolder = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name);
File[] files = zoneFolder.listFiles();
for (File file : files) {
boolean deletedData = file.delete();
if (!deletedData) {
War.war.log("Failed to delete file " + file.getName(), Level.WARNING);
}
}
boolean deletedData = zoneFolder.delete();
if (!deletedData) {
War.war.log("Failed to delete folder " + zoneFolder.getName(), Level.WARNING);
}
File zoneFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
if (zoneFile.exists()) {
deletedData = zoneFile.delete();
if (!deletedData) {
War.war.log("Failed to delete file " + zoneFile.getName(), Level.WARNING);
}
}
zoneFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".yml");
deletedData = zoneFile.delete();
if (!deletedData) {
War.war.log("Failed to delete file " + zoneFile.getName(), Level.WARNING);
}
}
}

View File

@ -1,5 +1,5 @@
name: War
version: 1.6.2 (de Gaulle)
version: 1.7 (Doolittle)
description: Lets you create TDM and CTF arenas (warzones) for a fast-paced and structured PVP experience.
author: tommytony
website: war.tommytony.com
@ -178,22 +178,42 @@ commands:
flagreturn:<both/spawn/flag> flagpointsonly:false glasswalls:on pvpinzone:true instabreak:false nodrops:false nohunger:false saturation:<0-20> minplayers:1 minteams:1
/setzoneconfig [zone-name] loadout:default => sets the respawn inventory to your current items,
/setzoneconfig [zone-name] loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/setzoneconfig [zone-name] deleteloadout:<extra-loadout-name> => removed teh specified loadout from the choices. You cannot remove the default loadout.
/setzoneconfig [zone-name] deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/setzoneconfig [zone-name] reward:default => sets the winner's reward to your current items.
/setzoneconfig [zone-name] author:tommytony,someguy => adds these players as authors of the warzone, allowing them to edit it.
/setzoneconfig [zone-name] deleteauthor:tommytony,someguy => removes these players from the warzone authors.
zonecfg:
description: War> Alias for /setzoneconfig
usage: Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
usage: Use named parameters to change the configuration of the warzone and default team settings. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
Ex -
/zonecfg [zone-name] lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>
flagreturn:<both/spawn/flag> flagpointsonly:false glasswalls:on pvpinzone:true instabreak:false nodrops:false nohunger:false saturation:<0-20> minplayers:1 minteams:1
/zonecfg [zone-name] loadout:default => sets the respawn inventory to your current items,
/zonecfg [zone-name] loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/zonecfg [zone-name] deleteloadout:<extra-loadout-name> => removed teh specified loadout from the choices. You cannot remove the default loadout.
/zonecfg [zone-name] deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/zonecfg [zone-name] reward:default => sets the winner's reward to your current items.
/zonecfg [zone-name] author:tommytony,someguy => adds these players as authors of the warzone, allowing them to edit it.
/zonecfg [zone-name] deleteauthor:tommytony,someguy => removes these players from the warzone authors.
setteamconfig:
description: War> Use named parameters to change team-specific settings. Resets warzone blocks like /nextbattle. Does not save zone blocks like /savezone.
usage: Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
Ex -
/setteamconfig [zone-name] <team-name> lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible>
flagreturn:<both/spawn/flag> flagpointsonly:false nohunger:false saturation:<0-20>
/setteamconfig [zone-name] <team-name> loadout:default => sets the respawn inventory to your current items,
/setteamconfig [zone-name] <team-name> loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/setteamconfig [zone-name] <team-name> deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/setteamconfig [zone-name] <team-name> reward:default => sets the winner's reward to your current items.
teamcfg:
description: War> Alias for /setteamconfig
usage: Use named parameters to change the team-specific settings. Resets warzone blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
Ex -
/teamcfg [zone-name] <team-name> lifepool:8 teamsize:5 maxscore:7 spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>
flagreturn:<both/spawn/flag> flagpointsonly:false nohunger:false saturation:<0-20>
/teamcfg [zone-name] <team-name> loadout:default => sets the respawn inventory to your current items,
/teamcfg [zone-name] <team-name> loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/teamcfg [zone-name] <team-name> deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/teamcfg [zone-name] <team-name> reward:default => sets the winner's reward to your current items.
zonemaker:
description: War> Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
usage: Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
@ -231,7 +251,7 @@ commands:
/loadwar
setwarconfig:
description: War> Change gobal settings and the default warzone configuration values.
usage: Change gobal settings and the default warzone configuration values.
usage: Change global settings and the default warzone and team configuration values.
Ex -
/setwarconfig pvpinzonesonly:on buildinzonesonly:on disablepvpmessage:off tntinzonesonly:off maxzones:12 => Global settings,
/setwarconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>
@ -244,7 +264,7 @@ commands:
/setwarconfig rallypoint:<warzone-name> => changes when players get teleported at the end of a match for that zone, useful for chaining warzones together in a sequence, or preventing players from rejoining immediately
warcfg:
description: War> Alias for /setwarconfig
usage: Change gobal settings and the default warzone configuration values.
usage: Change global settings and the default warzone and team configuration values.
Ex -
/warcfg pvpinzonesonly:on buildinzonesonly:on disablepvpmessage:off tntinzonesonly:off maxzones:12 => Global settings,
/warcfg lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>

View File

@ -1,5 +1,5 @@
name: War
version: 1.6.2 (de Gaulle)
version: 1.7 (Doolittle)
description: Lets you create TDM and CTF arenas (warzones) for a fast-paced and structured PVP experience.
author: tommytony
website: war.tommytony.com
@ -178,22 +178,42 @@ commands:
flagreturn:<both/spawn/flag> flagpointsonly:false glasswalls:on pvpinzone:true instabreak:false nodrops:false nohunger:false saturation:<0-20> minplayers:1 minteams:1
/setzoneconfig [zone-name] loadout:default => sets the respawn inventory to your current items,
/setzoneconfig [zone-name] loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/setzoneconfig [zone-name] deleteloadout:<extra-loadout-name> => removed teh specified loadout from the choices. You cannot remove the default loadout.
/setzoneconfig [zone-name] deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/setzoneconfig [zone-name] reward:default => sets the winner's reward to your current items.
/setzoneconfig [zone-name] author:tommytony,someguy => adds these players as authors of the warzone, allowing them to edit it.
/setzoneconfig [zone-name] deleteauthor:tommytony,someguy => removes these players from the warzone authors.
zonecfg:
description: War> Alias for /setzoneconfig
usage: Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
usage: Use named parameters to change the configuration of the warzone and default team settings. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
Ex -
/zonecfg [zone-name] lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>
flagreturn:<both/spawn/flag> flagpointsonly:false glasswalls:on pvpinzone:true instabreak:false nodrops:false nohunger:false saturation:<0-20> minplayers:1 minteams:1
/zonecfg [zone-name] loadout:default => sets the respawn inventory to your current items,
/zonecfg [zone-name] loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/zonecfg [zone-name] deleteloadout:<extra-loadout-name> => removed teh specified loadout from the choices. You cannot remove the default loadout.
/zonecfg [zone-name] deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/zonecfg [zone-name] reward:default => sets the winner's reward to your current items.
/zonecfg [zone-name] author:tommytony,someguy => adds these players as authors of the warzone, allowing them to edit it.
/zonecfg [zone-name] deleteauthor:tommytony,someguy => removes these players from the warzone authors.
setteamconfig:
description: War> Use named parameters to change team-specific settings. Resets warzone blocks like /nextbattle. Does not save zone blocks like /savezone.
usage: Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
Ex -
/setteamconfig [zone-name] <team-name> lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible>
flagreturn:<both/spawn/flag> flagpointsonly:false nohunger:false saturation:<0-20>
/setteamconfig [zone-name] <team-name> loadout:default => sets the respawn inventory to your current items,
/setteamconfig [zone-name] <team-name> loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/setteamconfig [zone-name] <team-name> deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/setteamconfig [zone-name] <team-name> reward:default => sets the winner's reward to your current items.
teamcfg:
description: War> Alias for /setteamconfig
usage: Use named parameters to change the team-specific settings. Resets warzone blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
Ex -
/teamcfg [zone-name] <team-name> lifepool:8 teamsize:5 maxscore:7 spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>
flagreturn:<both/spawn/flag> flagpointsonly:false nohunger:false saturation:<0-20>
/teamcfg [zone-name] <team-name> loadout:default => sets the respawn inventory to your current items,
/teamcfg [zone-name] <team-name> loadout:<extra-loadout-name> => adds an extra loadout (i.e. another player class) that the players can toggle to by sneaking while inside the spawn
/teamcfg [zone-name] <team-name> deleteloadout:<extra-loadout-name> => removed the specified loadout from the choices. You cannot remove the default loadout.
/teamcfg [zone-name] <team-name> reward:default => sets the winner's reward to your current items.
zonemaker:
description: War> Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
usage: Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
@ -231,7 +251,7 @@ commands:
/loadwar
setwarconfig:
description: War> Change gobal settings and the default warzone configuration values.
usage: Change gobal settings and the default warzone configuration values.
usage: Change global settings and the default warzone and team configuration values.
Ex -
/setwarconfig pvpinzonesonly:on buildinzonesonly:on disablepvpmessage:off tntinzonesonly:off maxzones:12 => Global settings,
/setwarconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>
@ -244,7 +264,7 @@ commands:
/setwarconfig rallypoint:<warzone-name> => changes when players get teleported at the end of a match for that zone, useful for chaining warzones together in a sequence, or preventing players from rejoining immediately
warcfg:
description: War> Alias for /setwarconfig
usage: Change gobal settings and the default warzone configuration values.
usage: Change global settings and the default warzone and team configuration values.
Ex -
/warcfg pvpinzonesonly:on buildinzonesonly:on disablepvpmessage:off tntinzonesonly:off maxzones:12 => Global settings,
/warcfg lifepool:8 teamsize:5 maxscore:7 autoassign:on ff:on blockheads:on spawnstyle:<big/flat/small/invisible> unbreakable:on nocreatures:on disabled:on monumentheal:<0-20>