Copy the Edit-World when unloading

This commit is contained in:
Sn0wStorm 2013-06-02 15:55:48 +02:00
parent 02862b4336
commit 8baac3202c
4 changed files with 15 additions and 14 deletions

View File

@ -63,8 +63,6 @@ public class EditWorld {
public void save() {
this.world.save();
p.copyDirectory(new File("DXL_Edit_" + this.id), new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
p.deletenotusingfiles(new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(p.getDataFolder(), "/dungeons/" + this.dungeonname + "/DXLData.data")));
out.writeInt(this.sign.size());
@ -102,6 +100,8 @@ public class EditWorld {
p.getServer().unloadWorld(this.world, true);
File dir = new File("DXL_Edit_" + this.id);
p.copyDirectory(dir, new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
p.deletenotusingfiles(new File(p.getDataFolder(), "/dungeons/" + this.dungeonname));
p.removeDirectory(dir);
}
@ -128,15 +128,7 @@ public class EditWorld {
public static void deleteAll() {
for (EditWorld eworld : eworlds) {
eworlds.remove(eworld);
for (Player player : eworld.world.getPlayers()) {
DPlayer dplayer = DPlayer.get(player);
dplayer.leave();
}
p.getServer().unloadWorld(eworld.world, true);
File dir = new File("DXL_Edit_" + eworld.id);
p.removeDirectory(dir);
eworld.delete();
}
}

View File

@ -179,7 +179,6 @@ public class P extends JavaPlugin {
}
for (EditWorld eworld : EditWorld.eworlds) {
if (eworld.world.getPlayers().isEmpty()) {
eworld.save();
eworld.delete();
}
}
@ -302,7 +301,7 @@ public class P extends JavaPlugin {
}
}
public String[] excludedFiles = { "config.yml", "uid.dat" };
public String[] excludedFiles = { "config.yml", "uid.dat", "DXLData.data" };
public void copyDirectory(File sourceLocation, File targetLocation) {
if (sourceLocation.isDirectory()) {

View File

@ -43,6 +43,8 @@ public class CMDEdit extends DCommand {
} else {
p.msg(player, p.language.get("Error_LeaveDungeon"));
}
} else {
p.msg(player, p.language.get("Error_NoPermission"));
}
}

View File

@ -26,6 +26,7 @@ import com.dre.dungeonsxl.DConfig;
import com.dre.dungeonsxl.DPlayer;
import com.dre.dungeonsxl.P;
import com.dre.dungeonsxl.signs.DSign;
import com.dre.dungeonsxl.EditWorld;
public class GameWorld {
private static P p = P.p;
@ -251,6 +252,13 @@ public class GameWorld {
GameWorld gworld = new GameWorld();
gworld.dungeonname = name;
// Unload empty eworlds
for (EditWorld eworld : EditWorld.eworlds) {
if (eworld.world.getPlayers().isEmpty()) {
eworld.delete();
}
}
// Config einlesen
gworld.config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + gworld.dungeonname, "config.yml"));
@ -264,7 +272,7 @@ public class GameWorld {
ObjectInputStream os;
try {
os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_" + gworld.id + "/DXLData.data")));
os = new ObjectInputStream(new FileInputStream(new File(p.getDataFolder() + "/dungeons/" + gworld.dungeonname + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {