mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-25 18:17:34 +01:00
Change use of String permissions to the permission enums
This commit is contained in:
parent
e519906dc5
commit
364583e7db
@ -1,5 +1,6 @@
|
|||||||
package fr.xephi.authme;
|
package fr.xephi.authme;
|
||||||
|
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.settings.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
@ -72,7 +73,7 @@ public class AntiBot {
|
|||||||
if (antiBotStatus == AntiBotStatus.ACTIVE || antiBotStatus == AntiBotStatus.DISABLED) {
|
if (antiBotStatus == AntiBotStatus.ACTIVE || antiBotStatus == AntiBotStatus.DISABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassantibot")) {
|
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import fr.xephi.authme.hooks.EssSpawn;
|
|||||||
import fr.xephi.authme.listener.*;
|
import fr.xephi.authme.listener.*;
|
||||||
import fr.xephi.authme.modules.ModuleManager;
|
import fr.xephi.authme.modules.ModuleManager;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.settings.*;
|
import fr.xephi.authme.settings.*;
|
||||||
import fr.xephi.authme.util.GeoLiteAPI;
|
import fr.xephi.authme.util.GeoLiteAPI;
|
||||||
@ -725,7 +726,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
public Player generateKickPlayer(Collection<? extends Player> collection) {
|
public Player generateKickPlayer(Collection<? extends Player> collection) {
|
||||||
Player player = null;
|
Player player = null;
|
||||||
for (Player p : collection) {
|
for (Player p : collection) {
|
||||||
if (!getPermissionsManager().hasPermission(p, "authme.vip")) {
|
if (!getPermissionsManager().hasPermission(p, UserPermission.IS_VIP)) {
|
||||||
player = p;
|
player = p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.xephi.authme.command;
|
package fr.xephi.authme.command;
|
||||||
|
|
||||||
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -921,7 +922,7 @@ public class CommandDescription {
|
|||||||
* @param permissionNode The permission node required.
|
* @param permissionNode The permission node required.
|
||||||
* @param defaultPermission The default permission.
|
* @param defaultPermission The default permission.
|
||||||
*/
|
*/
|
||||||
public void setCommandPermissions(String permissionNode, CommandPermissions.DefaultPermission defaultPermission) {
|
public void setCommandPermissions(PermissionNode permissionNode, CommandPermissions.DefaultPermission defaultPermission) {
|
||||||
this.permissions = new CommandPermissions(permissionNode, defaultPermission);
|
this.permissions = new CommandPermissions(permissionNode, defaultPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import fr.xephi.authme.command.executable.email.ChangeEmailCommand;
|
|||||||
import fr.xephi.authme.command.executable.email.RecoverEmailCommand;
|
import fr.xephi.authme.command.executable.email.RecoverEmailCommand;
|
||||||
import fr.xephi.authme.command.executable.login.LoginCommand;
|
import fr.xephi.authme.command.executable.login.LoginCommand;
|
||||||
import fr.xephi.authme.command.executable.logout.LogoutCommand;
|
import fr.xephi.authme.command.executable.logout.LogoutCommand;
|
||||||
|
import fr.xephi.authme.permission.AdminPermission;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -72,14 +74,14 @@ public class CommandManager {
|
|||||||
add("r");
|
add("r");
|
||||||
}
|
}
|
||||||
}, "Register a player", "Register the specified player with the specified password.", authMeBaseCommand);
|
}, "Register a player", "Register the specified player with the specified password.", authMeBaseCommand);
|
||||||
registerCommand.setCommandPermissions("authme.admin.register", CommandPermissions.DefaultPermission.OP_ONLY);
|
registerCommand.setCommandPermissions(UserPermission.REGISTER, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
registerCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
registerCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
||||||
registerCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
registerCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||||
|
|
||||||
// Register the unregister command
|
// Register the unregister command
|
||||||
CommandDescription unregisterCommand = new CommandDescription(new UnregisterCommand(), helpCommandLabels,
|
CommandDescription unregisterCommand = new CommandDescription(new UnregisterCommand(), helpCommandLabels,
|
||||||
"Unregister a player", "Unregister the specified player.", authMeBaseCommand);
|
"Unregister a player", "Unregister the specified player.", authMeBaseCommand);
|
||||||
unregisterCommand.setCommandPermissions("authme.admin.unregister", CommandPermissions.DefaultPermission.OP_ONLY);
|
unregisterCommand.setCommandPermissions(UserPermission.UNREGISTER, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
unregisterCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
unregisterCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
||||||
|
|
||||||
// Register the forcelogin command
|
// Register the forcelogin command
|
||||||
@ -90,7 +92,7 @@ public class CommandManager {
|
|||||||
add("login");
|
add("login");
|
||||||
}
|
}
|
||||||
}, "Enforce login player", "Enforce the specified player to login.", authMeBaseCommand);
|
}, "Enforce login player", "Enforce the specified player to login.", authMeBaseCommand);
|
||||||
forceLoginCommand.setCommandPermissions("authme.admin.forcelogin", CommandPermissions.DefaultPermission.OP_ONLY);
|
forceLoginCommand.setCommandPermissions(UserPermission.CAN_LOGIN_BE_FORCED, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
forceLoginCommand.addArgument(new CommandArgumentDescription("player", "Online player name", true));
|
forceLoginCommand.addArgument(new CommandArgumentDescription("player", "Online player name", true));
|
||||||
|
|
||||||
// Register the changepassword command
|
// Register the changepassword command
|
||||||
@ -103,7 +105,7 @@ public class CommandManager {
|
|||||||
add("cp");
|
add("cp");
|
||||||
}
|
}
|
||||||
}, "Change player's password", "Change the password of a player.", authMeBaseCommand);
|
}, "Change player's password", "Change the password of a player.", authMeBaseCommand);
|
||||||
changePasswordCommand.setCommandPermissions("authme.admin.changepassword", CommandPermissions.DefaultPermission.OP_ONLY);
|
changePasswordCommand.setCommandPermissions(AdminPermission.CHANGE_PASSWORD, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
changePasswordCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
changePasswordCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
||||||
changePasswordCommand.addArgument(new CommandArgumentDescription("pwd", "New password", false));
|
changePasswordCommand.addArgument(new CommandArgumentDescription("pwd", "New password", false));
|
||||||
|
|
||||||
@ -115,7 +117,7 @@ public class CommandManager {
|
|||||||
add("ll");
|
add("ll");
|
||||||
}
|
}
|
||||||
}, "Player's last login", "View the date of the specified players last login", authMeBaseCommand);
|
}, "Player's last login", "View the date of the specified players last login", authMeBaseCommand);
|
||||||
lastLoginCommand.setCommandPermissions("authme.admin.lastlogin", CommandPermissions.DefaultPermission.OP_ONLY);
|
lastLoginCommand.setCommandPermissions(AdminPermission.LAST_LOGIN, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
lastLoginCommand.addArgument(new CommandArgumentDescription("player", "Player name", true));
|
lastLoginCommand.addArgument(new CommandArgumentDescription("player", "Player name", true));
|
||||||
|
|
||||||
// Register the accounts command
|
// Register the accounts command
|
||||||
@ -126,7 +128,7 @@ public class CommandManager {
|
|||||||
add("account");
|
add("account");
|
||||||
}
|
}
|
||||||
}, "Display player accounts", "Display all accounts of a player by it's player name or IP.", authMeBaseCommand);
|
}, "Display player accounts", "Display all accounts of a player by it's player name or IP.", authMeBaseCommand);
|
||||||
accountsCommand.setCommandPermissions("authme.admin.accounts", CommandPermissions.DefaultPermission.OP_ONLY);
|
accountsCommand.setCommandPermissions(AdminPermission.ACCOUNTS, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
accountsCommand.addArgument(new CommandArgumentDescription("player", "Player name or IP", true));
|
accountsCommand.addArgument(new CommandArgumentDescription("player", "Player name or IP", true));
|
||||||
|
|
||||||
// Register the getemail command
|
// Register the getemail command
|
||||||
@ -139,7 +141,7 @@ public class CommandManager {
|
|||||||
add("mail");
|
add("mail");
|
||||||
}
|
}
|
||||||
}, "Display player's email", "Display the email address of the specified player if set.", authMeBaseCommand);
|
}, "Display player's email", "Display the email address of the specified player if set.", authMeBaseCommand);
|
||||||
getEmailCommand.setCommandPermissions("authme.admin.getemail", CommandPermissions.DefaultPermission.OP_ONLY);
|
getEmailCommand.setCommandPermissions(AdminPermission.GET_EMAIL, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
getEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", true));
|
getEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", true));
|
||||||
|
|
||||||
// Register the setemail command
|
// Register the setemail command
|
||||||
@ -152,7 +154,7 @@ public class CommandManager {
|
|||||||
add("setmail");
|
add("setmail");
|
||||||
}
|
}
|
||||||
}, "Change player's email", "Change the email address of the specified player.", authMeBaseCommand);
|
}, "Change player's email", "Change the email address of the specified player.", authMeBaseCommand);
|
||||||
setEmailCommand.setCommandPermissions("authme.admin.chgemail", CommandPermissions.DefaultPermission.OP_ONLY);
|
setEmailCommand.setCommandPermissions(AdminPermission.CHANGE_EMAIL, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
setEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
setEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
||||||
setEmailCommand.addArgument(new CommandArgumentDescription("email", "Player email", false));
|
setEmailCommand.addArgument(new CommandArgumentDescription("email", "Player email", false));
|
||||||
|
|
||||||
@ -164,7 +166,7 @@ public class CommandManager {
|
|||||||
add("ip");
|
add("ip");
|
||||||
}
|
}
|
||||||
}, "Get player's IP", "Get the IP address of the specified online player.", authMeBaseCommand);
|
}, "Get player's IP", "Get the IP address of the specified online player.", authMeBaseCommand);
|
||||||
getIpCommand.setCommandPermissions("authme.admin.getip", CommandPermissions.DefaultPermission.OP_ONLY);
|
getIpCommand.setCommandPermissions(AdminPermission.GET_IP, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
getIpCommand.addArgument(new CommandArgumentDescription("player", "Online player name", true));
|
getIpCommand.addArgument(new CommandArgumentDescription("player", "Online player name", true));
|
||||||
|
|
||||||
// Register the spawn command
|
// Register the spawn command
|
||||||
@ -175,7 +177,7 @@ public class CommandManager {
|
|||||||
add("home");
|
add("home");
|
||||||
}
|
}
|
||||||
}, "Teleport to spawn", "Teleport to the spawn.", authMeBaseCommand);
|
}, "Teleport to spawn", "Teleport to the spawn.", authMeBaseCommand);
|
||||||
spawnCommand.setCommandPermissions("authme.admin.spawn", CommandPermissions.DefaultPermission.OP_ONLY);
|
spawnCommand.setCommandPermissions(AdminPermission.SPAWN, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
|
||||||
// Register the setspawn command
|
// Register the setspawn command
|
||||||
CommandDescription setSpawnCommand = new CommandDescription(new SetSpawnCommand(), new ArrayList<String>() {
|
CommandDescription setSpawnCommand = new CommandDescription(new SetSpawnCommand(), new ArrayList<String>() {
|
||||||
@ -185,7 +187,7 @@ public class CommandManager {
|
|||||||
add("chgspawn");
|
add("chgspawn");
|
||||||
}
|
}
|
||||||
}, "Change the spawn", "Change the player's spawn to your current position.", authMeBaseCommand);
|
}, "Change the spawn", "Change the player's spawn to your current position.", authMeBaseCommand);
|
||||||
setSpawnCommand.setCommandPermissions("authme.admin.setspawn", CommandPermissions.DefaultPermission.OP_ONLY);
|
setSpawnCommand.setCommandPermissions(AdminPermission.SET_SPAWN, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
|
||||||
// Register the firstspawn command
|
// Register the firstspawn command
|
||||||
CommandDescription firstSpawnCommand = new CommandDescription(new FirstSpawnCommand(), new ArrayList<String>() {
|
CommandDescription firstSpawnCommand = new CommandDescription(new FirstSpawnCommand(), new ArrayList<String>() {
|
||||||
@ -195,7 +197,7 @@ public class CommandManager {
|
|||||||
add("firsthome");
|
add("firsthome");
|
||||||
}
|
}
|
||||||
}, "Teleport to first spawn", "Teleport to the first spawn.", authMeBaseCommand);
|
}, "Teleport to first spawn", "Teleport to the first spawn.", authMeBaseCommand);
|
||||||
firstSpawnCommand.setCommandPermissions("authme.admin.firstspawn", CommandPermissions.DefaultPermission.OP_ONLY);
|
firstSpawnCommand.setCommandPermissions(AdminPermission.FIRST_SPAWN, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
|
||||||
// Register the setfirstspawn command
|
// Register the setfirstspawn command
|
||||||
CommandDescription setFirstSpawnCommand = new CommandDescription(new SetFirstSpawnCommand(), new ArrayList<String>() {
|
CommandDescription setFirstSpawnCommand = new CommandDescription(new SetFirstSpawnCommand(), new ArrayList<String>() {
|
||||||
@ -205,7 +207,7 @@ public class CommandManager {
|
|||||||
add("chgfirstspawn");
|
add("chgfirstspawn");
|
||||||
}
|
}
|
||||||
}, "Change the first spawn", "Change the first player's spawn to your current position.", authMeBaseCommand);
|
}, "Change the first spawn", "Change the first player's spawn to your current position.", authMeBaseCommand);
|
||||||
setFirstSpawnCommand.setCommandPermissions("authme.admin.setfirstspawn", CommandPermissions.DefaultPermission.OP_ONLY);
|
setFirstSpawnCommand.setCommandPermissions(AdminPermission.SET_FIRST_SPAWN, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
|
||||||
// Register the purge command
|
// Register the purge command
|
||||||
CommandDescription purgeCommand = new CommandDescription(new PurgeCommand(), new ArrayList<String>() {
|
CommandDescription purgeCommand = new CommandDescription(new PurgeCommand(), new ArrayList<String>() {
|
||||||
@ -215,7 +217,7 @@ public class CommandManager {
|
|||||||
add("delete");
|
add("delete");
|
||||||
}
|
}
|
||||||
}, "Purge old data", "Purge old AuthMeReloaded data longer than the specified amount of days ago.", authMeBaseCommand);
|
}, "Purge old data", "Purge old AuthMeReloaded data longer than the specified amount of days ago.", authMeBaseCommand);
|
||||||
purgeCommand.setCommandPermissions("authme.admin.purge", CommandPermissions.DefaultPermission.OP_ONLY);
|
purgeCommand.setCommandPermissions(AdminPermission.PURGE, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
purgeCommand.addArgument(new CommandArgumentDescription("days", "Number of days", false));
|
purgeCommand.addArgument(new CommandArgumentDescription("days", "Number of days", false));
|
||||||
|
|
||||||
// Register the purgelastposition command
|
// Register the purgelastposition command
|
||||||
@ -230,7 +232,7 @@ public class CommandManager {
|
|||||||
add("resetlastpos");
|
add("resetlastpos");
|
||||||
}
|
}
|
||||||
}, "Purge player's last position", "Purge the last know position of the specified player.", authMeBaseCommand);
|
}, "Purge player's last position", "Purge the last know position of the specified player.", authMeBaseCommand);
|
||||||
purgeLastPositionCommand.setCommandPermissions("authme.admin.purgelastpos", CommandPermissions.DefaultPermission.OP_ONLY);
|
purgeLastPositionCommand.setCommandPermissions(AdminPermission.PURGE_LAST_POSITION, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
purgeLastPositionCommand.addArgument(new CommandArgumentDescription("player", "Player name", true));
|
purgeLastPositionCommand.addArgument(new CommandArgumentDescription("player", "Player name", true));
|
||||||
|
|
||||||
// Register the purgebannedplayers command
|
// Register the purgebannedplayers command
|
||||||
@ -243,7 +245,7 @@ public class CommandManager {
|
|||||||
add("deletebannedplayer");
|
add("deletebannedplayer");
|
||||||
}
|
}
|
||||||
}, "Purge banned palyers data", "Purge all AuthMeReloaded data for banned players.", authMeBaseCommand);
|
}, "Purge banned palyers data", "Purge all AuthMeReloaded data for banned players.", authMeBaseCommand);
|
||||||
purgeBannedPlayersCommand.setCommandPermissions("authme.admin.purgebannedplayers", CommandPermissions.DefaultPermission.OP_ONLY);
|
purgeBannedPlayersCommand.setCommandPermissions(AdminPermission.PURGE_BANNED_PLAYERS, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
|
||||||
// Register the switchantibot command
|
// Register the switchantibot command
|
||||||
CommandDescription switchAntiBotCommand = new CommandDescription(new SwitchAntiBotCommand(), new ArrayList<String>() {
|
CommandDescription switchAntiBotCommand = new CommandDescription(new SwitchAntiBotCommand(), new ArrayList<String>() {
|
||||||
@ -254,7 +256,7 @@ public class CommandManager {
|
|||||||
add("antibot");
|
add("antibot");
|
||||||
}
|
}
|
||||||
}, "Switch AntiBot mode", "Switch or toggle the AntiBot mode to the specified state.", authMeBaseCommand);
|
}, "Switch AntiBot mode", "Switch or toggle the AntiBot mode to the specified state.", authMeBaseCommand);
|
||||||
switchAntiBotCommand.setCommandPermissions("authme.admin.switchantibot", CommandPermissions.DefaultPermission.OP_ONLY);
|
switchAntiBotCommand.setCommandPermissions(AdminPermission.SWITCH_ANTIBOT, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
switchAntiBotCommand.addArgument(new CommandArgumentDescription("mode", "ON / OFF", true));
|
switchAntiBotCommand.addArgument(new CommandArgumentDescription("mode", "ON / OFF", true));
|
||||||
|
|
||||||
// // Register the resetname command
|
// // Register the resetname command
|
||||||
@ -278,14 +280,14 @@ public class CommandManager {
|
|||||||
add("rld");
|
add("rld");
|
||||||
}
|
}
|
||||||
}, "Reload plugin", "Reload the AuthMeReloaded plugin.", authMeBaseCommand);
|
}, "Reload plugin", "Reload the AuthMeReloaded plugin.", authMeBaseCommand);
|
||||||
reloadCommand.setCommandPermissions("authme.admin.reload", CommandPermissions.DefaultPermission.OP_ONLY);
|
reloadCommand.setCommandPermissions(AdminPermission.RELOAD, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
|
|
||||||
// Register the version command
|
// Register the version command
|
||||||
CommandDescription versionCommand = new CommandDescription(new VersionCommand(), helpCommandLabels,
|
CommandDescription versionCommand = new CommandDescription(new VersionCommand(), helpCommandLabels,
|
||||||
"Version info", "Show detailed information about the installed AuthMeReloaded version, and shows the developers, contributors, license and other information.", authMeBaseCommand);
|
"Version info", "Show detailed information about the installed AuthMeReloaded version, and shows the developers, contributors, license and other information.", authMeBaseCommand);
|
||||||
versionCommand.setMaximumArguments(false);
|
versionCommand.setMaximumArguments(false);
|
||||||
|
|
||||||
// Register the base Dungeon Maze command
|
// Register the base login command
|
||||||
CommandDescription loginBaseCommand = new CommandDescription(new LoginCommand(), new ArrayList<String>() {
|
CommandDescription loginBaseCommand = new CommandDescription(new LoginCommand(), new ArrayList<String>() {
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -293,7 +295,7 @@ public class CommandManager {
|
|||||||
add("l");
|
add("l");
|
||||||
}
|
}
|
||||||
}, "Login command", "Command to login using AuthMeReloaded.", null);
|
}, "Login command", "Command to login using AuthMeReloaded.", null);
|
||||||
loginBaseCommand.setCommandPermissions("authme.login", CommandPermissions.DefaultPermission.ALLOWED);
|
loginBaseCommand.setCommandPermissions(UserPermission.LOGIN, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
loginBaseCommand.addArgument(new CommandArgumentDescription("password", "Login password", false));
|
loginBaseCommand.addArgument(new CommandArgumentDescription("password", "Login password", false));
|
||||||
|
|
||||||
// Register the help command
|
// Register the help command
|
||||||
@ -309,7 +311,7 @@ public class CommandManager {
|
|||||||
add("logout");
|
add("logout");
|
||||||
}
|
}
|
||||||
}, "Logout command", "Command to logout using AuthMeReloaded.", null);
|
}, "Logout command", "Command to logout using AuthMeReloaded.", null);
|
||||||
logoutBaseCommand.setCommandPermissions("authme.logout", CommandPermissions.DefaultPermission.ALLOWED);
|
logoutBaseCommand.setCommandPermissions(UserPermission.LOGOUT, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
|
|
||||||
// Register the help command
|
// Register the help command
|
||||||
CommandDescription logoutHelpCommand = new CommandDescription(new HelpCommand(), helpCommandLabels,
|
CommandDescription logoutHelpCommand = new CommandDescription(new HelpCommand(), helpCommandLabels,
|
||||||
@ -325,7 +327,7 @@ public class CommandManager {
|
|||||||
add("reg");
|
add("reg");
|
||||||
}
|
}
|
||||||
}, "Registration command", "Command to register using AuthMeReloaded.", null);
|
}, "Registration command", "Command to register using AuthMeReloaded.", null);
|
||||||
registerBaseCommand.setCommandPermissions("authme.register", CommandPermissions.DefaultPermission.ALLOWED);
|
registerBaseCommand.setCommandPermissions(UserPermission.REGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
registerBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
registerBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||||
registerBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
registerBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
||||||
registerBaseCommand.setMaximumArguments(false);
|
registerBaseCommand.setMaximumArguments(false);
|
||||||
@ -344,7 +346,7 @@ public class CommandManager {
|
|||||||
add("unreg");
|
add("unreg");
|
||||||
}
|
}
|
||||||
}, "Unregistration command", "Command to unregister using AuthMeReloaded.", null);
|
}, "Unregistration command", "Command to unregister using AuthMeReloaded.", null);
|
||||||
unregisterBaseCommand.setCommandPermissions("authme.unregister", CommandPermissions.DefaultPermission.ALLOWED);
|
unregisterBaseCommand.setCommandPermissions(UserPermission.UNREGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
unregisterBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
unregisterBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||||
|
|
||||||
// Register the help command
|
// Register the help command
|
||||||
@ -360,7 +362,7 @@ public class CommandManager {
|
|||||||
add("changepass");
|
add("changepass");
|
||||||
}
|
}
|
||||||
}, "Change password command", "Command to change your password using AuthMeReloaded.", null);
|
}, "Change password command", "Command to change your password using AuthMeReloaded.", null);
|
||||||
changePasswordBaseCommand.setCommandPermissions("authme.changepassword", CommandPermissions.DefaultPermission.ALLOWED);
|
changePasswordBaseCommand.setCommandPermissions(UserPermission.CHANGE_PASSWORD, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||||
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
||||||
changePasswordBaseCommand.setMaximumArguments(false);
|
changePasswordBaseCommand.setMaximumArguments(false);
|
||||||
@ -395,7 +397,7 @@ public class CommandManager {
|
|||||||
add("addmail");
|
add("addmail");
|
||||||
}
|
}
|
||||||
}, "Add E-mail", "Add an new E-Mail address to your account.", emailBaseCommand);
|
}, "Add E-mail", "Add an new E-Mail address to your account.", emailBaseCommand);
|
||||||
addEmailCommand.setCommandPermissions("authme.email.add", CommandPermissions.DefaultPermission.ALLOWED);
|
addEmailCommand.setCommandPermissions(UserPermission.ADD_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
addEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
addEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||||
addEmailCommand.addArgument(new CommandArgumentDescription("verifyEmail", "Email address verification", false));
|
addEmailCommand.addArgument(new CommandArgumentDescription("verifyEmail", "Email address verification", false));
|
||||||
|
|
||||||
@ -408,7 +410,7 @@ public class CommandManager {
|
|||||||
add("changemail");
|
add("changemail");
|
||||||
}
|
}
|
||||||
}, "Change E-mail", "Change an E-Mail address of your account.", emailBaseCommand);
|
}, "Change E-mail", "Change an E-Mail address of your account.", emailBaseCommand);
|
||||||
changeEmailCommand.setCommandPermissions("authme.email.change", CommandPermissions.DefaultPermission.ALLOWED);
|
changeEmailCommand.setCommandPermissions(UserPermission.CHANGE_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
changeEmailCommand.addArgument(new CommandArgumentDescription("oldEmail", "Old email address", false));
|
changeEmailCommand.addArgument(new CommandArgumentDescription("oldEmail", "Old email address", false));
|
||||||
changeEmailCommand.addArgument(new CommandArgumentDescription("newEmail", "New email address", false));
|
changeEmailCommand.addArgument(new CommandArgumentDescription("newEmail", "New email address", false));
|
||||||
|
|
||||||
@ -422,7 +424,7 @@ public class CommandManager {
|
|||||||
add("recovermail");
|
add("recovermail");
|
||||||
}
|
}
|
||||||
}, "Recover using E-mail", "Recover your account using an E-mail address.", emailBaseCommand);
|
}, "Recover using E-mail", "Recover your account using an E-mail address.", emailBaseCommand);
|
||||||
recoverEmailCommand.setCommandPermissions("authme.email.recover", CommandPermissions.DefaultPermission.ALLOWED);
|
recoverEmailCommand.setCommandPermissions(UserPermission.RECOVER_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
recoverEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
recoverEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||||
|
|
||||||
// Register the base captcha command
|
// Register the base captcha command
|
||||||
@ -433,7 +435,7 @@ public class CommandManager {
|
|||||||
add("capt");
|
add("capt");
|
||||||
}
|
}
|
||||||
}, "Captcha command", "Captcha command for AuthMeReloaded.", null);
|
}, "Captcha command", "Captcha command for AuthMeReloaded.", null);
|
||||||
captchaBaseCommand.setCommandPermissions("authme.captcha", CommandPermissions.DefaultPermission.ALLOWED);
|
captchaBaseCommand.setCommandPermissions(UserPermission.CAPTCHA, CommandPermissions.DefaultPermission.ALLOWED);
|
||||||
captchaBaseCommand.addArgument(new CommandArgumentDescription("captcha", "The captcha", false));
|
captchaBaseCommand.addArgument(new CommandArgumentDescription("captcha", "The captcha", false));
|
||||||
captchaBaseCommand.setMaximumArguments(false);
|
captchaBaseCommand.setMaximumArguments(false);
|
||||||
|
|
||||||
@ -452,7 +454,7 @@ public class CommandManager {
|
|||||||
add("conv");
|
add("conv");
|
||||||
}
|
}
|
||||||
}, "Convert command", "Convert command for AuthMeReloaded.", null);
|
}, "Convert command", "Convert command for AuthMeReloaded.", null);
|
||||||
converterBaseCommand.setCommandPermissions("authme.converter", CommandPermissions.DefaultPermission.OP_ONLY);
|
converterBaseCommand.setCommandPermissions(UserPermission.CONVERTER, CommandPermissions.DefaultPermission.OP_ONLY);
|
||||||
converterBaseCommand.addArgument(new CommandArgumentDescription("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / royalauth / vauth / sqltoflat", false));
|
converterBaseCommand.addArgument(new CommandArgumentDescription("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / royalauth / vauth / sqltoflat", false));
|
||||||
converterBaseCommand.setMaximumArguments(false);
|
converterBaseCommand.setMaximumArguments(false);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package fr.xephi.authme.command;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ public class CommandPermissions {
|
|||||||
/**
|
/**
|
||||||
* Defines the permission nodes required to have permission to execute this command.
|
* Defines the permission nodes required to have permission to execute this command.
|
||||||
*/
|
*/
|
||||||
private List<String> permissionNodes = new ArrayList<>();
|
private List<PermissionNode> permissionNodes = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* Defines the default permission if the permission nodes couldn't be used.
|
* Defines the default permission if the permission nodes couldn't be used.
|
||||||
*/
|
*/
|
||||||
@ -36,7 +37,7 @@ public class CommandPermissions {
|
|||||||
* @param permissionNode The permission node required to execute a command.
|
* @param permissionNode The permission node required to execute a command.
|
||||||
* @param defaultPermission The default permission if the permission nodes couldn't be used.
|
* @param defaultPermission The default permission if the permission nodes couldn't be used.
|
||||||
*/
|
*/
|
||||||
public CommandPermissions(String permissionNode, DefaultPermission defaultPermission) {
|
public CommandPermissions(PermissionNode permissionNode, DefaultPermission defaultPermission) {
|
||||||
this.permissionNodes.add(permissionNode);
|
this.permissionNodes.add(permissionNode);
|
||||||
this.defaultPermission = defaultPermission;
|
this.defaultPermission = defaultPermission;
|
||||||
}
|
}
|
||||||
@ -47,7 +48,7 @@ public class CommandPermissions {
|
|||||||
* @param permissionNodes The permission nodes required to execute a command.
|
* @param permissionNodes The permission nodes required to execute a command.
|
||||||
* @param defaultPermission The default permission if the permission nodes couldn't be used.
|
* @param defaultPermission The default permission if the permission nodes couldn't be used.
|
||||||
*/
|
*/
|
||||||
public CommandPermissions(List<String> permissionNodes, DefaultPermission defaultPermission) {
|
public CommandPermissions(List<PermissionNode> permissionNodes, DefaultPermission defaultPermission) {
|
||||||
this.permissionNodes.addAll(permissionNodes);
|
this.permissionNodes.addAll(permissionNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,14 +59,7 @@ public class CommandPermissions {
|
|||||||
*
|
*
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
*/
|
*/
|
||||||
public boolean addPermissionNode(String permissionNode) {
|
public boolean addPermissionNode(PermissionNode permissionNode) {
|
||||||
// Trim the permission node
|
|
||||||
permissionNode = permissionNode.trim();
|
|
||||||
|
|
||||||
// Make sure the permission node is valid
|
|
||||||
if (permissionNode.length() == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Make sure this permission node hasn't been added already
|
// Make sure this permission node hasn't been added already
|
||||||
if (hasPermissionNode(permissionNode))
|
if (hasPermissionNode(permissionNode))
|
||||||
return true;
|
return true;
|
||||||
@ -81,7 +75,7 @@ public class CommandPermissions {
|
|||||||
*
|
*
|
||||||
* @return True if this permission node is required, false if not.
|
* @return True if this permission node is required, false if not.
|
||||||
*/
|
*/
|
||||||
public boolean hasPermissionNode(String permissionNode) {
|
public boolean hasPermissionNode(PermissionNode permissionNode) {
|
||||||
return this.permissionNodes.contains(permissionNode);
|
return this.permissionNodes.contains(permissionNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +84,7 @@ public class CommandPermissions {
|
|||||||
*
|
*
|
||||||
* @return The permission nodes required to execute this command.
|
* @return The permission nodes required to execute this command.
|
||||||
*/
|
*/
|
||||||
public List<String> getPermissionNodes() {
|
public List<PermissionNode> getPermissionNodes() {
|
||||||
return this.permissionNodes;
|
return this.permissionNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +93,7 @@ public class CommandPermissions {
|
|||||||
*
|
*
|
||||||
* @param permissionNodes The permission nodes required to execute this command.
|
* @param permissionNodes The permission nodes required to execute this command.
|
||||||
*/
|
*/
|
||||||
public void setPermissionNodes(List<String> permissionNodes) {
|
public void setPermissionNodes(List<PermissionNode> permissionNodes) {
|
||||||
this.permissionNodes = permissionNodes;
|
this.permissionNodes = permissionNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,9 +134,11 @@ public class CommandPermissions {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check whether the player has permission, return the result
|
// Check whether the player has permission, return the result
|
||||||
for (String node : this.permissionNodes)
|
for (PermissionNode node : this.permissionNodes) {
|
||||||
if (!permissionsManager.hasPermission(player, node, defaultPermission))
|
if (!permissionsManager.hasPermission(player, node, defaultPermission)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -29,7 +30,7 @@ public class ForceLoginCommand extends ExecutableCommand {
|
|||||||
sender.sendMessage("Player needs to be online!");
|
sender.sendMessage("Player needs to be online!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.canbeforced")) {
|
if (!plugin.getPermissionsManager().hasPermission(player, UserPermission.CAN_LOGIN_BE_FORCED)) {
|
||||||
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import fr.xephi.authme.command.CommandArgumentDescription;
|
|||||||
import fr.xephi.authme.command.CommandDescription;
|
import fr.xephi.authme.command.CommandDescription;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.CommandPermissions;
|
import fr.xephi.authme.command.CommandPermissions;
|
||||||
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -103,7 +104,7 @@ public class HelpPrinter {
|
|||||||
sender.sendMessage(ChatColor.GOLD + "Permissions:");
|
sender.sendMessage(ChatColor.GOLD + "Permissions:");
|
||||||
|
|
||||||
// Print each node
|
// Print each node
|
||||||
for (String node : permissions.getPermissionNodes()) {
|
for (PermissionNode node : permissions.getPermissionNodes()) {
|
||||||
boolean nodePermission = true;
|
boolean nodePermission = true;
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
nodePermission = AuthMe.getInstance().getPermissionsManager().hasPermission((Player) sender, node);
|
nodePermission = AuthMe.getInstance().getPermissionsManager().hasPermission((Player) sender, node);
|
||||||
|
@ -10,6 +10,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.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.settings.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
@ -41,21 +42,11 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
public final AuthMe plugin;
|
public final AuthMe plugin;
|
||||||
private final Messages m;
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for AuthMePlayerListener.
|
|
||||||
*
|
|
||||||
* @param plugin AuthMe
|
|
||||||
*/
|
|
||||||
public AuthMePlayerListener(AuthMe plugin) {
|
public AuthMePlayerListener(AuthMe plugin) {
|
||||||
this.m = plugin.getMessages();
|
this.m = plugin.getMessages();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method handleChat.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerChatEvent
|
|
||||||
*/
|
|
||||||
private void handleChat(AsyncPlayerChatEvent event) {
|
private void handleChat(AsyncPlayerChatEvent event) {
|
||||||
if (Settings.isChatAllowed) {
|
if (Settings.isChatAllowed) {
|
||||||
return;
|
return;
|
||||||
@ -89,11 +80,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerCommandPreprocess.
|
|
||||||
*
|
|
||||||
* @param event PlayerCommandPreprocessEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
String cmd = event.getMessage().split(" ")[0].toLowerCase();
|
String cmd = event.getMessage().split(" ")[0].toLowerCase();
|
||||||
@ -109,71 +95,36 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerNormalChat.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerChatEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
public void onPlayerNormalChat(AsyncPlayerChatEvent event) {
|
public void onPlayerNormalChat(AsyncPlayerChatEvent event) {
|
||||||
handleChat(event);
|
handleChat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerHighChat.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerChatEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||||
public void onPlayerHighChat(AsyncPlayerChatEvent event) {
|
public void onPlayerHighChat(AsyncPlayerChatEvent event) {
|
||||||
handleChat(event);
|
handleChat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerChat.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerChatEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
handleChat(event);
|
handleChat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerHighestChat.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerChatEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
|
public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
|
||||||
handleChat(event);
|
handleChat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerEarlyChat.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerChatEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
|
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
|
||||||
handleChat(event);
|
handleChat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerLowChat.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerChatEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||||
public void onPlayerLowChat(AsyncPlayerChatEvent event) {
|
public void onPlayerLowChat(AsyncPlayerChatEvent event) {
|
||||||
handleChat(event);
|
handleChat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerMove.
|
|
||||||
*
|
|
||||||
* @param event PlayerMoveEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (Settings.isMovementAllowed && Settings.getMovementRadius <= 0) {
|
if (Settings.isMovementAllowed && Settings.getMovementRadius <= 0) {
|
||||||
@ -216,11 +167,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerJoin.
|
|
||||||
*
|
|
||||||
* @param event PlayerJoinEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
if (event.getPlayer() == null || Utils.isNPC(event.getPlayer())) {
|
if (event.getPlayer() == null || Utils.isNPC(event.getPlayer())) {
|
||||||
@ -250,11 +196,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPreLogin.
|
|
||||||
*
|
|
||||||
* @param event AsyncPlayerPreLoginEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
|
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||||
final String name = event.getName().toLowerCase();
|
final String name = event.getName().toLowerCase();
|
||||||
@ -282,11 +223,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerLogin.
|
|
||||||
*
|
|
||||||
* @param event PlayerLoginEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
if (event.getPlayer() == null) {
|
if (event.getPlayer() == null) {
|
||||||
@ -318,7 +254,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
PermissionsManager permsMan = plugin.getPermissionsManager();
|
PermissionsManager permsMan = plugin.getPermissionsManager();
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL && !permsMan.hasPermission(player, "authme.vip")) {
|
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL && !permsMan.hasPermission(player, UserPermission.IS_VIP)) {
|
||||||
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_FULL_SERVER));
|
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_FULL_SERVER));
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
||||||
return;
|
return;
|
||||||
@ -331,7 +267,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||||
|
|
||||||
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) {
|
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||||
if (Settings.countriesBlacklist.contains(code)) {
|
if (Settings.countriesBlacklist.contains(code)) {
|
||||||
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||||
@ -340,7 +276,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) {
|
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) {
|
||||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||||
if (!Settings.countries.contains(code)) {
|
if (!Settings.countries.contains(code)) {
|
||||||
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR));
|
||||||
@ -383,11 +319,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerQuit.
|
|
||||||
*
|
|
||||||
* @param event PlayerQuitEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
if (event.getPlayer() == null) {
|
if (event.getPlayer() == null) {
|
||||||
@ -403,11 +334,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
plugin.management.performQuit(player, false);
|
plugin.management.performQuit(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerKick.
|
|
||||||
*
|
|
||||||
* @param event PlayerKickEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
if (event.getPlayer() == null) {
|
if (event.getPlayer() == null) {
|
||||||
@ -423,11 +349,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
plugin.management.performQuit(player, true);
|
plugin.management.performQuit(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerPickupItem.
|
|
||||||
*
|
|
||||||
* @param event PlayerPickupItemEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||||
if (Utils.checkAuth(event.getPlayer()))
|
if (Utils.checkAuth(event.getPlayer()))
|
||||||
@ -435,11 +356,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerInteract.
|
|
||||||
*
|
|
||||||
* @param event PlayerInteractEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -448,11 +364,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerConsumeItem.
|
|
||||||
*
|
|
||||||
* @param event PlayerItemConsumeEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
|
public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
|
||||||
if (Utils.checkAuth(event.getPlayer()))
|
if (Utils.checkAuth(event.getPlayer()))
|
||||||
@ -460,11 +371,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerInventoryOpen.
|
|
||||||
*
|
|
||||||
* @param event InventoryOpenEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
|
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
|
||||||
final Player player = (Player) event.getPlayer();
|
final Player player = (Player) event.getPlayer();
|
||||||
@ -485,11 +391,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerInventoryClick.
|
|
||||||
*
|
|
||||||
* @param event InventoryClickEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerInventoryClick(InventoryClickEvent event) {
|
public void onPlayerInventoryClick(InventoryClickEvent event) {
|
||||||
if (event.getWhoClicked() == null)
|
if (event.getWhoClicked() == null)
|
||||||
@ -501,11 +402,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method playerHitPlayerEvent.
|
|
||||||
*
|
|
||||||
* @param event EntityDamageByEntityEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void playerHitPlayerEvent(EntityDamageByEntityEvent event) {
|
public void playerHitPlayerEvent(EntityDamageByEntityEvent event) {
|
||||||
Entity damager = event.getDamager();
|
Entity damager = event.getDamager();
|
||||||
@ -518,11 +414,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerInteractEntity.
|
|
||||||
*
|
|
||||||
* @param event PlayerInteractEntityEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -531,11 +422,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerDropItem.
|
|
||||||
*
|
|
||||||
* @param event PlayerDropItemEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
if (Utils.checkAuth(event.getPlayer()))
|
if (Utils.checkAuth(event.getPlayer()))
|
||||||
@ -543,11 +429,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerBedEnter.
|
|
||||||
*
|
|
||||||
* @param event PlayerBedEnterEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||||
if (Utils.checkAuth(event.getPlayer()))
|
if (Utils.checkAuth(event.getPlayer()))
|
||||||
@ -555,11 +436,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onSignChange.
|
|
||||||
*
|
|
||||||
* @param event SignChangeEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onSignChange(SignChangeEvent event) {
|
public void onSignChange(SignChangeEvent event) {
|
||||||
if (Utils.checkAuth(event.getPlayer()))
|
if (Utils.checkAuth(event.getPlayer()))
|
||||||
@ -567,11 +443,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerRespawn.
|
|
||||||
*
|
|
||||||
* @param event PlayerRespawnEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -588,17 +459,12 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerGameModeChange.
|
|
||||||
*
|
|
||||||
* @param event PlayerGameModeChangeEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival"))
|
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL))
|
||||||
return;
|
return;
|
||||||
if (Utils.checkAuth(player))
|
if (Utils.checkAuth(player))
|
||||||
return;
|
return;
|
||||||
@ -611,11 +477,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerShear.
|
|
||||||
*
|
|
||||||
* @param event PlayerShearEntityEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
public void onPlayerShear(PlayerShearEntityEvent event) {
|
public void onPlayerShear(PlayerShearEntityEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -624,11 +485,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method onPlayerFish.
|
|
||||||
*
|
|
||||||
* @param event PlayerFishEvent
|
|
||||||
*/
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
public void onPlayerFish(PlayerFishEvent event) {
|
public void onPlayerFish(PlayerFishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.permission;
|
|||||||
/**
|
/**
|
||||||
* AuthMe admin permissions.
|
* AuthMe admin permissions.
|
||||||
*/
|
*/
|
||||||
public enum AdminPermission implements PermissionsNode {
|
public enum AdminPermission implements PermissionNode {
|
||||||
|
|
||||||
REGISTER("authme.admin.register"),
|
REGISTER("authme.admin.register"),
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.permission;
|
|||||||
/**
|
/**
|
||||||
* Common interface for AuthMe permission nodes.
|
* Common interface for AuthMe permission nodes.
|
||||||
*/
|
*/
|
||||||
public interface PermissionsNode {
|
public interface PermissionNode {
|
||||||
|
|
||||||
/** Return the node of the permission, e.g. "authme.unregister". */
|
/** Return the node of the permission, e.g. "authme.unregister". */
|
||||||
String getNode();
|
String getNode();
|
@ -98,10 +98,10 @@ public class PermissionsManager {
|
|||||||
/**
|
/**
|
||||||
* Return the permissions system where the permissions manager is currently hooked into.
|
* Return the permissions system where the permissions manager is currently hooked into.
|
||||||
*
|
*
|
||||||
* @return Permissions system type.
|
* @return The name of the permissions system used.
|
||||||
*/
|
*/
|
||||||
public PermissionsSystemType getUsedPermissionsSystemType() {
|
public String getUsedPermissionsSystemType() {
|
||||||
return this.permsType;
|
return this.permsType.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -330,12 +330,16 @@ public class PermissionsManager {
|
|||||||
* the player has to be OP in order to have the permission.
|
* the player has to be OP in order to have the permission.
|
||||||
*
|
*
|
||||||
* @param player The player.
|
* @param player The player.
|
||||||
* @param permissionsNode The permissions node to verify.
|
* @param permissionNode The permissions node to verify.
|
||||||
*
|
*
|
||||||
* @return True if the player has the permission, false otherwise.
|
* @return True if the player has the permission, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean hasPermission(Player player, PermissionsNode permissionsNode) {
|
public boolean hasPermission(Player player, PermissionNode permissionNode) {
|
||||||
return hasPermission(player, permissionsNode.getNode(), player.isOp());
|
return hasPermission(player, permissionNode, player.isOp());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(Player player, PermissionNode permissionNode, boolean def) {
|
||||||
|
return hasPermission(player, permissionNode.getNode(), def);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -910,7 +914,7 @@ public class PermissionsManager {
|
|||||||
return removeGroups(player, groupNames);
|
return removeGroups(player, groupNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PermissionsSystemType {
|
private enum PermissionsSystemType {
|
||||||
NONE("None"),
|
NONE("None"),
|
||||||
PERMISSIONS_EX("PermissionsEx"),
|
PERMISSIONS_EX("PermissionsEx"),
|
||||||
PERMISSIONS_BUKKIT("Permissions Bukkit"),
|
PERMISSIONS_BUKKIT("Permissions Bukkit"),
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.permission;
|
|||||||
/**
|
/**
|
||||||
* AuthMe user permission nodes.
|
* AuthMe user permission nodes.
|
||||||
*/
|
*/
|
||||||
public enum UserPermission implements PermissionsNode {
|
public enum UserPermission implements PermissionNode {
|
||||||
|
|
||||||
BYPASS_ANTIBOT("authme.bypassantibot"),
|
BYPASS_ANTIBOT("authme.bypassantibot"),
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.settings.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
@ -38,7 +39,7 @@ public class AsyncChangeEmail {
|
|||||||
String playerName = player.getName().toLowerCase();
|
String playerName = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
if (Settings.getmaxRegPerEmail > 0) {
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts")
|
if (!plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||||
&& plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
&& plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
||||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||||
return;
|
return;
|
||||||
|
@ -10,6 +10,7 @@ import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
|||||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.settings.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
@ -93,7 +94,10 @@ public class AsynchronousJoin {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Settings.getMaxJoinPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
|
if (Settings.getMaxJoinPerIp > 0
|
||||||
|
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||||
|
&& !ip.equalsIgnoreCase("127.0.0.1")
|
||||||
|
&& !ip.equalsIgnoreCase("localhost")) {
|
||||||
if (plugin.hasJoinedIp(player.getName(), ip)) {
|
if (plugin.hasJoinedIp(player.getName(), ip)) {
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.settings.MessageKey;
|
||||||
@ -119,7 +120,7 @@ public class AsynchronousLogin {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (Settings.getMaxLoginPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
if (Settings.getMaxLoginPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
||||||
if (plugin.isLoggedIp(name, getIP())) {
|
if (plugin.isLoggedIp(name, getIP())) {
|
||||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||||
return null;
|
return null;
|
||||||
@ -267,7 +268,7 @@ public class AsynchronousLogin {
|
|||||||
* uuidaccounts + "."; } }
|
* uuidaccounts + "."; } }
|
||||||
*/
|
*/
|
||||||
for (Player player : Utils.getOnlinePlayers()) {
|
for (Player player : Utils.getOnlinePlayers()) {
|
||||||
if (plugin.getPermissionsManager().hasPermission(player, "authme.seeOtherAccounts")) {
|
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.SEE_OTHER_ACCOUNTS)) {
|
||||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
||||||
player.sendMessage(message.toString());
|
player.sendMessage(message.toString());
|
||||||
// player.sendMessage(uuidaccounts.replace("%size%",
|
// player.sendMessage(uuidaccounts.replace("%size%",
|
||||||
|
@ -5,6 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.settings.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
@ -26,15 +27,6 @@ public class AsyncRegister {
|
|||||||
private final DataSource database;
|
private final DataSource database;
|
||||||
private final Messages m;
|
private final Messages m;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for AsyncRegister.
|
|
||||||
*
|
|
||||||
* @param player Player
|
|
||||||
* @param password String
|
|
||||||
* @param email String
|
|
||||||
* @param plugin AuthMe
|
|
||||||
* @param data DataSource
|
|
||||||
*/
|
|
||||||
public AsyncRegister(Player player, String password, String email, AuthMe plugin, DataSource data) {
|
public AsyncRegister(Player player, String password, String email, AuthMe plugin, DataSource data) {
|
||||||
this.m = plugin.getMessages();
|
this.m = plugin.getMessages();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@ -45,20 +37,10 @@ public class AsyncRegister {
|
|||||||
this.database = data;
|
this.database = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getIp.
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
protected String getIp() {
|
protected String getIp() {
|
||||||
return plugin.getIP(player);
|
return plugin.getIP(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method preRegisterCheck.
|
|
||||||
*
|
|
||||||
* @return boolean * @throws Exception
|
|
||||||
*/
|
|
||||||
protected boolean preRegisterCheck() throws Exception {
|
protected boolean preRegisterCheck() throws Exception {
|
||||||
String passLow = password.toLowerCase();
|
String passLow = password.toLowerCase();
|
||||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
@ -82,25 +64,28 @@ public class AsyncRegister {
|
|||||||
} else if (database.isAuthAvailable(name)) {
|
} else if (database.isAuthAvailable(name)) {
|
||||||
m.send(player, MessageKey.NAME_ALREADY_REGISTERED);
|
m.send(player, MessageKey.NAME_ALREADY_REGISTERED);
|
||||||
return false;
|
return false;
|
||||||
} else if (Settings.getmaxRegPerIp > 0) {
|
} else if (Settings.getmaxRegPerIp > 0
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) {
|
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
&& database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp
|
||||||
return false;
|
&& !getIp().equalsIgnoreCase("127.0.0.1")
|
||||||
}
|
&& !getIp().equalsIgnoreCase("localhost")) {
|
||||||
|
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process() {
|
public void process() {
|
||||||
try {
|
try {
|
||||||
if (!preRegisterCheck())
|
if (!preRegisterCheck()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (!email.isEmpty() && !email.equals("")) {
|
if (!email.isEmpty() && !email.equals("")) {
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
if (Settings.getmaxRegPerEmail > 0
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||||
return;
|
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
emailRegister();
|
emailRegister();
|
||||||
return;
|
return;
|
||||||
@ -113,17 +98,12 @@ public class AsyncRegister {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method emailRegister.
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
protected void emailRegister() throws Exception {
|
protected void emailRegister() throws Exception {
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
if (Settings.getmaxRegPerEmail > 0
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||||
return;
|
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
PlayerAuth auth;
|
PlayerAuth auth;
|
||||||
final String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
final String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
||||||
|
@ -7,6 +7,7 @@ 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.permission.PermissionsManager;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
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;
|
||||||
@ -200,7 +201,7 @@ public final class Utils {
|
|||||||
* @param player the player to modify.
|
* @param player the player to modify.
|
||||||
*/
|
*/
|
||||||
public static void forceGM(Player player) {
|
public static void forceGM(Player player) {
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival")) {
|
if (!plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)) {
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package fr.xephi.authme.util;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ReflectionTestUtils;
|
import fr.xephi.authme.ReflectionTestUtils;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
|
import fr.xephi.authme.permission.UserPermission;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -53,7 +54,7 @@ public class UtilsTest {
|
|||||||
public void shouldForceSurvivalGameMode() {
|
public void shouldForceSurvivalGameMode() {
|
||||||
// given
|
// given
|
||||||
Player player = mock(Player.class);
|
Player player = mock(Player.class);
|
||||||
given(permissionsManagerMock.hasPermission(player, "authme.bypassforcesurvival")).willReturn(false);
|
given(permissionsManagerMock.hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)).willReturn(false);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Utils.forceGM(player);
|
Utils.forceGM(player);
|
||||||
@ -67,14 +68,14 @@ public class UtilsTest {
|
|||||||
public void shouldNotForceGameModeForUserWithBypassPermission() {
|
public void shouldNotForceGameModeForUserWithBypassPermission() {
|
||||||
// given
|
// given
|
||||||
Player player = mock(Player.class);
|
Player player = mock(Player.class);
|
||||||
given(permissionsManagerMock.hasPermission(player, "authme.bypassforcesurvival")).willReturn(true);
|
given(permissionsManagerMock.hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)).willReturn(true);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Utils.forceGM(player);
|
Utils.forceGM(player);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(authMeMock).getPermissionsManager();
|
verify(authMeMock).getPermissionsManager();
|
||||||
verify(permissionsManagerMock).hasPermission(player, "authme.bypassforcesurvival");
|
verify(permissionsManagerMock).hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL);
|
||||||
verify(player, never()).setGameMode(any(GameMode.class));
|
verify(player, never()).setGameMode(any(GameMode.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user