mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-31 07:39:42 +01:00
Improved setGroup method in Utils class, to replace legacy permissions code
This commit is contained in:
parent
973c683c90
commit
69d6518b30
@ -7,6 +7,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||||
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -125,47 +126,49 @@ public class Utils {
|
|||||||
* @param group GroupType
|
* @param group GroupType
|
||||||
*/
|
*/
|
||||||
public static void setGroup(Player player, GroupType group) {
|
public static void setGroup(Player player, GroupType group) {
|
||||||
if (!Settings.isPermissionCheckEnabled)
|
if(!Settings.isPermissionCheckEnabled)
|
||||||
return;
|
return;
|
||||||
if (plugin.vaultGroupManagement == null)
|
|
||||||
return;
|
// TODO: Make sure a groups system is used!
|
||||||
String currentGroup;
|
|
||||||
try {
|
// Get the permissions manager, and make sure it's valid
|
||||||
currentGroup = plugin.vaultGroupManagement.getPrimaryGroup(player);
|
PermissionsManager permsMan = plugin.getPermissionsManager();
|
||||||
} catch (UnsupportedOperationException e) {
|
if(permsMan == null)
|
||||||
ConsoleLogger.showError("Your permission plugin (" + plugin.vaultGroupManagement.getName() + ") doesn't support the Group system... unhook!");
|
ConsoleLogger.showError("Failed to access permissions manager instance, shutting down.");
|
||||||
plugin.vaultGroupManagement = null;
|
assert permsMan != null;
|
||||||
return;
|
|
||||||
}
|
switch(group) {
|
||||||
switch (group) {
|
case UNREGISTERED:
|
||||||
case UNREGISTERED: {
|
// Remove the other group type groups, set the current group
|
||||||
plugin.vaultGroupManagement.playerRemoveGroup(player, currentGroup);
|
permsMan.removeGroups(player, Arrays.asList(Settings.getRegisteredGroup, Settings.getUnloggedinGroup));
|
||||||
plugin.vaultGroupManagement.playerAddGroup(player, Settings.unRegisteredGroup);
|
permsMan.addGroup(player, Settings.unRegisteredGroup);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case REGISTERED: {
|
case REGISTERED:
|
||||||
plugin.vaultGroupManagement.playerRemoveGroup(player, currentGroup);
|
// Remove the other group type groups, set the current group
|
||||||
plugin.vaultGroupManagement.playerAddGroup(player, Settings.getRegisteredGroup);
|
permsMan.removeGroups(player, Arrays.asList(Settings.unRegisteredGroup, Settings.getUnloggedinGroup));
|
||||||
|
permsMan.addGroup(player, Settings.getRegisteredGroup);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case NOTLOGGEDIN: {
|
case NOTLOGGEDIN:
|
||||||
if (!useGroupSystem())
|
// Remove the other group type groups, set the current group
|
||||||
break;
|
permsMan.removeGroups(player, Arrays.asList(Settings.unRegisteredGroup, Settings.getRegisteredGroup));
|
||||||
plugin.vaultGroupManagement.playerRemoveGroup(player, currentGroup);
|
permsMan.addGroup(player, Settings.getUnloggedinGroup);
|
||||||
plugin.vaultGroupManagement.playerAddGroup(player, Settings.getUnloggedinGroup);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case LOGGEDIN: {
|
case LOGGEDIN:
|
||||||
if (!useGroupSystem())
|
// Get the limbo player data
|
||||||
break;
|
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||||
if (limbo == null)
|
if(limbo == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Get the players group
|
||||||
String realGroup = limbo.getGroup();
|
String realGroup = limbo.getGroup();
|
||||||
plugin.vaultGroupManagement.playerRemoveGroup(player, currentGroup);
|
|
||||||
plugin.vaultGroupManagement.playerAddGroup(player, realGroup);
|
// Remove the other group types groups, set the real group
|
||||||
|
permsMan.removeGroups(player, Arrays.asList(Settings.unRegisteredGroup, Settings.getRegisteredGroup, Settings.getUnloggedinGroup));
|
||||||
|
permsMan.addGroup(player, realGroup);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user