#761 Simplify auth group handling
This commit is contained in:
parent
d2fccdeb80
commit
7c1a9062ba
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the permission group according to the auth status of the player and the configuration.
|
* Changes the permission group according to the auth status of the player and the configuration.
|
||||||
@ -51,11 +52,10 @@ public class AuthGroupHandler implements Reloadable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String primaryGroup = "";
|
String primaryGroup = Optional
|
||||||
LimboPlayer limboPlayer = limboCache.getPlayerData(player.getName());
|
.ofNullable(limboCache.getPlayerData(player.getName()))
|
||||||
if (limboPlayer != null) {
|
.map(LimboPlayer::getGroup)
|
||||||
primaryGroup = limboPlayer.getGroup();
|
.orElse("");
|
||||||
}
|
|
||||||
|
|
||||||
switch (groupType) {
|
switch (groupType) {
|
||||||
// Implementation note: some permission systems don't support players not being in any group,
|
// Implementation note: some permission systems don't support players not being in any group,
|
||||||
@ -71,7 +71,8 @@ public class AuthGroupHandler implements Reloadable {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LOGGED_IN:
|
case LOGGED_IN:
|
||||||
restoreGroup(player);
|
permissionsManager.addGroup(player, primaryGroup);
|
||||||
|
permissionsManager.removeGroups(player, unregisteredGroup, registeredGroup);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -101,20 +102,6 @@ public class AuthGroupHandler implements Reloadable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Restores the player's original primary group (taken from LimboPlayer).
|
|
||||||
*
|
|
||||||
* @param player the player to process
|
|
||||||
*/
|
|
||||||
private void restoreGroup(Player player) {
|
|
||||||
LimboPlayer limbo = limboCache.getPlayerData(player.getName());
|
|
||||||
if (limbo != null) {
|
|
||||||
String primaryGroup = limbo.getGroup();
|
|
||||||
permissionsManager.addGroup(player, primaryGroup);
|
|
||||||
}
|
|
||||||
permissionsManager.removeGroups(player, unregisteredGroup, registeredGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user