Fixed NPE in world loading.. Thanks Grimlock257 for spotting this.

This commit is contained in:
Jeremy Wood 2012-08-21 13:20:13 -04:00
parent 242d20884c
commit 9196973d1c

View File

@ -15,9 +15,9 @@ import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.WorldPurger; import com.onarandombox.MultiverseCore.api.WorldPurger;
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent; import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException; import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.Location;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -811,6 +811,7 @@ public class WorldManager implements MVWorldManager {
Object obj = this.configWorlds.get(path); Object obj = this.configWorlds.get(path);
if ((obj != null) && (obj instanceof MVWorld)) { if ((obj != null) && (obj instanceof MVWorld)) {
String worldName = key.replaceAll(String.valueOf(SEPARATOR), "."); String worldName = key.replaceAll(String.valueOf(SEPARATOR), ".");
MVWorld mvWorld = null;
if (this.worldsFromTheConfig.containsKey(worldName)) { if (this.worldsFromTheConfig.containsKey(worldName)) {
// Object-Recycling :D // Object-Recycling :D
Thread thread = Thread.currentThread(); Thread thread = Thread.currentThread();
@ -820,20 +821,24 @@ public class WorldManager implements MVWorldManager {
worldsLock.lock(); worldsLock.lock();
try { try {
plugin.log(Level.FINEST, "Accessing worlds on thread: " + thread); plugin.log(Level.FINEST, "Accessing worlds on thread: " + thread);
MVWorld oldMVWorld = (MVWorld) this.worlds.get(worldName); // TODO Why is is checking worldsFromTheConfig and then getting from worlds? So confused... (DTM)
oldMVWorld.copyValues((MVWorld) obj); mvWorld = (MVWorld) this.worlds.get(worldName);
newWorldsFromTheConfig.put(worldName, oldMVWorld); if (mvWorld != null) {
mvWorld.copyValues((MVWorld) obj);
}
} finally { } finally {
worldsLock.unlock(); worldsLock.unlock();
} }
} else { }
if (mvWorld == null) {
// we have to use a new one // we have to use a new one
World cbworld = this.plugin.getServer().getWorld(worldName); World cbworld = this.plugin.getServer().getWorld(worldName);
MVWorld mvworld = (MVWorld) obj; mvWorld = (MVWorld) obj;
if (cbworld != null) if (cbworld != null) {
mvworld.init(cbworld, this.plugin); mvWorld.init(cbworld, this.plugin);
newWorldsFromTheConfig.put(worldName, mvworld);
} }
}
newWorldsFromTheConfig.put(worldName, mvWorld);
} else if (this.configWorlds.isConfigurationSection(path)) { } else if (this.configWorlds.isConfigurationSection(path)) {
ConfigurationSection section = this.configWorlds.getConfigurationSection(path); ConfigurationSection section = this.configWorlds.getConfigurationSection(path);
Set<String> subkeys = section.getKeys(false); Set<String> subkeys = section.getKeys(false);