mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Copy the Edit-World when unloading
This commit is contained in:
parent
02862b4336
commit
8baac3202c
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()) {
|
||||
|
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user