}
int bombX = warzoneRootSection.getInt(bombPrefix + "x");
int bombY = warzoneRootSection.getInt(bombPrefix + "y");
int bombZ = warzoneRootSection.getInt(bombPrefix + "z");
int bombYaw = warzoneRootSection.getInt(bombPrefix + "yaw");
Bomb bomb = new Bomb(bombName, warzone, new Location(world, bombX, bombY, bombZ, bombYaw, 0));
warzone.getBombs().add(bomb);
}
}
}
// cakes
if (warzoneRootSection.contains(zoneInfoPrefix + "cake")) {
List<String> cakeNames = warzoneRootSection.getStringList(zoneInfoPrefix + "cake.names");
for (String cakeName : cakeNames) {
if (cakeName != null && !cakeName.equals("")) {
String cakePrefix = zoneInfoPrefix + "cake." + cakeName + ".";
if (!warzoneRootSection.contains(cakePrefix + "x")) {
// try lowercase instead
cakePrefix = zoneInfoPrefix + "cake." + cakeName + ".";
}
int cakeX = warzoneRootSection.getInt(cakePrefix + "x");
int cakeY = warzoneRootSection.getInt(cakePrefix + "y");
int cakeZ = warzoneRootSection.getInt(cakePrefix + "z");
int cakeYaw = warzoneRootSection.getInt(cakePrefix + "yaw");
Cake cake = new Cake(cakeName, warzone, new Location(world, cakeX, cakeY, cakeZ, cakeYaw, 0));
warzone.getCakes().add(cake);
}
}
}
// teams (maybe no teams)
if (warzoneRootSection.contains("team.names")) {
List<String> teamsNames = warzoneRootSection.getStringList("team.names");
for (String teamName : teamsNames) {
// team info
String teamInfoPrefix = "team." + teamName + ".info.";
if (!warzoneRootSection.contains(teamInfoPrefix + "spawn.x")) {
// try lowercase instead - supports custom team names
teamInfoPrefix = "team." + teamName.toLowerCase() + ".info.";
}
List<Location> teamSpawns = new ArrayList<Location>();
if (warzoneRootSection.contains(teamInfoPrefix + "spawn")) {
int teamX = warzoneRootSection.getInt(teamInfoPrefix + "spawn.x");
int teamY = warzoneRootSection.getInt(teamInfoPrefix + "spawn.y");
int teamZ = warzoneRootSection.getInt(teamInfoPrefix + "spawn.z");
int teamYaw = warzoneRootSection.getInt(teamInfoPrefix + "spawn.yaw");
Location teamLocation = new Location(world, teamX, teamY, teamZ, teamYaw, 0);
teamSpawns.add(teamLocation);
File original = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + ".dat");
File modified = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + teamSpawns.indexOf(teamLocation) + ".dat");
File originalSql = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + ".sl3");
File modifiedSql = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamName + teamSpawns.indexOf(teamLocation) + ".sl3");
try {
original.renameTo(modified);
} catch (Exception ignored) {
}
try {
originalSql.renameTo(modifiedSql);
} catch (Exception ignored) {
}
}
if (warzoneRootSection.contains(teamInfoPrefix + "spawns")) {
for (Map<?, ?> map : warzoneRootSection.getMapList(teamInfoPrefix + "spawns")) {
int teamX = (Integer) map.get("x");
int teamY = (Integer) map.get("y");
int teamZ = (Integer) map.get("z");
int teamYaw = (Integer) map.get("yaw");
Location teamLocation = new Location(world, teamX, teamY, teamZ, teamYaw, 0);
teamSpawns.add(teamLocation);
}
}
Team team = new Team(teamName, TeamKind.teamKindFromString(teamName), teamSpawns, warzone);
warzone.getTeams().add(team);
if (warzoneRootSection.contains(teamInfoPrefix + "flag")) {
int flagX = warzoneRootSection.getInt(teamInfoPrefix + "flag.x");
int flagY = warzoneRootSection.getInt(teamInfoPrefix + "flag.y");
int flagZ = warzoneRootSection.getInt(teamInfoPrefix + "flag.z");
int flagYaw = warzoneRootSection.getInt(teamInfoPrefix + "flag.yaw");
Location flagLocation = new Location(world, flagX, flagY, flagZ, flagYaw, 0);
team.setTeamFlag(flagLocation);
}
String teamConfigPrefix = "team." + teamName + ".config";
if (warzoneRootSection.contains(teamConfigPrefix)) {
// team specific config
ConfigurationSection teamConfigSection = warzoneRootSection.getConfigurationSection(teamConfigPrefix);
team.getTeamConfig().loadFrom(teamConfigSection);
} else if (warzoneRootSection.contains(teamConfigPrefix.toLowerCase())) {
// try lowercase instead
ConfigurationSection teamConfigSection = warzoneRootSection.getConfigurationSection(teamConfigPrefix.toLowerCase());
team.getTeamConfig().loadFrom(teamConfigSection);
}
// LIFEPOOL INITIALIZATION HERE
team.setRemainingLives(team.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
String teamLoadoutPrefix = "team." + teamName + ".loadout";
if (warzoneRootSection.contains(teamLoadoutPrefix)) {
// team specific loadouts
ConfigurationSection loadoutsSection = warzoneRootSection.getConfigurationSection(teamLoadoutPrefix);
team.getInventories().setLoadouts(LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, new HashMap<String, HashMap<Integer, ItemStack>>()));
} else if (warzoneRootSection.contains(teamLoadoutPrefix.toLowerCase())) {
// try lowercase instead
ConfigurationSection loadoutsSection = warzoneRootSection.getConfigurationSection(teamLoadoutPrefix.toLowerCase());
team.getInventories().setLoadouts(LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, new HashMap<String, HashMap<Integer, ItemStack>>()));
}
String teamRewardPrefix = "team." + teamName + ".reward";
if (warzoneRootSection.contains(teamRewardPrefix)) {
// team specific reward
ConfigurationSection rewardsSection = warzoneRootSection.getConfigurationSection(teamRewardPrefix);
HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
warzone.getDefaultInventories().setReward(reward);
} else if (warzoneRootSection.contains(teamRewardPrefix.toLowerCase())) {
// try lowercase instead
ConfigurationSection rewardsSection = warzoneRootSection.getConfigurationSection(teamRewardPrefix.toLowerCase());
HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
LoadoutYmlMapper.fromConfigToLoadout(rewardsSection, reward, "default");
warzone.getDefaultInventories().setReward(reward);
}
}
}
Connection connection = null;
try {
connection = ZoneVolumeMapper.getZoneConnection(warzone.getVolume(), warzone.getName(), warzone.getWorld());
} catch (SQLException e) {
War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
}
// monument blocks
for (Monument monument : warzone.getMonuments()) {
try {
monument.setVolume(warzone.loadStructure(monument.getName(), connection));
} catch (SQLException e) {
War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
}
}
// bomb blocks
for (Bomb bomb : warzone.getBombs()) {
try {
bomb.setVolume(warzone.loadStructure("bomb-" + bomb.getName(), connection));
} catch (SQLException e) {
War.war.getLogger().log(Level.WARNING, "Failed to load warzone structures volume", e);
}
}