#761 Restore permission group in sync with limbo players

- Couple AuthGroupHandler closer to the LimboService: whenever a limbo player is restored, the auth group should be restored as well. This fixes some consistency issues.
- Move AuthGroupHandler into limbo package and make it package-private
- Change permission handler to skip any empty groups (prevents odd command output e.g. for BukkitPermissions)
This commit is contained in:
ljacqu
2017-04-29 22:37:34 +02:00
parent d4c1370da6
commit e0e4cd112d
15 changed files with 47 additions and 104 deletions
@@ -9,7 +9,6 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.ProtectInventoryEvent;
import fr.xephi.authme.events.RestoreSessionEvent;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.login.AsynchronousLogin;
@@ -111,8 +110,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
final boolean isAuthAvailable = database.isAuthAvailable(name);
if (isAuthAvailable) {
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
// Protect inventory
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
ProtectInventoryEvent ev = bukkitService.createAndCallEvent(
@@ -129,14 +126,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
bukkitService.runTaskOptionallyAsync(() -> asynchronousLogin.forceLogin(player));
return;
}
} else {
// Groups logic
service.setGroup(player, AuthGroupType.UNREGISTERED);
} else if (!service.getProperty(RegistrationSettings.FORCE)) {
// Skip if registration is optional
if (!service.getProperty(RegistrationSettings.FORCE)) {
return;
}
return;
}
final int registrationTimeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
@@ -6,8 +6,6 @@ import fr.xephi.authme.data.limbo.LimboService;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RestoreInventoryEvent;
import fr.xephi.authme.listener.PlayerListener;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.BungeeService;
@@ -17,7 +15,6 @@ import fr.xephi.authme.service.TeleportationService;
import fr.xephi.authme.settings.WelcomeMessageConfiguration;
import fr.xephi.authme.settings.commandconfig.CommandManager;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.StringUtils;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
@@ -68,9 +65,8 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
public void processPlayerLogin(Player player) {
final String name = player.getName().toLowerCase();
commonService.setGroup(player, AuthGroupType.LOGGED_IN);
final LimboPlayer limbo = limboService.getLimboPlayer(name);
// Limbo contains the State of the Player before /login
if (limbo != null) {
limboService.restoreData(player);
@@ -6,7 +6,6 @@ import fr.xephi.authme.data.limbo.LimboService;
import fr.xephi.authme.events.LogoutEvent;
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.CommonService;
@@ -75,7 +74,6 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
// Set player's data to unauthenticated
limboService.createLimboPlayer(player, true);
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
}
}
@@ -3,7 +3,6 @@ package fr.xephi.authme.process.register;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.data.limbo.LimboService;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.util.PlayerUtils;
@@ -24,9 +23,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
}
public void processEmailRegister(Player player) {
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
limboService.replaceTasksAfterRegistration(player);
player.saveData();
@@ -3,7 +3,6 @@ package fr.xephi.authme.process.register;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.data.limbo.LimboService;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.service.BungeeService;
import fr.xephi.authme.service.CommonService;
@@ -48,7 +47,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
}
public void processPasswordRegister(Player player) {
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
service.send(player, MessageKey.REGISTER_SUCCESS);
if (!service.getProperty(EmailSettings.MAIL_ACCOUNT).isEmpty()) {
@@ -8,8 +8,6 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.UnregisterByAdminEvent;
import fr.xephi.authme.events.UnregisterByPlayerEvent;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupHandler;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.service.BukkitService;
@@ -50,9 +48,6 @@ public class AsynchronousUnregister implements AsynchronousProcess {
@Inject
private TeleportationService teleportationService;
@Inject
private AuthGroupHandler authGroupHandler;
@Inject
private CommandManager commandManager;
@@ -123,7 +118,6 @@ public class AsynchronousUnregister implements AsynchronousProcess {
applyBlindEffect(player);
});
}
authGroupHandler.setGroup(player, AuthGroupType.UNREGISTERED);
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
}