#761 Fix removal and restoration of primary permission group
- Improve how a player is being switched between permission groups (add new group before removing old one) - Remove group handling logic from LimboCache: AuthGroupHandler is now solely responsible for changing the player's permission group
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.process.login;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.limbo.LimboCache;
|
||||
import fr.xephi.authme.data.limbo.LimboPlayer;
|
||||
@@ -8,17 +7,17 @@ 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;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.TeleportationService;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
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.plugin.PluginManager;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -28,9 +27,6 @@ import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_IN
|
||||
|
||||
public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
|
||||
@Inject
|
||||
private AuthMe plugin;
|
||||
|
||||
@Inject
|
||||
private BungeeService bungeeService;
|
||||
|
||||
@@ -40,9 +36,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Inject
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@Inject
|
||||
private TeleportationService teleportationService;
|
||||
|
||||
@@ -53,7 +46,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
private CommandManager commandManager;
|
||||
|
||||
@Inject
|
||||
private Settings settings;
|
||||
private CommonService commonService;
|
||||
|
||||
@Inject
|
||||
private WelcomeMessageConfiguration welcomeMessageConfiguration;
|
||||
@@ -63,7 +56,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
|
||||
private void restoreInventory(Player player) {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
||||
pluginManager.callEvent(event);
|
||||
bukkitService.callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
player.updateInventory();
|
||||
}
|
||||
@@ -80,8 +73,9 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
// do we really need to use location from database for now?
|
||||
// because LimboCache#restoreData teleport player to last location.
|
||||
}
|
||||
commonService.setGroup(player, AuthGroupType.LOGGED_IN);
|
||||
|
||||
if (settings.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||
if (commonService.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||
restoreInventory(player);
|
||||
}
|
||||
|
||||
@@ -98,7 +92,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
if (commonService.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
}
|
||||
|
||||
@@ -108,8 +102,8 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
|
||||
// Login is done, display welcome message
|
||||
List<String> welcomeMessage = welcomeMessageConfiguration.getWelcomeMessage(player);
|
||||
if (settings.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
|
||||
if (settings.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) {
|
||||
if (commonService.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
|
||||
if (commonService.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) {
|
||||
welcomeMessage.forEach(bukkitService::broadcastMessage);
|
||||
} else {
|
||||
welcomeMessage.forEach(player::sendMessage);
|
||||
|
||||
Reference in New Issue
Block a user