Shifted world properties to its own class WorldProperties so we can now only initialize an MVWorld if there is a 'more solid' world reference. Let's hope this works! Should fix #947
This commit is contained in:
parent
957c55955d
commit
7d1c47c2fc
File diff suppressed because it is too large
Load Diff
|
@ -61,7 +61,6 @@ import com.onarandombox.MultiverseCore.destination.ExactDestination;
|
||||||
import com.onarandombox.MultiverseCore.destination.PlayerDestination;
|
import com.onarandombox.MultiverseCore.destination.PlayerDestination;
|
||||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
|
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||||
|
@ -80,6 +79,7 @@ import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||||
|
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Difficulty;
|
import org.bukkit.Difficulty;
|
||||||
|
@ -222,7 +222,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
// Register our config
|
// Register our config
|
||||||
SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
|
SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
|
||||||
// Register our world
|
// Register our world
|
||||||
SerializationConfig.registerAll(MVWorld.class);
|
SerializationConfig.registerAll(WorldProperties.class);
|
||||||
// Create our DataFolder
|
// Create our DataFolder
|
||||||
getDataFolder().mkdirs();
|
getDataFolder().mkdirs();
|
||||||
// Setup our Debug Log
|
// Setup our Debug Log
|
||||||
|
@ -567,14 +567,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
boolean wasChanged = false;
|
boolean wasChanged = false;
|
||||||
Map<String, Object> newValues = new LinkedHashMap<String, Object>(values.size());
|
Map<String, Object> newValues = new LinkedHashMap<String, Object>(values.size());
|
||||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||||
if (entry.getValue() instanceof MVWorld) {
|
if (entry.getValue() instanceof WorldProperties) {
|
||||||
// fine
|
// fine
|
||||||
newValues.put(entry.getKey(), entry.getValue());
|
newValues.put(entry.getKey(), entry.getValue());
|
||||||
} else if (entry.getValue() instanceof ConfigurationSection) {
|
} else if (entry.getValue() instanceof ConfigurationSection) {
|
||||||
this.log(Level.FINE, "Migrating: " + entry.getKey());
|
this.log(Level.FINE, "Migrating: " + entry.getKey());
|
||||||
// we have to migrate this
|
// we have to migrate this
|
||||||
MVWorld world = new MVWorld(Collections.EMPTY_MAP);
|
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
|
||||||
world.setPluginAndWorld(this, entry.getKey());
|
|
||||||
ConfigurationSection section = (ConfigurationSection) entry.getValue();
|
ConfigurationSection section = (ConfigurationSection) entry.getValue();
|
||||||
|
|
||||||
// migrate animals and monsters
|
// migrate animals and monsters
|
||||||
|
@ -669,7 +668,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
if (section.isString("portalform")) {
|
if (section.isString("portalform")) {
|
||||||
try {
|
try {
|
||||||
world.setPropertyValue("portalform", section.getString("portalform"));
|
world.setPropertyValue("portalform", section.getString("portalform"));
|
||||||
} catch (PropertyDoesNotExistException e) {
|
} catch (NoSuchPropertyException e) {
|
||||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -678,7 +677,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
if (section.isString("environment")) {
|
if (section.isString("environment")) {
|
||||||
try {
|
try {
|
||||||
world.setPropertyValue("environment", section.getString("environment"));
|
world.setPropertyValue("environment", section.getString("environment"));
|
||||||
} catch (PropertyDoesNotExistException e) {
|
} catch (NoSuchPropertyException e) {
|
||||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,616 @@
|
||||||
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
|
||||||
|
import com.onarandombox.MultiverseCore.configuration.EntryFee;
|
||||||
|
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
|
||||||
|
import com.onarandombox.MultiverseCore.configuration.SpawnSettings;
|
||||||
|
import com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator;
|
||||||
|
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||||
|
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||||
|
import com.onarandombox.MultiverseCore.enums.EnglishChatStyle;
|
||||||
|
import me.main__.util.SerializationConfig.IllegalPropertyValueException;
|
||||||
|
import me.main__.util.SerializationConfig.Property;
|
||||||
|
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||||
|
import me.main__.util.SerializationConfig.Serializor;
|
||||||
|
import me.main__.util.SerializationConfig.Validator;
|
||||||
|
import me.main__.util.SerializationConfig.VirtualProperty;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@SerializableAs("MVWorld")
|
||||||
|
public class WorldProperties extends SerializationConfig {
|
||||||
|
|
||||||
|
private static final Map<String, String> PROPERTY_ALIASES;
|
||||||
|
|
||||||
|
static {
|
||||||
|
PROPERTY_ALIASES = new HashMap<String, String>();
|
||||||
|
PROPERTY_ALIASES.put("curr", "currency");
|
||||||
|
PROPERTY_ALIASES.put("scaling", "scale");
|
||||||
|
PROPERTY_ALIASES.put("aliascolor", "color");
|
||||||
|
PROPERTY_ALIASES.put("heal", "autoHeal");
|
||||||
|
PROPERTY_ALIASES.put("storm", "allowWeather");
|
||||||
|
PROPERTY_ALIASES.put("weather", "allowWeather");
|
||||||
|
PROPERTY_ALIASES.put("spawnmemory", "keepSpawnInMemory");
|
||||||
|
PROPERTY_ALIASES.put("memory", "keepSpawnInMemory");
|
||||||
|
PROPERTY_ALIASES.put("mode", "gameMode");
|
||||||
|
PROPERTY_ALIASES.put("diff", "difficulty");
|
||||||
|
PROPERTY_ALIASES.put("spawnlocation", "spawn");
|
||||||
|
PROPERTY_ALIASES.put("limit", "playerLimit");
|
||||||
|
PROPERTY_ALIASES.put("animals", "spawning.animals.spawn");
|
||||||
|
PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn");
|
||||||
|
PROPERTY_ALIASES.put("animalsrate", "spawning.animals.spawnrate");
|
||||||
|
PROPERTY_ALIASES.put("monstersrate", "spawning.monsters.spawnrate");
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldProperties(Map<String, Object> values) {
|
||||||
|
super(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldProperties() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldProperties(boolean fixSpawn) {
|
||||||
|
super();
|
||||||
|
if (!fixSpawn) {
|
||||||
|
this.adjustSpawn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMVWorld(MVWorld world) {
|
||||||
|
registerObjectUsing(world);
|
||||||
|
registerGlobalValidator(new WorldPropertyValidator());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializor for the color-property.
|
||||||
|
*/
|
||||||
|
private static final class EnumPropertySerializor<T extends Enum<T>> implements Serializor<T, String> {
|
||||||
|
@Override
|
||||||
|
public String serialize(T from) {
|
||||||
|
return from.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T deserialize(String serialized, Class<T> wanted) throws IllegalPropertyValueException {
|
||||||
|
try {
|
||||||
|
return Enum.valueOf(wanted, serialized.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new IllegalPropertyValueException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializor for the difficulty-property.
|
||||||
|
*/
|
||||||
|
private static final class DifficultyPropertySerializor implements Serializor<Difficulty, String> {
|
||||||
|
@Override
|
||||||
|
public String serialize(Difficulty from) {
|
||||||
|
return from.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Difficulty deserialize(String serialized, Class<Difficulty> wanted) throws IllegalPropertyValueException {
|
||||||
|
try {
|
||||||
|
return Difficulty.getByValue(Integer.parseInt(serialized));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Difficulty.valueOf(serialized.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
throw new IllegalPropertyValueException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializor for the gameMode-property.
|
||||||
|
*/
|
||||||
|
private static final class GameModePropertySerializor implements Serializor<GameMode, String> {
|
||||||
|
@Override
|
||||||
|
public String serialize(GameMode from) {
|
||||||
|
return from.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameMode deserialize(String serialized, Class<GameMode> wanted) throws IllegalPropertyValueException {
|
||||||
|
try {
|
||||||
|
return GameMode.getByValue(Integer.parseInt(serialized));
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return GameMode.valueOf(serialized.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
throw new IllegalPropertyValueException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializor for the time-property.
|
||||||
|
*/
|
||||||
|
private static final class TimePropertySerializor implements Serializor<Long, String> {
|
||||||
|
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||||
|
private static final String TIME_REGEX = "(\\d\\d?):?(\\d\\d)(a|p)?m?";
|
||||||
|
private static final Map<String, String> TIME_ALIASES;
|
||||||
|
static {
|
||||||
|
Map<String, String> staticTimes = new HashMap<String, String>();
|
||||||
|
staticTimes.put("morning", "8:00");
|
||||||
|
staticTimes.put("day", "12:00");
|
||||||
|
staticTimes.put("noon", "12:00");
|
||||||
|
staticTimes.put("midnight", "0:00");
|
||||||
|
staticTimes.put("night", "20:00");
|
||||||
|
|
||||||
|
// now set TIME_ALIASES to a "frozen" map
|
||||||
|
TIME_ALIASES = Collections.unmodifiableMap(staticTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serialize(Long from) {
|
||||||
|
// I'm tired, so they get time in 24 hour for now.
|
||||||
|
// Someone else can add 12 hr format if they want :P
|
||||||
|
|
||||||
|
int hours = (int) ((from / 1000 + 8) % 24);
|
||||||
|
int minutes = (int) (60 * (from % 1000) / 1000);
|
||||||
|
|
||||||
|
return String.format("%d:%02d", hours, minutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long deserialize(String serialized, Class<Long> wanted) throws IllegalPropertyValueException {
|
||||||
|
if (TIME_ALIASES.containsKey(serialized.toLowerCase())) {
|
||||||
|
serialized = TIME_ALIASES.get(serialized.toLowerCase());
|
||||||
|
}
|
||||||
|
// Regex that extracts a time in the following formats:
|
||||||
|
// 11:11pm, 11:11, 23:11, 1111, 1111p, and the aliases at the top of this file.
|
||||||
|
Pattern pattern = Pattern.compile(TIME_REGEX, Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher matcher = pattern.matcher(serialized);
|
||||||
|
matcher.find();
|
||||||
|
int hour = 0;
|
||||||
|
double minute = 0;
|
||||||
|
int count = matcher.groupCount();
|
||||||
|
if (count >= 2) {
|
||||||
|
hour = Integer.parseInt(matcher.group(1));
|
||||||
|
minute = Integer.parseInt(matcher.group(2));
|
||||||
|
}
|
||||||
|
// If there were 4 matches (all, hour, min, am/pm)
|
||||||
|
if (count == 4) {
|
||||||
|
// We want 24 hour time for calcs, but if they
|
||||||
|
// added a p[m], turn it into a 24 hr one.
|
||||||
|
if (matcher.group(3).equals("p")) {
|
||||||
|
hour += 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Translate 24th hour to 0th hour.
|
||||||
|
if (hour == 24) {
|
||||||
|
hour = 0;
|
||||||
|
}
|
||||||
|
// Clamp the hour
|
||||||
|
if (hour > 23 || hour < 0) {
|
||||||
|
throw new IllegalPropertyValueException("Illegal hour!");
|
||||||
|
}
|
||||||
|
// Clamp the minute
|
||||||
|
if (minute > 59 || minute < 0) {
|
||||||
|
throw new IllegalPropertyValueException("Illegal minute!");
|
||||||
|
}
|
||||||
|
// 60 seconds in a minute, time needs to be in hrs * 1000, per
|
||||||
|
// the bukkit docs.
|
||||||
|
double totaltime = (hour + (minute / 60.0)) * 1000;
|
||||||
|
// Somehow there's an 8 hour offset...
|
||||||
|
totaltime -= 8000;
|
||||||
|
if (totaltime < 0) {
|
||||||
|
totaltime = 24000 + totaltime;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (long) totaltime;
|
||||||
|
}
|
||||||
|
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Begin properties
|
||||||
|
@Property(description = "Sorry, 'hidden' must either be: true or false.")
|
||||||
|
private volatile boolean hidden;
|
||||||
|
@Property(description = "Alias must be a valid string.")
|
||||||
|
private volatile String alias;
|
||||||
|
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'color' must be a valid color-name.")
|
||||||
|
private volatile EnglishChatColor color;
|
||||||
|
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'style' must be a valid style-name.")
|
||||||
|
private volatile EnglishChatStyle style;
|
||||||
|
@Property(description = "Sorry, 'pvp' must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
|
||||||
|
volatile VirtualProperty<Boolean> pvp;
|
||||||
|
@Property(description = "Scale must be a positive double value. ex: 2.3")
|
||||||
|
private volatile double scale;
|
||||||
|
@Property(description = "You must set this to the NAME not alias of a world.")
|
||||||
|
private volatile String respawnWorld;
|
||||||
|
@Property(description = "Sorry, this must either be: true or false.")
|
||||||
|
private volatile boolean allowWeather;
|
||||||
|
@Property(serializor = DifficultyPropertySerializor.class, virtualType = Difficulty.class, persistVirtual = true,
|
||||||
|
description = "Difficulty must be set as one of the following: peaceful easy normal hard")
|
||||||
|
volatile VirtualProperty<Difficulty> difficulty;
|
||||||
|
@Property(description = "Sorry, 'animals' must either be: true or false.")
|
||||||
|
private volatile SpawnSettings spawning;
|
||||||
|
@Property
|
||||||
|
private volatile EntryFee entryfee;
|
||||||
|
@Property(description = "Sorry, 'hunger' must either be: true or false.")
|
||||||
|
private volatile boolean hunger;
|
||||||
|
@Property(description = "Sorry, 'autoheal' must either be: true or false.")
|
||||||
|
private volatile boolean autoHeal;
|
||||||
|
@Property(description = "Sorry, 'adjustspawn' must either be: true or false.")
|
||||||
|
private volatile boolean adjustSpawn;
|
||||||
|
@Property(serializor = EnumPropertySerializor.class, description = "Allow portal forming must be NONE, ALL, NETHER or END.")
|
||||||
|
private volatile AllowedPortalType portalForm;
|
||||||
|
@Property(serializor = GameModePropertySerializor.class, description = "GameMode must be set as one of the following: survival creative")
|
||||||
|
private volatile GameMode gameMode;
|
||||||
|
@Property(description = "Sorry, this must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
|
||||||
|
volatile VirtualProperty<Boolean> keepSpawnInMemory;
|
||||||
|
@Property
|
||||||
|
volatile SpawnLocation spawnLocation;
|
||||||
|
@Property(virtualType = Location.class,
|
||||||
|
description = "There is no help available for this variable. Go bug Rigby90 about it.")
|
||||||
|
volatile VirtualProperty<Location> spawn;
|
||||||
|
@Property(description = "Set this to false ONLY if you don't want this world to load itself on server restart.")
|
||||||
|
private volatile boolean autoLoad;
|
||||||
|
@Property(description = "If a player dies in this world, shoudld they go to their bed?")
|
||||||
|
private volatile boolean bedRespawn;
|
||||||
|
@Property
|
||||||
|
private volatile List<String> worldBlacklist;
|
||||||
|
@Property(serializor = TimePropertySerializor.class, virtualType = Long.class,
|
||||||
|
description = "Set the time to whatever you want! (Will NOT freeze time)")
|
||||||
|
volatile VirtualProperty<Long> time;
|
||||||
|
@Property
|
||||||
|
volatile Environment environment;
|
||||||
|
@Property
|
||||||
|
volatile long seed;
|
||||||
|
@Property
|
||||||
|
private volatile String generator;
|
||||||
|
@Property
|
||||||
|
private volatile int playerLimit;
|
||||||
|
// End of properties
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
|
||||||
|
void setValidator(String fieldName, Validator validator) {
|
||||||
|
registerValidator(fieldName, validator); //To change body of overridden methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void copyValues(SerializationConfig other) {
|
||||||
|
super.copyValues(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This prepares the MVWorld for unloading.
|
||||||
|
*/
|
||||||
|
public void tearDown() {
|
||||||
|
try {
|
||||||
|
this.buildVPropChanges();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void setDefaults() {
|
||||||
|
this.hidden = false;
|
||||||
|
this.alias = new String();
|
||||||
|
this.color = EnglishChatColor.WHITE;
|
||||||
|
this.style = EnglishChatStyle.NORMAL;
|
||||||
|
this.scale = getDefaultScale(environment);
|
||||||
|
this.respawnWorld = new String();
|
||||||
|
this.allowWeather = true;
|
||||||
|
this.spawning = new SpawnSettings();
|
||||||
|
this.entryfee = new EntryFee();
|
||||||
|
this.hunger = true;
|
||||||
|
this.autoHeal = true;
|
||||||
|
this.adjustSpawn = true;
|
||||||
|
this.portalForm = AllowedPortalType.ALL;
|
||||||
|
this.gameMode = GameMode.SURVIVAL;
|
||||||
|
this.spawnLocation = new NullLocation();
|
||||||
|
this.autoLoad = true;
|
||||||
|
this.bedRespawn = true;
|
||||||
|
this.worldBlacklist = new ArrayList<String>();
|
||||||
|
this.generator = null;
|
||||||
|
this.playerLimit = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double getDefaultScale(Environment environment) {
|
||||||
|
if (environment == Environment.NETHER) {
|
||||||
|
return 8.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||||
|
}
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getAliases().
|
||||||
|
* @return The alias-map.
|
||||||
|
* @see SerializationConfig
|
||||||
|
*/
|
||||||
|
protected static Map<String, String> getAliases() {
|
||||||
|
return PROPERTY_ALIASES;
|
||||||
|
}
|
||||||
|
|
||||||
|
void flushChanges() {
|
||||||
|
this.flushPendingVPropChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
String getAlias() {
|
||||||
|
return this.alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlias(String alias) {
|
||||||
|
this.setPropertyValueUnchecked("alias", alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Environment getEnvironment() {
|
||||||
|
return this.environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnvironment(Environment environment) {
|
||||||
|
this.setPropertyValueUnchecked("environment", environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSeed() {
|
||||||
|
return this.seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeed(long seed) {
|
||||||
|
this.setPropertyValueUnchecked("seed", seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGenerator() {
|
||||||
|
return this.generator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGenerator(String generator) {
|
||||||
|
this.setPropertyValueUnchecked("generator", generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerLimit() {
|
||||||
|
return this.playerLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerLimit(int limit) {
|
||||||
|
this.setPropertyValueUnchecked("playerLimit", limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canAnimalsSpawn() {
|
||||||
|
return this.spawning.getAnimalSettings().doSpawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowAnimalSpawn(boolean animals) {
|
||||||
|
this.setPropertyValueUnchecked("spawning.animals.spawn", animals);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAnimalList() {
|
||||||
|
// These don't fire events at the moment. Should they?
|
||||||
|
return this.spawning.getAnimalSettings().getExceptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canMonstersSpawn() {
|
||||||
|
return this.spawning.getMonsterSettings().doSpawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowMonsterSpawn(boolean monsters) {
|
||||||
|
this.setPropertyValueUnchecked("spawning.monsters.spawn", monsters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAnimalSpawnRate() {
|
||||||
|
return this.spawning.getAnimalSettings().getSpawnRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMonsterSpawnRate() {
|
||||||
|
return this.spawning.getMonsterSettings().getSpawnRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getMonsterList() {
|
||||||
|
// These don't fire events at the moment. Should they?
|
||||||
|
return this.spawning.getMonsterSettings().getExceptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPVPEnabled() {
|
||||||
|
return this.pvp.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPVPMode(boolean pvp) {
|
||||||
|
this.setPropertyValueUnchecked("pvp", pvp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHidden() {
|
||||||
|
return this.hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHidden(boolean hidden) {
|
||||||
|
this.setPropertyValueUnchecked("hidden", hidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getWorldBlacklist() {
|
||||||
|
return this.worldBlacklist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getScaling() {
|
||||||
|
return this.scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setScaling(double scaling) {
|
||||||
|
return this.setPropertyValueUnchecked("scale", scaling);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setColor(String aliasColor) {
|
||||||
|
return this.setPropertyUnchecked("color", aliasColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setColor(EnglishChatColor color) {
|
||||||
|
return this.setPropertyValueUnchecked("color", color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnglishChatColor getColor() {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRespawnToWorld() {
|
||||||
|
return this.respawnWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setRespawnToWorld(String respawnToWorld) {
|
||||||
|
return this.setPropertyValueUnchecked("respawnWorld", respawnToWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCurrency() {
|
||||||
|
return this.entryfee.getCurrency();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrency(int currency) {
|
||||||
|
this.setPropertyValueUnchecked("entryfee.currency", currency);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPrice() {
|
||||||
|
return this.entryfee.getAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(double price) {
|
||||||
|
this.setPropertyValueUnchecked("entryfee.amount", price);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setGameMode(String mode) {
|
||||||
|
return this.setPropertyUnchecked("gameMode", mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setGameMode(GameMode mode) {
|
||||||
|
return this.setPropertyValueUnchecked("gameMode", mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameMode getGameMode() {
|
||||||
|
return this.gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnableWeather(boolean weather) {
|
||||||
|
this.setPropertyValueUnchecked("allowWeather", weather);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWeatherEnabled() {
|
||||||
|
return this.allowWeather;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isKeepingSpawnInMemory() {
|
||||||
|
return this.keepSpawnInMemory.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeepSpawnInMemory(boolean value) {
|
||||||
|
this.setPropertyValueUnchecked("keepSpawnInMemory", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHunger() {
|
||||||
|
return this.hunger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHunger(boolean hunger) {
|
||||||
|
this.setPropertyValueUnchecked("hunger", hunger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getSpawnLocation() {
|
||||||
|
return this.spawn.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpawnLocation(Location l) {
|
||||||
|
this.setPropertyValueUnchecked("spawn", l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Difficulty getDifficulty() {
|
||||||
|
return this.difficulty.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public boolean setDifficulty(String difficulty) {
|
||||||
|
return this.setPropertyUnchecked("difficulty", difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setDifficulty(Difficulty difficulty) {
|
||||||
|
return this.setPropertyValueUnchecked("difficulty", difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAutoHeal() {
|
||||||
|
return this.autoHeal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoHeal(boolean heal) {
|
||||||
|
this.setPropertyValueUnchecked("autoHeal", heal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdjustSpawn(boolean adjust) {
|
||||||
|
this.setPropertyValueUnchecked("adjustSpawn", adjust);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAdjustSpawn() {
|
||||||
|
return this.adjustSpawn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoLoad(boolean load) {
|
||||||
|
this.setPropertyValueUnchecked("autoLoad", load);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAutoLoad() {
|
||||||
|
return this.autoLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBedRespawn(boolean respawn) {
|
||||||
|
this.setPropertyValueUnchecked("bedRespawn", respawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBedRespawn() {
|
||||||
|
return this.bedRespawn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAllPropertyNames() {
|
||||||
|
ChatColor myColor = ChatColor.AQUA;
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
Map<String, Object> serialized = this.serialize();
|
||||||
|
for (String key : serialized.keySet()) {
|
||||||
|
result.append(myColor).append(key).append(' ');
|
||||||
|
myColor = (myColor == ChatColor.AQUA) ? ChatColor.GOLD : ChatColor.AQUA;
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTime() {
|
||||||
|
return this.getPropertyUnchecked("time");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setTime(String timeAsString) {
|
||||||
|
return this.setPropertyUnchecked("time", timeAsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AllowedPortalType getAllowedPortals() {
|
||||||
|
return portalForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void allowPortalMaking(AllowedPortalType portalType) {
|
||||||
|
this.setPropertyValueUnchecked("portalForm", portalType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnglishChatStyle getStyle() {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setStyle(String style) {
|
||||||
|
return this.setPropertyUnchecked("style", style);
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,14 +30,14 @@ public interface MVPlugin extends LoggablePlugin {
|
||||||
/**
|
/**
|
||||||
* Gets the reference to MultiverseCore.
|
* Gets the reference to MultiverseCore.
|
||||||
*
|
*
|
||||||
* @return A valid {@link MultiverseCore}.
|
* @return A valid {@link com.onarandombox.MultiverseCore}.
|
||||||
*/
|
*/
|
||||||
MultiverseCore getCore();
|
MultiverseCore getCore();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the reference to MultiverseCore.
|
* Sets the reference to MultiverseCore.
|
||||||
*
|
*
|
||||||
* @param core A valid {@link MultiverseCore}.
|
* @param core A valid {@link com.onarandombox.MultiverseCore}.
|
||||||
*/
|
*/
|
||||||
void setCore(MultiverseCore core);
|
void setCore(MultiverseCore core);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.utils;
|
||||||
import com.dumptruckman.minecraft.util.Logging;
|
import com.dumptruckman.minecraft.util.Logging;
|
||||||
import com.onarandombox.MultiverseCore.MVWorld;
|
import com.onarandombox.MultiverseCore.MVWorld;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import com.onarandombox.MultiverseCore.WorldProperties;
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||||
|
@ -52,14 +53,14 @@ public class WorldManager implements MVWorldManager {
|
||||||
private final MultiverseCore plugin;
|
private final MultiverseCore plugin;
|
||||||
private final WorldPurger worldPurger;
|
private final WorldPurger worldPurger;
|
||||||
private final Map<String, MultiverseWorld> worlds;
|
private final Map<String, MultiverseWorld> worlds;
|
||||||
private Map<String, MVWorld> worldsFromTheConfig;
|
private Map<String, WorldProperties> worldsFromTheConfig;
|
||||||
private FileConfiguration configWorlds = null;
|
private FileConfiguration configWorlds = null;
|
||||||
private Map<String, String> defaultGens;
|
private Map<String, String> defaultGens;
|
||||||
private String firstSpawn;
|
private String firstSpawn;
|
||||||
|
|
||||||
public WorldManager(MultiverseCore core) {
|
public WorldManager(MultiverseCore core) {
|
||||||
this.plugin = core;
|
this.plugin = core;
|
||||||
this.worldsFromTheConfig = new HashMap<String, MVWorld>();
|
this.worldsFromTheConfig = new HashMap<String, WorldProperties>();
|
||||||
this.worlds = new ConcurrentHashMap<String, MultiverseWorld>();
|
this.worlds = new ConcurrentHashMap<String, MultiverseWorld>();
|
||||||
this.worldPurger = new SimpleWorldPurger(plugin);
|
this.worldPurger = new SimpleWorldPurger(plugin);
|
||||||
}
|
}
|
||||||
|
@ -207,8 +208,10 @@ public class WorldManager implements MVWorldManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Important: doLoad() needs the MVWorld-object in worldsFromTheConfig
|
// Important: doLoad() needs the MVWorld-object in worldsFromTheConfig
|
||||||
if (!worldsFromTheConfig.containsKey(name))
|
if (!worldsFromTheConfig.containsKey(name)) {
|
||||||
worldsFromTheConfig.put(name, new MVWorld(useSpawnAdjust));
|
WorldProperties props = new WorldProperties(useSpawnAdjust);
|
||||||
|
worldsFromTheConfig.put(name, props);
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("Loading World & Settings - '").append(name).append("'");
|
builder.append("Loading World & Settings - '").append(name).append("'");
|
||||||
|
@ -362,7 +365,7 @@ public class WorldManager implements MVWorldManager {
|
||||||
if (!worldsFromTheConfig.containsKey(name))
|
if (!worldsFromTheConfig.containsKey(name))
|
||||||
throw new IllegalArgumentException("That world doesn't exist!");
|
throw new IllegalArgumentException("That world doesn't exist!");
|
||||||
|
|
||||||
MVWorld world = worldsFromTheConfig.get(name);
|
WorldProperties world = worldsFromTheConfig.get(name);
|
||||||
WorldCreator creator = WorldCreator.name(name);
|
WorldCreator creator = WorldCreator.name(name);
|
||||||
|
|
||||||
creator.environment(world.getEnvironment()).seed(world.getSeed());
|
creator.environment(world.getEnvironment()).seed(world.getSeed());
|
||||||
|
@ -385,7 +388,7 @@ public class WorldManager implements MVWorldManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MVWorld mvworld = worldsFromTheConfig.get(worldName);
|
WorldProperties mvworld = worldsFromTheConfig.get(worldName);
|
||||||
World cbworld;
|
World cbworld;
|
||||||
try {
|
try {
|
||||||
cbworld = creator.createWorld();
|
cbworld = creator.createWorld();
|
||||||
|
@ -394,9 +397,9 @@ public class WorldManager implements MVWorldManager {
|
||||||
brokenWorld(worldName);
|
brokenWorld(worldName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mvworld.init(cbworld, plugin);
|
MVWorld world = new MVWorld(plugin, cbworld, mvworld);
|
||||||
this.worldPurger.purgeWorld(mvworld);
|
this.worldPurger.purgeWorld(world);
|
||||||
this.worlds.put(worldName, mvworld);
|
this.worlds.put(worldName, world);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +639,7 @@ public class WorldManager implements MVWorldManager {
|
||||||
this.worlds.clear();
|
this.worlds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, MVWorld> entry : worldsFromTheConfig.entrySet()) {
|
for (Map.Entry<String, WorldProperties> entry : worldsFromTheConfig.entrySet()) {
|
||||||
if (worlds.containsKey(entry.getKey())) {
|
if (worlds.containsKey(entry.getKey())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -696,31 +699,23 @@ public class WorldManager implements MVWorldManager {
|
||||||
// load world-objects
|
// load world-objects
|
||||||
Stack<String> worldKeys = new Stack<String>();
|
Stack<String> worldKeys = new Stack<String>();
|
||||||
worldKeys.addAll(this.configWorlds.getConfigurationSection("worlds").getKeys(false));
|
worldKeys.addAll(this.configWorlds.getConfigurationSection("worlds").getKeys(false));
|
||||||
Map<String, MVWorld> newWorldsFromTheConfig = new HashMap<String, MVWorld>();
|
Map<String, WorldProperties> newWorldsFromTheConfig = new HashMap<String, WorldProperties>();
|
||||||
while (!worldKeys.isEmpty()) {
|
while (!worldKeys.isEmpty()) {
|
||||||
String key = worldKeys.pop();
|
String key = worldKeys.pop();
|
||||||
String path = "worlds" + SEPARATOR + key;
|
String path = "worlds" + SEPARATOR + key;
|
||||||
Object obj = this.configWorlds.get(path);
|
Object obj = this.configWorlds.get(path);
|
||||||
if ((obj != null) && (obj instanceof MVWorld)) {
|
if ((obj != null) && (obj instanceof WorldProperties)) {
|
||||||
String worldName = key.replaceAll(String.valueOf(SEPARATOR), ".");
|
String worldName = key.replaceAll(String.valueOf(SEPARATOR), ".");
|
||||||
MVWorld mvWorld = null;
|
WorldProperties props = (WorldProperties) obj;
|
||||||
if (this.worldsFromTheConfig.containsKey(worldName)) {
|
if (this.worldsFromTheConfig.containsKey(worldName)) {
|
||||||
// Object-Recycling :D
|
// Object-Recycling :D
|
||||||
// TODO Why is is checking worldsFromTheConfig and then getting from worlds? So confused... (DTM)
|
// TODO Why is is checking worldsFromTheConfig and then getting from worlds? So confused... (DTM)
|
||||||
mvWorld = (MVWorld) this.worlds.get(worldName);
|
MVWorld mvWorld = (MVWorld) this.worlds.get(worldName);
|
||||||
if (mvWorld != null) {
|
if (mvWorld != null) {
|
||||||
mvWorld.copyValues((MVWorld) obj);
|
mvWorld.copyValues((WorldProperties) obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mvWorld == null) {
|
newWorldsFromTheConfig.put(worldName, props);
|
||||||
// we have to use a new one
|
|
||||||
World cbworld = this.plugin.getServer().getWorld(worldName);
|
|
||||||
mvWorld = (MVWorld) obj;
|
|
||||||
if (cbworld != null) {
|
|
||||||
mvWorld.init(cbworld, this.plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
||||||
|
@ -742,7 +737,7 @@ public class WorldManager implements MVWorldManager {
|
||||||
try {
|
try {
|
||||||
this.configWorlds.options().pathSeparator(SEPARATOR);
|
this.configWorlds.options().pathSeparator(SEPARATOR);
|
||||||
this.configWorlds.set("worlds", null);
|
this.configWorlds.set("worlds", null);
|
||||||
for (Map.Entry<String, ? extends MultiverseWorld> entry : worldsFromTheConfig.entrySet()) {
|
for (Map.Entry<String, WorldProperties> entry : worldsFromTheConfig.entrySet()) {
|
||||||
this.configWorlds.set("worlds" + SEPARATOR + entry.getKey(), entry.getValue());
|
this.configWorlds.set("worlds" + SEPARATOR + entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||||
|
|
|
@ -5,17 +5,11 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test;
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.api.Core;
|
||||||
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -28,9 +22,12 @@ import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import java.io.File;
|
||||||
import com.onarandombox.MultiverseCore.api.Core;
|
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
|
@ -1,13 +1,9 @@
|
||||||
package com.onarandombox.MultiverseCore.test;
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
|
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||||
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -24,11 +20,13 @@ import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import java.lang.reflect.Field;
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import java.util.Arrays;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import java.util.Collections;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
import java.util.List;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
|
@ -1,8 +1,7 @@
|
||||||
package com.onarandombox.MultiverseCore.test;
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -15,9 +14,9 @@ import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import static org.junit.Assert.*;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import static org.mockito.Mockito.mock;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
|
@ -5,15 +5,13 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test;
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MVWorld;
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
|
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -300,7 +298,8 @@ public class TestWorldProperties {
|
||||||
assertTrue(core.saveMVConfigs());
|
assertTrue(core.saveMVConfigs());
|
||||||
// change a value here
|
// change a value here
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(core.getDataFolder(), "worlds.yml"));
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(core.getDataFolder(), "worlds.yml"));
|
||||||
MVWorld worldObj = (MVWorld) config.get("worlds.world");
|
WorldProperties worldObj = (WorldProperties) config.get("worlds.world");
|
||||||
|
System.out.println(worldObj.setColor("GREEN"));
|
||||||
assertTrue(worldObj.setColor("GREEN"));
|
assertTrue(worldObj.setColor("GREEN"));
|
||||||
config.set("worlds.world", worldObj);
|
config.set("worlds.world", worldObj);
|
||||||
config.save(new File(core.getDataFolder(), "worlds.yml"));
|
config.save(new File(core.getDataFolder(), "worlds.yml"));
|
|
@ -1,10 +1,8 @@
|
||||||
package com.onarandombox.MultiverseCore.test;
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
|
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||||
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -18,10 +16,10 @@ import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import java.util.Arrays;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
|
||||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
import static org.junit.Assert.assertTrue;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
|
@ -5,15 +5,18 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test;
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.WorldCreatorMatcher;
|
import com.onarandombox.MultiverseCore.utils.WorldCreatorMatcher;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
|
@ -5,7 +5,7 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
|
@ -5,16 +5,7 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.WeakHashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Difficulty;
|
import org.bukkit.Difficulty;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -26,6 +17,15 @@ import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
public class MockWorldFactory {
|
public class MockWorldFactory {
|
||||||
|
|
||||||
private static final Map<String, World> createdWorlds = new HashMap<String, World>();
|
private static final Map<String, World> createdWorlds = new HashMap<String, World>();
|
|
@ -5,7 +5,7 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import buscript.Buscript;
|
import buscript.Buscript;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
@ -13,8 +13,6 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||||
import com.onarandombox.MultiverseCore.utils.FileUtils;
|
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
|
@ -5,7 +5,7 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import java.util.logging.ConsoleHandler;
|
import java.util.logging.ConsoleHandler;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
|
@ -5,7 +5,7 @@
|
||||||
* with this project. *
|
* with this project. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.mockito.ArgumentMatcher;
|
import org.mockito.ArgumentMatcher;
|
Loading…
Reference in New Issue