This commit is contained in:
Simon Rigby 2011-03-01 17:18:49 +00:00
parent bee723182a
commit 0efc0c98ff
2 changed files with 19 additions and 25 deletions

View File

@ -6,19 +6,16 @@ import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.util.config.Configuration;
import com.onarandombox.utils.stringLocation;
@SuppressWarnings("unused")
public class MVWorld {
private MultiVerseCore plugin; // Hold the Plugin Instance.
private Configuration config; // Hold the Configuration File.
public World world; // The World Instance.
public Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
public Location spawn; // Location of the Spawn Point.
public String name; // The Worlds Name, EG its folder name.
public String alias = ""; // Short Alias for the World, this will be used in Chat Prefixes.
@ -34,32 +31,29 @@ public class MVWorld {
public List<String> editBlacklist; // Contain a list of Players/Groups which cannot edit this World. (Place/Destroy Blocks)
public List<String> worldBlacklist; // Contain a list of Worlds which Players cannot use to Portal to this World.
public MVWorld(World world, Configuration config, MultiVerseCore instance){
this.config = config;
this.plugin = instance;
public int compression = 0; // TODO: Needs a description, minds blank and can't think :).
/**
* @param world
* @param handle - If the World was loaded by MultiVerse then this will be true and means we can do
* what we wan't with it else it's only here to be read from.
*/
public MVWorld(World world, boolean handle){
this.world = world;
this.name = world.getName();
this.alias = config.getString("worlds." + this.name + ".alias","");
this.environment = world.getEnvironment();
this.spawn = getSpawn(this.config.getString("worlds." + name + ".spawn", "").split(":"));
// The following should already of been set when the World was created, so we don't wan't to overwrite these values we'll just grab them.
this.monsters = ((CraftWorld) world).getHandle().D = monsters; // TODO: Swap to Bukkit Function when implemented.
this.animals = ((CraftWorld) world).getHandle().E = animals; // TODO: Swap to Bukkit Function when implemented.
this.monsters = config.getBoolean("worlds." + this.name + ".monsters", true);
this.animals = config.getBoolean("worlds." + this.name + ".animals", true);
this.pvp = config.getBoolean("worlds." + this.name + ".pvp", true);
}
private Location getSpawn(String[] spawn){
Location l = null;
if(spawn.length!=5){
return this.world.getSpawnLocation();
} else {
return new stringLocation().stringToLocation(world, spawn[0], spawn[1], spawn[2], spawn[3], spawn[4]);
// If MultiVerse created/loaded the World then it means we wan't to handle it as well, otherwise
// we don't touch any settings unless the user specifically asks us to.
if(handle==true){
this.alias = MultiVerseCore.configWorlds.getString("worlds." + this.name + ".alias","");
this.compression = MultiVerseCore.configWorlds.getInt("worlds." + this.name + ".compression", 0);
this.pvp = MultiVerseCore.configWorlds.getBoolean("worlds." + this.name + ".pvp", false);
}
}
}

View File

@ -159,7 +159,7 @@ public class MultiVerseCore extends JavaPlugin {
for (World world : worlds){
log.info(logPrefix + "Loading existing World - '" + world.getName() + "' - " + world.getEnvironment().toString()); // Output to the Log that wea re loading a world, specify the name and environment type.
MultiVerseCore.worlds.put(world.getName(), new MVWorld(world, MultiVerseCore.configWorlds, this)); // Place the World into the HashMap.
MultiVerseCore.worlds.put(world.getName(), new MVWorld(world, false)); // Place the World into the HashMap.
count++; // Increment the World Count.
}
}