mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-07 03:11:02 +01:00
Bunch of NPE fixes
This commit is contained in:
parent
f4093cbe51
commit
c200d43f51
@ -80,14 +80,18 @@ public class MVWorld implements MultiverseWorld {
|
||||
// Initialize our lists
|
||||
this.initLists();
|
||||
worldSection = config.getConfigurationSection("worlds." + this.name);
|
||||
if (worldSection == null) {
|
||||
config.createSection("worlds." + this.name);
|
||||
worldSection = config.getConfigurationSection("worlds." + this.name);
|
||||
}
|
||||
// Write these files to the config (once it's saved)
|
||||
if (generatorString != null) {
|
||||
worldSection.set("generator", generatorString);
|
||||
}
|
||||
if (seed != null) {
|
||||
worldSection.set("worlds." + this.name + "seed", this.seed);
|
||||
worldSection.set("seed", this.seed);
|
||||
}
|
||||
worldSection.set("worlds." + this.name + "environment", this.environment.toString());
|
||||
worldSection.set("environment", this.environment.toString());
|
||||
|
||||
|
||||
// Set local values that CAN be changed by the user
|
||||
@ -363,8 +367,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
}
|
||||
if (name.equalsIgnoreCase("scale") || name.equalsIgnoreCase("scaling")) {
|
||||
try {
|
||||
this.setScaling(Double.parseDouble(value));
|
||||
return true;
|
||||
return this.setScaling(Double.parseDouble(value));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
@ -525,14 +528,17 @@ public class MVWorld implements MultiverseWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScaling(double scaling) {
|
||||
public boolean setScaling(double scaling) {
|
||||
boolean success = true;
|
||||
if (scaling <= 0) {
|
||||
// Disallow negative or 0 scalings.
|
||||
scaling = 1.0;
|
||||
success = false;
|
||||
}
|
||||
this.scaling = scaling;
|
||||
this.worldSection.set("scale", scaling);
|
||||
saveConfig();
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -548,6 +554,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
}
|
||||
|
||||
public boolean isValidAliasColor(String aliasColor) {
|
||||
System.out.print("Checking color... " + aliasColor);
|
||||
return (EnglishChatColor.fromString(aliasColor) != null);
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
|
||||
BedRespawn = this.multiverseConfig.getBoolean("bedrespawn", true);
|
||||
this.multiverseConfig.set("enforceaccess", EnforceAccess);
|
||||
this.multiverseConfig.set("enforcegamemodes", EnforceAccess);
|
||||
this.multiverseConfig.set("enforcegamemodes", EnforceGameModes);
|
||||
this.multiverseConfig.set("bedrespawn", BedRespawn);
|
||||
this.multiverseConfig.set("worldnameprefix", PrefixChat);
|
||||
this.multiverseConfig.set("debug", GlobalDebug);
|
||||
this.messaging = new MVMessaging(this);
|
||||
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000));
|
||||
try {
|
||||
|
@ -366,7 +366,7 @@ public interface MultiverseWorld {
|
||||
*
|
||||
* @param scaling A scaling value, cannot be negative or 0.
|
||||
*/
|
||||
public void setScaling(double scaling);
|
||||
public boolean setScaling(double scaling);
|
||||
|
||||
/**
|
||||
* Gets the scaling value of this world.Really only has an effect if you use
|
||||
|
@ -55,6 +55,6 @@ public enum EnglishChatColor {
|
||||
}
|
||||
}
|
||||
}
|
||||
return EnglishChatColor.WHITE;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -357,6 +357,14 @@ public class WorldManager implements MVWorldManager {
|
||||
// Basic Counter to count how many Worlds we are loading.
|
||||
int count = 0;
|
||||
// Grab all the Worlds from the Config.
|
||||
if (this.configWorlds.getConfigurationSection("worlds") == null) {
|
||||
this.configWorlds.createSection("worlds");
|
||||
try {
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
} catch (IOException e) {
|
||||
this.plugin.log(Level.SEVERE, "Failed to save worlds.yml. Please check your file permissions.");
|
||||
}
|
||||
}
|
||||
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||
|
||||
// Force the worlds to be loaded, ie don't just load new worlds.
|
||||
|
Loading…
Reference in New Issue
Block a user