diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 6c3a7c60..00000000
--- a/.gitmodules
+++ /dev/null
@@ -1,7 +0,0 @@
-[submodule "lib/allpay"]
- path = lib/allpay
- url = git://github.com/FernFerret/AllPay.git
-[submodule "lib/commandhandler"]
- path = lib/commandhandler
- url = git://github.com/PneumatiCraft/CommandHandler.git
- branch = notrie
diff --git a/README.md b/README.md
index d1c7b96d..41d090ee 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,8 @@
Building
========
-Update the submodules after you clone and before you build with maven.
+Simply build the source with maven:
-```
-$ git submodule update --init --recursive
-$ mvn install
-```
+ $ mvn install
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
diff --git a/config/mv_checks.xml b/config/mv_checks.xml
index 30f45212..73be9841 100644
--- a/config/mv_checks.xml
+++ b/config/mv_checks.xml
@@ -13,9 +13,7 @@
-
-
-
+
diff --git a/lib/allpay b/lib/allpay
deleted file mode 160000
index 7abba1f0..00000000
--- a/lib/allpay
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 7abba1f0040862e9fabdafb3d44c6cf0b914cc7c
diff --git a/lib/commandhandler b/lib/commandhandler
deleted file mode 160000
index 46a3ab6e..00000000
--- a/lib/commandhandler
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 46a3ab6e4e444cd84f836aa6d36ed02cf6347454
diff --git a/pom.xml b/pom.xml
index 47364a2d..a4ef10c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,10 @@
onarandomboxhttp://repo.onarandombox.com/content/groups/public
+
+ Bukkit Official
+ http://repo.bukkit.org/content/repositories/public
+
@@ -63,28 +67,6 @@
1.6
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- 1.7
-
-
- add-wsdl-source
- generate-sources
-
- add-source
-
-
-
-
-
-
-
-
-
-
- com.google.code.maven-replacer-pluginmaven-replacer-plugin
@@ -154,6 +136,42 @@
${project.basedir}/config/mv_checks.xml
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 1.5
+
+
+ package
+
+ shade
+
+
+
+
+ me.main__.util:SerializationConfig
+ com.fernferret.allpay:AllPay
+ com.pneumaticraft.commandhandler:CommandHandler
+
+
+
+
+ com.fernferret.allpay
+ com.fernferret.allpay.multiverse
+
+
+ me.main__.util
+ me.main__.util.multiverse
+
+
+ com.pneumaticraft.commandhandler
+ com.pneumaticraft.commandhandler.multiverse
+
+
+
+
+
+
@@ -162,7 +180,7 @@
org.bukkitbukkit
- 1.1-R1-SNAPSHOT
+ 1.1-R3jarcompile
@@ -174,69 +192,33 @@
dev-SNAPSHOT
-
+
- cosine.boseconomy
- BOSEconomy
- 0.6.2
+ me.main__.util
+ SerializationConfig
+ 1.1jarcompile
-
+
+
- fr.crafter.tickleman.RealShop
- RealShop
- 0.63
+ com.fernferret.allpay
+ AllPay
+ 6jarcompile
-
+
+
- com.iCo6
- iConomy
- 6.0
+ com.pneumaticraft.commandhandler
+ CommandHandler
+ 6jarcompile
-
-
- com.iConomy
- iConomy
- 5.0
- jar
- compile
-
-
-
- com.nijiko.coelho.iConomy
- iConomy
- 4.65
- jar
- compile
-
-
-
- com.earth2me.essentials
- Essentials
- 2.4.2
- jar
- compile
-
-
- me.ashtheking.currency
- MultiCurrency
- 0.09
- jar
- compile
-
-
- ca.agnate
- EconXP
- 1.0.0
- jar
- compile
-
-
+
junit
diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
index a7806c34..ab81d4e0 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
@@ -7,16 +7,16 @@
package com.onarandombox.MultiverseCore;
+import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.configuration.ConfigPropertyFactory;
import com.onarandombox.MultiverseCore.configuration.MVActiveConfigProperty;
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
+import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
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 com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
@@ -33,7 +33,6 @@ 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;
@@ -158,6 +157,8 @@ public class MVWorld implements MultiverseWorld {
this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true,
"Sorry, 'adjustspawn' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
+ "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
+ this.propertyList.put("portalform", fac.getNewProperty("portalform", AllowedPortalType.ALL,
+ "Allow portal forming must be NONE, ALL, NETHER or END."));
if (!fixSpawn) {
this.setAdjustSpawn(false);
}
@@ -433,7 +434,7 @@ public class MVWorld implements MultiverseWorld {
} else {
this.world.setSpawnFlags(true, this.world.getAllowAnimals());
}
- this.plugin.getMVWorldManager().getWorldPurger().purgeWorld(null, this);
+ this.plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(this);
}
/**
@@ -513,6 +514,7 @@ public class MVWorld implements MultiverseWorld {
return (MVConfigProperty) this.propertyList.get(this.propertyAliases.get(name));
}
} catch (ClassCastException e) {
+ return null;
}
return null;
}
@@ -558,6 +560,7 @@ public class MVWorld implements MultiverseWorld {
try {
if (property.getMethod() == null) {
// This property did not have a method.
+ this.saveConfig();
return true;
}
Method method = this.getClass().getMethod(property.getMethod());
@@ -572,6 +575,8 @@ public class MVWorld implements MultiverseWorld {
return true;
}
} catch (Exception e) {
+ // TODO: I don't care about 3 catches,
+ // TODO: I hate pokemon errors :/ - FernFerret
e.printStackTrace();
return false;
}
@@ -986,8 +991,8 @@ public class MVWorld implements MultiverseWorld {
// Set the worldspawn to our configspawn
w.setSpawnLocation(configLocation.getBlockX(), configLocation.getBlockY(), configLocation.getBlockZ());
- SafeTTeleporter teleporter = this.plugin.getTeleporter();
- BlockSafety bs = new BlockSafety();
+ SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
+ BlockSafety bs = this.plugin.getBlockSafety();
// Verify that location was safe
if (!bs.playerCanSpawnHereSafely(configLocation)) {
if (!this.getAdjustSpawn()) {
@@ -999,7 +1004,7 @@ 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));
+ this.plugin.log(Level.WARNING, "Original Location: " + plugin.getLocationManipulation().strCoordsRaw(spawnLocation));
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.
@@ -1008,7 +1013,8 @@ public class MVWorld implements MultiverseWorld {
if (newSpawn != null) {
this.setSpawnLocation(newSpawn);
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: " + plugin.getLocationManipulation().locationToString(configLocation));
} else {
// If it's a standard end world, let's check in a better place:
Location newerSpawn;
@@ -1017,7 +1023,7 @@ public class MVWorld implements MultiverseWorld {
this.setSpawnLocation(newerSpawn);
configLocation = this.getSpawnLocation();
this.plugin.log(Level.INFO, "New Spawn for '" + this.getName()
- + "' is Located at: " + LocationManipulation.locationToString(configLocation));
+ + "' is Located at: " + plugin.getLocationManipulation().locationToString(configLocation));
} else {
this.plugin.log(Level.SEVERE, "New safe spawn NOT found!!!");
}
@@ -1160,6 +1166,22 @@ public class MVWorld implements MultiverseWorld {
return this.type;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void allowPortalMaking(AllowedPortalType type) {
+ this.setKnownProperty("portalform", type.toString(), null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AllowedPortalType getAllowedPortals() {
+ return this.getKnownProperty("portalform", AllowedPortalType.class).getValue();
+ }
+
/**
* Used by the active time-property to set the "actual" property.
* @return True if the property was successfully set.
diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
index 73ecc74e..e9424141 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
@@ -9,10 +9,15 @@ package com.onarandombox.MultiverseCore;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
+import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.Core;
+import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.api.MVPlugin;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
+import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
+import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
+import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.commands.*;
import com.onarandombox.MultiverseCore.destination.AnchorDestination;
import com.onarandombox.MultiverseCore.destination.BedDestination;
@@ -28,17 +33,14 @@ import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.localization.MessageProvider;
import com.onarandombox.MultiverseCore.localization.MessageProviding;
+import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
+import com.onarandombox.MultiverseCore.utils.*;
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
import com.onarandombox.MultiverseCore.localization.SimpleMessageProvider;
-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 me.main__.util.SerializationConfig.SerializationConfig;
+
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
@@ -66,22 +68,15 @@ import java.util.logging.Logger;
* The implementation of the Multiverse-{@link Core}.
*/
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, MessageProviding {
- private static final int PROTOCOL = 12;
- // 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 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 static final int PROTOCOL = 13;
+ // TODO: Investigate if this one is really needed to be static.
+ // Doubt it. -- FernFerret
+ private static Map teleportQueue = new HashMap();
private AnchorManager anchorManager = new AnchorManager(this);
private MessageProvider messageProvider = new SimpleMessageProvider(this);
+ // TODO please let's make this non-static
+ private static MultiverseCoreConfiguration config;
/**
* This method is used to find out who is teleporting a player.
@@ -162,8 +157,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
private MVEntityListener entityListener = new MVEntityListener(this);
private MVPluginListener pluginListener = new MVPluginListener(this);
private MVWeatherListener weatherListener = new MVWeatherListener(this);
-
- //public UpdateChecker updateCheck;
+ private MVPortalListener portalListener = new MVPortalListener(this);
// HashMap to contain information relating to the Players.
private HashMap playerSessions;
@@ -172,24 +166,35 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
private int pluginCount;
private DestinationFactory destFactory;
private SpoutInterface spoutInterface = null;
- private static final double ALLPAY_VERSION = 5;
- private static final double CH_VERSION = 4;
- private MVMessaging messaging;
+ private MultiverseMessaging messaging;
+ private BlockSafety blockSafety;
+ private LocationManipulation locationManipulation;
+ private SafeTTeleporter safeTTeleporter;
private File serverFolder = new File(System.getProperty("user.dir"));
@Override
public void onLoad() {
+ // Register our config
+ SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
// Create our DataFolder
getDataFolder().mkdirs();
// Setup our Debug Log
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
+ // Setup our BlockSafety
+ this.blockSafety = new SimpleBlockSafety(this);
+ // Setup our LocationManipulation
+ this.locationManipulation = new SimpleLocationManipulation();
+ // Setup our SafeTTeleporter
+ this.safeTTeleporter = new SimpleSafeTTeleporter(this);
}
/**
* {@inheritDoc}
+ * @deprecated This is deprecated.
*/
@Override
+ @Deprecated
public FileConfiguration getMVConfiguration() {
return this.multiverseConfig;
}
@@ -207,12 +212,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
*/
@Override
public void onEnable() {
- //this.worldManager = new WorldManager(this);
- // Perform initial checks for AllPay
- if (!this.validateAllpay() || !this.validateCH()) {
- this.getServer().getPluginManager().disablePlugin(this);
- return;
- }
this.messaging = new MVMessaging();
this.banker = new AllPay(this, LOG_TAG + " ");
// Output a little snippet to show it's enabled.
@@ -260,12 +259,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
this.anchorManager.loadAnchors();
// Now set the firstspawnworld (after the worlds are loaded):
- // Default as the server.props world.
- this.worldManager.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld", getDefaultWorldName()));
- // We have to set this one here, if it's not present, we don't know the name of the default world.
- // and this one won't be in the defaults yml file.
+ this.worldManager.setFirstSpawnWorld(config.getFirstSpawnWorld());
try {
- this.multiverseConfig.set("firstspawnworld", this.worldManager.getFirstSpawnWorld().getName());
+ config.setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
} catch (NullPointerException e) {
// A test that had no worlds loaded was being run. This should never happen in production
}
@@ -277,42 +273,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
}
}
- private boolean validateAllpay() {
- try {
- this.banker = new AllPay(this, "Verify");
- if (this.banker.getVersion() >= ALLPAY_VERSION) {
- return true;
- }
- } catch (Throwable t) {
- //TODO: Deal with this. It's bad.
- }
- 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() >= CH_VERSION) {
- return true;
- }
- } catch (Throwable t) {
- //TODO: Deal with this. It's bad.
- }
- 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;
- }
-
private void initializeDestinationFactory() {
this.destFactory = new DestinationFactory(this);
this.destFactory.registerDestinationType(WorldDestination.class, "");
@@ -333,6 +293,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
pm.registerEvents(this.entityListener, this);
pm.registerEvents(this.pluginListener, this);
pm.registerEvents(this.weatherListener, this);
+ pm.registerEvents(this.portalListener, this);
+
}
/**
@@ -344,53 +306,87 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
this.multiverseConfig.setDefaults(coreDefaults);
- this.multiverseConfig.options().copyDefaults(true);
- this.saveMVConfig();
- this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
+ this.multiverseConfig.options().copyDefaults(false);
+ this.multiverseConfig.options().copyHeader(true);
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
- // Setup the Debug option, we'll default to false because this option will not be in the default config.
- 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);
- PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
- // Should MV Intercept teleports by other plugins?
- TeleportIntercept = this.multiverseConfig.getBoolean("teleportintercept", true);
- // Should MV do the first spawn stuff?
- FirstSpawnOverride = this.multiverseConfig.getBoolean("firstspawnoverride", true);
- // Should permissions errors display to users?
- DisplayPermErrors = this.multiverseConfig.getBoolean("displaypermerrors", true);
+ MultiverseCoreConfiguration wantedConfig = null;
+ try {
+ wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
+ } catch (Exception e) {
+ // We're just thinking "no risk no fun" and therefore have to catch and forget this exception
+ } finally {
+ config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
+ }
- this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
- // Update the version of the config!
- this.multiverseConfig.set("version", coreDefaults.get("version"));
+ this.messaging.setCooldown(config.getMessageCooldown());
// Remove old values.
this.multiverseConfig.set("enforcegamemodes", null);
this.multiverseConfig.set("bedrespawn", null);
this.multiverseConfig.set("opfallback", null);
+ // Old Config Format
+ this.migrate22Values();
this.saveMVConfigs();
}
/**
- * Safely return a world name.
- * (The tests call this with no worlds loaded)
- *
- * @return The default world name.
+ * Thes are the MV config 2.0-2.2 values,
+ * they should be migrated to the new format.
*/
- private String getDefaultWorldName() {
- if (this.getServer().getWorlds().size() > 0) {
- return this.getServer().getWorlds().get(0).getName();
+ private void migrate22Values() {
+ if (this.multiverseConfig.isSet("worldnameprefix")) {
+ this.log(Level.INFO, "Migrating 'worldnameprefix'...");
+ this.config.setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
+ this.multiverseConfig.set("worldnameprefix", null);
+ }
+ if (this.multiverseConfig.isSet("firstspawnworld")) {
+ this.log(Level.INFO, "Migrating 'firstspawnworld'...");
+ this.config.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
+ this.multiverseConfig.set("firstspawnworld", null);
+ }
+ if (this.multiverseConfig.isSet("enforceaccess")) {
+ this.log(Level.INFO, "Migrating 'enforceaccess'...");
+ this.config.setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
+ this.multiverseConfig.set("enforceaccess", null);
+ }
+ if (this.multiverseConfig.isSet("displaypermerrors")) {
+ this.log(Level.INFO, "Migrating 'displaypermerrors'...");
+ this.config.setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
+ this.multiverseConfig.set("displaypermerrors", null);
+ }
+ if (this.multiverseConfig.isSet("teleportintercept")) {
+ this.log(Level.INFO, "Migrating 'teleportintercept'...");
+ this.config.setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
+ this.multiverseConfig.set("teleportintercept", null);
+ }
+ if (this.multiverseConfig.isSet("firstspawnoverride")) {
+ this.log(Level.INFO, "Migrating 'firstspawnoverride'...");
+ this.config.setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
+ this.multiverseConfig.set("firstspawnoverride", null);
+ }
+ if (this.multiverseConfig.isSet("messagecooldown")) {
+ this.log(Level.INFO, "Migrating 'messagecooldown'...");
+ this.config.setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
+ this.multiverseConfig.set("messagecooldown", null);
+ }
+ if (this.multiverseConfig.isSet("debug")) {
+ this.log(Level.INFO, "Migrating 'debug'...");
+ this.config.setGlobalDebug(this.multiverseConfig.getInt("debug"));
+ this.multiverseConfig.set("debug", null);
+ }
+ if (this.multiverseConfig.isSet("version")) {
+ this.log(Level.INFO, "Migrating 'version'...");
+ this.multiverseConfig.set("version", null);
}
- return "";
}
/**
* {@inheritDoc}
*/
@Override
- public MVMessaging getMessaging() {
+ public MultiverseMessaging getMessaging() {
return this.messaging;
}
@@ -453,17 +449,20 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
if (this.playerSessions.containsKey(player.getName())) {
return this.playerSessions.get(player.getName());
} else {
- this.playerSessions.put(player.getName(), new MVPlayerSession(player, this.multiverseConfig, this));
+ this.playerSessions.put(player.getName(), new MVPlayerSession(player, config));
return this.playerSessions.get(player.getName());
}
}
/**
* {@inheritDoc}
+ *
+ * @deprecated This is deprecated.
*/
@Override
- public SafeTTeleporter getTeleporter() {
- return new SafeTTeleporter(this);
+ @Deprecated
+ public com.onarandombox.MultiverseCore.utils.SafeTTeleporter getTeleporter() {
+ return new com.onarandombox.MultiverseCore.utils.SafeTTeleporter(this);
}
/**
@@ -485,7 +484,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
}
ArrayList allArgs = new ArrayList(Arrays.asList(args));
allArgs.add(0, command.getName());
- return this.commandHandler.locateAndRunCommand(sender, allArgs, DisplayPermErrors);
+ return this.commandHandler.locateAndRunCommand(sender, allArgs, config.getDisplayPermErrors());
}
/**
@@ -503,13 +502,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
* @param msg The message to log.
*/
public static void staticLog(Level level, String msg) {
- if (level == Level.FINE && GlobalDebug >= 1) {
+ if (level == Level.FINE && config.getGlobalDebug() >= 1) {
staticDebugLog(Level.INFO, msg);
return;
- } else if (level == Level.FINER && GlobalDebug >= 2) {
+ } else if (level == Level.FINER && config.getGlobalDebug() >= 2) {
staticDebugLog(Level.INFO, msg);
return;
- } else if (level == Level.FINEST && GlobalDebug >= 3) {
+ } else if (level == Level.FINEST && config.getGlobalDebug() >= 3) {
staticDebugLog(Level.INFO, msg);
return;
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
@@ -652,7 +651,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
*/
public void teleportPlayer(CommandSender teleporter, Player p, Location l) {
// This command is the override, and MUST NOT TELEPORT SAFELY
- this.getTeleporter().safelyTeleport(teleporter, p, l, false);
+ this.getSafeTTeleporter().safelyTeleport(teleporter, p, l, false);
}
/**
@@ -735,6 +734,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
*/
public boolean saveMVConfig() {
try {
+ this.multiverseConfig.set("multiverse-configuration", config);
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
return true;
} catch (IOException e) {
@@ -794,7 +794,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
}
if (this.worldManager.deleteWorld(name, false)) {
this.worldManager.loadWorlds(false);
- SafeTTeleporter teleporter = this.getTeleporter();
+ SafeTTeleporter teleporter = this.getSafeTTeleporter();
Location newSpawn = this.getServer().getWorld(name).getSpawnLocation();
// Send all players that were in the old world, BACK to it!
for (Player p : ps) {
@@ -832,4 +832,69 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
messageProvider = provider;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public BlockSafety getBlockSafety() {
+ return blockSafety;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setBlockSafety(BlockSafety bs) {
+ this.blockSafety = bs;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public LocationManipulation getLocationManipulation() {
+ return locationManipulation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setLocationManipulation(LocationManipulation locationManipulation) {
+ this.locationManipulation = locationManipulation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public SafeTTeleporter getSafeTTeleporter() {
+ return safeTTeleporter;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSafeTTeleporter(SafeTTeleporter safeTTeleporter) {
+ this.safeTTeleporter = safeTTeleporter;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public MultiverseCoreConfig getMVConfig() {
+ return config;
+ }
+
+ /**
+ * This method is currently used by other plugins.
+ * It will be removed in 2.4
+ * @return
+ */
+ @Deprecated
+ public static MultiverseCoreConfiguration getStaticConfig() {
+ return config;
+ }
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java
new file mode 100644
index 00000000..6446ba3d
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java
@@ -0,0 +1,222 @@
+package com.onarandombox.MultiverseCore;
+
+import java.util.Map;
+
+import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
+
+import me.main__.util.SerializationConfig.Property;
+import me.main__.util.SerializationConfig.SerializationConfig;
+
+/**
+ * Our configuration.
+ */
+public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig {
+ @Property
+ private boolean enforceaccess;
+ @Property
+ private boolean prefixchat;
+ @Property
+ private boolean teleportintercept;
+ @Property
+ private boolean firstspawnoverride;
+ @Property
+ private boolean displaypermerrors;
+ @Property
+ private int globaldebug;
+ @Property
+ private int messagecooldown;
+ @Property
+ private double version;
+ @Property
+ private String firstspawnworld;
+ @Property
+ private int teleportcooldown;
+
+ public MultiverseCoreConfiguration() {
+ super();
+ }
+
+ public MultiverseCoreConfiguration(Map values) {
+ super(values);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setDefaults() {
+ // BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
+ enforceaccess = false;
+ prefixchat = true;
+ teleportintercept = true;
+ firstspawnoverride = true;
+ displaypermerrors = true;
+ globaldebug = 0;
+ messagecooldown = 5000;
+ teleportcooldown = 1000;
+ this.version = 2.9;
+ // END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
+ }
+
+ // And here we go:
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean getEnforceAccess() {
+ return this.enforceaccess;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setEnforceAccess(boolean enforceAccess) {
+ this.enforceaccess = enforceAccess;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean getPrefixChat() {
+ return this.prefixchat;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setPrefixChat(boolean prefixChat) {
+ this.prefixchat = prefixChat;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean getTeleportIntercept() {
+ return this.teleportintercept;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setTeleportIntercept(boolean teleportIntercept) {
+ this.teleportintercept = teleportIntercept;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean getFirstSpawnOverride() {
+ return this.firstspawnoverride;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setFirstSpawnOverride(boolean firstSpawnOverride) {
+ this.firstspawnoverride = firstSpawnOverride;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean getDisplayPermErrors() {
+ return this.displaypermerrors;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setDisplayPermErrors(boolean displayPermErrors) {
+ this.displaypermerrors = displayPermErrors;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getGlobalDebug() {
+ return this.globaldebug;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setGlobalDebug(int globalDebug) {
+ this.globaldebug = globalDebug;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getMessageCooldown() {
+ return this.messagecooldown;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setMessageCooldown(int messageCooldown) {
+ this.messagecooldown = messageCooldown;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public double getVersion() {
+ return this.version;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getFirstSpawnWorld() {
+ return this.firstspawnworld;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setFirstSpawnWorld(String firstSpawnWorld) {
+ this.firstspawnworld = firstSpawnWorld;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getTeleportCooldown() {
+ return this.teleportcooldown;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setTeleportCooldown(int teleportCooldown) {
+ this.teleportcooldown = teleportCooldown;
+ }
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/BlockSafety.java b/src/main/java/com/onarandombox/MultiverseCore/api/BlockSafety.java
new file mode 100644
index 00000000..db25a17e
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/BlockSafety.java
@@ -0,0 +1,72 @@
+package com.onarandombox.MultiverseCore.api;
+
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.entity.Minecart;
+import org.bukkit.entity.Vehicle;
+
+/**
+ * Used to get block/location-related information.
+ */
+public interface BlockSafety {
+ /**
+ * This function checks whether the block at the given coordinates are above air or not.
+ * @param l The {@link Location} of the block.
+ * @return True if the block at that {@link Location} is above air.
+ */
+ boolean isBlockAboveAir(Location l);
+
+ /**
+ * Checks if a player can spawn safely at the given coordinates.
+ * @param world The {@link World}.
+ * @param x The x-coordinate.
+ * @param y The y-coordinate.
+ * @param z The z-coordinate.
+ * @return True if a player can spawn safely at the given coordinates.
+ */
+ boolean playerCanSpawnHereSafely(World world, double x, double y, double z);
+
+ /**
+ * This function checks whether the block at the coordinates given is safe or not by checking for Lava/Fire/Air
+ * etc. This also ensures there is enough space for a player to spawn!
+ *
+ * @param l The {@link Location}
+ * @return Whether the player can spawn safely at the given {@link Location}
+ */
+ boolean playerCanSpawnHereSafely(Location l);
+
+ /**
+ * Gets the location of the top block at the specified {@link Location}.
+ * @param l Any {@link Location}.
+ * @return The {@link Location} of the top-block.
+ */
+ Location getTopBlock(Location l);
+
+ /**
+ * Gets the location of the top block at the specified {@link Location}.
+ * @param l Any {@link Location}.
+ * @return The {@link Location} of the top-block.
+ */
+ Location getBottomBlock(Location l);
+
+ /**
+ * Checks if an entity would be on track at the specified {@link Location}.
+ * @param l The {@link Location}.
+ * @return True if an entity would be on tracks at the specified {@link Location}.
+ */
+ boolean isEntitiyOnTrack(Location l);
+
+ /**
+ * Checks if the specified {@link Minecart} can spawn safely.
+ * @param cart The {@link Minecart}.
+ * @return True if the minecart can spawn safely.
+ */
+ boolean canSpawnCartSafely(Minecart cart);
+
+ /**
+ * Checks if the specified {@link Vehicle} can spawn safely.
+ * @param vehicle The {@link Vehicle}.
+ * @return True if the vehicle can spawn safely.
+ */
+ boolean canSpawnVehicleSafely(Vehicle vehicle);
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/Core.java b/src/main/java/com/onarandombox/MultiverseCore/api/Core.java
index 7eec0ba2..01c684d0 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/Core.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/Core.java
@@ -26,7 +26,9 @@ public interface Core {
* Gets the Multiverse config file.
*
* @return The Multiverse config file.
+ * @deprecated Don't modify the config-file manually!
*/
+ @Deprecated
FileConfiguration getMVConfiguration();
/**
@@ -46,9 +48,9 @@ public interface Core {
* Gets the Multiverse message system. This allows you to send messages
* to users at specified intervals.
*
- * @return The loaded {@link MVMessaging}.
+ * @return The loaded {@link MultiverseMessaging}.
*/
- MVMessaging getMessaging();
+ MultiverseMessaging getMessaging();
/**
* Gets the {@link MVPlayerSession} for the given player.
@@ -66,8 +68,11 @@ public interface Core {
* safe teleports.
*
* @return A non-null {@link SafeTTeleporter}.
+ *
+ * @deprecated Use {@link #getSafeTTeleporter()} instead.
*/
- SafeTTeleporter getTeleporter();
+ @Deprecated
+ com.onarandombox.MultiverseCore.utils.SafeTTeleporter getTeleporter();
/**
* Multiverse uses an advanced permissions setup, this object
@@ -163,4 +168,58 @@ public interface Core {
* @return The readable authors-{@link String}
*/
String getAuthors();
+
+ /**
+ * Gets the {@link BlockSafety} this {@link Core} is using.
+ * @return The {@link BlockSafety} this {@link Core} is using.
+ * @see BlockSafety
+ * @see SimpleBlockSafety
+ */
+ BlockSafety getBlockSafety();
+
+ /**
+ * Sets the {@link BlockSafety} this {@link Core} is using.
+ * @param blockSafety The new {@link BlockSafety}.
+ * @see BlockSafety
+ * @see SimpleBlockSafety
+ */
+ void setBlockSafety(BlockSafety blockSafety);
+
+ /**
+ * Gets the {@link LocationManipulation} this {@link Core} is using.
+ * @return The {@link LocationManipulation} this {@link Core} is using.
+ * @see LocationManipulation
+ * @see SimpleLocationManipulation
+ */
+ LocationManipulation getLocationManipulation();
+
+ /**
+ * Sets the {@link LocationManipulation} this {@link Core} is using.
+ * @param locationManipulation The new {@link LocationManipulation}.
+ * @see LocationManipulation
+ * @see SimpleLocationManipulation
+ */
+ void setLocationManipulation(LocationManipulation locationManipulation);
+
+ /**
+ * Gets the {@link SafeTTeleporter} this {@link Core} is using.
+ * @return The {@link SafeTTeleporter} this {@link Core} is using.
+ * @see SafeTTeleporter
+ * @see SimpleSafeTTeleporter
+ */
+ SafeTTeleporter getSafeTTeleporter();
+
+ /**
+ * Sets the {@link SafeTTeleporter} this {@link Core} is using.
+ * @param safeTTeleporter The new {@link SafeTTeleporter}.
+ * @see SafeTTeleporter
+ * @see SimpleSafeTTeleporter
+ */
+ void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
+
+ /**
+ * Gets the {@link MultiverseCoreConfig}.
+ * @return The configuration.
+ */
+ MultiverseCoreConfig getMVConfig();
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java b/src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java
new file mode 100644
index 00000000..e246c8da
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java
@@ -0,0 +1,99 @@
+package com.onarandombox.MultiverseCore.api;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.util.Vector;
+
+/**
+ * Used to manipulate locations.
+ */
+public interface LocationManipulation {
+ /**
+ * Convert a Location into a Colon separated string to allow us to store it in text.
+ *
+ * WORLD:X,Y,Z:yaw:pitch
+ *
+ * The corresponding String2Loc function is {@link #stringToLocation}
+ *
+ * @param location The Location to save.
+ * @return The location as a string in this format: WORLD:x,y,z:yaw:pitch
+ */
+ String locationToString(Location location);
+
+ /**
+ * This method simply does some rounding, rather than forcing a call to the server to get the blockdata.
+ *
+ * @param l The location to round to the block location
+ * @return A rounded location.
+ */
+ Location getBlockLocation(Location l);
+
+ /**
+ * Returns a new location from a given string. The format is as follows:
+ *
+ * WORLD:X,Y,Z:yaw:pitch
+ *
+ * The corresponding Location2String function is {@link #stringToLocation}
+ *
+ * @param locationString The location represented as a string (WORLD:X,Y,Z:yaw:pitch)
+ * @return A new location defined by the string or null if the string was invalid.
+ */
+ Location stringToLocation(String locationString);
+
+ /**
+ * Returns a colored string with the coords.
+ *
+ * @param l The {@link Location}
+ * @return The {@link String}
+ */
+ String strCoords(Location l);
+
+ /**
+ * Converts a location to a printable readable formatted string including pitch/yaw.
+ *
+ * @param l The {@link Location}
+ * @return The {@link String}
+ */
+ String strCoordsRaw(Location l);
+
+ /**
+ * Return the NESW Direction a Location is facing.
+ *
+ * @param location The {@link Location}
+ * @return The NESW Direction
+ */
+ String getDirection(Location location);
+
+ /**
+ * Returns the float yaw position for the given cardinal direction.
+ *
+ * @param orientation The cardinal direction
+ * @return The yaw
+ */
+ float getYaw(String orientation);
+
+ /**
+ * Returns a speed float from a given vector.
+ *
+ * @param v The {@link Vector}
+ * @return The speed
+ */
+ float getSpeed(Vector v);
+
+ /**
+ * Returns a translated vector from the given direction.
+ *
+ * @param v The old {@link Vector}
+ * @param direction The new direction
+ * @return The translated {@link Vector}
+ */
+ Vector getTranslatedVector(Vector v, String direction);
+
+ /**
+ * Returns the next Location that a {@link Vehicle} is traveling at.
+ *
+ * @param v The {@link Vehicle}
+ * @return The {@link Location}
+ */
+ Location getNextBlock(Vehicle v);
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
index 40300ef0..5492b77d 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java
@@ -8,6 +8,8 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
+import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
+
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
@@ -28,31 +30,35 @@ public interface MVWorldManager {
/**
* Add a new World to the Multiverse Setup.
*
- * @param name World Name
- * @param env Environment Type
- * @param seedString The seed in the form of a string.
- * If the seed is a Long,
- * it will be interpreted as such.
- * @param type The Type of the world to be made.
- * @param generator The Custom generator plugin to use.
+ * @param name World Name
+ * @param env Environment Type
+ * @param seedString The seed in the form of a string.
+ * If the seed is a Long,
+ * it will be interpreted as such.
+ * @param type The Type of the world to be made.
+ * @param generateStructures If true, this world will get NPC villages.
+ * @param generator The Custom generator plugin to use.
* @return True if the world is added, false if not.
*/
- boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator);
+ boolean addWorld(String name, Environment env, String seedString, WorldType type, boolean generateStructures,
+ String generator);
/**
* Add a new World to the Multiverse Setup.
*
- * @param name World Name
- * @param env Environment Type
- * @param seedString The seed in the form of a string.
- * If the seed is a Long,
- * it will be interpreted as such.
- * @param type The Type of the world to be made.
- * @param generator The Custom generator plugin to use.
+ * @param name World Name
+ * @param env Environment Type
+ * @param seedString The seed in the form of a string.
+ * If the seed is a Long,
+ * it will be interpreted as such.
+ * @param type The Type of the world to be made.
+ * @param generateStructures If true, this world will get NPC villages.
+ * @param generator The Custom generator plugin to use.
* @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.
*/
- boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust);
+ boolean addWorld(String name, Environment env, String seedString, WorldType type, boolean generateStructures,
+ String generator, boolean useSpawnAdjust);
/**
* Remove the world from the Multiverse list, from the
@@ -168,9 +174,21 @@ public interface MVWorldManager {
* Return the World Purger.
*
* @return A valid {@link PurgeWorlds}.
+ * @deprecated {@link PurgeWorlds} is deprecated!
*/
+ @Deprecated
PurgeWorlds getWorldPurger();
+ /**
+ * Gets the {@link WorldPurger}.
+ *
+ * TODO: Remove {@link #getWorldPurger()} and replace it with this method.
+ * @return The {@link WorldPurger} this {@link MVWorldManager} is using.
+ * @see WorldPurger
+ * @see SimpleWorldPurger
+ */
+ WorldPurger getTheWorldPurger();
+
/**
* Gets the world players will spawn in on first join.
* Currently this always returns worlds.get(0) from Bukkit.
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java
new file mode 100644
index 00000000..25f6fad4
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java
@@ -0,0 +1,136 @@
+package com.onarandombox.MultiverseCore.api;
+
+import org.bukkit.configuration.serialization.ConfigurationSerializable;
+
+/**
+ * The configuration of MultiverseCore.
+ */
+public interface MultiverseCoreConfig extends ConfigurationSerializable {
+ /**
+ * Sets a property using a {@link String}.
+ * @param property The name of the property.
+ * @param value The value.
+ * @return True on success, false if the operation failed.
+ */
+ boolean setProperty(String property, String value);
+
+ /**
+ * Sets portalCooldown.
+ * @param portalCooldown The new value.
+ */
+ void setTeleportCooldown(int portalCooldown);
+
+ /**
+ * Gets portalCooldown.
+ * @return portalCooldown.
+ */
+ int getTeleportCooldown();
+
+ /**
+ * Sets firstSpawnWorld.
+ * @param firstSpawnWorld The new value.
+ */
+ void setFirstSpawnWorld(String firstSpawnWorld);
+
+ /**
+ * Gets firstSpawnWorld.
+ * @return firstSpawnWorld.
+ */
+ String getFirstSpawnWorld();
+
+ /**
+ * Sets version.
+ * @param version The new value.
+ */
+ void setVersion(int version);
+
+ /**
+ * Gets version.
+ * @return version.
+ */
+ double getVersion();
+
+ /**
+ * Sets messageCooldown.
+ * @param messageCooldown The new value.
+ */
+ void setMessageCooldown(int messageCooldown);
+
+ /**
+ * Gets messageCooldown.
+ * @return messageCooldown.
+ */
+ int getMessageCooldown();
+
+ /**
+ * Sets globalDebug.
+ * @param globalDebug The new value.
+ */
+ void setGlobalDebug(int globalDebug);
+
+ /**
+ * Gets globalDebug.
+ * @return globalDebug.
+ */
+ int getGlobalDebug();
+
+ /**
+ * Sets displayPermErrors.
+ * @param displayPermErrors The new value.
+ */
+ void setDisplayPermErrors(boolean displayPermErrors);
+
+ /**
+ * Gets displayPermErrors.
+ * @return displayPermErrors.
+ */
+ boolean getDisplayPermErrors();
+
+ /**
+ * Sets firstSpawnOverride.
+ * @param firstSpawnOverride The new value.
+ */
+ void setFirstSpawnOverride(boolean firstSpawnOverride);
+
+ /**
+ * Gets firstSpawnOverride.
+ * @return firstSpawnOverride.
+ */
+ boolean getFirstSpawnOverride();
+
+ /**
+ * Sets teleportIntercept.
+ * @param teleportIntercept The new value.
+ */
+ void setTeleportIntercept(boolean teleportIntercept);
+
+ /**
+ * Gets teleportIntercept.
+ * @return teleportIntercept.
+ */
+ boolean getTeleportIntercept();
+
+ /**
+ * Sets prefixChat.
+ * @param prefixChat The new value.
+ */
+ void setPrefixChat(boolean prefixChat);
+
+ /**
+ * Gets prefixChat.
+ * @return prefixChat.
+ */
+ boolean getPrefixChat();
+
+ /**
+ * Sets enforceAccess.
+ * @param enforceAccess The new value.
+ */
+ void setEnforceAccess(boolean enforceAccess);
+
+ /**
+ * Gets enforceAccess.
+ * @return enforceAccess.
+ */
+ boolean getEnforceAccess();
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseMessaging.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseMessaging.java
new file mode 100644
index 00000000..ae2bd004
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseMessaging.java
@@ -0,0 +1,56 @@
+package com.onarandombox.MultiverseCore.api;
+
+import java.util.Collection;
+
+import org.bukkit.command.CommandSender;
+
+/**
+ * Multiverse-messaging.
+ */
+public interface MultiverseMessaging {
+ /**
+ * Sets the message-cooldown.
+ * @param milliseconds The new message-cooldown in milliseconds.
+ */
+ void setCooldown(int milliseconds);
+
+ /**
+ * Sends a message to the specified sender if the cooldown has passed.
+ *
+ * @param sender The person/console to send the message to.
+ * @param message The message to send.
+ * @param ignoreCooldown If true this message will always be sent. Useful for things like menus
+ * @return true if the message was sent, false if not.
+ */
+ boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown);
+
+ /**
+ * Sends a group of messages to the specified sender if the cooldown has passed.
+ * This method is needed, since sending many messages in quick succession would violate
+ * the cooldown.
+ *
+ * @param sender The person/console to send the message to.
+ * @param messages The messages to send.
+ * @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
+ * @return true if the message was sent, false if not.
+ */
+ boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown);
+
+ /**
+ * Sends a group of messages to the specified sender if the cooldown has passed.
+ * This method is needed, since sending many messages in quick succession would violate
+ * the cooldown.
+ *
+ * @param sender The person/console to send the message to.
+ * @param messages The messages to send.
+ * @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
+ * @return true if the message was sent, false if not.
+ */
+ boolean sendMessages(CommandSender sender, Collection messages, boolean ignoreCooldown);
+
+ /**
+ * Gets the message-cooldown.
+ * @return The message-cooldown.
+ */
+ int getCooldown();
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
index fb473ce8..5bd1eb11 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
@@ -8,6 +8,7 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
+import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import org.bukkit.ChatColor;
@@ -573,4 +574,18 @@ public interface MultiverseWorld {
* @return The Type of this world.
*/
WorldType getWorldType();
+
+ /**
+ * Sets The types of portals that are allowed in this world.
+ *
+ * @param type The type of portals allowed in this world.
+ */
+ void allowPortalMaking(AllowedPortalType type);
+
+ /**
+ * Gets which type(s) of portals are allowed to be constructed in this world.
+ *
+ * @return The type of portals that are allowed.
+ */
+ AllowedPortalType getAllowedPortals();
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/SafeTTeleporter.java b/src/main/java/com/onarandombox/MultiverseCore/api/SafeTTeleporter.java
new file mode 100644
index 00000000..a38140e1
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/SafeTTeleporter.java
@@ -0,0 +1,71 @@
+package com.onarandombox.MultiverseCore.api;
+
+import org.bukkit.Location;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Entity;
+
+import com.onarandombox.MultiverseCore.enums.TeleportResult;
+
+/**
+ * Used to safely teleport people.
+ */
+public interface SafeTTeleporter {
+
+ /**
+ * Gets the next safe location around the given location.
+ * @param l A {@link Location}.
+ * @return A safe {@link Location}.
+ */
+ Location getSafeLocation(Location l);
+
+ /**
+ * Gets the next safe location around the given location.
+ * @param l A {@link Location}.
+ * @param tolerance The tolerance.
+ * @param radius The radius.
+ * @return A safe {@link Location}.
+ */
+ Location getSafeLocation(Location l, int tolerance, int radius);
+
+ /**
+ * Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
+ * it's not, will adjust the final destination accordingly.
+ *
+ * @param teleporter Person who performed the teleport command.
+ * @param teleportee Entity to teleport
+ * @param d Destination to teleport them to
+ * @return true for success, false for failure
+ */
+ TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d);
+
+ /**
+ * Safely teleport the entity to the Location. This may perform checks to
+ * see if the place is safe, and if
+ * it's not, will adjust the final destination accordingly.
+ *
+ * @param teleporter Person who issued the teleport command.
+ * @param teleportee Entity to teleport.
+ * @param location Location to teleport them to.
+ * @param safely Should the destination be checked for safety before teleport?
+ * @return true for success, false for failure.
+ */
+ TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, Location location,
+ boolean safely);
+
+ /**
+ * Returns a safe location for the entity to spawn at.
+ *
+ * @param e The entity to spawn
+ * @param d The MVDestination to take the entity to.
+ * @return A new location to spawn the entity at.
+ */
+ Location getSafeLocation(Entity e, MVDestination d);
+
+ /**
+ * Finds a portal-block next to the specified {@link Location}.
+ * @param l The {@link Location}
+ * @return The next portal-block's {@link Location}.
+ */
+ Location findPortalBlockNextTo(Location l);
+
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/WorldPurger.java b/src/main/java/com/onarandombox/MultiverseCore/api/WorldPurger.java
new file mode 100644
index 00000000..6be96bba
--- /dev/null
+++ b/src/main/java/com/onarandombox/MultiverseCore/api/WorldPurger.java
@@ -0,0 +1,49 @@
+package com.onarandombox.MultiverseCore.api;
+
+import java.util.List;
+
+import org.bukkit.command.CommandSender;
+
+/**
+ * Used to remove animals from worlds that don't belong there.
+ */
+public interface WorldPurger {
+
+ /**
+ * Synchronizes the given world with it's settings.
+ *
+ * @param worlds A list of {@link MultiverseWorld}
+ */
+ void purgeWorlds(List worlds);
+
+ /**
+ * Convenience method for {@link #purgeWorld(CommandSender, MultiverseWorld, List, boolean, boolean)} that takes the settings from the world-config.
+ *
+ * @param world The {@link MultiverseWorld}.
+ */
+ void purgeWorld(MultiverseWorld world);
+
+ /**
+ * Clear all animals/monsters that do not belong to a world according to the config.
+ *
+ * @param mvworld The {@link MultiverseWorld}.
+ * @param thingsToKill A {@link List} of animals/monsters to be killed.
+ * @param negateAnimals Whether the monsters in the list should be negated.
+ * @param negateMonsters Whether the animals in the list should be negated.
+ */
+ void purgeWorld(MultiverseWorld mvworld, List thingsToKill, boolean negateAnimals,
+ boolean negateMonsters);
+
+ /**
+ * Clear all animals/monsters that do not belong to a world according to the config.
+ *
+ * @param mvworld The {@link MultiverseWorld}.
+ * @param thingsToKill A {@link List} of animals/monsters to be killed.
+ * @param negateAnimals Whether the monsters in the list should be negated.
+ * @param negateMonsters Whether the animals in the list should be negated.
+ * @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
+ */
+ void purgeWorld(MultiverseWorld mvworld, List thingsToKill, boolean negateAnimals,
+ boolean negateMonsters, CommandSender sender);
+
+}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
index 232aabc0..731e6f95 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/AnchorCommand.java
@@ -85,6 +85,8 @@ public class AnchorCommand extends PaginatedCoreCommand {
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
+ } else if (filterObject.getPage() < 1) {
+ filterObject.setPage(1);
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
@@ -98,7 +100,11 @@ public class AnchorCommand extends PaginatedCoreCommand {
this.showList(sender, args);
return;
}
- if (args.size() == 2) {
+ if (args.size() == 1 && (this.getPageAndFilter(args).getPage() != 1 || args.get(0).equals("1"))) {
+ this.showList(sender, args);
+ return;
+ }
+ if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
} else {
@@ -111,6 +117,7 @@ public class AnchorCommand extends PaginatedCoreCommand {
sender.sendMessage("You must be a player to create Anchors.");
return;
}
+
Player player = (Player) sender;
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
index 3b48e1ce..6290183a 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
@@ -8,12 +8,12 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseCore.enums.ConfigProperty;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
+import java.util.Map;
/**
* Allows you to set Global MV Variables.
@@ -28,7 +28,6 @@ public class ConfigCommand extends MultiverseCommand {
this.addKey("mvconfig");
this.addKey("mv conf");
this.addKey("mvconf");
- this.addCommandExample("All values: " + ConfigProperty.getAllValues());
this.addCommandExample("/mv config show");
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
@@ -38,55 +37,31 @@ public class ConfigCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List args) {
if (args.size() <= 1) {
- String[] allProps = ConfigProperty.getAllValues().split(" ");
- String currentvals = "";
- for (String prop : allProps) {
- currentvals += ChatColor.GREEN;
- currentvals += prop;
- currentvals += ChatColor.WHITE;
- currentvals += " = ";
- currentvals += ChatColor.GOLD;
- currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
- currentvals += ChatColor.WHITE;
- currentvals += ", ";
+ StringBuilder builder = new StringBuilder();
+ Map serializedConfig = this.plugin.getMVConfig().serialize();
+ for (Map.Entry entry : serializedConfig.entrySet()) {
+ builder.append(ChatColor.GREEN);
+ builder.append(entry.getKey());
+ builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD);
+ builder.append(entry.getValue().toString());
+ builder.append(ChatColor.WHITE).append(", ");
}
- sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
+ String message = builder.toString();
+ message = message.substring(0, message.length() - 2);
+ sender.sendMessage(message);
return;
}
+ if (!this.plugin.getMVConfig().setProperty(args.get(0).toLowerCase(), args.get(1))) {
+ sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1)));
+ return;
+ }
+
+ // special rule
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
- 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")) {
- try {
- this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
- } catch (NumberFormatException e) {
- sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
- return;
- }
- } else {
- ConfigProperty property = null;
- 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.GREEN + "Valid values are:");
- sender.sendMessage(ConfigProperty.getAllValues());
- return;
- }
-
- if (property != null) {
- try {
- this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(1)));
- } catch (Exception e) {
- sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
- return;
- }
-
- }
}
+
if (this.plugin.saveMVConfigs()) {
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
this.plugin.loadConfigs();
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java
index f2d09887..944d8029 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java
@@ -10,7 +10,6 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
-import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
@@ -61,8 +60,8 @@ public class CoordCommand extends MultiverseCommand {
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
- p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + LocationManipulation.strCoords(p.getLocation()));
- p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + LocationManipulation.getDirection(p.getLocation()));
+ p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + plugin.getLocationManipulation().strCoords(p.getLocation()));
+ p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + plugin.getLocationManipulation().getDirection(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
} else {
sender.sendMessage("This command needs to be used from a Player.");
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java
index ffc3533d..d820626b 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java
@@ -29,8 +29,9 @@ public class CreateCommand extends MultiverseCommand {
public CreateCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create World");
- this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n]");
- this.setArgRange(2, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
+ this.setCommandUsage(String.format("/mv create %s{NAME} {ENV} %s-s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n] -a [true|false]",
+ ChatColor.GREEN, ChatColor.GOLD));
+ this.setArgRange(2, 11); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvcreate");
this.addKey("mvc");
this.addKey("mv create");
@@ -51,6 +52,11 @@ public class CreateCommand extends MultiverseCommand {
String env = args.get(1);
String seed = CommandHandler.getFlag("-s", args);
String generator = CommandHandler.getFlag("-g", args);
+ boolean allowStructures = true;
+ String structureString = CommandHandler.getFlag("-a", args);
+ if (structureString != null) {
+ allowStructures = Boolean.parseBoolean(structureString);
+ }
String typeString = CommandHandler.getFlag("-t", args);
boolean useSpawnAdjust = true;
for (String s : args) {
@@ -58,6 +64,7 @@ public class CreateCommand extends MultiverseCommand {
useSpawnAdjust = false;
}
}
+
if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
@@ -84,7 +91,7 @@ public class CreateCommand extends MultiverseCommand {
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
- if (this.worldManager.addWorld(worldName, environment, seed, type, generator, useSpawnAdjust)) {
+ if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
Command.broadcastCommandMessage(sender, "Complete!");
} else {
Command.broadcastCommandMessage(sender, "FAILED.");
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java
index 83f7cdd5..53fc01b5 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java
@@ -36,14 +36,14 @@ public class DebugCommand extends MultiverseCommand {
public void runCommand(CommandSender sender, List args) {
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("off")) {
- MultiverseCore.GlobalDebug = 0;
+ plugin.getMVConfig().setGlobalDebug(0);
} else {
try {
int debugLevel = Integer.parseInt(args.get(0));
if (debugLevel > 3 || debugLevel < 0) {
throw new NumberFormatException();
}
- MultiverseCore.GlobalDebug = debugLevel;
+ plugin.getMVConfig().setGlobalDebug(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!)");
@@ -55,10 +55,10 @@ public class DebugCommand extends MultiverseCommand {
}
private void displayDebugMode(CommandSender sender) {
- if (MultiverseCore.GlobalDebug == 0) {
+ if (plugin.getMVConfig().getGlobalDebug() == 0) {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else {
- sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.GlobalDebug);
+ sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/EnvironmentCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/EnvironmentCommand.java
index 4531b39e..6be7f7fe 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/EnvironmentCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/EnvironmentCommand.java
@@ -91,6 +91,7 @@ public class EnvironmentCommand extends MultiverseCommand {
* @return The environment as {@link org.bukkit.World.Environment}
*/
public static World.Environment getEnvFromString(String env) {
+ env = env.toUpperCase();
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
env = "NETHER";
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java
index bbb1edbc..90084e71 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java
@@ -33,8 +33,8 @@ public class ImportCommand extends MultiverseCommand {
public ImportCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Import World");
- this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE]");
- this.setArgRange(2, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
+ this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE] -a [true|false]");
+ this.setArgRange(1, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvimport");
this.addKey("mvim");
this.addKey("mv import");
@@ -129,6 +129,11 @@ public class ImportCommand extends MultiverseCommand {
String generator = CommandHandler.getFlag("-g", args);
String typeString = CommandHandler.getFlag("-t", args);
+ boolean allowStructures = true;
+ String structureString = CommandHandler.getFlag("-a", args);
+ if (structureString != null) {
+ allowStructures = Boolean.parseBoolean(structureString);
+ }
boolean useSpawnAdjust = true;
for (String s : args) {
if (s.equalsIgnoreCase("-n")) {
@@ -157,7 +162,7 @@ public class ImportCommand extends MultiverseCommand {
if (worldFile.exists() && env != null) {
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
- if (this.worldManager.addWorld(worldName, environment, null, type, generator, useSpawnAdjust))
+ if (this.worldManager.addWorld(worldName, environment, null, type, allowStructures, generator, useSpawnAdjust))
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
else
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java
index dffbd882..e7ad09bf 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java
@@ -14,7 +14,6 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.FancyColorScheme;
import com.onarandombox.MultiverseCore.utils.FancyHeader;
import com.onarandombox.MultiverseCore.utils.FancyMessage;
-import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
@@ -62,9 +61,13 @@ public class InfoCommand extends MultiverseCommand {
return;
}
} else if (args.size() == 1) {
- if (this.worldManager.getMVWorld(args.get(0)) != null) {
+ if (this.worldManager.isMVWorld(args.get(0))) {
// then we have a world!
worldName = args.get(0);
+ } else if(this.worldManager.getUnloadedWorlds().contains(args.get(0))){
+ sender.sendMessage("That world exists, but it is unloaded!");
+ sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, args.get(0)));
+ return;
} else {
if (sender instanceof Player) {
Player p = (Player) sender;
@@ -94,8 +97,11 @@ public class InfoCommand extends MultiverseCommand {
p = (Player) sender;
}
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
+ } else if (this.worldManager.getUnloadedWorlds().contains(worldName)) {
+ sender.sendMessage("That world exists, but it is unloaded!");
+ sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, worldName));
} else if (this.plugin.getServer().getWorld(worldName) != null) {
- sender.sendMessage("That world exists, but multiverse does not know about it!");
+ sender.sendMessage("That world exists, but Multiverse does not know about it!");
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
}
@@ -110,10 +116,11 @@ public class InfoCommand extends MultiverseCommand {
message.add(new FancyMessage("World Name: ", world.getName(), colors));
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
- message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
+ message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
+
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
Location spawn = world.getSpawnLocation();
- message.add(new FancyMessage("Spawn Location: ", LocationManipulation.strCoords(spawn), colors));
+ message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
if (world.getPrice() > 0) {
message.add(new FancyMessage("Price to enter this world: ",
@@ -136,7 +143,8 @@ public class InfoCommand extends MultiverseCommand {
// Page 2
message = new ArrayList();
message.add(new FancyHeader("More World Settings", colors));
- message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
+ message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
+ message.add(new FancyMessage("Structures: ", world.getCBWorld().canGenerateStructures() + "", colors));
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java
index 5c822fb9..0c584d19 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ListCommand.java
@@ -57,14 +57,16 @@ public class ListCommand extends PaginatedCoreCommand {
} else if (env == Environment.THE_END) {
color = ChatColor.AQUA;
}
- String outputCache = world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment();
+ StringBuilder builder = new StringBuilder();
+ builder.append(world.getColoredWorldString()).append(ChatColor.WHITE);
+ builder.append(" - ").append(color).append(world.getEnvironment());
if (world.isHidden()) {
- if (p == null || p.hasPermission("multiverse.core.modify")) {
+ if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true)) {
// Prefix hidden worlds with an "[H]"
- worldList.add(ChatColor.GRAY + "[H]" + outputCache);
+ worldList.add(ChatColor.GRAY + "[H]" + builder.toString());
}
} else {
- worldList.add(outputCache);
+ worldList.add(builder.toString());
}
}
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCommand.java
index 9790b110..ae54a9b8 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCommand.java
@@ -8,7 +8,7 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseCore.utils.MVMessaging;
+import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.command.CommandSender;
@@ -24,9 +24,9 @@ public abstract class MultiverseCommand extends Command {
*/
protected MultiverseCore plugin;
/**
- * The reference to {@link MVMessaging}.
+ * The reference to {@link MultiverseMessaging}.
*/
- protected MVMessaging messaging;
+ protected MultiverseMessaging messaging;
public MultiverseCommand(MultiverseCore plugin) {
super(plugin);
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/PurgeCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/PurgeCommand.java
index 89950d5b..8112fd0f 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/PurgeCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/PurgeCommand.java
@@ -10,7 +10,7 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
-import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
+import com.onarandombox.MultiverseCore.api.WorldPurger;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -78,7 +78,7 @@ public class PurgeCommand extends MultiverseCommand {
worldsToRemoveEntitiesFrom.add(this.worldManager.getMVWorld(worldName));
}
- PurgeWorlds purger = this.worldManager.getWorldPurger();
+ WorldPurger purger = this.worldManager.getTheWorldPurger();
ArrayList thingsToKill = new ArrayList();
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase());
@@ -86,7 +86,7 @@ public class PurgeCommand extends MultiverseCommand {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
}
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
- purger.purgeWorld(sender, w, thingsToKill, false, false);
+ purger.purgeWorld(w, thingsToKill, false, false, sender);
}
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/SetSpawnCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/SetSpawnCommand.java
index ba8863e9..0e0cd96d 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/SetSpawnCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/SetSpawnCommand.java
@@ -8,9 +8,8 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
-import com.onarandombox.MultiverseCore.utils.BlockSafety;
-import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
@@ -56,7 +55,7 @@ public class SetSpawnCommand extends MultiverseCommand {
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
if (foundWorld != null) {
foundWorld.setSpawnLocation(p.getLocation());
- BlockSafety bs = new BlockSafety();
+ BlockSafety bs = this.plugin.getBlockSafety();
if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) {
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
@@ -64,7 +63,7 @@ public class SetSpawnCommand extends MultiverseCommand {
sender.sendMessage(ChatColor.AQUA + "/mvm set adjustspawn true " + foundWorld.getAlias());
foundWorld.setAdjustSpawn(false);
}
- sender.sendMessage("Spawn was set to: " + LocationManipulation.strCoords(p.getLocation()));
+ sender.sendMessage("Spawn was set to: " + plugin.getLocationManipulation().strCoords(p.getLocation()));
} else {
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
sender.sendMessage("Multiverse does not know about this world, only X,Y and Z set. Please import it to set the spawn fully (Pitch/Yaws).");
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/SpawnCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/SpawnCommand.java
index 80620b78..5925d887 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/SpawnCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/SpawnCommand.java
@@ -85,6 +85,6 @@ public class SpawnCommand extends MultiverseCommand {
} else {
spawnLocation = player.getWorld().getSpawnLocation();
}
- this.plugin.getTeleporter().safelyTeleport(player, player, spawnLocation, false);
+ this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false);
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java
index 8adc91ac..b20f7e73 100644
--- a/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java
+++ b/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java
@@ -14,8 +14,7 @@ import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.destination.WorldDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
-import com.onarandombox.MultiverseCore.utils.LocationManipulation;
-import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
+import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
@@ -43,7 +42,7 @@ public class TeleportCommand extends MultiverseCommand {
this.setArgRange(1, 2);
this.addKey("mvtp");
this.addKey("mv tp");
- this.playerTeleporter = new SafeTTeleporter(this.plugin);
+ this.playerTeleporter = this.plugin.getSafeTTeleporter();
this.setPermission(menu);
}
@@ -111,7 +110,7 @@ public class TeleportCommand extends MultiverseCommand {
return;
}
- if (MultiverseCore.EnforceAccess && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
+ if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {
@@ -163,7 +162,8 @@ public class TeleportCommand extends MultiverseCommand {
}
TeleportResult result = this.playerTeleporter.safelyTeleport(teleporter, teleportee, d);
if (result == TeleportResult.FAIL_UNSAFE) {
- this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + LocationManipulation.strCoordsRaw(d.getLocation(teleportee)));
+ this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName()
+ + " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
this.plugin.log(Level.FINE, "Queueing Command");
Class>[] paramTypes = { CommandSender.class, Player.class, Location.class };
List