diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 75606f3e3..a4a13b988 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -234,11 +234,6 @@ public class AuthMe extends JavaPlugin { // Some statically injected things initializer.register(PlayerCache.class, PlayerCache.getInstance()); - // Note ljacqu 20160612: Instantiate LimboCache first to make sure it is instantiated - // (because sometimes it's used via LimboCache.getInstance()) - // Once LimboCache#getInstance() no longer exists this can be removed! - initializer.get(LimboCache.class); - permsMan = initializer.get(PermissionsManager.class); bukkitService = initializer.get(BukkitService.class); pluginHooks = initializer.get(PluginHooks.class); @@ -296,8 +291,7 @@ public class AuthMe extends JavaPlugin { ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!"); // If server is using PermissionsBukkit, print a warning that some features may not be supported - if (permsMan.isEnabled() && - permsMan.getHandler().getPermissionSystem() == PermissionsSystemType.PERMISSIONS_BUKKIT) { + if (PermissionsSystemType.PERMISSIONS_BUKKIT.equals(permsMan.getPermissionSystem())) { ConsoleLogger.info("Warning! This server uses PermissionsBukkit for permissions! Some permissions features may not be supported!"); } @@ -497,7 +491,7 @@ public class AuthMe extends JavaPlugin { ConsoleLogger.showError("THE SERVER IS GOING TO SHUT DOWN AS DEFINED IN THE CONFIGURATION!"); getServer().shutdown(); } else { - getServer().getPluginManager().disablePlugin(AuthMe.getInstance()); + getServer().getPluginManager().disablePlugin(this); } } diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java index 6295bbb7d..6029e6dad 100644 --- a/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java +++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java @@ -11,11 +11,11 @@ public class LimboPlayer { private final String name; private final boolean fly; - private Location loc = null; + private final boolean operator; + private final String group; + private final Location loc; private BukkitTask timeoutTask = null; private BukkitTask messageTask = null; - private boolean operator = false; - private String group; public LimboPlayer(String name, Location loc, boolean operator, String group, boolean fly) { diff --git a/src/main/java/fr/xephi/authme/permission/DefaultPermission.java b/src/main/java/fr/xephi/authme/permission/DefaultPermission.java index 31838b6a5..d4b542cd9 100644 --- a/src/main/java/fr/xephi/authme/permission/DefaultPermission.java +++ b/src/main/java/fr/xephi/authme/permission/DefaultPermission.java @@ -1,6 +1,5 @@ package fr.xephi.authme.permission; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; /** @@ -30,8 +29,8 @@ public enum DefaultPermission { @Override public boolean evaluateOffline(String name) { - // TODO Gnat008 20160617: Is this safe? - return Bukkit.getOfflinePlayer(name).isOp(); + // TODO #784: Check if there is an elegant way to evaluate OP status + return false; } }, diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 90199958c..0e3d57b30 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -217,12 +217,12 @@ public class PermissionsManager { } /** - * Get the current permissions system handler. + * Return the permissions system that is hooked into. * - * @return The permissions system handler. + * @return The permissions system, or null. */ - public PermissionHandler getHandler() { - return handler; + public PermissionsSystemType getPermissionSystem() { + return isEnabled() ? handler.getPermissionSystem() : null; } /** diff --git a/src/main/java/fr/xephi/authme/task/PurgeService.java b/src/main/java/fr/xephi/authme/task/PurgeService.java index baa4e9eb9..7549371b1 100644 --- a/src/main/java/fr/xephi/authme/task/PurgeService.java +++ b/src/main/java/fr/xephi/authme/task/PurgeService.java @@ -15,6 +15,7 @@ import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -238,7 +239,7 @@ public class PurgeService implements Reloadable { * @param cleared List of String */ synchronized void purgeEssentials(Set cleared) { - if (!settings.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES) && !pluginHooks.isEssentialsAvailable()) { + if (!settings.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES)) { return; } @@ -281,7 +282,8 @@ public class PurgeService implements Reloadable { private static void logAndSendMessage(CommandSender sender, String message) { ConsoleLogger.info(message); - if (sender != null) { + // Make sure sender is not console user, which will see the message from ConsoleLogger already + if (sender != null && !(sender instanceof ConsoleCommandSender)) { sender.sendMessage(message); } } diff --git a/src/main/java/fr/xephi/authme/task/PurgeTask.java b/src/main/java/fr/xephi/authme/task/PurgeTask.java index e2252da8d..d06367592 100644 --- a/src/main/java/fr/xephi/authme/task/PurgeTask.java +++ b/src/main/java/fr/xephi/authme/task/PurgeTask.java @@ -14,11 +14,10 @@ import java.util.UUID; public class PurgeTask extends BukkitRunnable { - private PurgeService purgeService; - //how many players we should check for each tick private static final int INTERVALL_CHECK = 5; + private final PurgeService purgeService; private final UUID sender; private final Set toPurge; @@ -52,15 +51,14 @@ public class PurgeTask extends BukkitRunnable { Set namePortion = new HashSet(INTERVALL_CHECK); for (int i = 0; i < INTERVALL_CHECK; i++) { int nextPosition = (currentPage * INTERVALL_CHECK) + i; - if (offlinePlayers.length >= nextPosition) { + if (offlinePlayers.length <= nextPosition) { //no more offline players on this page break; } OfflinePlayer offlinePlayer = offlinePlayers[nextPosition]; - String offlineName = offlinePlayer.getName(); //remove to speed up later lookups - if (toPurge.remove(offlineName.toLowerCase())) { + if (toPurge.remove(offlinePlayer.getName().toLowerCase())) { playerPortion.add(offlinePlayer); namePortion.add(offlinePlayer.getName()); }