mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-30 04:27:50 +01:00
Refactored player permissions enum, to make the name suit better
This commit is contained in:
parent
7f54838ad4
commit
fdc747d007
@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@ -73,7 +73,7 @@ public class AntiBot {
|
||||
if (antiBotStatus == AntiBotStatus.ACTIVE || antiBotStatus == AntiBotStatus.DISABLED) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_ANTIBOT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ import fr.xephi.authme.hooks.EssSpawn;
|
||||
import fr.xephi.authme.listener.*;
|
||||
import fr.xephi.authme.modules.ModuleManager;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.settings.*;
|
||||
import fr.xephi.authme.util.GeoLiteAPI;
|
||||
@ -735,7 +735,7 @@ public class AuthMe extends JavaPlugin {
|
||||
public Player generateKickPlayer(Collection<? extends Player> collection) {
|
||||
Player player = null;
|
||||
for (Player p : collection) {
|
||||
if (!getPermissionsManager().hasPermission(p, UserPermission.IS_VIP)) {
|
||||
if (!getPermissionsManager().hasPermission(p, PlayerPermission.IS_VIP)) {
|
||||
player = p;
|
||||
break;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import fr.xephi.authme.command.executable.email.RecoverEmailCommand;
|
||||
import fr.xephi.authme.command.executable.login.LoginCommand;
|
||||
import fr.xephi.authme.command.executable.logout.LogoutCommand;
|
||||
import fr.xephi.authme.permission.AdminPermission;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -73,7 +73,7 @@ public class CommandManager {
|
||||
.description("Register a player")
|
||||
.detailedDescription("Register the specified player with the specified password.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, UserPermission.REGISTER)
|
||||
.permissions(OP_ONLY, PlayerPermission.REGISTER)
|
||||
.withArgument("player", "Player name", false)
|
||||
.withArgument("password", "Password", false)
|
||||
.build();
|
||||
@ -85,7 +85,7 @@ public class CommandManager {
|
||||
.description("Unregister a player")
|
||||
.detailedDescription("Unregister the specified player.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, UserPermission.UNREGISTER)
|
||||
.permissions(OP_ONLY, PlayerPermission.UNREGISTER)
|
||||
.withArgument("player", "Player name", false)
|
||||
.build();
|
||||
|
||||
@ -96,7 +96,7 @@ public class CommandManager {
|
||||
.description("Enforce login player")
|
||||
.detailedDescription("Enforce the specified player to login.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, UserPermission.CAN_LOGIN_BE_FORCED)
|
||||
.permissions(OP_ONLY, PlayerPermission.CAN_LOGIN_BE_FORCED)
|
||||
.withArgument("player", "Online player name", true)
|
||||
.build();
|
||||
|
||||
@ -107,7 +107,7 @@ public class CommandManager {
|
||||
.description("Change a player's password")
|
||||
.detailedDescription("Change the password of a player.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, UserPermission.CHANGE_PASSWORD)
|
||||
.permissions(OP_ONLY, PlayerPermission.CHANGE_PASSWORD)
|
||||
.withArgument("player", "Player name", false)
|
||||
.withArgument("pwd", "New password", false)
|
||||
.build();
|
||||
@ -290,7 +290,7 @@ public class CommandManager {
|
||||
.description("Login command")
|
||||
.detailedDescription("Command to log in using AuthMeReloaded.")
|
||||
.parent(null)
|
||||
.permissions(ALLOWED, UserPermission.LOGIN)
|
||||
.permissions(ALLOWED, PlayerPermission.LOGIN)
|
||||
.withArgument("password", "Login password", false)
|
||||
.build();
|
||||
|
||||
@ -305,7 +305,7 @@ public class CommandManager {
|
||||
add("logout");
|
||||
}
|
||||
}, "Logout command", "Command to logout using AuthMeReloaded.", null);
|
||||
logoutBaseCommand.setCommandPermissions(UserPermission.LOGOUT, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
logoutBaseCommand.setCommandPermissions(PlayerPermission.LOGOUT, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
|
||||
// Register the help command
|
||||
CommandDescription logoutHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
@ -319,7 +319,7 @@ public class CommandManager {
|
||||
add("reg");
|
||||
}
|
||||
}, "Registration command", "Command to register using AuthMeReloaded.", null);
|
||||
registerBaseCommand.setCommandPermissions(UserPermission.REGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
registerBaseCommand.setCommandPermissions(PlayerPermission.REGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
registerBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
registerBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
||||
|
||||
@ -335,7 +335,7 @@ public class CommandManager {
|
||||
add("unreg");
|
||||
}
|
||||
}, "Unregistration command", "Command to unregister using AuthMeReloaded.", null);
|
||||
unregisterBaseCommand.setCommandPermissions(UserPermission.UNREGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
unregisterBaseCommand.setCommandPermissions(PlayerPermission.UNREGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
unregisterBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
|
||||
// Register the help command
|
||||
@ -349,7 +349,7 @@ public class CommandManager {
|
||||
add("changepass");
|
||||
}
|
||||
}, "Change password command", "Command to change your password using AuthMeReloaded.", null);
|
||||
changePasswordBaseCommand.setCommandPermissions(UserPermission.CHANGE_PASSWORD, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changePasswordBaseCommand.setCommandPermissions(PlayerPermission.CHANGE_PASSWORD, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
||||
|
||||
@ -379,7 +379,7 @@ public class CommandManager {
|
||||
add("addmail");
|
||||
}
|
||||
}, "Add E-mail", "Add an new E-Mail address to your account.", emailBaseCommand);
|
||||
addEmailCommand.setCommandPermissions(UserPermission.ADD_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
addEmailCommand.setCommandPermissions(PlayerPermission.ADD_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
addEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||
addEmailCommand.addArgument(new CommandArgumentDescription("verifyEmail", "Email address verification", false));
|
||||
|
||||
@ -391,7 +391,7 @@ public class CommandManager {
|
||||
add("changemail");
|
||||
}
|
||||
}, "Change E-mail", "Change an E-Mail address of your account.", emailBaseCommand);
|
||||
changeEmailCommand.setCommandPermissions(UserPermission.CHANGE_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changeEmailCommand.setCommandPermissions(PlayerPermission.CHANGE_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changeEmailCommand.addArgument(new CommandArgumentDescription("oldEmail", "Old email address", false));
|
||||
changeEmailCommand.addArgument(new CommandArgumentDescription("newEmail", "New email address", false));
|
||||
|
||||
@ -404,7 +404,7 @@ public class CommandManager {
|
||||
add("recovermail");
|
||||
}
|
||||
}, "Recover using E-mail", "Recover your account using an E-mail address.", emailBaseCommand);
|
||||
recoverEmailCommand.setCommandPermissions(UserPermission.RECOVER_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
recoverEmailCommand.setCommandPermissions(PlayerPermission.RECOVER_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
recoverEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||
|
||||
// Register the base captcha command
|
||||
@ -414,7 +414,7 @@ public class CommandManager {
|
||||
add("capt");
|
||||
}
|
||||
}, "Captcha command", "Captcha command for AuthMeReloaded.", null);
|
||||
captchaBaseCommand.setCommandPermissions(UserPermission.CAPTCHA, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
captchaBaseCommand.setCommandPermissions(PlayerPermission.CAPTCHA, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
captchaBaseCommand.addArgument(new CommandArgumentDescription("captcha", "The captcha", false));
|
||||
|
||||
// Register the help command
|
||||
@ -430,7 +430,7 @@ public class CommandManager {
|
||||
add("conv");
|
||||
}
|
||||
}, "Convert command", "Convert command for AuthMeReloaded.", null);
|
||||
converterBaseCommand.setCommandPermissions(UserPermission.CONVERTER, OP_ONLY);
|
||||
converterBaseCommand.setCommandPermissions(PlayerPermission.CONVERTER, OP_ONLY);
|
||||
converterBaseCommand.addArgument(new CommandArgumentDescription("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / royalauth / vauth / sqltoflat", false));
|
||||
|
||||
// Register the help command
|
||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -30,7 +30,7 @@ public class ForceLoginCommand extends ExecutableCommand {
|
||||
sender.sendMessage("Player needs to be online!");
|
||||
return true;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, UserPermission.CAN_LOGIN_BE_FORCED)) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.CAN_LOGIN_BE_FORCED)) {
|
||||
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
||||
return true;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@ -254,7 +254,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
PermissionsManager permsMan = plugin.getPermissionsManager();
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL && !permsMan.hasPermission(player, UserPermission.IS_VIP)) {
|
||||
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL && !permsMan.hasPermission(player, PlayerPermission.IS_VIP)) {
|
||||
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_FULL_SERVER));
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
||||
return;
|
||||
@ -267,7 +267,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
final String name = player.getName().toLowerCase();
|
||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||
|
||||
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, PlayerPermission.BYPASS_ANTIBOT)) {
|
||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (Settings.countriesBlacklist.contains(code)) {
|
||||
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
@ -276,7 +276,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, PlayerPermission.BYPASS_ANTIBOT)) {
|
||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (!Settings.countries.contains(code)) {
|
||||
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||
@ -464,7 +464,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null)
|
||||
return;
|
||||
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL))
|
||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL))
|
||||
return;
|
||||
if (Utils.checkAuth(player))
|
||||
return;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package fr.xephi.authme.permission;
|
||||
|
||||
/**
|
||||
* AuthMe user permission nodes.
|
||||
* AuthMe player permission nodes, for regular players.
|
||||
*/
|
||||
public enum UserPermission implements PermissionNode {
|
||||
public enum PlayerPermission implements PermissionNode {
|
||||
|
||||
BYPASS_ANTIBOT("authme.command.player.bypassantibot"),
|
||||
|
||||
@ -44,7 +44,7 @@ public enum UserPermission implements PermissionNode {
|
||||
return node;
|
||||
}
|
||||
|
||||
UserPermission(String node) {
|
||||
PlayerPermission(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@ -39,7 +39,7 @@ public class AsyncChangeEmail {
|
||||
String playerName = player.getName().toLowerCase();
|
||||
|
||||
if (Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||
return;
|
||||
|
@ -10,7 +10,7 @@ import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@ -95,7 +95,7 @@ public class AsynchronousJoin {
|
||||
return;
|
||||
}
|
||||
if (Settings.getMaxJoinPerIp > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||
&& !ip.equalsIgnoreCase("localhost")) {
|
||||
if (plugin.hasJoinedIp(player.getName(), ip)) {
|
||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
@ -120,7 +120,7 @@ public class AsynchronousLogin {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (Settings.getMaxLoginPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
||||
if (Settings.getMaxLoginPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS) && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
||||
if (plugin.isLoggedIp(name, getIP())) {
|
||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||
return null;
|
||||
@ -268,7 +268,7 @@ public class AsynchronousLogin {
|
||||
* uuidaccounts + "."; } }
|
||||
*/
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.SEE_OTHER_ACCOUNTS)) {
|
||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.SEE_OTHER_ACCOUNTS)) {
|
||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
||||
player.sendMessage(message.toString());
|
||||
// player.sendMessage(uuidaccounts.replace("%size%",
|
||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
@ -65,7 +65,7 @@ public class AsyncRegister {
|
||||
m.send(player, MessageKey.NAME_ALREADY_REGISTERED);
|
||||
return false;
|
||||
} else if (Settings.getmaxRegPerIp > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp
|
||||
&& !getIp().equalsIgnoreCase("127.0.0.1")
|
||||
&& !getIp().equalsIgnoreCase("localhost")) {
|
||||
@ -82,7 +82,7 @@ public class AsyncRegister {
|
||||
}
|
||||
if (!email.isEmpty() && !email.equals("")) {
|
||||
if (Settings.getmaxRegPerEmail > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||
return;
|
||||
@ -100,7 +100,7 @@ public class AsyncRegister {
|
||||
|
||||
protected void emailRegister() throws Exception {
|
||||
if (Settings.getmaxRegPerEmail > 0
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||
return;
|
||||
|
@ -7,7 +7,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -201,7 +201,7 @@ public final class Utils {
|
||||
* @param player the player to modify.
|
||||
*/
|
||||
public static void forceGM(Player player) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ import java.util.Set;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Test for {@link UserPermission}.
|
||||
* Test for {@link PlayerPermission}.
|
||||
*/
|
||||
public class UserPermissionTest {
|
||||
public class PlayerPermissionTest {
|
||||
|
||||
@Test
|
||||
public void shouldStartWithRegularAuthMePrefix() {
|
||||
@ -19,7 +19,7 @@ public class UserPermissionTest {
|
||||
String adminPrefix = "authme.admin";
|
||||
|
||||
// when/then
|
||||
for (UserPermission perm : UserPermission.values()) {
|
||||
for (PlayerPermission perm : PlayerPermission.values()) {
|
||||
if (!perm.getNode().startsWith(requiredPrefix)) {
|
||||
fail("The permission '" + perm + "' does not start with the required prefix '" + requiredPrefix + "'");
|
||||
} else if (perm.getNode().startsWith(adminPrefix)) {
|
||||
@ -35,7 +35,7 @@ public class UserPermissionTest {
|
||||
Set<String> nodes = new HashSet<>();
|
||||
|
||||
// when/then
|
||||
for (UserPermission perm : UserPermission.values()) {
|
||||
for (PlayerPermission perm : PlayerPermission.values()) {
|
||||
if (nodes.contains(perm.getNode())) {
|
||||
fail("More than one enum value defines the node '" + perm.getNode() + "'");
|
||||
}
|
@ -3,7 +3,7 @@ package fr.xephi.authme.util;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -54,7 +54,7 @@ public class UtilsTest {
|
||||
public void shouldForceSurvivalGameMode() {
|
||||
// given
|
||||
Player player = mock(Player.class);
|
||||
given(permissionsManagerMock.hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)).willReturn(false);
|
||||
given(permissionsManagerMock.hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)).willReturn(false);
|
||||
|
||||
// when
|
||||
Utils.forceGM(player);
|
||||
@ -68,14 +68,14 @@ public class UtilsTest {
|
||||
public void shouldNotForceGameModeForUserWithBypassPermission() {
|
||||
// given
|
||||
Player player = mock(Player.class);
|
||||
given(permissionsManagerMock.hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)).willReturn(true);
|
||||
given(permissionsManagerMock.hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)).willReturn(true);
|
||||
|
||||
// when
|
||||
Utils.forceGM(player);
|
||||
|
||||
// then
|
||||
verify(authMeMock).getPermissionsManager();
|
||||
verify(permissionsManagerMock).hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL);
|
||||
verify(permissionsManagerMock).hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL);
|
||||
verify(player, never()).setGameMode(any(GameMode.class));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user