Hi, I need to rebuild a world myself. I saw topics but not answered ... I have modified codes. I want to know : is my code correct ?! Help me please The plugin must : => • So first in onEnable I'm checking if worldName+"#tksave" exists. If false then I create it from worldName. Code: if(new File(getDataFolder(), worldName+"#tksave").exists()){ getLogger().info(worldName+"#tksave"+" exists."); }else{ File worldNameLoading = new File(Bukkit.getWorldContainer(), worldName); worldNameLoading.mkdirs();//crée le dossier FileUtil.copy(new File(getDataFolder(), worldName+"#save"), worldNameLoading); Bukkit.createWorld(new WorldCreator(worldName)); getLogger().info(worldName+"#tksave"+" created."); } • Reload the world, delete worldName then create worldName from worldName+"#tksave". Code: public void reloadWorld(String map){ getLogger().info("Reload "+worldName); try{ for(Player p : Bukkit.getOnlinePlayers()) if(p.getLocation().getWorld().getName().equals(worldName)) p.teleport(Bukkit.getWorld(worldSpawn).getSpawnLocation()); Bukkit.unloadWorld(worldName, false);//on unload map getLogger().info(worldName+" unload."); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){ @Override public void run() { new File(Bukkit.getWorldContainer(), worldName).delete();//on delete map getLogger().info(worldName+" deleted."); }}, 200); }catch(Exception e){ } if(new File(getDataFolder(), worldName+"#tksave").exists()){ File worldNameLoading = new File(Bukkit.getWorldContainer(), worldName+"#tksave"); worldNameLoading.mkdirs();//crée le dossier FileUtil.copy(new File(getDataFolder(), worldName), worldNameLoading); } Bukkit.createWorld(new WorldCreator(worldName)); getLogger().info(worldName+" created."); } Like that I have a clean worldName.
@To175 To "roll back" a world, you can unload it with Code:java Bukkit.unloadWorld(name, false); and then load it back normally. This will work as long as you have save-all off for this world and nobody saves the world manually
There is not any error, read my question. I meant, I want to know if my code is correct ? @Hawktasard Thanks, I'm not asking "is there an other way", I'm asking if my code is correct.