So I've been trying to create a simple minigame engine. Within my Arena Manager class I create the arena's based on the config file information. I then make it so these worlds have autosave set to false. That way when I unload and reload the world in the reset() method of my Arena class the map/arena should be as good as new. However, that is not the case. If someone could please tell me what I am doing wrong or some good alternate methods that would be greatly appreciated! Game class is where reset() is called
Relevant Classes
Arena ClassArena Class
Arena Manager ClassArena Manager
Game ClassGame Class
Config
text
Tried setting autosave in the bukkit.yml to be -1 to see if that was overriding my plugin settings. Expected it to ensure unloading the world didn't have any changes left. Instead didn't work.
For more clarification the world isn't being unloaded so changes made to the arena map carry over into the next game.
Code For Creating Minigame Arena
for (String str: config.getConfigurationSection("arenas.").getKeys(false)){
// Returns a set of strings
World world = Bukkit.createWorld(new WorldCreator(config.getString("arenas."+str+".world")));
world.save();
world.setAutoSave(false); // Setting World 1's Autosave to false
arenas.add(new Arena(minigame,Integer.parseInt(str),new Location(
Bukkit.getWorld(config.getString("arenas."+str+".world")),
config.getDouble("arenas."+str+".x"),
config.getDouble("arenas."+str+".y"),
config.getDouble("arenas."+str+".z"),
(float) config.getDouble("arenas."+str+".yaw"),
(float) config.getDouble("arenas."+str+".pitch"))));
}
Code For Resetting Arena:
public void reset(){
System.out.println("Method fired!");
if (state == GameState.LIVE) {
this.canJoin = false;
// Adding check to see if GameState is Live which indicates we need to reset a map and kick players,
// However, in other cases we don't need to bother with kicking players
Location lobbySpawn = ConfigManager.getLobbySpawn();
for (UUID uuid : playersinArena) {
Bukkit.getPlayer(uuid).teleport(lobbySpawn);
}
playersinArena.clear();
String worldname = spawn.getWorld().getName();
System.out.println("World Name:"+worldname);
Bukkit.unloadWorld(spawn.getWorld(), false);
World world = Bukkit.createWorld(new WorldCreator(worldname));
world.setAutoSave(false); // Setting World 1's Auto-save to false
}