mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-09-29 23:57:28 +02:00
Fix Difficulty and GameMode not reloading properly. Closes #190
This commit is contained in:
parent
ea920c1252
commit
3284670153
@ -104,7 +104,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
this.setScaling(worldSection.getDouble("scale", this.getDefaultScale(this.environment)));
|
||||
this.setRespawnToWorld(worldSection.getString("respawnworld", ""));
|
||||
this.setEnableWeather(worldSection.getBoolean("allowweather", true));
|
||||
this.setDifficulty(worldSection.getString("difficulty", "1"));
|
||||
this.setDifficulty(worldSection.get("difficulty", "EASY"));
|
||||
|
||||
this.setAllowAnimalSpawn(worldSection.getBoolean("animals.spawn", true));
|
||||
this.setAllowMonsterSpawn(worldSection.getBoolean("monsters.spawn", true));
|
||||
@ -114,7 +114,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
this.setHidden(worldSection.getBoolean("hidden", false));
|
||||
this.getMobExceptions();
|
||||
|
||||
this.setGameMode(worldSection.getString("gamemode", GameMode.SURVIVAL.toString()));
|
||||
this.setGameMode(worldSection.get("gamemode", GameMode.SURVIVAL.toString()));
|
||||
|
||||
this.setKeepSpawnInMemory(worldSection.getBoolean("keepspawninmemory", true));
|
||||
|
||||
@ -670,12 +670,30 @@ public class MVWorld implements MultiverseWorld {
|
||||
return false;
|
||||
}
|
||||
this.setGameMode(mode);
|
||||
this.worldSection.set("gamemode", mode.getValue());
|
||||
this.worldSection.set("gamemode", mode.toString());
|
||||
saveConfig();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* FernFerret messed up and now config values could be in either string or Int
|
||||
*
|
||||
* @param mode The gamemode as an object.
|
||||
*
|
||||
* @return True if the mode was set, false if not.
|
||||
*/
|
||||
private boolean setGameMode(Object mode) {
|
||||
if (mode instanceof Integer) {
|
||||
return this.setGameMode(GameMode.getByValue((Integer) mode));
|
||||
}
|
||||
try {
|
||||
return this.setGameMode((String) mode);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean setGameMode(GameMode mode) {
|
||||
|
||||
this.gameMode = mode;
|
||||
@ -765,6 +783,24 @@ public class MVWorld implements MultiverseWorld {
|
||||
return this.getCBWorld().getDifficulty();
|
||||
}
|
||||
|
||||
/**
|
||||
* FernFerret messed up and now config values could be in either string or Int
|
||||
*
|
||||
* @param mode The gamemode as an object.
|
||||
*
|
||||
* @return True if the mode was set, false if not.
|
||||
*/
|
||||
private boolean setDifficulty(Object mode) {
|
||||
if (mode instanceof Integer) {
|
||||
return this.setDifficulty(Difficulty.getByValue((Integer) mode));
|
||||
}
|
||||
try {
|
||||
return this.setDifficulty((String) mode);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setDifficulty(String difficulty) {
|
||||
Difficulty worlddiff;
|
||||
@ -782,8 +818,14 @@ public class MVWorld implements MultiverseWorld {
|
||||
if (worlddiff == null) {
|
||||
return false;
|
||||
}
|
||||
this.getCBWorld().setDifficulty(worlddiff);
|
||||
this.worldSection.set("difficulty", worlddiff.getValue());
|
||||
this.setDifficulty(worlddiff);
|
||||
saveConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean setDifficulty(Difficulty diff) {
|
||||
this.getCBWorld().setDifficulty(diff);
|
||||
this.worldSection.set("difficulty", diff.toString());
|
||||
saveConfig();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user