Save Worldnames for later use

This commit is contained in:
Sn0wStorm
2013-09-05 19:53:49 +02:00
parent 8ab8fe91a6
commit dee9208b82
+19 -1
View File
@@ -452,6 +452,8 @@ public class P extends JavaPlugin {
p.log("Saving Wakeups (" + ftime + "ms)"); p.log("Saving Wakeups (" + ftime + "ms)");
time = System.nanoTime(); time = System.nanoTime();
saveWorldNames(configFile, oldData.getConfigurationSection("Worlds"));
try { try {
configFile.save(datafile); configFile.save(datafile);
} catch (IOException e) { } catch (IOException e) {
@@ -465,6 +467,22 @@ public class P extends JavaPlugin {
p.log("Writing Data to File (" + ftime + "ms)"); p.log("Writing Data to File (" + ftime + "ms)");
} }
public void saveWorldNames(FileConfiguration root, ConfigurationSection old) {
if (old != null) {
root.set("Worlds", old);
}
for (World world : p.getServer().getWorlds()) {
String worldName = world.getName();
if (worldName.startsWith("DXL_")) {
worldName = getDxlName(worldName);
root.set("Worlds." + worldName, 0);
} else {
worldName = world.getUID().toString();
root.set("Worlds." + worldName, world.getName());
}
}
}
// Utility // Utility
@@ -481,7 +499,7 @@ public class P extends JavaPlugin {
for (File file : dungeonFolder.listFiles()) { for (File file : dungeonFolder.listFiles()) {
if (!file.isDirectory()) { if (!file.isDirectory()) {
if (file.getName().startsWith(".id_")) { if (file.getName().startsWith(".id_")) {
return file.getName().substring(1); return file.getName().substring(1).toLowerCase();
} }
} }
} }