#415 Move some permission nodes out of authme.player.*
- Move certain permission nodes outside of the authme.player branch - Update classes / permissions list - Remove wildcard node from code completely (since not used)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -73,7 +73,7 @@ public class AntiBot {
|
||||
if (antiBotStatus == AntiBotStatus.ACTIVE || antiBotStatus == AntiBotStatus.DISABLED) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_ANTIBOT)) {
|
||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.BYPASS_ANTIBOT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.logging.Logger;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Resources;
|
||||
import fr.xephi.authme.datasource.DataSourceType;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.settings.SettingsMigrationService;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -68,7 +69,6 @@ import fr.xephi.authme.output.Log4JFilter;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
@@ -707,7 +707,7 @@ public class AuthMe extends JavaPlugin {
|
||||
// Select the player to kick when a vip player joins the server when full
|
||||
public Player generateKickPlayer(Collection<? extends Player> collection) {
|
||||
for (Player player : collection) {
|
||||
if (!getPermissionsManager().hasPermission(player, PlayerPermission.IS_VIP)) {
|
||||
if (!getPermissionsManager().hasPermission(player, PlayerStatePermission.IS_VIP)) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.GeoLiteAPI;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
@@ -222,7 +223,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
|
||||
if (Settings.isForceSurvivalModeEnabled
|
||||
&& !player.hasPermission(PlayerPermission.BYPASS_FORCE_SURVIVAL.getNode())) {
|
||||
&& !player.hasPermission(PlayerStatePermission.BYPASS_FORCE_SURVIVAL.getNode())) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
@@ -295,7 +296,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
PermissionsManager permsMan = plugin.getPermissionsManager();
|
||||
|
||||
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL) {
|
||||
if (permsMan.hasPermission(player, PlayerPermission.IS_VIP)) {
|
||||
if (permsMan.hasPermission(player, PlayerStatePermission.IS_VIP)) {
|
||||
int playersOnline = Utils.getOnlinePlayers().size();
|
||||
if (playersOnline > plugin.getServer().getMaxPlayers()) {
|
||||
event.allow();
|
||||
|
||||
@@ -100,10 +100,10 @@ public enum AdminPermission implements PermissionNode {
|
||||
*/
|
||||
RELOAD("authme.admin.reload"),
|
||||
|
||||
/**
|
||||
* Give access to all admin commands.
|
||||
*/
|
||||
ADMIN_ALL("authme.admin.*");
|
||||
/**
|
||||
* Permission to see the other accounts of the players that log in.
|
||||
*/
|
||||
SEE_OTHER_ACCOUNTS("authme.admin.seeotheraccounts");
|
||||
|
||||
/**
|
||||
* The permission node.
|
||||
@@ -124,8 +124,4 @@ public enum AdminPermission implements PermissionNode {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionNode getWildcardNode() {
|
||||
return ADMIN_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public enum DefaultPermission {
|
||||
/**
|
||||
* Return the textual representation.
|
||||
*
|
||||
* @return String
|
||||
* @return The textual representation
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
|
||||
@@ -12,11 +12,4 @@ public interface PermissionNode {
|
||||
*/
|
||||
String getNode();
|
||||
|
||||
/**
|
||||
* Return the wildcard node that also grants the permission.
|
||||
*
|
||||
* @return The wildcard permission node (e.g. "authme.player.*")
|
||||
*/
|
||||
PermissionNode getWildcardNode();
|
||||
|
||||
}
|
||||
|
||||
@@ -299,7 +299,6 @@ public class PermissionsManager implements PermissionsService {
|
||||
|
||||
Player player = (Player) sender;
|
||||
return hasPermission(player, permissionNode.getNode(), def);
|
||||
// || hasPermission(player, permissionNode.getWildcardNode().getNode(), def);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, Iterable<PermissionNode> nodes, boolean def) {
|
||||
|
||||
@@ -5,16 +5,6 @@ package fr.xephi.authme.permission;
|
||||
*/
|
||||
public enum PlayerPermission implements PermissionNode {
|
||||
|
||||
/**
|
||||
* Permission node to bypass AntiBot protection.
|
||||
*/
|
||||
BYPASS_ANTIBOT("authme.player.bypassantibot"),
|
||||
|
||||
/**
|
||||
* Permission node to identify VIP users.
|
||||
*/
|
||||
IS_VIP("authme.player.vip"),
|
||||
|
||||
/**
|
||||
* Command permission to login.
|
||||
*/
|
||||
@@ -65,26 +55,6 @@ public enum PlayerPermission implements PermissionNode {
|
||||
*/
|
||||
CAN_LOGIN_BE_FORCED("authme.player.canbeforced"),
|
||||
|
||||
/**
|
||||
* Permission for users to bypass force-survival mode.
|
||||
*/
|
||||
BYPASS_FORCE_SURVIVAL("authme.player.bypassforcesurvival"),
|
||||
|
||||
/**
|
||||
* Permission for users to allow two accounts.
|
||||
*/
|
||||
ALLOW_MULTIPLE_ACCOUNTS("authme.player.allow2accounts"),
|
||||
|
||||
/**
|
||||
* Permission for user to see other accounts.
|
||||
*/
|
||||
SEE_OTHER_ACCOUNTS("authme.player.seeotheraccounts"),
|
||||
|
||||
/**
|
||||
* Permission to use all player (non-admin) commands.
|
||||
*/
|
||||
PLAYER_ALL("authme.player.*"),
|
||||
|
||||
/**
|
||||
* Permission to use to see own other accounts.
|
||||
*/
|
||||
@@ -109,8 +79,4 @@ public enum PlayerPermission implements PermissionNode {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionNode getWildcardNode() {
|
||||
return PLAYER_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package fr.xephi.authme.permission;
|
||||
|
||||
/**
|
||||
* Permission nodes that give a player a status (e.g. VIP)
|
||||
* or grant them more freedom (e.g. less restrictions).
|
||||
*/
|
||||
public enum PlayerStatePermission implements PermissionNode {
|
||||
|
||||
/**
|
||||
* Permission node to bypass AntiBot protection.
|
||||
*/
|
||||
BYPASS_ANTIBOT("authme.bypassantibot"),
|
||||
|
||||
/**
|
||||
* Permission for users to bypass force-survival mode.
|
||||
*/
|
||||
BYPASS_FORCE_SURVIVAL("authme.bypassforcesurvival"),
|
||||
|
||||
/**
|
||||
* Permission node to identify VIP users.
|
||||
*/
|
||||
IS_VIP("authme.vip"),
|
||||
|
||||
/**
|
||||
* Permission to be able to register multiple accounts.
|
||||
*/
|
||||
ALLOW_MULTIPLE_ACCOUNTS("authme.allowmultipleaccounts");
|
||||
|
||||
/**
|
||||
* The permission node.
|
||||
*/
|
||||
private String node;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param node Permission node.
|
||||
*/
|
||||
PlayerStatePermission(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
@@ -78,7 +79,7 @@ public class AsynchronousJoin {
|
||||
return;
|
||||
}
|
||||
if (Settings.getMaxJoinPerIp > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||
&& !ip.equalsIgnoreCase("localhost")
|
||||
&& plugin.hasJoinedIp(player.getName(), ip)) {
|
||||
|
||||
@@ -7,7 +7,9 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||
import fr.xephi.authme.permission.AdminPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@@ -117,7 +119,7 @@ public class AsynchronousLogin {
|
||||
}
|
||||
|
||||
if (Settings.getMaxLoginPerIp > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
|
||||
if (plugin.isLoggedIp(name, ip)) {
|
||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||
@@ -230,7 +232,7 @@ public class AsynchronousLogin {
|
||||
}
|
||||
String message = "[AuthMe] " + StringUtils.join(", ", auths) + ".";
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.SEE_OTHER_ACCOUNTS)
|
||||
if (plugin.getPermissionsManager().hasPermission(player, AdminPermission.SEE_OTHER_ACCOUNTS)
|
||||
|| (player.getName().equals(this.player.getName())
|
||||
&& plugin.getPermissionsManager().hasPermission(player, PlayerPermission.SEE_OWN_ACCOUNTS))) {
|
||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
||||
|
||||
@@ -8,6 +8,7 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.security.crypts.TwoFactor;
|
||||
@@ -75,7 +76,7 @@ public class AsyncRegister {
|
||||
m.send(player, MessageKey.NAME_ALREADY_REGISTERED);
|
||||
return false;
|
||||
} else if (Settings.getmaxRegPerIp > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||
&& !ip.equalsIgnoreCase("localhost")
|
||||
&& database.getAllAuthsByIp(ip).size() >= Settings.getmaxRegPerIp) {
|
||||
@@ -97,7 +98,7 @@ public class AsyncRegister {
|
||||
|
||||
private void emailRegister() {
|
||||
if (Settings.getmaxRegPerEmail > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user