Merge enum branch into master

This commit is contained in:
ljacqu
2015-11-26 21:45:06 +01:00
21 changed files with 537 additions and 155 deletions
@@ -17,7 +17,6 @@ public class GeoLiteAPI {
"available at http://www.maxmind.com";
private static final String GEOIP_URL = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry" +
"/GeoIP.dat.gz";
private static final Wrapper wrapper = new Wrapper(AuthMe.getInstance());
private static final AuthMe plugin = AuthMe.getInstance();
private static LookupService lookupService;
@@ -10,10 +10,14 @@ import java.io.StringWriter;
/**
* Utility class for String operations.
*/
public class StringUtils {
public final class StringUtils {
public static final String newline = System.getProperty("line.separator");
private StringUtils() {
// Utility class
}
/**
* Get the difference of two strings.
*
@@ -26,7 +26,7 @@ import java.util.Collections;
*/
public final class Utils {
private static final AuthMe plugin;
private static AuthMe plugin;
private static Wrapper wrapper;
private static boolean getOnlinePlayersIsCollection = false;
@@ -34,7 +34,7 @@ public final class Utils {
static {
plugin = AuthMe.getInstance();
wrapper = new Wrapper(plugin);
wrapper = Wrapper.getInstance();
initializeOnlinePlayersIsCollectionField();
}
@@ -116,9 +116,10 @@ public final class Utils {
// Get the permissions manager, and make sure it's valid
PermissionsManager permsMan = plugin.getPermissionsManager();
if (permsMan == null)
ConsoleLogger.showError("Failed to access permissions manager instance, shutting down.");
assert permsMan != null;
if (permsMan == null) {
ConsoleLogger.showError("Failed to access permissions manager instance, aborting.");
return false;
}
// Remove old groups
permsMan.removeGroups(player, Arrays.asList(Settings.unRegisteredGroup,
@@ -13,22 +13,31 @@ import java.util.logging.Logger;
*/
public class Wrapper {
private AuthMe authMe;
private static Wrapper singleton;
public Wrapper(AuthMe authMe) {
this.authMe = authMe;
/**
* Package-private constructor for testing purposes to inject a mock instance.
*/
Wrapper() {
}
public static Wrapper getInstance() {
if (singleton == null) {
singleton = new Wrapper();
}
return singleton;
}
public AuthMe getAuthMe() {
return authMe;
return AuthMe.getInstance();
}
public Server getServer() {
return authMe.getServer();
return getAuthMe().getServer();
}
public Logger getLogger() {
return authMe.getLogger();
return getAuthMe().getLogger();
}
public BukkitScheduler getScheduler() {