mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-02 16:59:56 +01:00
1.5 Compatibility
This commit is contained in:
parent
dad4547c21
commit
2ff10d0882
@ -32,65 +32,64 @@ import com.onarandombox.utils.PurgeWorlds;
|
|||||||
import com.onarandombox.utils.UpdateChecker;
|
import com.onarandombox.utils.UpdateChecker;
|
||||||
|
|
||||||
public class MultiverseCore extends JavaPlugin {
|
public class MultiverseCore extends JavaPlugin {
|
||||||
|
|
||||||
// Useless stuff to keep us going.
|
// Useless stuff to keep us going.
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
private static final Logger log = Logger.getLogger("Minecraft");
|
||||||
private static DebugLog debugLog;
|
private static DebugLog debugLog;
|
||||||
|
|
||||||
// Debug Mode
|
// Debug Mode
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
|
|
||||||
// Setup our Map for our Commands using the CommandHandler.
|
// Setup our Map for our Commands using the CommandHandler.
|
||||||
private CommandManager commandManager;
|
private CommandManager commandManager;
|
||||||
|
|
||||||
private final String tag = "[Multiverse-Core]";
|
private final String tag = "[Multiverse-Core]";
|
||||||
|
|
||||||
// Multiverse Permissions Handler
|
// Multiverse Permissions Handler
|
||||||
public MVPermissions ph = new MVPermissions(this);
|
public MVPermissions ph = new MVPermissions(this);
|
||||||
|
|
||||||
// Permissions Handler
|
// Permissions Handler
|
||||||
public static PermissionHandler Permissions = null;
|
public static PermissionHandler Permissions = null;
|
||||||
|
|
||||||
// iConomy Handler
|
// iConomy Handler
|
||||||
public static iConomy iConomy = null;
|
public static iConomy iConomy = null;
|
||||||
public static boolean useiConomy = false;
|
public static boolean useiConomy = false;
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
public Configuration configMV = null;
|
public Configuration configMV = null;
|
||||||
public Configuration configWorlds = null;
|
public Configuration configWorlds = null;
|
||||||
|
|
||||||
// Setup the block/player/entity listener.
|
// Setup the block/player/entity listener.
|
||||||
private MVPlayerListener playerListener = new MVPlayerListener(this);;
|
private MVPlayerListener playerListener = new MVPlayerListener(this);;
|
||||||
|
|
||||||
private MVBlockListener blockListener = new MVBlockListener(this);
|
private MVBlockListener blockListener = new MVBlockListener(this);
|
||||||
private MVEntityListener entityListener = new MVEntityListener(this);
|
private MVEntityListener entityListener = new MVEntityListener(this);
|
||||||
private MVPluginListener pluginListener = new MVPluginListener(this);
|
private MVPluginListener pluginListener = new MVPluginListener(this);
|
||||||
|
|
||||||
public UpdateChecker updateCheck;
|
public UpdateChecker updateCheck;
|
||||||
|
|
||||||
// HashMap to contain all the Worlds which this Plugin will manage.
|
// HashMap to contain all the Worlds which this Plugin will manage.
|
||||||
private HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
private HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
||||||
|
|
||||||
// HashMap to contain information relating to the Players.
|
// HashMap to contain information relating to the Players.
|
||||||
public HashMap<String, MVPlayerSession> playerSessions = new HashMap<String, MVPlayerSession>();
|
public HashMap<String, MVPlayerSession> playerSessions = new HashMap<String, MVPlayerSession>();
|
||||||
private PurgeWorlds worldPurger;
|
private PurgeWorlds worldPurger;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
// Create our DataFolder
|
// Create our DataFolder
|
||||||
getDataFolder().mkdirs();
|
getDataFolder().mkdirs();
|
||||||
// Setup our Debug Log
|
// Setup our Debug Log
|
||||||
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
||||||
|
|
||||||
// Setup & Load our Configuration files.
|
// Setup & Load our Configuration files.
|
||||||
loadConfigs();
|
loadConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Output a little snippet to show it's enabled.
|
// Output a little snippet to show it's enabled.
|
||||||
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors());
|
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors());
|
||||||
|
|
||||||
// Setup all the Events the plugin needs to Monitor.
|
// Setup all the Events the plugin needs to Monitor.
|
||||||
this.registerEvents();
|
this.registerEvents();
|
||||||
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
|
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
|
||||||
@ -103,16 +102,16 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
this.setupEconomy();
|
this.setupEconomy();
|
||||||
// Call the Function to assign all the Commands to their Class.
|
// Call the Function to assign all the Commands to their Class.
|
||||||
this.registerCommands();
|
this.registerCommands();
|
||||||
|
|
||||||
// Start the Update Checker
|
// Start the Update Checker
|
||||||
// updateCheck = new UpdateChecker(this.getDescription().getName(), this.getDescription().getVersion());
|
// updateCheck = new UpdateChecker(this.getDescription().getName(), this.getDescription().getVersion());
|
||||||
|
|
||||||
// Call the Function to load all the Worlds and setup the HashMap
|
// Call the Function to load all the Worlds and setup the HashMap
|
||||||
// When called with null, it tries to load ALL
|
// When called with null, it tries to load ALL
|
||||||
// this function will be called every time a plugin registers a new envtype with MV
|
// this function will be called every time a plugin registers a new envtype with MV
|
||||||
this.loadWorlds(true);
|
this.loadWorlds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to Register all the Events needed.
|
* Function to Register all the Events needed.
|
||||||
*/
|
*/
|
||||||
@ -125,25 +124,25 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth.
|
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth.
|
||||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.
|
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this.pluginListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this.pluginListener, Priority.Monitor, this);
|
||||||
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this.pluginListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this.pluginListener, Priority.Monitor, this);
|
||||||
|
|
||||||
// pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this); // To prevent Blocks being destroyed.
|
// pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this); // To prevent Blocks being destroyed.
|
||||||
// pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); // To prevent Blocks being placed.
|
// pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); // To prevent Blocks being placed.
|
||||||
// pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this); // Try to prevent Ghasts from blowing up structures.
|
// pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this); // Try to prevent Ghasts from blowing up structures.
|
||||||
// pm.registerEvent(Event.Type.EXPLOSION_PRIMED, entityListener, Priority.Normal, this); // Try to prevent Ghasts from blowing up structures.
|
// pm.registerEvent(Event.Type.EXPLOSION_PRIMED, entityListener, Priority.Normal, this); // Try to prevent Ghasts from blowing up structures.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for Permissions plugin and then setup our own Permissions Handler.
|
* Check for Permissions plugin and then setup our own Permissions Handler.
|
||||||
*/
|
*/
|
||||||
private void setupPermissions() {
|
private void setupPermissions() {
|
||||||
Plugin p = this.getServer().getPluginManager().getPlugin("Permissions");
|
Plugin p = this.getServer().getPluginManager().getPlugin("Permissions");
|
||||||
|
|
||||||
if (MultiverseCore.Permissions == null) {
|
if (MultiverseCore.Permissions == null) {
|
||||||
if (p != null && p.isEnabled()) {
|
if (p != null && p.isEnabled()) {
|
||||||
MultiverseCore.Permissions = ((Permissions) p).getHandler();
|
MultiverseCore.Permissions = ((Permissions) p).getHandler();
|
||||||
@ -151,20 +150,20 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for the iConomy plugin and set it up accordingly.
|
* Check for the iConomy plugin and set it up accordingly.
|
||||||
*/
|
*/
|
||||||
private void setupEconomy() {
|
private void setupEconomy() {
|
||||||
Plugin test = this.getServer().getPluginManager().getPlugin("iConomy");
|
Plugin test = this.getServer().getPluginManager().getPlugin("iConomy");
|
||||||
|
|
||||||
if (MultiverseCore.iConomy == null) {
|
if (MultiverseCore.iConomy == null) {
|
||||||
if (test != null) {
|
if (test != null) {
|
||||||
MultiverseCore.iConomy = (iConomy) test;
|
MultiverseCore.iConomy = (iConomy) test;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Configuration files OR create the default config files.
|
* Load the Configuration files OR create the default config files.
|
||||||
*/
|
*/
|
||||||
@ -172,11 +171,11 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
// Call the defaultConfiguration class to create the config files if they don't already exist.
|
// Call the defaultConfiguration class to create the config files if they don't already exist.
|
||||||
new DefaultConfiguration(getDataFolder(), "config.yml");
|
new DefaultConfiguration(getDataFolder(), "config.yml");
|
||||||
new DefaultConfiguration(getDataFolder(), "worlds.yml");
|
new DefaultConfiguration(getDataFolder(), "worlds.yml");
|
||||||
|
|
||||||
// Now grab the Configuration Files.
|
// Now grab the Configuration Files.
|
||||||
this.configMV = new Configuration(new File(getDataFolder(), "config.yml"));
|
this.configMV = new Configuration(new File(getDataFolder(), "config.yml"));
|
||||||
this.configWorlds = new Configuration(new File(getDataFolder(), "worlds.yml"));
|
this.configWorlds = new Configuration(new File(getDataFolder(), "worlds.yml"));
|
||||||
|
|
||||||
// Now attempt to Load the configurations.
|
// Now attempt to Load the configurations.
|
||||||
try {
|
try {
|
||||||
this.configMV.load();
|
this.configMV.load();
|
||||||
@ -184,18 +183,18 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log(Level.INFO, "- Failed to load config.yml");
|
log(Level.INFO, "- Failed to load config.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.configWorlds.load();
|
this.configWorlds.load();
|
||||||
log(Level.INFO, "- World Config -- Loaded");
|
log(Level.INFO, "- World Config -- Loaded");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log(Level.INFO, "- Failed to load worlds.yml");
|
log(Level.INFO, "- Failed to load worlds.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the Debug option, we'll default to false because this option will not be in the default config.
|
// Setup the Debug option, we'll default to false because this option will not be in the default config.
|
||||||
this.debug = this.configMV.getBoolean("debug", false);
|
this.debug = this.configMV.getBoolean("debug", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Multiverse-Core commands to DThielke's Command Manager.
|
* Register Multiverse-Core commands to DThielke's Command Manager.
|
||||||
*/
|
*/
|
||||||
@ -220,7 +219,7 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
this.commandManager.addCommand(new EnvironmentCommand(this));
|
this.commandManager.addCommand(new EnvironmentCommand(this));
|
||||||
this.commandManager.addCommand(new PurgeCommand(this));
|
this.commandManager.addCommand(new PurgeCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Worlds & Settings from the configuration file.
|
* Load the Worlds & Settings from the configuration file.
|
||||||
*/
|
*/
|
||||||
@ -229,12 +228,12 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
// Grab all the Worlds from the Config.
|
// Grab all the Worlds from the Config.
|
||||||
List<String> worldKeys = this.configWorlds.getKeys("worlds");
|
List<String> worldKeys = this.configWorlds.getKeys("worlds");
|
||||||
|
|
||||||
// Force the worlds to be loaded, ie don't just load new worlds.
|
// Force the worlds to be loaded, ie don't just load new worlds.
|
||||||
if (forceLoad) {
|
if (forceLoad) {
|
||||||
this.worlds.clear();
|
this.worlds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the list is not null.
|
// Check that the list is not null.
|
||||||
if (worldKeys != null) {
|
if (worldKeys != null) {
|
||||||
for (String worldKey : worldKeys) {
|
for (String worldKey : worldKeys) {
|
||||||
@ -245,27 +244,27 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
// Grab the initial values from the config file.
|
// Grab the initial values from the config file.
|
||||||
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||||
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", "");
|
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", "");
|
||||||
|
|
||||||
String generatorstring = this.configWorlds.getString("worlds." + worldKey + ".generator");
|
String generatorstring = this.configWorlds.getString("worlds." + worldKey + ".generator");
|
||||||
|
|
||||||
addWorld(worldKey, getEnvFromString(environment), seedString, generatorstring);
|
addWorld(worldKey, getEnvFromString(environment), seedString, generatorstring);
|
||||||
|
|
||||||
// Increment the world count
|
// Increment the world count
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the worlds created by the default server were loaded into MV, useful for first time runs
|
// Ensure that the worlds created by the default server were loaded into MV, useful for first time runs
|
||||||
// count += loadDefaultWorlds();
|
// count += loadDefaultWorlds();
|
||||||
// TODO: This was taken out because some people don't want nether! Instead show a message to people who have MVImport
|
// TODO: This was taken out because some people don't want nether! Instead show a message to people who have MVImport
|
||||||
// and tell them to do MVImports for their worlds!
|
// and tell them to do MVImports for their worlds!
|
||||||
|
|
||||||
// Simple Output to the Console to show how many Worlds were loaded.
|
// Simple Output to the Console to show how many Worlds were loaded.
|
||||||
log(Level.INFO, count + " - World(s) loaded.");
|
log(Level.INFO, count + " - World(s) loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int loadDefaultWorlds() {
|
private int loadDefaultWorlds() {
|
||||||
@ -276,22 +275,22 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
addWorld(world.getName(), Environment.NORMAL, null, null);
|
addWorld(world.getName(), Environment.NORMAL, null, null);
|
||||||
additonalWorldsLoaded++;
|
additonalWorldsLoaded++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This next one could be null if they have it disabled in server.props
|
// This next one could be null if they have it disabled in server.props
|
||||||
World world_nether = this.getServer().getWorld(world.getName() + "_nether");
|
World world_nether = this.getServer().getWorld(world.getName() + "_nether");
|
||||||
if (world_nether != null && !this.worlds.containsKey(world_nether.getName())) {
|
if (world_nether != null && !this.worlds.containsKey(world_nether.getName())) {
|
||||||
addWorld(world_nether.getName(), Environment.NETHER, null, null);
|
addWorld(world_nether.getName(), Environment.NETHER, null, null);
|
||||||
additonalWorldsLoaded++;
|
additonalWorldsLoaded++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return additonalWorldsLoaded;
|
return additonalWorldsLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new World to the Multiverse Setup.
|
* Add a new World to the Multiverse Setup.
|
||||||
*
|
*
|
||||||
* Isn't there a prettier way to do this??!!?!?!
|
* Isn't there a prettier way to do this??!!?!?!
|
||||||
*
|
*
|
||||||
* @param name World Name
|
* @param name World Name
|
||||||
* @param environment Environment Type
|
* @param environment Environment Type
|
||||||
*/
|
*/
|
||||||
@ -305,7 +304,7 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
seed = (long) seedString.hashCode();
|
seed = (long) seedString.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String generatorID = null;
|
String generatorID = null;
|
||||||
String generatorName = null;
|
String generatorName = null;
|
||||||
if (generator != null) {
|
if (generator != null) {
|
||||||
@ -314,20 +313,20 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
generatorName = split[0];
|
generatorName = split[0];
|
||||||
generatorID = id;
|
generatorID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkGenerator customGenerator = getChunkGenerator(generatorName, generatorID, name);
|
ChunkGenerator customGenerator = getChunkGenerator(generatorName, generatorID, name);
|
||||||
|
|
||||||
if (customGenerator == null && generator != null && !generator.isEmpty()) {
|
if (customGenerator == null && generator != null && (generator.length() > 0)) {
|
||||||
if (!pluginExists(generatorName)) {
|
if (!pluginExists(generatorName)) {
|
||||||
log(Level.WARNING, "Could not find plugin: " + generatorName);
|
log(Level.WARNING, "Could not find plugin: " + generatorName);
|
||||||
} else {
|
} else {
|
||||||
log(Level.WARNING, "Found plugin: " + generatorName + ", but did not find generatorID: " + generatorID);
|
log(Level.WARNING, "Found plugin: " + generatorName + ", but did not find generatorID: " + generatorID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = null;
|
World world = null;
|
||||||
if (seed != null) {
|
if (seed != null) {
|
||||||
if (customGenerator != null) {
|
if (customGenerator != null) {
|
||||||
@ -350,31 +349,31 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
this.worldPurger.purgeWorld(null, mvworld);
|
this.worldPurger.purgeWorld(null, mvworld);
|
||||||
this.worlds.put(name, mvworld);
|
this.worlds.put(name, mvworld);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean pluginExists(String generator) {
|
private boolean pluginExists(String generator) {
|
||||||
Plugin plugin = getServer().getPluginManager().getPlugin(generator);
|
Plugin plugin = getServer().getPluginManager().getPlugin(generator);
|
||||||
return plugin != null;
|
return plugin != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) {
|
private ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) {
|
||||||
if (generator == null) {
|
if (generator == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin plugin = getServer().getPluginManager().getPlugin(generator);
|
Plugin plugin = getServer().getPluginManager().getPlugin(generator);
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return plugin.getDefaultWorldGenerator(worldName, generatorID);
|
return plugin.getDefaultWorldGenerator(worldName, generatorID);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the world from the Multiverse list
|
* Remove the world from the Multiverse list
|
||||||
*
|
*
|
||||||
* @param name The name of the world to remove
|
* @param name The name of the world to remove
|
||||||
* @return True if success, false if failure.
|
* @return True if success, false if failure.
|
||||||
*/
|
*/
|
||||||
@ -385,10 +384,10 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the world from the Multiverse list and from the config
|
* Remove the world from the Multiverse list and from the config
|
||||||
*
|
*
|
||||||
* @param name The name of the world to remove
|
* @param name The name of the world to remove
|
||||||
* @return True if success, false if failure.
|
* @return True if success, false if failure.
|
||||||
*/
|
*/
|
||||||
@ -398,10 +397,10 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
this.configWorlds.save();
|
this.configWorlds.save();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the world from the Multiverse list, from the config and deletes the folder
|
* Remove the world from the Multiverse list, from the config and deletes the folder
|
||||||
*
|
*
|
||||||
* @param name The name of the world to remove
|
* @param name The name of the world to remove
|
||||||
* @return True if success, false if failure.
|
* @return True if success, false if failure.
|
||||||
*/
|
*/
|
||||||
@ -413,10 +412,10 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a folder Courtesy of: lithium3141
|
* Delete a folder Courtesy of: lithium3141
|
||||||
*
|
*
|
||||||
* @param file The folder to delete
|
* @param file The folder to delete
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
@ -436,20 +435,19 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What happens when the plugin gets disabled...
|
* What happens when the plugin gets disabled...
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
debugLog.close();
|
debugLog.close();
|
||||||
MultiverseCore.Permissions = null;
|
MultiverseCore.Permissions = null;
|
||||||
log(Level.INFO, "- Disabled");
|
log(Level.INFO, "- Disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab the players session if one exists, otherwise create a session then return it.
|
* Grab the players session if one exists, otherwise create a session then return it.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -461,36 +459,36 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
return this.playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab and return the Teleport class.
|
* Grab and return the Teleport class.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public MVTeleport getTeleporter() {
|
public MVTeleport getTeleporter() {
|
||||||
return new MVTeleport(this);
|
return new MVTeleport(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab the iConomy setup.
|
* Grab the iConomy setup.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static iConomy getiConomy() {
|
public static iConomy getiConomy() {
|
||||||
return iConomy;
|
return iConomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab the Permissions Handler for MultiVerse
|
* Grab the Permissions Handler for MultiVerse
|
||||||
*/
|
*/
|
||||||
public MVPermissions getPermissions() {
|
public MVPermissions getPermissions() {
|
||||||
return this.ph;
|
return this.ph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PurgeWorlds getWorldPurger() {
|
public PurgeWorlds getWorldPurger() {
|
||||||
return this.worldPurger;
|
return this.worldPurger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onCommand
|
* onCommand
|
||||||
*/
|
*/
|
||||||
@ -502,10 +500,10 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return this.commandManager.dispatch(sender, command, commandLabel, args);
|
return this.commandManager.dispatch(sender, command, commandLabel, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print messages to the server Log as well as to our DebugLog. 'debugLog' is used to seperate Heroes information from the Servers Log Output.
|
* Print messages to the server Log as well as to our DebugLog. 'debugLog' is used to seperate Heroes information from the Servers Log Output.
|
||||||
*
|
*
|
||||||
* @param level
|
* @param level
|
||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
@ -513,10 +511,10 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
log.log(level, this.tag + " " + msg);
|
log.log(level, this.tag + " " + msg);
|
||||||
debugLog.log(level, this.tag + " " + msg);
|
debugLog.log(level, this.tag + " " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the standard Server Console.
|
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the standard Server Console.
|
||||||
*
|
*
|
||||||
* @param level
|
* @param level
|
||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
@ -526,20 +524,20 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
debugLog.log(level, "[Debug] " + msg);
|
debugLog.log(level, "[Debug] " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the Authors Array into a readable String with ',' and 'and'.
|
* Parse the Authors Array into a readable String with ',' and 'and'.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getAuthors() {
|
private String getAuthors() {
|
||||||
String authors = "";
|
String authors = "";
|
||||||
ArrayList<String> auths = this.getDescription().getAuthors();
|
ArrayList<String> auths = this.getDescription().getAuthors();
|
||||||
|
|
||||||
if (auths.size() == 1) {
|
if (auths.size() == 1) {
|
||||||
return auths.get(0);
|
return auths.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < auths.size(); i++) {
|
for (int i = 0; i < auths.size(); i++) {
|
||||||
if (i == this.getDescription().getAuthors().size() - 1) {
|
if (i == this.getDescription().getAuthors().size() - 1) {
|
||||||
authors += " and " + this.getDescription().getAuthors().get(i);
|
authors += " and " + this.getDescription().getAuthors().get(i);
|
||||||
@ -549,18 +547,18 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return authors.substring(2);
|
return authors.substring(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandManager getCommandManager() {
|
public CommandManager getCommandManager() {
|
||||||
return this.commandManager;
|
return this.commandManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return this.tag;
|
return this.tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This code should get moved somewhere more appropriate, but for now, it's here.
|
* This code should get moved somewhere more appropriate, but for now, it's here.
|
||||||
*
|
*
|
||||||
* @param env
|
* @param env
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -568,33 +566,33 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
// 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"))
|
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
|
||||||
env = "NETHER";
|
env = "NETHER";
|
||||||
|
|
||||||
if (env.equalsIgnoreCase("SKYLANDS") || env.equalsIgnoreCase("SKYLAND") || env.equalsIgnoreCase("STARWARS"))
|
if (env.equalsIgnoreCase("SKYLANDS") || env.equalsIgnoreCase("SKYLAND") || env.equalsIgnoreCase("STARWARS"))
|
||||||
env = "SKYLANDS";
|
env = "SKYLANDS";
|
||||||
|
|
||||||
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
|
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
|
||||||
env = "NORMAL";
|
env = "NORMAL";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Environment.valueOf(env);
|
return Environment.valueOf(env);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Find out where to put these next 3 methods! I just stuck them here for now --FF
|
// TODO: Find out where to put these next 3 methods! I just stuck them here for now --FF
|
||||||
|
|
||||||
public Collection<MVWorld> getMVWorlds() {
|
public Collection<MVWorld> getMVWorlds() {
|
||||||
return this.worlds.values();
|
return this.worlds.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MVWorld getMVWorld(String name) {
|
public MVWorld getMVWorld(String name) {
|
||||||
if (this.worlds.containsKey(name)) {
|
if (this.worlds.containsKey(name)) {
|
||||||
return this.worlds.get(name);
|
return this.worlds.get(name);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMVWorld(String name) {
|
public boolean isMVWorld(String name) {
|
||||||
return this.worlds.containsKey(name);
|
return this.worlds.containsKey(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user