mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-09-16 09:37:37 +02:00
Refactor MVWorld
This commit is contained in:
parent
cedc097efa
commit
028b910e9a
@ -36,33 +36,47 @@ public class MVWorld {
|
||||
public List<String> worldBlacklist; // Contain a list of Worlds which Players cannot use to Portal to this World.
|
||||
|
||||
public Double scaling; // How stretched/compressed distances are
|
||||
private ChunkGenerator generator;
|
||||
private String generatorString;
|
||||
|
||||
/**
|
||||
* The generator as a string. This is used only for reporting.
|
||||
* ex: BukkitFullOfMoon:GenID
|
||||
*/
|
||||
private String generator;
|
||||
|
||||
public MVWorld(World world, Configuration config, MultiverseCore instance, Long seed, String generatorString) {
|
||||
this.config = config;
|
||||
this.plugin = instance;
|
||||
|
||||
// Set local values that CANNOT be changed by user
|
||||
this.world = world;
|
||||
this.name = world.getName();
|
||||
this.generator = world.getGenerator();
|
||||
this.generatorString = generatorString;
|
||||
this.generator = generatorString;
|
||||
this.seed = seed;
|
||||
this.environment = world.getEnvironment();
|
||||
|
||||
// Write these files to the config (once it's saved)
|
||||
if (generatorString != null) {
|
||||
config.setProperty("worlds." + this.name + ".generator", this.generator);
|
||||
}
|
||||
if (seed != null) {
|
||||
config.setProperty("worlds." + this.name + ".seed", this.seed);
|
||||
}
|
||||
config.setProperty("worlds." + this.name + ".environment", this.environment.toString());
|
||||
|
||||
// Initialize our lists
|
||||
this.initLists();
|
||||
|
||||
// Set local values that CAN be changed by the user
|
||||
this.setAlias(config.getString("worlds." + this.name + ".alias", ""));
|
||||
|
||||
this.setPvp(config.getBoolean("worlds." + this.name + ".pvp", true));
|
||||
|
||||
this.setScaling(config.getDouble("worlds." + this.name + ".scale", 1.0));
|
||||
if (this.scaling <= 0) {
|
||||
// Disallow negative or 0 scalings.
|
||||
config.setProperty("worlds." + this.name + ".scale", 1.0);
|
||||
this.scaling = 1.0;
|
||||
}
|
||||
this.setAnimals(config.getBoolean("worlds." + this.name + ".animals.spawn", true));
|
||||
this.setMonsters(config.getBoolean("worlds." + this.name + ".monsters.spawn", true));
|
||||
this.getMobExceptions();
|
||||
|
||||
this.playerWhitelist = config.getStringList("worlds." + this.name + ".playerWhitelist", this.playerWhitelist);
|
||||
this.playerBlacklist = config.getStringList("worlds." + this.name + ".playerBlacklist", this.playerBlacklist);
|
||||
@ -71,18 +85,6 @@ public class MVWorld {
|
||||
this.editWhitelist = config.getStringList("worlds." + this.name + ".editWhitelist", this.editWhitelist);
|
||||
this.editBlacklist = config.getStringList("worlds." + this.name + ".editBlacklist", this.editBlacklist);
|
||||
|
||||
this.animals = config.getBoolean("worlds." + this.name + ".animals.spawn", true);
|
||||
this.monsters = config.getBoolean("worlds." + this.name + ".monsters.spawn", true);
|
||||
|
||||
this.getMobExceptions();
|
||||
|
||||
this.setRealMobBehaviors();
|
||||
|
||||
config.setProperty("worlds." + this.name + ".environment", this.environment.toString());
|
||||
config.setProperty("worlds." + this.name + ".generator",generatorString);
|
||||
if (seed != null) {
|
||||
config.setProperty("worlds." + this.name + ".seed", this.seed);
|
||||
}
|
||||
config.save();
|
||||
// The following 3 lines will add some sample data to new worlds created.
|
||||
// if (config.getIntList("worlds." + name + ".blockBlacklist", new ArrayList<Integer>()).size() == 0) {
|
||||
@ -109,19 +111,6 @@ public class MVWorld {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
private void setRealMobBehaviors() {
|
||||
boolean animals = true;
|
||||
boolean monsters = true;
|
||||
if (!this.animals && this.animalList.isEmpty()) {
|
||||
animals = false;
|
||||
}
|
||||
if (!this.monsters && this.monsterList.isEmpty()) {
|
||||
monsters = false;
|
||||
}
|
||||
this.world.setSpawnFlags(monsters, animals);
|
||||
|
||||
}
|
||||
|
||||
private void initLists() {
|
||||
this.blockBlacklist = new ArrayList<Integer>();
|
||||
this.playerWhitelist = new ArrayList<String>();
|
||||
@ -174,17 +163,16 @@ public class MVWorld {
|
||||
boolean boolValue = Boolean.parseBoolean(value);
|
||||
if (name.equalsIgnoreCase("pvp")) {
|
||||
this.pvp = boolValue;
|
||||
}
|
||||
else if(name.equalsIgnoreCase("animals")){
|
||||
} else if (name.equalsIgnoreCase("animals")) {
|
||||
this.animals = boolValue;
|
||||
}
|
||||
else if(name.equalsIgnoreCase("monsters")){
|
||||
} else if (name.equalsIgnoreCase("monsters")) {
|
||||
this.monsters = boolValue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
// The Doubles
|
||||
try {
|
||||
@ -194,7 +182,8 @@ public class MVWorld {
|
||||
return true;
|
||||
}
|
||||
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
// The Strings
|
||||
if (name.equalsIgnoreCase("alias")) {
|
||||
@ -278,7 +267,6 @@ public class MVWorld {
|
||||
return this.monsterList;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getPvp() {
|
||||
return this.pvp;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user