Should fix environment, seed and generator-issues.

This commit is contained in:
main() 2012-05-01 12:23:04 +02:00
parent 1496d940bf
commit d7a3e1839e
3 changed files with 57 additions and 12 deletions

View File

@ -69,8 +69,6 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
private MultiverseCore plugin; // Hold the Plugin Instance.
private Reference<World> world; // A reference to the World Instance.
private Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
private long seed; // The world seed
private String name; // The Worlds Name, EG its folder name.
/**
@ -438,6 +436,12 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
return world.get().getTime();
}
};
@Property
private Environment environment;
@Property
private long seed;
@Property
private String generator;
// End of properties
// --------------------------------------------------------------
@ -446,6 +450,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
private Permission ignoreperm;
public MVWorld(boolean fixSpawn) {
super();
if (!fixSpawn) {
this.adjustSpawn = false;
}
@ -570,6 +575,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
this.autoLoad = true;
this.bedRespawn = true;
this.worldBlacklist = new ArrayList<String>();
this.generator = null;
}
/**
@ -791,7 +797,6 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public Environment getEnvironment() {
// This variable is not settable in-game, therefore does not get a property.
return this.environment;
}
@ -800,16 +805,14 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public void setEnvironment(Environment environment) {
// This variable is not settable in-game, therefore does not get a property.
this.environment = environment;
this.setPropertyValueUnchecked("environment", environment);
}
/**
* {@inheritDoc}
*/
@Override
public Long getSeed() {
// This variable is not settable in-game, therefore does not get a property.
public long getSeed() {
return this.seed;
}
@ -818,8 +821,23 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public void setSeed(long seed) {
// This variable is not settable in-game, therefore does not get a property.
this.seed = seed;
this.setPropertyValueUnchecked("seed", seed);
}
/**
* {@inheritDoc}
*/
@Override
public String getGenerator() {
return this.generator;
}
/**
* {@inheritDoc}
*/
@Override
public void setGenerator(String generator) {
this.setPropertyValueUnchecked("generator", generator);
}
/**

View File

@ -46,7 +46,7 @@ public interface MultiverseWorld {
* Gets the type of this world. As of 1.2 this will be:
* FLAT, NORMAL or VERSION_1_1
* <p>
* This is *not* the generator.
* This is <b>not</b> the generator.
*
* @return The Type of this world.
*/
@ -104,7 +104,7 @@ public interface MultiverseWorld {
*
* @return The Long version of the seed.
*/
Long getSeed();
long getSeed();
/**
* Sets the seed of this world.
@ -113,6 +113,20 @@ public interface MultiverseWorld {
*/
void setSeed(long seed);
/**
* Gets the generator of this world.
*
* @return The name of the generator.
*/
String getGenerator();
/**
* Sets the generator of this world.
*
* @param generator The new generator's name.
*/
void setGenerator(String generator);
/**
* Gets the help-message for a property.
* @param property The name of the property.

View File

@ -142,6 +142,9 @@ public class WorldManager implements MVWorldManager {
return false;
}
// set generator (special case because we can't read it from org.bukkit.World)
this.worlds.get(name).setGenerator(generator);
this.saveWorldsConfig();
return true;
}
@ -262,7 +265,17 @@ public class WorldManager implements MVWorldManager {
}
private boolean doLoad(String name) {
return doLoad(WorldCreator.name(name));
if (!worldsFromTheConfig.containsKey(name))
throw new IllegalArgumentException("That world doesn't exist!");
MVWorld world = worldsFromTheConfig.get(name);
WorldCreator creator = WorldCreator.name(name);
creator.environment(world.getEnvironment()).seed(world.getSeed());
if (world.getGenerator() != null)
creator.generator(world.getGenerator());
return doLoad(creator);
}
private boolean doLoad(WorldCreator creator) {