Create Wrapper as singleton; fix UtilsTest
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user