mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-08 11:40:58 +01:00
Fix bugs in purge classes, cleanup
- OfflinePlayer objects were never mapped to names - Essentials purge was run even if setting was disabled - Console user saw messages twice - Misc: trivial field reorderings, change DefaultPermission to be null safe - Permissions: do not expose PermissionHandler just to get its type
This commit is contained in:
parent
a0abe3d19d
commit
ff2f8a63bb
@ -234,11 +234,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Some statically injected things
|
// Some statically injected things
|
||||||
initializer.register(PlayerCache.class, PlayerCache.getInstance());
|
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);
|
permsMan = initializer.get(PermissionsManager.class);
|
||||||
bukkitService = initializer.get(BukkitService.class);
|
bukkitService = initializer.get(BukkitService.class);
|
||||||
pluginHooks = initializer.get(PluginHooks.class);
|
pluginHooks = initializer.get(PluginHooks.class);
|
||||||
@ -296,8 +291,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!");
|
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!");
|
||||||
|
|
||||||
// If server is using PermissionsBukkit, print a warning that some features may not be supported
|
// If server is using PermissionsBukkit, print a warning that some features may not be supported
|
||||||
if (permsMan.isEnabled() &&
|
if (PermissionsSystemType.PERMISSIONS_BUKKIT.equals(permsMan.getPermissionSystem())) {
|
||||||
permsMan.getHandler().getPermissionSystem() == PermissionsSystemType.PERMISSIONS_BUKKIT) {
|
|
||||||
ConsoleLogger.info("Warning! This server uses PermissionsBukkit for permissions! Some permissions features may not be supported!");
|
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!");
|
ConsoleLogger.showError("THE SERVER IS GOING TO SHUT DOWN AS DEFINED IN THE CONFIGURATION!");
|
||||||
getServer().shutdown();
|
getServer().shutdown();
|
||||||
} else {
|
} else {
|
||||||
getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ public class LimboPlayer {
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final boolean fly;
|
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 timeoutTask = null;
|
||||||
private BukkitTask messageTask = null;
|
private BukkitTask messageTask = null;
|
||||||
private boolean operator = false;
|
|
||||||
private String group;
|
|
||||||
|
|
||||||
public LimboPlayer(String name, Location loc, boolean operator,
|
public LimboPlayer(String name, Location loc, boolean operator,
|
||||||
String group, boolean fly) {
|
String group, boolean fly) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.permission;
|
package fr.xephi.authme.permission;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,8 +29,8 @@ public enum DefaultPermission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean evaluateOffline(String name) {
|
public boolean evaluateOffline(String name) {
|
||||||
// TODO Gnat008 20160617: Is this safe?
|
// TODO #784: Check if there is an elegant way to evaluate OP status
|
||||||
return Bukkit.getOfflinePlayer(name).isOp();
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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() {
|
public PermissionsSystemType getPermissionSystem() {
|
||||||
return handler;
|
return isEnabled() ? handler.getPermissionSystem() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -238,7 +239,7 @@ public class PurgeService implements Reloadable {
|
|||||||
* @param cleared List of String
|
* @param cleared List of String
|
||||||
*/
|
*/
|
||||||
synchronized void purgeEssentials(Set<OfflinePlayer> cleared) {
|
synchronized void purgeEssentials(Set<OfflinePlayer> cleared) {
|
||||||
if (!settings.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES) && !pluginHooks.isEssentialsAvailable()) {
|
if (!settings.getProperty(PurgeSettings.REMOVE_ESSENTIALS_FILES)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +282,8 @@ public class PurgeService implements Reloadable {
|
|||||||
|
|
||||||
private static void logAndSendMessage(CommandSender sender, String message) {
|
private static void logAndSendMessage(CommandSender sender, String message) {
|
||||||
ConsoleLogger.info(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);
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,10 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PurgeTask extends BukkitRunnable {
|
public class PurgeTask extends BukkitRunnable {
|
||||||
|
|
||||||
private PurgeService purgeService;
|
|
||||||
|
|
||||||
//how many players we should check for each tick
|
//how many players we should check for each tick
|
||||||
private static final int INTERVALL_CHECK = 5;
|
private static final int INTERVALL_CHECK = 5;
|
||||||
|
|
||||||
|
private final PurgeService purgeService;
|
||||||
private final UUID sender;
|
private final UUID sender;
|
||||||
private final Set<String> toPurge;
|
private final Set<String> toPurge;
|
||||||
|
|
||||||
@ -52,15 +51,14 @@ public class PurgeTask extends BukkitRunnable {
|
|||||||
Set<String> namePortion = new HashSet<String>(INTERVALL_CHECK);
|
Set<String> namePortion = new HashSet<String>(INTERVALL_CHECK);
|
||||||
for (int i = 0; i < INTERVALL_CHECK; i++) {
|
for (int i = 0; i < INTERVALL_CHECK; i++) {
|
||||||
int nextPosition = (currentPage * INTERVALL_CHECK) + i;
|
int nextPosition = (currentPage * INTERVALL_CHECK) + i;
|
||||||
if (offlinePlayers.length >= nextPosition) {
|
if (offlinePlayers.length <= nextPosition) {
|
||||||
//no more offline players on this page
|
//no more offline players on this page
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer offlinePlayer = offlinePlayers[nextPosition];
|
OfflinePlayer offlinePlayer = offlinePlayers[nextPosition];
|
||||||
String offlineName = offlinePlayer.getName();
|
|
||||||
//remove to speed up later lookups
|
//remove to speed up later lookups
|
||||||
if (toPurge.remove(offlineName.toLowerCase())) {
|
if (toPurge.remove(offlinePlayer.getName().toLowerCase())) {
|
||||||
playerPortion.add(offlinePlayer);
|
playerPortion.add(offlinePlayer);
|
||||||
namePortion.add(offlinePlayer.getName());
|
namePortion.add(offlinePlayer.getName());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user