diff --git a/config/mv_checks.xml b/config/mv_checks.xml
index 96e2788c..30f45212 100644
--- a/config/mv_checks.xml
+++ b/config/mv_checks.xml
@@ -5,7 +5,9 @@
~ with this project. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
+
@@ -23,7 +25,19 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -61,12 +75,16 @@
-
+
+
+
-
+
+
+
@@ -93,7 +111,9 @@
-
+
+
+
@@ -115,5 +135,8 @@
+
+
+
diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
index 782557d5..0d177c1a 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
@@ -8,14 +8,15 @@
package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
-import com.onarandombox.MultiverseCore.configuration.*;
+import com.onarandombox.MultiverseCore.configuration.ConfigPropertyFactory;
+import com.onarandombox.MultiverseCore.configuration.MVActiveConfigProperty;
+import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.utils.BlockSafety;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
-
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
@@ -31,11 +32,16 @@ import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* The implementation of a Multiverse handled world.
@@ -53,7 +59,6 @@ public class MVWorld implements MultiverseWorld {
private Map> masterList;
private Map> propertyList;
- private String generator;
private Permission permission;
private Permission exempt;
@@ -62,6 +67,20 @@ public class MVWorld implements MultiverseWorld {
private Map propertyAliases;
private Permission ignoreperm;
+ private static final Map TIME_ALIASES;
+
+ static {
+ Map staticTimes = new HashMap();
+ 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);
+ }
+
public MVWorld(World world, FileConfiguration config, MultiverseCore instance, Long seed, String generatorString, boolean fixSpawn) {
this.config = config;
this.plugin = instance;
@@ -97,29 +116,57 @@ public class MVWorld implements MultiverseWorld {
// getNewProperty(name, defaultValue, yamlConfigNode, helpText)
//
// If the first type is used, name is used as the yamlConfigNode
- this.propertyList.put("hidden", fac.getNewProperty("hidden", false, "Sorry, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("alias", fac.getNewProperty("alias", "", "alias.name", "Alias must be a valid string."));
- this.propertyList.put("color", fac.getNewProperty("color", EnglishChatColor.WHITE, "alias.color", "Sorry, 'color' must either one of: " + EnglishChatColor.getAllColors()));
- this.propertyList.put("pvp", fac.getNewProperty("pvp", true, "Sorry, 'pvp' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("scale", fac.getNewProperty("scale", this.getDefaultScale(this.environment), "Scale must be a positive double value. ex: " + ChatColor.GOLD + "2.3"));
- this.propertyList.put("respawn", fac.getNewProperty("respawn", "", "respawnworld", "You must set this to the " + ChatColor.GOLD + " NAME" + ChatColor.RED + " not alias of a world."));
- this.propertyList.put("weather", fac.getNewProperty("weather", true, "allowweather", "Sorry, 'weather' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("difficulty", fac.getNewProperty("difficulty", Difficulty.EASY, "Difficulty must be set as one of the following: " + ChatColor.GREEN + "peaceful " + ChatColor.AQUA + "easy " + ChatColor.GOLD + "normal " + ChatColor.RED + "hard"));
- this.propertyList.put("animals", fac.getNewProperty("animals", true, "animals.spawn", "Sorry, 'animals' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("monsters", fac.getNewProperty("monsters", true, "monsters.spawn", "Sorry, 'monsters' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("currency", fac.getNewProperty("currency", -1, "entryfee.currency", "Currency must be an integer between -1 and the highest Minecraft item ID."));
- this.propertyList.put("price", fac.getNewProperty("price", 0.0, "entryfee.price", "Price must be a double value. ex: " + ChatColor.GOLD + "1.2" + ChatColor.WHITE + ". Set to a negative value to give players money for entering this world."));
- this.propertyList.put("hunger", fac.getNewProperty("hunger", true, "Sorry, 'hunger' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("autoheal", fac.getNewProperty("autoheal", true, "Sorry, 'autoheal' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true, "Sorry, 'adjustspawn' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- if(!fixSpawn) {
+ this.propertyList.put("hidden", fac.getNewProperty("hidden", false,
+ "Sorry, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
+ this.propertyList.put("alias", fac.getNewProperty("alias", "", "alias.name",
+ "Alias must be a valid string."));
+ this.propertyList.put("color", fac.getNewProperty("color", EnglishChatColor.WHITE, "alias.color",
+ "Sorry, 'color' must either one of: " + EnglishChatColor.getAllColors()));
+ this.propertyList.put("pvp", fac.getNewProperty("pvp", true, "pvp",
+ "Sorry, 'pvp' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
+ + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualPVP"));
+ this.propertyList.put("scale", fac.getNewProperty("scale", this.getDefaultScale(this.environment), "scale",
+ "Scale must be a positive double value. ex: " + ChatColor.GOLD + "2.3", "verifyScaleSetProperly"));
+ this.propertyList.put("respawn", fac.getNewProperty("respawn", "", "respawnworld",
+ "You must set this to the " + ChatColor.GOLD + " NAME" + ChatColor.RED + " not alias of a world."));
+ this.propertyList.put("weather", fac.getNewProperty("weather", true, "allowweather",
+ "Sorry, 'weather' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
+ + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualWeather"));
+ this.propertyList.put("difficulty", fac.getNewProperty("difficulty", Difficulty.EASY,
+ "Difficulty must be set as one of the following: " + ChatColor.GREEN + "peaceful "
+ + ChatColor.AQUA + "easy " + ChatColor.GOLD + "normal " + ChatColor.RED + "hard"));
+ this.propertyList.put("animals", fac.getNewProperty("animals", true, "animals.spawn",
+ "Sorry, 'animals' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
+ + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "syncMobs"));
+ this.propertyList.put("monsters", fac.getNewProperty("monsters", true, "monsters.spawn",
+ "Sorry, 'monsters' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
+ + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "syncMobs"));
+ this.propertyList.put("currency", fac.getNewProperty("currency", -1, "entryfee.currency",
+ "Currency must be an integer between -1 and the highest Minecraft item ID."));
+ this.propertyList.put("price", fac.getNewProperty("price", 0.0, "entryfee.price",
+ "Price must be a double value. ex: " + ChatColor.GOLD + "1.2" + ChatColor.WHITE
+ + ". Set to a negative value to give players money for entering this world."));
+ this.propertyList.put("hunger", fac.getNewProperty("hunger", true,
+ "Sorry, 'hunger' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
+ this.propertyList.put("autoheal", fac.getNewProperty("autoheal", true,
+ "Sorry, 'autoheal' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
+ this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true,
+ "Sorry, 'adjustspawn' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
+ + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
+ if (!fixSpawn) {
this.setAdjustSpawn(false);
}
- this.propertyList.put("gamemode", fac.getNewProperty("gamemode", GameMode.SURVIVAL, "GameMode must be set as one of the following: " + ChatColor.RED + "survival " + ChatColor.GREEN + "creative "));
- this.propertyList.put("memory", fac.getNewProperty("keepspawninmemory", true, "keepspawninmemory", "Sorry, 'memory' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
- this.propertyList.put("spawn", fac.getNewProperty("spawn", this.world.getSpawnLocation(), "There is no help available for this variable. Go bug Rigby90 about it."));
- this.propertyList.put("autoload", fac.getNewProperty("autoload", true, "Set this to false ONLY if you don't want this world to load itself on server restart."));
+ this.propertyList.put("gamemode", fac.getNewProperty("gamemode", GameMode.SURVIVAL,
+ "GameMode must be set as one of the following: " + ChatColor.RED + "survival " + ChatColor.GREEN + "creative "));
+ this.propertyList.put("memory", fac.getNewProperty("keepspawninmemory", true, "keepspawninmemory",
+ "Sorry, 'memory' must either be:" + ChatColor.GREEN + " true "
+ + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualKeepSpawnInMemory"));
+ this.propertyList.put("spawn", fac.getNewProperty("spawn", this.world.getSpawnLocation(), "spawn",
+ "There is no help available for this variable. Go bug Rigby90 about it.", "setActualKeepSpawnInMemory"));
+ this.propertyList.put("autoload", fac.getNewProperty("autoload", true,
+ "Set this to false ONLY if you don't want this world to load itself on server restart."));
this.propertyList.put("bedrespawn", fac.getNewProperty("bedrespawn", true, "If a player dies in this world, shoudld they go to their bed?"));
+ this.propertyList.put("time", fac.getNewProperty("time", "", "Set the time to whatever you want! (Will NOT freeze time)", "setActualTime", true));
this.getKnownProperty("spawn", Location.class).setValue(this.readSpawnFromConfig(this.getCBWorld()));
@@ -144,9 +191,11 @@ public class MVWorld implements MultiverseWorld {
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.OP);
// This guy is special. He shouldn't be added to any parent perms.
- this.ignoreperm = new Permission("mv.bypass.gamemode." + this.getName(), "Allows players with this permission to ignore gamemode changes.", PermissionDefault.FALSE);
+ this.ignoreperm = new Permission("mv.bypass.gamemode." + this.getName(),
+ "Allows players with this permission to ignore gamemode changes.", PermissionDefault.FALSE);
- this.exempt = new Permission("multiverse.exempt." + this.getName(), "A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
+ this.exempt = new Permission("multiverse.exempt." + this.getName(),
+ "A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
try {
this.plugin.getServer().getPluginManager().addPermission(this.permission);
this.plugin.getServer().getPluginManager().addPermission(this.exempt);
@@ -158,51 +207,53 @@ public class MVWorld implements MultiverseWorld {
}
/**
- * Applies all settings to the Bukkit-{@link World}.
+ * Used by the active PVP-property to set the "actual" PVP-property.
+ * @return True if the property was successfully set.
*/
- public void changeActiveEffects() {
- // Disable any current weather
- if (!this.getKnownProperty("weather", Boolean.class).getValue()) {
- this.getCBWorld().setStorm(false);
- this.getCBWorld().setThundering(false);
- }
-
- // Set the spawn location
- Location spawnLocation = this.getKnownProperty("spawn", Location.class).getValue();
- this.getCBWorld().setSpawnLocation(spawnLocation.getBlockX(), spawnLocation.getBlockY(), spawnLocation.getBlockZ());
-
- // Synchronize all Mob settings
- this.syncMobs();
-
- // Ensure the memory setting is correct
- this.world.setKeepSpawnInMemory(this.getKnownProperty("memory", Boolean.class).getValue());
-
+ public boolean setActualPVP() {
// Set the PVP mode
this.world.setPVP(this.getKnownProperty("pvp", Boolean.class).getValue());
+ return true;
+ }
+ /**
+ * Used by the active scale-property to set the "actual" scale-property.
+ * @return True if the property was successfully set.
+ */
+ public boolean verifyScaleSetProperly() {
// Ensure the scale is above 0
if (this.getKnownProperty("scale", Double.class).getValue() <= 0) {
// Disallow negative or 0 scalings.
this.getKnownProperty("scale", Double.class).setValue(1.0);
this.plugin.log(Level.WARNING, "Someone tried to set a scale <= 0, defaulting to 1.");
}
+ return true;
+ }
- // Set the gamemode
- // TODO: Move this to a per world gamemode
- if (MultiverseCore.EnforceGameModes) {
- for (Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) {
- this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.getKnownProperty("mode", GameMode.class).getValue().toString());
- this.plugin.getPlayerListener().handleGameMode(p, this);
- }
- }
+ /**
+ * Used by the active keepSpawnInMemory-property to set the "actual" property.
+ * @return True if the property was successfully set.
+ */
+ public boolean setActualKeepSpawnInMemory() {
+ // Ensure the memory setting is correct
+ this.world.setKeepSpawnInMemory(this.getKnownProperty("memory", Boolean.class).getValue());
+ return true;
+ }
- // Set the difficulty
- this.getCBWorld().setDifficulty(this.getKnownProperty("diff", Difficulty.class).getValue());
+ /**
+ * Used by the active spawn-property to set the "actual" property.
+ * @return True if the property was successfully set.
+ */
+ public boolean setActualSpawn() {
+ // Set the spawn location
+ Location spawnLocation = this.getKnownProperty("spawn", Location.class).getValue();
+ this.getCBWorld().setSpawnLocation(spawnLocation.getBlockX(), spawnLocation.getBlockY(), spawnLocation.getBlockZ());
+ return true;
}
private double getDefaultScale(Environment environment) {
if (environment == Environment.NETHER) {
- return 8.0;
+ return 8.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
return 1.0;
}
@@ -342,7 +393,12 @@ public class MVWorld implements MultiverseWorld {
return false;
}
- private void syncMobs() {
+ /**
+ * Ensure that the value of the animals and monsters config
+ * properties are set in accordance with the current animals
+ * and monsters in the world, respectively.
+ */
+ public void syncMobs() {
if (this.getAnimalList().isEmpty()) {
this.world.setSpawnFlags(this.world.getAllowMonsters(), this.getKnownProperty("animals", Boolean.class).getValue());
@@ -396,6 +452,8 @@ public class MVWorld implements MultiverseWorld {
/**
* {@inheritDoc}
+ *
+ * @deprecated Use {@link #getProperty(String, Class)} instead
*/
@Override
@Deprecated
@@ -418,7 +476,7 @@ public class MVWorld implements MultiverseWorld {
/**
* This method should only be used from inside this class when it is KNOWN that the property exists.
*
- * @param name The known name of a property
+ * @param name The known name of a property
* @param expected The Type of the expected value
* @return The property object.
*/
@@ -464,12 +522,40 @@ public class MVWorld implements MultiverseWorld {
value = propertyChangeEvent.getNewValue();
}
if (property.parseValue(value)) {
+ if (property instanceof MVActiveConfigProperty) {
+ return this.setActiveProperty((MVActiveConfigProperty>) property);
+ }
this.saveConfig();
return true;
}
return false;
}
+ private boolean setActiveProperty(MVActiveConfigProperty> property) {
+ try {
+ if (property.getMethod() == null) {
+ // This property did not have a method.
+ return true;
+ }
+ Method method = this.getClass().getMethod(property.getMethod());
+ Object returnVal = method.invoke(this);
+ if (returnVal instanceof Boolean) {
+ return (Boolean) returnVal;
+ } else {
+ return true;
+ }
+ } catch (NoSuchMethodException e) {
+ System.out.println(e);
+ return false;
+ } catch (IllegalAccessException e) {
+ System.out.println(e);
+ return false;
+ } catch (InvocationTargetException e) {
+ System.out.println(e);
+ return false;
+ }
+ }
+
/**
* {@inheritDoc}
*/
@@ -681,6 +767,8 @@ public class MVWorld implements MultiverseWorld {
/**
* {@inheritDoc}
+ *
+ * @deprecated This is deprecated.
*/
@Override
@Deprecated
@@ -756,7 +844,6 @@ public class MVWorld implements MultiverseWorld {
private void saveConfig() {
if (this.canSave) {
try {
- this.changeActiveEffects();
this.config.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
} catch (IOException e) {
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your filesystem permissions.");
@@ -769,7 +856,25 @@ public class MVWorld implements MultiverseWorld {
*/
@Override
public boolean setGameMode(String gameMode) {
- return this.setKnownProperty("mode", gameMode + "", null);
+ return this.setKnownProperty("mode", gameMode, null);
+ }
+
+ /**
+ * Sets the actual gamemode by iterating through players.
+ *
+ * gameMode is not used, but it's in the reflection template.
+ *
+ * Needs a bit o' refactoring.
+ *
+ * @return True if the gamemodes of players were set successfully. (always)
+ */
+ public boolean setActualGameMode() {
+ for (Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) {
+ this.plugin.log(Level.FINER, String.format("Setting %s's GameMode to %s",
+ p.getName(), this.getKnownProperty("mode", GameMode.class).getValue().toString()));
+ this.plugin.getPlayerListener().handleGameMode(p, this);
+ }
+ return true;
}
/**
@@ -788,6 +893,19 @@ public class MVWorld implements MultiverseWorld {
this.setKnownProperty("weather", weather + "", null);
}
+ /**
+ * Used by the active weather-property to set the "actual" property.
+ * @return True if the property was successfully set.
+ */
+ public boolean setActualWeather() {
+ // Disable any current weather
+ if (!this.getKnownProperty("weather", Boolean.class).getValue()) {
+ this.getCBWorld().setStorm(false);
+ this.getCBWorld().setThundering(false);
+ }
+ return true;
+ }
+
/**
* {@inheritDoc}
*/
@@ -830,6 +948,9 @@ public class MVWorld implements MultiverseWorld {
this.saveConfig();
}
+ private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16;
+ private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16;
+
private Location readSpawnFromConfig(World w) {
Location spawnLocation = w.getSpawnLocation();
Location configLocation = this.getSpawnLocation();
@@ -850,7 +971,8 @@ public class MVWorld implements MultiverseWorld {
// If it's not, find a better one.
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting...");
this.plugin.log(Level.WARNING, "Original Location: " + LocationManipulation.strCoordsRaw(spawnLocation));
- Location newSpawn = teleporter.getSafeLocation(spawnLocation, 16, 16);
+ Location newSpawn = teleporter.getSafeLocation(spawnLocation,
+ SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
// I think we could also do this, as I think this is what Notch does.
// Not sure how it will work in the nether...
//Location newSpawn = this.spawnLocation.getWorld().getHighestBlockAt(this.spawnLocation).getLocation();
@@ -865,7 +987,8 @@ public class MVWorld implements MultiverseWorld {
if (newerSpawn != null) {
this.setSpawnLocation(newerSpawn);
configLocation = this.getSpawnLocation();
- this.plugin.log(Level.INFO, "New Spawn for '" + this.getName() + "' is Located at: " + LocationManipulation.locationToString(configLocation));
+ this.plugin.log(Level.INFO, "New Spawn for '" + this.getName()
+ + "' is Located at: " + LocationManipulation.locationToString(configLocation));
} else {
this.plugin.log(Level.SEVERE, "New safe spawn NOT found!!!");
}
@@ -897,7 +1020,12 @@ public class MVWorld implements MultiverseWorld {
*/
@Override
public boolean setDifficulty(String difficulty) {
- return this.setKnownProperty("diff", difficulty, null);
+ if (this.setKnownProperty("diff", difficulty, null)) {
+ // Set the difficulty
+ this.getCBWorld().setDifficulty(this.getKnownProperty("diff", Difficulty.class).getValue());
+ return true;
+ }
+ return false;
}
/**
@@ -978,6 +1106,87 @@ public class MVWorld implements MultiverseWorld {
return result;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTime() {
+ long time = this.getCBWorld().getTime();
+ // I'm tired, so they get time in 24 hour for now.
+ // Someone else can add 12 hr format if they want :P
+
+ // BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
+ int hours = (int) ((time / 1000 + 8) % 24);
+ int minutes = (int) (60 * (time % 1000) / 1000);
+ // END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
+
+ return String.format("%d:%02d", hours, minutes);
+ }
+
+ /**
+ * Used by the active time-property to set the "actual" property.
+ * @return True if the property was successfully set.
+ */
+ public boolean setActualTime() {
+ return this.setTime(this.getKnownProperty("time", String.class).toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ // BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
+ public boolean setTime(String timeAsString) {
+ if (TIME_ALIASES.containsKey(timeAsString.toLowerCase())) {
+ return this.setTime(TIME_ALIASES.get(timeAsString.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.
+ String timeRegex = "(\\d\\d?):?(\\d\\d)(a|p)?m?";
+ Pattern pattern = Pattern.compile(timeRegex, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(timeAsString);
+ 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, ampm)
+ 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) { // SUPPRESS CHECKSTYLE MagicNumberCheck
+ hour = 0;
+ }
+ // Clamp the hour
+ if (hour > 23 || hour < 0) {
+ return false;
+ }
+ // Clamp the minute
+ if (minute > 59 || minute < 0) {
+ return false;
+ }
+ // 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;
+ }
+
+ this.getCBWorld().setTime((long) totaltime);
+ return true;
+ }
+ // END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
+
@Override
public String toString() {
StringBuilder toStringBuilder = new StringBuilder();
diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
index 8ac188fd..397ae2b0 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
@@ -14,12 +14,27 @@ import com.onarandombox.MultiverseCore.api.MVPlugin;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commands.*;
-import com.onarandombox.MultiverseCore.destination.*;
+import com.onarandombox.MultiverseCore.destination.AnchorDestination;
+import com.onarandombox.MultiverseCore.destination.BedDestination;
+import com.onarandombox.MultiverseCore.destination.CannonDestination;
+import com.onarandombox.MultiverseCore.destination.DestinationFactory;
+import com.onarandombox.MultiverseCore.destination.ExactDestination;
+import com.onarandombox.MultiverseCore.destination.PlayerDestination;
+import com.onarandombox.MultiverseCore.destination.WorldDestination;
+import com.onarandombox.MultiverseCore.event.MVVersionEvent;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
+import com.onarandombox.MultiverseCore.listeners.MVPortalAdjustListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
-import com.onarandombox.MultiverseCore.utils.*;
+import com.onarandombox.MultiverseCore.utils.AnchorManager;
+import com.onarandombox.MultiverseCore.utils.DebugLog;
+import com.onarandombox.MultiverseCore.utils.MVMessaging;
+import com.onarandombox.MultiverseCore.utils.MVPermissions;
+import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
+import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
+import com.onarandombox.MultiverseCore.utils.SpoutInterface;
+import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -50,17 +65,20 @@ import java.util.logging.Logger;
* The implementation of the Multiverse-{@link Core}.
*/
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
- private final static int Protocol = 10;
+ private static final int PROTOCOL = 10;
// Global Multiverse config variable, states whether or not
// Multiverse should stop other plugins from teleporting players
// to worlds.
+ // TODO This is REALLY bad style! We have to change this!
+ // No, I'm NOT going to suppress these warnings because we HAVE TO CHANGE THIS!
public static boolean EnforceAccess;
- public static boolean EnforceGameModes;
public static boolean PrefixChat;
public static boolean DisplayPermErrors;
public static boolean TeleportIntercept;
public static boolean FirstSpawnOverride;
public static Map teleportQueue = new HashMap();
+ public static int GlobalDebug = 0;
+
private AnchorManager anchorManager = new AnchorManager(this);
/**
@@ -77,6 +95,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return null;
}
+ /**
+ * This method is used to add a teleportation to the teleportQueue.
+ *
+ * @param teleporter The name of the player that initiated the teleportation.
+ * @param teleportee The name of the player that was teleported.
+ */
public static void addPlayerToTeleportQueue(String teleporter, String teleportee) {
staticLog(Level.FINEST, "Adding mapping '" + teleporter + "' => '" + teleportee + "' to teleport queue");
teleportQueue.put(teleportee, teleporter);
@@ -87,9 +111,14 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return "The Multiverse-Core Plugin";
}
+ /**
+ * {@inheritDoc}
+ * @deprecated This is now deprecated, nobody needs it any longer.
+ * All version info-dumping is now done with {@link MVVersionEvent}.
+ */
@Override
+ @Deprecated
public String dumpVersionInfo(String buffer) {
- // I'm kinda cheating on this one, since we call the init event.
return buffer;
}
@@ -106,18 +135,17 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
@Override
public int getProtocolVersion() {
- return MultiverseCore.Protocol;
+ return MultiverseCore.PROTOCOL;
}
// Useless stuff to keep us going.
- private static final Logger log = Logger.getLogger("Minecraft");
+ private static final Logger LOGGER = Logger.getLogger("Minecraft");
private static DebugLog debugLog;
- public static boolean MobsDisabledInDefaultWorld = false;
// Setup our Map for our Commands using the CommandHandler.
private CommandHandler commandHandler;
- private final static String tag = "[Multiverse-Core]";
+ private static final String LOG_TAG = "[Multiverse-Core]";
// Multiverse Permissions Handler
private MVPermissions ph;
@@ -129,23 +157,22 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup the block/player/entity listener.
private MVPlayerListener playerListener = new MVPlayerListener(this);
+ private MVPortalAdjustListener portalAdjustListener = new MVPortalAdjustListener(this);
private MVEntityListener entityListener = new MVEntityListener(this);
private MVPluginListener pluginListener = new MVPluginListener(this);
private MVWeatherListener weatherListener = new MVWeatherListener(this);
- public UpdateChecker updateCheck;
-
- public static int GlobalDebug = 0;
+ //public UpdateChecker updateCheck;
// HashMap to contain information relating to the Players.
private HashMap playerSessions;
private GenericBank bank = null;
private AllPay banker;
- protected int pluginCount;
+ private int pluginCount;
private DestinationFactory destFactory;
private SpoutInterface spoutInterface = null;
- private double allpayversion = 3;
- private double chversion = 4;
+ private static final double ALLPAY_VERSION = 3;
+ private static final double CH_VERSION = 4;
private MVMessaging messaging;
private File serverFolder = new File(System.getProperty("user.dir"));
@@ -185,9 +212,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.getServer().getPluginManager().disablePlugin(this);
return;
}
- this.banker = new AllPay(this, tag + " ");
+ this.messaging = new MVMessaging();
+ this.banker = new AllPay(this, LOG_TAG + " ");
// Output a little snippet to show it's enabled.
- this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " (API v" + Protocol + ") Enabled - By " + getAuthors());
+ this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " (API v" + PROTOCOL + ") Enabled - By " + getAuthors());
// Load the defaultWorldGenerators
this.worldManager.getDefaultWorldGenerators();
@@ -244,44 +272,34 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private boolean validateAllpay() {
try {
this.banker = new AllPay(this, "Verify");
- if (this.banker.getVersion() >= allpayversion) {
+ if (this.banker.getVersion() >= ALLPAY_VERSION) {
return true;
- } else {
- log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
- log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of AllPay!");
- log.info(tag + " The Following Plugins MAY out of date!");
- log.info(tag + " This plugin needs AllPay v" + allpayversion + " or higher and another plugin has loaded v" + this.banker.getVersion() + "!");
- log.info(tag + AllPay.pluginsThatUseUs.toString());
- return false;
}
} catch (Throwable t) {
}
- log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
- log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of AllPay!");
- log.info(tag + " Check the logs for [AllPay] - Version ... for PLUGIN NAME to find the culprit! Then Yell at that dev!");
- log.info(tag + " Or update that plugin :P");
- log.info(tag + " This plugin needs AllPay v" + allpayversion + " or higher!");
+ LOGGER.info(String.format("%s - Version %s was NOT ENABLED!!!", LOG_TAG, this.getDescription().getVersion()));
+ LOGGER.info(String.format("%s A plugin that has loaded before %s has an incompatible version of AllPay (an internal library)!",
+ LOG_TAG, this.getDescription().getName()));
+ LOGGER.info(String.format("%s The Following Plugins MAY out of date: %s", LOG_TAG, AllPay.pluginsThatUseUs.toString()));
+ LOGGER.info(String.format("%s This plugin needs AllPay v%f or higher and another plugin has loaded v%f!",
+ LOG_TAG, ALLPAY_VERSION, this.banker.getVersion()));
return false;
}
private boolean validateCH() {
try {
this.commandHandler = new CommandHandler(this, null);
- if (this.commandHandler.getVersion() >= chversion) {
+ if (this.commandHandler.getVersion() >= CH_VERSION) {
return true;
- } else {
- log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
- log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of CommandHandler (an internal library)!");
- log.info(tag + " Please contact this plugin author!!!!!!!");
- log.info(tag + " This plugin needs CommandHandler v" + chversion + " or higher and another plugin has loaded v" + this.commandHandler.getVersion() + "!");
- return false;
}
} catch (Throwable t) {
}
- log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
- log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of CommandHandler (an internal library)!");
- log.info(tag + " Please contact this plugin author!!!!!!!");
- log.info(tag + " This plugin needs CommandHandler v" + chversion + " or higher!");
+ LOGGER.info(String.format("%s - Version %s was NOT ENABLED!!!", LOG_TAG, this.getDescription().getVersion()));
+ LOGGER.info(String.format("%s A plugin that has loaded before %s has an incompatible version of CommandHandler (an internal library)!",
+ LOG_TAG, this.getDescription().getName()));
+ LOGGER.info(String.format("%s Please contact this plugin author!!!", LOG_TAG));
+ LOGGER.info(String.format("%s This plugin needs CommandHandler v%f or higher and another plugin has loaded v%f!",
+ LOG_TAG, CH_VERSION, this.commandHandler.getVersion()));
return false;
}
@@ -307,7 +325,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
pm.registerEvent(Event.Type.PLAYER_LOGIN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this); // To prepend the world name
- pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.Lowest, this); // To switch gamemode
+ pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.High, this);
+ // We want this high to have it go last, so it can cancel if needbe.
+
+ pm.registerEvent(Event.Type.PLAYER_PORTAL, this.portalAdjustListener, Priority.Lowest, this); // To handle portal correction
pm.registerEvent(Event.Type.PLAYER_CHANGED_WORLD, this.playerListener, Priority.Monitor, this); // To switch gamemode
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
@@ -340,7 +361,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
GlobalDebug = this.multiverseConfig.getInt("debug", 0);
// Lets cache these values due to the fact that they will be accessed many times.
EnforceAccess = this.multiverseConfig.getBoolean("enforceaccess", false);
- EnforceGameModes = this.multiverseConfig.getBoolean("enforcegamemodes", true);
PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
// Should MV Intercept teleports by other plugins?
TeleportIntercept = this.multiverseConfig.getBoolean("teleportintercept", true);
@@ -348,13 +368,21 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
FirstSpawnOverride = this.multiverseConfig.getBoolean("firstspawnoverride", true);
// Should permissions errors display to users?
DisplayPermErrors = this.multiverseConfig.getBoolean("displaypermerrors", true);
- this.messaging = new MVMessaging(this);
- this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000));
+
+ this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
+ // Update the version of the config!
+ this.multiverseConfig.set("version", coreDefaults.get("version"));
+
+ // Remove old values.
+ this.multiverseConfig.set("enforcegamemodes", null);
+ this.multiverseConfig.set("bedrespawn", null);
+ this.multiverseConfig.set("opfallback", null);
+
this.saveMVConfigs();
}
/**
- * Safely return a world name
+ * Safely return a world name.
* (The tests call this with no worlds loaded)
*
* @return The default world name.
@@ -476,6 +504,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
staticLog(level, msg);
}
+ /**
+ * Logs a message at the specified level.
+ *
+ * @param level The Log-{@link Level}.
+ * @param msg The message to log.
+ */
public static void staticLog(Level level, String msg) {
if (level == Level.FINE && GlobalDebug >= 1) {
staticDebugLog(Level.INFO, msg);
@@ -487,8 +521,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
staticDebugLog(Level.INFO, msg);
return;
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
- log.log(level, tag + " " + msg);
- debugLog.log(level, tag + " " + msg);
+ LOGGER.log(level, String.format("%s %s", LOG_TAG, msg));
+ debugLog.log(level, String.format("%s %s", LOG_TAG, msg));
}
}
@@ -500,7 +534,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* @param msg The message
*/
public static void staticDebugLog(Level level, String msg) {
- log.log(level, "[MVCore-Debug] " + msg);
+ LOGGER.log(level, "[MVCore-Debug] " + msg);
debugLog.log(level, "[MVCore-Debug] " + msg);
}
@@ -544,7 +578,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/
// TODO this should be static!
public String getTag() {
- return MultiverseCore.tag;
+ return MultiverseCore.LOG_TAG;
}
// TODO This code should get moved somewhere more appropriate, but for now, it's here.
@@ -585,6 +619,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
sender.sendMessage("Type " + ChatColor.DARK_AQUA + "/mv import ?" + ChatColor.WHITE + " for help!");
}
+ /**
+ * Removes a player-session.
+ *
+ * @param player The {@link Player} that owned the session.
+ */
public void removePlayerSession(Player player) {
if (this.playerSessions.containsKey(player.getName())) {
this.playerSessions.remove(player.getName());
@@ -672,6 +711,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.serverFolder = newServerFolder;
}
+ /**
+ * Initializes Spout.
+ */
public void setSpout() {
this.spoutInterface = new SpoutInterface();
this.commandHandler.registerCommand(new SpoutCommand(this));
@@ -686,6 +728,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
}
}
+ /**
+ * Gets our {@link SpoutInterface}.
+ *
+ * @return The {@link SpoutInterface} we're using.
+ */
public SpoutInterface getSpout() {
return this.spoutInterface;
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java b/src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java
index 7aac36cb..abc740db 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java
@@ -7,11 +7,14 @@
package com.onarandombox.MultiverseCore.api;
+/**
+ * A fancy text.
+ */
public interface FancyText {
/**
- * TODO: Write something useful here.
+ * Gets the {@link String}-representation of this {@link FancyText}.
*
- * @return And Here.
+ * @return The {@link String}-representation of this {@link FancyText}.
*/
String getFancyText();
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MVPlugin.java b/src/main/java/com/onarandombox/MultiverseCore/api/MVPlugin.java
index aa9ea92d..a8fce38c 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MVPlugin.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MVPlugin.java
@@ -8,7 +8,11 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.event.MVVersionEvent;
+/**
+ * This interface is implemented by every official Multiverse-plugin.
+ */
public interface MVPlugin extends LoggablePlugin {
/**
* Adds This plugin's version information to the buffer and returns the new string.
@@ -16,7 +20,11 @@ public interface MVPlugin extends LoggablePlugin {
* @param buffer The string that contains Core and all other MV plugins' versions.
*
* @return A modified buffer that contains this MVPlugin's version information.
+ *
+ * @deprecated This is now deprecated, nobody needs it any longer.
+ * All version info-dumping is now done with {@link MVVersionEvent}.
*/
+ @Deprecated
String dumpVersionInfo(String buffer);
/**
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
index dc7b2e45..75cc9da7 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
@@ -35,7 +35,7 @@ public interface MVWorldManager {
* @param generator The Custom generator plugin to use.
* @return True if the world is added, false if not.
*/
- public boolean addWorld(String name, Environment env, String seedString, String generator);
+ boolean addWorld(String name, Environment env, String seedString, String generator);
/**
* Add a new World to the Multiverse Setup.
@@ -49,7 +49,7 @@ public interface MVWorldManager {
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
* @return True if the world is added, false if not.
*/
- public boolean addWorld(String name, Environment env, String seedString, String generator, boolean useSpawnAdjust);
+ boolean addWorld(String name, Environment env, String seedString, String generator, boolean useSpawnAdjust);
/**
* Remove the world from the Multiverse list, from the
@@ -58,7 +58,7 @@ public interface MVWorldManager {
* @param name The name of the world to remove
* @return True if success, false if failure.
*/
- public Boolean deleteWorld(String name);
+ boolean deleteWorld(String name);
/**
* Remove the world from the Multiverse list, from the
@@ -69,7 +69,7 @@ public interface MVWorldManager {
* config. If false, they'll stay and the world may come back.
* @return True if success, false if failure.
*/
- public Boolean deleteWorld(String name, boolean removeConfig);
+ boolean deleteWorld(String name, boolean removeConfig);
/**
* Unload a world from Multiverse.
@@ -77,7 +77,7 @@ public interface MVWorldManager {
* @param name Name of the world to unload
* @return True if the world was unloaded, false if not.
*/
- public boolean unloadWorld(String name);
+ boolean unloadWorld(String name);
/**
* Loads the world. Only use this if the world has been
@@ -86,14 +86,14 @@ public interface MVWorldManager {
* @param name The name of the world to load
* @return True if success, false if failure.
*/
- public boolean loadWorld(String name);
+ boolean loadWorld(String name);
/**
* Removes all players from the specified world.
*
* @param name World to remove players from.
*/
- public void removePlayersFromWorld(String name);
+ void removePlayersFromWorld(String name);
/**
* Test if a given chunk generator is valid.
@@ -103,14 +103,14 @@ public interface MVWorldManager {
* @param worldName The worldName to use as the default.
* @return A {@link ChunkGenerator} or null
*/
- public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
+ ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
/**
* Returns a list of all the worlds Multiverse knows about.
*
* @return A list of {@link MultiverseWorld}.
*/
- public Collection getMVWorlds();
+ Collection getMVWorlds();
/**
@@ -120,7 +120,7 @@ public interface MVWorldManager {
* @param name The name or alias of the world to get.
* @return A {@link MultiverseWorld} or null.
*/
- public MultiverseWorld getMVWorld(String name);
+ MultiverseWorld getMVWorld(String name);
/**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
@@ -128,7 +128,7 @@ public interface MVWorldManager {
* @param world The Bukkit world to check.
* @return A {@link MultiverseWorld} or null.
*/
- public MultiverseWorld getMVWorld(World world);
+ MultiverseWorld getMVWorld(World world);
/**
* Checks to see if the given name is a valid {@link MultiverseWorld}.
@@ -136,7 +136,7 @@ public interface MVWorldManager {
* @param name The name or alias of the world to check.
* @return True if the world exists, false if not.
*/
- public boolean isMVWorld(String name);
+ boolean isMVWorld(String name);
/**
* Checks to see if the given world is a valid {@link MultiverseWorld}.
@@ -144,7 +144,7 @@ public interface MVWorldManager {
* @param world The Bukkit world to check.
* @return True if the world has been loaded into MV2, false if not.
*/
- public boolean isMVWorld(World world);
+ boolean isMVWorld(World world);
/**
* Load the Worlds & Settings from the configuration file.
@@ -152,21 +152,21 @@ public interface MVWorldManager {
* @param forceLoad If set to true, this will perform a total
* reset and not just load new worlds.
*/
- public void loadWorlds(boolean forceLoad);
+ void loadWorlds(boolean forceLoad);
/**
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
*
* This way people will _always_ have some worlds in the list.
*/
- public void loadDefaultWorlds();
+ void loadDefaultWorlds();
/**
* Return the World Purger.
*
* @return A valid {@link PurgeWorlds}.
*/
- public PurgeWorlds getWorldPurger();
+ PurgeWorlds getWorldPurger();
/**
* Gets the world players will spawn in on first join.
@@ -174,19 +174,19 @@ public interface MVWorldManager {
*
* @return A Multiverse world that players will spawn in or null if no MV world has been set.
*/
- public MultiverseWorld getSpawnWorld();
+ MultiverseWorld getSpawnWorld();
/**
* Gets the list of worlds in the config, but unloaded.
*
* @return A List of worlds as strings.
*/
- public List getUnloadedWorlds();
+ List getUnloadedWorlds();
/**
* This method populates an internal list and needs to be called after multiverse initialization.
*/
- public void getDefaultWorldGenerators();
+ void getDefaultWorldGenerators();
/**
* Load the config from a file.
@@ -194,14 +194,14 @@ public interface MVWorldManager {
* @param file The file to load.
* @return A loaded configuration.
*/
- public FileConfiguration loadWorldConfig(File file);
+ FileConfiguration loadWorldConfig(File file);
/**
* Saves the world config to disk.
*
* @return True if success, false if fail.
*/
- public boolean saveWorldsConfig();
+ boolean saveWorldsConfig();
/**
* Remove the world from the Multiverse list and from the config.
@@ -209,19 +209,19 @@ public interface MVWorldManager {
* @param name The name of the world to remove
* @return True if success, false if failure.
*/
- public boolean removeWorldFromConfig(String name);
+ boolean removeWorldFromConfig(String name);
/**
* Sets the initial spawn world for new players.
*
* @param world The World new players should spawn in.
*/
- public void setFirstSpawnWorld(String world);
+ void setFirstSpawnWorld(String world);
/**
* Gets the world players should spawn in first.
*
* @return The {@link MultiverseWorld} new players should spawn in.
*/
- public MultiverseWorld getFirstSpawnWorld();
+ MultiverseWorld getFirstSpawnWorld();
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
index 72a3b8bd..7d878328 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
@@ -217,6 +217,7 @@ public interface MultiverseWorld {
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
*
* @return True if this world has fakepvp on
+ * @deprecated This is deprecated.
*/
@Deprecated
boolean getFakePVP();
@@ -532,4 +533,23 @@ public interface MultiverseWorld {
* @return All property names, with alternating colors.
*/
String getAllPropertyNames();
+
+ /**
+ * Sets the current time in a world.
+ *
+ * This method will take the following formats:
+ * 11:37am
+ * 4:30p
+ * day(morning), night, noon, midnight
+ *
+ * @param timeAsString The formatted time to set the world to.
+ * @return True if the time was set, false if not.
+ */
+ boolean setTime(String timeAsString);
+
+ /**
+ * Same as {@link #getTime()}, but returns a string.
+ * @return The time as a short string: 12:34pm
+ */
+ String getTime();
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/package-info.java b/src/main/java/com/onarandombox/MultiverseCore/api/package-info.java
new file mode 100644
index 00000000..c19d6732
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * The Multiverse-API, containing lots of interfaces that can be quite useful for other
+ * plugins when interacting with Multiverse.
+ */
+package com.onarandombox.MultiverseCore.api;
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
index 9f5c3267..232aabc0 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
@@ -16,6 +16,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Allows management of Anchor Destinations.
+ */
public class AnchorCommand extends PaginatedCoreCommand {
public AnchorCommand(MultiverseCore plugin) {
@@ -32,7 +35,7 @@ public class AnchorCommand extends PaginatedCoreCommand {
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
this.addCommandExample("/mv anchors ");
this.setPermission("multiverse.core.anchor", "Allows management of Anchor Destinations.", PermissionDefault.OP);
- this.setItemsPerPage(8);
+ this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
private List getFancyAnchorList(Player p) {
@@ -59,7 +62,8 @@ public class AnchorCommand extends PaginatedCoreCommand {
if (filterObject.getFilter().length() > 0) {
availableAnchors = this.getFilteredItems(availableAnchors, filterObject.getFilter());
if (availableAnchors.size() == 0) {
- sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
+ sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ + "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
} else {
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java
index 1d2a8688..9a91013e 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java
@@ -17,7 +17,9 @@ import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
-
+/**
+ * Checks to see if a player can go to a destination.
+ */
public class CheckCommand extends MultiverseCommand {
public CheckCommand(MultiverseCore plugin) {
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
index 159092aa..3b48e1ce 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
@@ -8,7 +8,6 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@@ -16,9 +15,10 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
+/**
+ * Allows you to set Global MV Variables.
+ */
public class ConfigCommand extends MultiverseCommand {
- private MVWorldManager worldManager;
-
public ConfigCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Configuration");
@@ -33,7 +33,6 @@ public class ConfigCommand extends MultiverseCommand {
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
- this.worldManager = this.plugin.getMVWorldManager();
}
@Override
@@ -58,7 +57,8 @@ public class ConfigCommand extends MultiverseCommand {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), args.get(1));
// Don't forget to set the world!
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
- } else if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown") || args.get(0).equalsIgnoreCase("debug")) {
+ } else if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown")
+ || args.get(0).equalsIgnoreCase("debug")) {
try {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
} catch (NumberFormatException e) {
@@ -70,7 +70,8 @@ public class ConfigCommand extends MultiverseCommand {
try {
property = ConfigProperty.valueOf(args.get(0).toLowerCase());
} catch (IllegalArgumentException e) {
- sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " you can't set " + ChatColor.AQUA + args.get(0));
+ sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA
+ + args.get(0) + ChatColor.WHITE + " you can't set " + ChatColor.AQUA + args.get(0));
sender.sendMessage(ChatColor.GREEN + "Valid values are:");
sender.sendMessage(ConfigProperty.getAllValues());
return;
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java
index bd4ce09b..2a68f353 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java
@@ -13,6 +13,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
+/**
+ * Confirms actions.
+ */
public class ConfirmCommand extends MultiverseCommand {
public ConfirmCommand(MultiverseCore plugin) {
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java
index 2551ebe0..f2d09887 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java
@@ -21,6 +21,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.text.DecimalFormat;
import java.util.List;
+/**
+ * Returns detailed information on the Players where abouts.
+ */
public class CoordCommand extends MultiverseCommand {
private MVWorldManager worldManager;
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java
index a99697e9..e6613c17 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java
@@ -19,6 +19,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.util.List;
+/**
+ * Creates a new world and loads it.
+ */
public class CreateCommand extends MultiverseCommand {
private MVWorldManager worldManager;
@@ -26,7 +29,7 @@ public class CreateCommand extends MultiverseCommand {
super(plugin);
this.setName("Create World");
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] [-n]");
- this.setArgRange(2, 7);
+ this.setArgRange(2, 7); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvcreate");
this.addKey("mvc");
this.addKey("mv create");
@@ -47,8 +50,8 @@ public class CreateCommand extends MultiverseCommand {
String seed = CommandHandler.getFlag("-s", args);
String generator = CommandHandler.getFlag("-g", args);
boolean useSpawnAdjust = true;
- for(String s : args) {
- if(s.equalsIgnoreCase("-n")) {
+ for (String s : args) {
+ if (s.equalsIgnoreCase("-n")) {
useSpawnAdjust = false;
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java
index a633f89b..83f7cdd5 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java
@@ -15,6 +15,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
import java.util.logging.Level;
+/**
+ * Enables debug-information.
+ */
public class DebugCommand extends MultiverseCommand {
public DebugCommand(MultiverseCore plugin) {
@@ -42,7 +45,8 @@ public class DebugCommand extends MultiverseCommand {
}
MultiverseCore.GlobalDebug = debugLevel;
} catch (NumberFormatException e) {
- sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE + " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
+ sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
+ + " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java
index 14805d94..05ada3a8 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java
@@ -15,6 +15,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Deletes worlds.
+ */
public class DeleteCommand extends MultiverseCommand {
public DeleteCommand(MultiverseCore plugin) {
@@ -30,8 +33,9 @@ public class DeleteCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List args) {
- Class> paramTypes[] = {String.class};
+ Class>[] paramTypes = {String.class};
List