Start main class cleanup 1/?

This commit is contained in:
Gabriele C 2015-12-23 12:12:00 +01:00
parent 8bfb56f34e
commit 0a2f26deea

View File

@ -76,39 +76,21 @@ import java.util.logging.Logger;
*/ */
public class AuthMe extends JavaPlugin { public class AuthMe extends JavaPlugin {
/** // Defines the name of the plugin.
* Defines the name of the plugin.
*/
private static final String PLUGIN_NAME = "AuthMeReloaded"; private static final String PLUGIN_NAME = "AuthMeReloaded";
// Default version and build number values;
private static String pluginVersion = "N/D"; private static String pluginVersion = "N/D";
private static String pluginBuildNumber = "Unknown"; private static String pluginBuildNumber = "Unknown";
/*
* Private Instances
* TODO: should we set every instance to null as initial status?
*/
private static AuthMe plugin; private static AuthMe plugin;
private static Server server; private static Server server;
private static Wrapper wrapper = Wrapper.getInstance(); private static Wrapper wrapper = Wrapper.getInstance();
private Management management; private Management management;
public NewAPI api;
public SendMailSSL mail;
public DataManager dataManager;
public DataSource database;
public OtherAccounts otherAccounts;
public Location essentialsSpawn;
// Hooks TODO: Move into modules
public Essentials ess;
public MultiverseCore multiverse;
public CombatTagPlus combatTagPlus;
public AuthMeInventoryPacketAdapter inventoryProtector;
// Data maps and stuff
// TODO: Move into a manager
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
private CommandHandler commandHandler = null; private CommandHandler commandHandler = null;
private PermissionsManager permsMan = null; private PermissionsManager permsMan = null;
private Settings settings; private Settings settings;
@ -116,9 +98,34 @@ public class AuthMe extends JavaPlugin {
private JsonCache playerBackup; private JsonCache playerBackup;
private ModuleManager moduleManager; private ModuleManager moduleManager;
// Public Instances
public NewAPI api;
public SendMailSSL mail;
public DataManager dataManager;
public DataSource database;
public OtherAccounts otherAccounts;
public Location essentialsSpawn;
/*
* Plugin Hooks
* TODO: Move into modules
*/
public Essentials ess;
public MultiverseCore multiverse;
public CombatTagPlus combatTagPlus;
public AuthMeInventoryPacketAdapter inventoryProtector;
/*
* Maps and stuff
* TODO: Clean up and Move into a manager
*/
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
/** /**
* Returns the plugin's instance. * Get the plugin's instance.
*
* @return AuthMe * @return AuthMe
*/ */
public static AuthMe getInstance() { public static AuthMe getInstance() {
@ -127,52 +134,46 @@ public class AuthMe extends JavaPlugin {
/** /**
* Get the plugin's name. * Get the plugin's name.
* * @return The plugin's name.
* @return Plugin name.
*/ */
public static String getPluginName() { public static String getPluginName() {
return PLUGIN_NAME; return PLUGIN_NAME;
} }
/** /**
* Get the current installed AuthMeReloaded version name. * Get the plugin's version.
* * @return The plugin's version.
* @return The version name of the currently installed AuthMeReloaded instance.
*/ */
public static String getPluginVersion() { public static String getPluginVersion() {
return pluginVersion; return pluginVersion;
} }
/** /**
* Get the current installed AuthMeReloaded version code. * Get the plugin's build number.
* * @return The plugin's build number.
* @return The version code of the currently installed AuthMeReloaded instance.
*/ */
public static String getPluginBuildNumber() { public static String getPluginBuildNumber() {
return pluginBuildNumber; return pluginBuildNumber;
} }
/** /**
* Returns the plugin's Settings. * Get the plugin's Settings.
* * @return Plugin's settings.
* @return Settings
*/ */
public Settings getSettings() { public Settings getSettings() {
return settings; return settings;
} }
/** /**
* Returns the Messages instance. * Get the Messages instance.
* * @return Plugin's messages.
* @return Messages
*/ */
public Messages getMessages() { public Messages getMessages() {
return messages; return messages;
} }
// Get version and build number of the plugin // Get version and build number of the plugin
// TODO: enhance this private void setPluginInfos() {
private void setupConstants() {
String versionRaw = this.getDescription().getVersion(); String versionRaw = this.getDescription().getVersion();
int index = versionRaw.lastIndexOf("-"); int index = versionRaw.lastIndexOf("-");
if (index != -1) { if (index != -1) {
@ -186,7 +187,6 @@ public class AuthMe extends JavaPlugin {
/** /**
* Method called when the server enables the plugin. * Method called when the server enables the plugin.
*
* @see org.bukkit.plugin.Plugin#onEnable() * @see org.bukkit.plugin.Plugin#onEnable()
*/ */
@Override @Override
@ -194,7 +194,7 @@ public class AuthMe extends JavaPlugin {
// Set various instances // Set various instances
server = getServer(); server = getServer();
plugin = this; plugin = this;
setupConstants(); setPluginInfos();
// Set up the permissions manager and command handler // Set up the permissions manager and command handler
permsMan = initializePermissionsManager(); permsMan = initializePermissionsManager();
@ -491,9 +491,6 @@ public class AuthMe extends JavaPlugin {
} }
} }
// Show the exception message and stop/unload the server/plugin as defined
// in the configuration
/** /**
* Method onDisable. * Method onDisable.
* *
@ -524,8 +521,6 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!"); ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
} }
// Initialize and setup the database
// Stop/unload the server/plugin as defined in the configuration // Stop/unload the server/plugin as defined in the configuration
public void stopOrUnload() { public void stopOrUnload() {
if (Settings.isStopEnabled) { if (Settings.isStopEnabled) {