Fixed spawn location loading

This commit is contained in:
main() 2012-05-01 17:00:05 +02:00
parent 9b2dd0d6c9
commit a4196a901a

View File

@ -39,6 +39,7 @@ import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import org.bukkit.util.Vector;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -465,6 +466,36 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
super.copyValues(other); super.copyValues(other);
} }
/**
* That's the spawn-location when the MVWorld-object wasn't property initialized.
*/
public static final SpawnLocation NULL_LOCATION = new SpawnLocation(0, -1, 0) {
@Override
public Location clone() {
throw new UnsupportedOperationException();
};
@Override
public Map<String, Object> serialize() {
throw new UnsupportedOperationException();
}
@Override
public Vector toVector() {
throw new UnsupportedOperationException();
}
@Override
public int hashCode() {
return -1;
};
@Override
public String toString() {
return "NULL LOCATION";
};
};
/** /**
* Sets the CB-World. * Sets the CB-World.
* <p> * <p>
@ -480,7 +511,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
this.environment = cbWorld.getEnvironment(); this.environment = cbWorld.getEnvironment();
this.seed = cbWorld.getSeed(); this.seed = cbWorld.getSeed();
this.name = cbWorld.getName(); this.name = cbWorld.getName();
if (this.spawnLocation == null) if (this.spawnLocation == NULL_LOCATION)
this.spawnLocation = new SpawnLocation(readSpawnFromWorld(cbWorld)); this.spawnLocation = new SpawnLocation(readSpawnFromWorld(cbWorld));
this.initPerms(); this.initPerms();
@ -571,7 +602,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
this.adjustSpawn = true; this.adjustSpawn = true;
this.portalForm = AllowedPortalType.ALL; this.portalForm = AllowedPortalType.ALL;
this.gameMode = GameMode.SURVIVAL; this.gameMode = GameMode.SURVIVAL;
this.spawnLocation = (world != null) ? new SpawnLocation(world.get().getSpawnLocation()) : new SpawnLocation(0, 0, 0); this.spawnLocation = (world != null) ? new SpawnLocation(world.get().getSpawnLocation()) : NULL_LOCATION;
this.autoLoad = true; this.autoLoad = true;
this.bedRespawn = true; this.bedRespawn = true;
this.worldBlacklist = new ArrayList<String>(); this.worldBlacklist = new ArrayList<String>();