From 95cc2c7a34a52a122b37a4b54563e5551d56c2f0 Mon Sep 17 00:00:00 2001 From: Connor Monahan Date: Sat, 11 Jan 2014 22:13:11 -0600 Subject: [PATCH] Update team spawns for TXT files. Closes #717 --- .../java/com/tommytony/war/mapper/WarzoneTxtMapper.java | 9 ++++++++- .../java/com/tommytony/war/mapper/WarzoneYmlMapper.java | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/war/src/main/java/com/tommytony/war/mapper/WarzoneTxtMapper.java b/war/src/main/java/com/tommytony/war/mapper/WarzoneTxtMapper.java index 9115940..3e5ab41 100644 --- a/war/src/main/java/com/tommytony/war/mapper/WarzoneTxtMapper.java +++ b/war/src/main/java/com/tommytony/war/mapper/WarzoneTxtMapper.java @@ -303,6 +303,13 @@ public class WarzoneTxtMapper { int yaw = Integer.parseInt(teamStrSplit[4]); teamLocation.setYaw(yaw); } + File original = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamStrSplit[0] + ".dat"); + File modified = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamStrSplit[0] + "0.dat"); + try { + original.renameTo(modified); + } catch (Exception ignored) { + } + Team team = new Team(teamStrSplit[0], TeamKind.teamKindFromString(teamStrSplit[0]), Arrays.asList(teamLocation), warzone); team.setRemainingLives(warzone.getTeamDefaultConfig().resolveInt(TeamConfig.LIFEPOOL)); warzone.getTeams().add(team); @@ -356,7 +363,7 @@ public class WarzoneTxtMapper { for (Team team : warzone.getTeams()) { for (Location spawnLocation : team.getTeamSpawns()) { try { - team.setSpawnVolume(spawnLocation, VolumeMapper.loadVolume(team.getName(), warzone.getName(), world)); + team.setSpawnVolume(spawnLocation, VolumeMapper.loadVolume(team.getName() + "0", warzone.getName(), world)); } catch (SQLException e) { War.war.getLogger().log(Level.WARNING, "Failed to load some ambiguous old volume", e); } diff --git a/war/src/main/java/com/tommytony/war/mapper/WarzoneYmlMapper.java b/war/src/main/java/com/tommytony/war/mapper/WarzoneYmlMapper.java index 8a84605..bd5d05b 100644 --- a/war/src/main/java/com/tommytony/war/mapper/WarzoneYmlMapper.java +++ b/war/src/main/java/com/tommytony/war/mapper/WarzoneYmlMapper.java @@ -206,10 +206,15 @@ public class WarzoneYmlMapper { 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 e) { - // Will be logged later + } catch (Exception ignored) { + } + try { + originalSql.renameTo(modifiedSql); + } catch (Exception ignored) { } } if (warzoneRootSection.contains(teamInfoPrefix + "spawns")) {