Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into commands-refactor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import fr.xephi.authme.permission.DefaultPermission;
|
||||
import fr.xephi.authme.permission.PermissionNode;
|
||||
import fr.xephi.authme.util.CollectionUtils;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
@@ -558,16 +559,6 @@ public class CommandDescription {
|
||||
return this.permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the command permissions.
|
||||
*
|
||||
* @param permissionNode The permission node required.
|
||||
* @param defaultPermission The default permission.
|
||||
*/
|
||||
public void setCommandPermissions(PermissionNode permissionNode, CommandPermissions.DefaultPermission defaultPermission) {
|
||||
this.permissions = new CommandPermissions(permissionNode, defaultPermission);
|
||||
}
|
||||
|
||||
public static CommandBuilder builder() {
|
||||
return new CommandBuilder();
|
||||
}
|
||||
@@ -646,7 +637,7 @@ public class CommandDescription {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder permissions(CommandPermissions.DefaultPermission defaultPermission,
|
||||
public CommandBuilder permissions(DefaultPermission defaultPermission,
|
||||
PermissionNode... permissionNodes) {
|
||||
this.permissions = new CommandPermissions(asMutableList(permissionNodes), defaultPermission);
|
||||
return this;
|
||||
|
||||
@@ -37,8 +37,8 @@ import fr.xephi.authme.util.Wrapper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static fr.xephi.authme.command.CommandPermissions.DefaultPermission.ALLOWED;
|
||||
import static fr.xephi.authme.command.CommandPermissions.DefaultPermission.OP_ONLY;
|
||||
import static fr.xephi.authme.permission.DefaultPermission.ALLOWED;
|
||||
import static fr.xephi.authme.permission.DefaultPermission.OP_ONLY;
|
||||
|
||||
/**
|
||||
* Initializes all available AuthMe commands.
|
||||
@@ -162,7 +162,7 @@ public final class CommandInitializer {
|
||||
.build();
|
||||
|
||||
// Register the setemail command
|
||||
CommandDescription setEmailCommand = CommandDescription.builder()
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new SetEmailCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("chgemail", "chgmail", "setemail", "setmail")
|
||||
@@ -174,96 +174,101 @@ public final class CommandInitializer {
|
||||
.build();
|
||||
|
||||
// Register the getip command
|
||||
CommandDescription getIpCommand = new CommandDescription(new GetIpCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("getip");
|
||||
add("ip");
|
||||
}
|
||||
}, "Get player's IP", "Get the IP address of the specified online player.", AUTHME_BASE);
|
||||
getIpCommand.setCommandPermissions(AdminPermission.GET_IP, OP_ONLY);
|
||||
getIpCommand.addArgument(new CommandArgumentDescription("player", "Online player name", true));
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new GetIpCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("getip", "ip")
|
||||
.description("Get player's IP")
|
||||
.detailedDescription("Get the IP address of the specified online player.")
|
||||
.permissions(OP_ONLY, AdminPermission.GET_IP)
|
||||
.withArgument("player", "Player Name", false)
|
||||
.build();
|
||||
|
||||
|
||||
// Register the spawn command
|
||||
CommandDescription spawnCommand = new CommandDescription(new SpawnCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("spawn");
|
||||
add("home");
|
||||
}
|
||||
}, "Teleport to spawn", "Teleport to the spawn.", AUTHME_BASE);
|
||||
spawnCommand.setCommandPermissions(AdminPermission.SPAWN, OP_ONLY);
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new SpawnCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("spawn", "home")
|
||||
.description("Teleport to spawn")
|
||||
.detailedDescription("Teleport to the spawn.")
|
||||
.permissions(OP_ONLY, AdminPermission.SPAWN)
|
||||
.withArgument("player", "Player Name", false)
|
||||
.build();
|
||||
|
||||
// Register the setspawn command
|
||||
CommandDescription setSpawnCommand = new CommandDescription(new SetSpawnCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("setspawn");
|
||||
add("chgspawn");
|
||||
}
|
||||
}, "Change the spawn", "Change the player's spawn to your current position.", AUTHME_BASE);
|
||||
setSpawnCommand.setCommandPermissions(AdminPermission.SET_SPAWN, OP_ONLY);
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new SetSpawnCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("setspawn", "chgspawn")
|
||||
.description("Change the spawn")
|
||||
.detailedDescription("Change the player's spawn to your current position.")
|
||||
.permissions(OP_ONLY, AdminPermission.SET_SPAWN)
|
||||
.build();
|
||||
|
||||
// Register the firstspawn command
|
||||
CommandDescription firstSpawnCommand = new CommandDescription(new FirstSpawnCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("firstspawn");
|
||||
add("firsthome");
|
||||
}
|
||||
}, "Teleport to first spawn", "Teleport to the first spawn.", AUTHME_BASE);
|
||||
firstSpawnCommand.setCommandPermissions(AdminPermission.FIRST_SPAWN, OP_ONLY);
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new FirstSpawnCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("firstspawn", "firsthome")
|
||||
.description("Teleport to first spawn")
|
||||
.detailedDescription("Teleport to the first spawn.")
|
||||
.permissions(OP_ONLY, AdminPermission.FIRST_SPAWN)
|
||||
.build();
|
||||
|
||||
|
||||
// Register the setfirstspawn command
|
||||
CommandDescription setFirstSpawnCommand = new CommandDescription(new SetFirstSpawnCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("setfirstspawn");
|
||||
add("chgfirstspawn");
|
||||
}
|
||||
}, "Change the first spawn", "Change the first player's spawn to your current position.", AUTHME_BASE);
|
||||
setFirstSpawnCommand.setCommandPermissions(AdminPermission.SET_FIRST_SPAWN, OP_ONLY);
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new SetFirstSpawnCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("setfirstspawn", "chgfirstspawn")
|
||||
.description("Change the first spawn")
|
||||
.detailedDescription("Change the first player's spawn to your current position.")
|
||||
.permissions(OP_ONLY, AdminPermission.SET_FIRST_SPAWN)
|
||||
.build();
|
||||
|
||||
// Register the purge command
|
||||
CommandDescription purgeCommand = new CommandDescription(new PurgeCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("purge");
|
||||
add("delete");
|
||||
}
|
||||
}, "Purge old data", "Purge old AuthMeReloaded data longer than the specified amount of days ago.", AUTHME_BASE);
|
||||
purgeCommand.setCommandPermissions(AdminPermission.PURGE, OP_ONLY);
|
||||
purgeCommand.addArgument(new CommandArgumentDescription("days", "Number of days", false));
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new PurgeCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("purge", "delete")
|
||||
.description("Purge old data")
|
||||
.detailedDescription("Purge old AuthMeReloaded data longer than the specified amount of days ago.")
|
||||
.permissions(OP_ONLY, AdminPermission.PURGE)
|
||||
.withArgument("days", "Number of days", false)
|
||||
.build();
|
||||
|
||||
// Register the purgelastposition command
|
||||
CommandDescription purgeLastPositionCommand = new CommandDescription(new PurgeLastPositionCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("resetpos");
|
||||
add("purgelastposition");
|
||||
add("purgelastpos");
|
||||
add("resetposition");
|
||||
add("resetlastposition");
|
||||
add("resetlastpos");
|
||||
}
|
||||
}, "Purge player's last position", "Purge the last know position of the specified player.", AUTHME_BASE);
|
||||
purgeLastPositionCommand.setCommandPermissions(AdminPermission.PURGE_LAST_POSITION, OP_ONLY);
|
||||
purgeLastPositionCommand.addArgument(new CommandArgumentDescription("player", "Player name", true));
|
||||
CommandDescription.builder()
|
||||
.executableCommand(new PurgeLastPositionCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("resetpos", "purgelastposition", "purgelastpos", "resetposition", "resetlastposition", "resetlastpos")
|
||||
.description("Purge player's last position")
|
||||
.detailedDescription("Purge the last know position of the specified player.")
|
||||
.permissions(OP_ONLY, AdminPermission.PURGE_LAST_POSITION)
|
||||
.withArgument("player", "Player name", false)
|
||||
.build();
|
||||
|
||||
// Register the purgebannedplayers command
|
||||
CommandDescription purgeBannedPlayersCommand = new CommandDescription(new PurgeBannedPlayersCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("purgebannedplayers");
|
||||
add("purgebannedplayer");
|
||||
add("deletebannedplayers");
|
||||
add("deletebannedplayer");
|
||||
}
|
||||
}, "Purge banned palyers data", "Purge all AuthMeReloaded data for banned players.", AUTHME_BASE);
|
||||
purgeBannedPlayersCommand.setCommandPermissions(AdminPermission.PURGE_BANNED_PLAYERS, OP_ONLY);
|
||||
CommandDescription purgeBannedPlayersCommand = CommandDescription.builder()
|
||||
.executableCommand(new PurgeBannedPlayersCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("purgebannedplayers", "purgebannedplayer", "deletebannedplayers", "deletebannedplayer")
|
||||
.description("Purge banned players data")
|
||||
.detailedDescription("Purge all AuthMeReloaded data for banned players.")
|
||||
.permissions(OP_ONLY, AdminPermission.PURGE_BANNED_PLAYERS)
|
||||
.build();
|
||||
|
||||
// Register the switchantibot command
|
||||
CommandDescription switchAntiBotCommand = new CommandDescription(new SwitchAntiBotCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("switchantibot");
|
||||
add("toggleantibot");
|
||||
add("antibot");
|
||||
}
|
||||
}, "Switch AntiBot mode", "Switch or toggle the AntiBot mode to the specified state.", AUTHME_BASE);
|
||||
switchAntiBotCommand.setCommandPermissions(AdminPermission.SWITCH_ANTIBOT, OP_ONLY);
|
||||
switchAntiBotCommand.addArgument(new CommandArgumentDescription("mode", "ON / OFF", true));
|
||||
CommandDescription switchAntiBotCommand = CommandDescription.builder()
|
||||
.executableCommand(new SwitchAntiBotCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("switchantibot", "toggleantibot", "antibot")
|
||||
.description("Switch AntiBot mode")
|
||||
.detailedDescription("Switch or toggle the AntiBot mode to the specified state.")
|
||||
.permissions(OP_ONLY, AdminPermission.SWITCH_ANTIBOT)
|
||||
.withArgument("mode", "ON / OFF", true)
|
||||
.build();
|
||||
|
||||
// // Register the resetname command
|
||||
// CommandDescription resetNameCommand = new CommandDescription(
|
||||
@@ -279,13 +284,14 @@ public final class CommandInitializer {
|
||||
// CommandPermissions.DefaultPermission.OP_ONLY);
|
||||
|
||||
// Register the reload command
|
||||
CommandDescription reloadCommand = new CommandDescription(new ReloadCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("reload");
|
||||
add("rld");
|
||||
}
|
||||
}, "Reload plugin", "Reload the AuthMeReloaded plugin.", AUTHME_BASE);
|
||||
reloadCommand.setCommandPermissions(AdminPermission.RELOAD, OP_ONLY);
|
||||
CommandDescription reloadCommand = CommandDescription.builder()
|
||||
.executableCommand(new PurgeLastPositionCommand())
|
||||
.parent(AUTHME_BASE)
|
||||
.labels("reload", "reload")
|
||||
.description("Reload plugin")
|
||||
.detailedDescription("Reload the AutheMeReloaded plugin.")
|
||||
.permissions(OP_ONLY, AdminPermission.RELOAD)
|
||||
.build();
|
||||
|
||||
// Register the version command
|
||||
CommandDescription.builder()
|
||||
@@ -309,22 +315,36 @@ public final class CommandInitializer {
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription loginHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
"View help", "View detailed help pages about AuthMeReloaded login commands.", LOGIN_BASE);
|
||||
loginHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription loginHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(LOGIN_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View Help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded login commands.")
|
||||
.permissions(ALLOWED)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Register the base logout command
|
||||
CommandDescription LOGOUT_BASE = new CommandDescription(new LogoutCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("logout");
|
||||
}
|
||||
}, "Logout command", "Command to logout using AuthMeReloaded.", null);
|
||||
LOGOUT_BASE.setCommandPermissions(PlayerPermission.LOGOUT, ALLOWED);
|
||||
CommandDescription LOGOUT_BASE = CommandDescription.builder()
|
||||
.executableCommand(new LogoutCommand())
|
||||
.parent(null)
|
||||
.labels("logout")
|
||||
.description("Logout command")
|
||||
.detailedDescription("Command to logout using AuthMeReloaded.")
|
||||
.permissions(ALLOWED, PlayerPermission.LOGOUT)
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription logoutHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
"View help", "View detailed help pages about AuthMeReloaded logout commands.", LOGOUT_BASE);
|
||||
logoutHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription logoutHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(LOGOUT_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded logout commands.")
|
||||
.permissions(ALLOWED)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Register the base register command
|
||||
final CommandDescription REGISTER_BASE = CommandDescription.builder()
|
||||
@@ -339,120 +359,161 @@ public final class CommandInitializer {
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription registerHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
"View help", "View detailed help pages about AuthMeReloaded register commands.", REGISTER_BASE);
|
||||
registerHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription registerHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(REGISTER_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded register commands.")
|
||||
.permissions(ALLOWED)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Register the base unregister command
|
||||
CommandDescription UNREGISTER_BASE = new CommandDescription(new UnregisterCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("unregister");
|
||||
add("unreg");
|
||||
}
|
||||
}, "Unregistration command", "Command to unregister using AuthMeReloaded.", null);
|
||||
UNREGISTER_BASE.setCommandPermissions(PlayerPermission.UNREGISTER, ALLOWED);
|
||||
UNREGISTER_BASE.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
CommandDescription UNREGISTER_BASE = CommandDescription.builder()
|
||||
.executableCommand(new UnregisterCommand())
|
||||
.parent(null)
|
||||
.labels("unreg", "unregister")
|
||||
.description("Unregistration Command")
|
||||
.detailedDescription("Command to unregister using AuthMeReloaded.")
|
||||
.permissions(ALLOWED, PlayerPermission.UNREGISTER)
|
||||
.withArgument("password", "Password", false)
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription unregisterHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels, "View help", "View detailed help pages about AuthMeReloaded unregister commands.", UNREGISTER_BASE);
|
||||
unregisterHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription unregisterHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(UNREGISTER_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded unregister commands.")
|
||||
.permissions(ALLOWED)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Register the base changepassword command
|
||||
final CommandDescription CHANGE_PASSWORD_BASE = new CommandDescription(
|
||||
new ChangePasswordCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("changepassword");
|
||||
add("changepass");
|
||||
}
|
||||
}, "Change password command", "Command to change your password using AuthMeReloaded.", null);
|
||||
CHANGE_PASSWORD_BASE.setCommandPermissions(PlayerPermission.CHANGE_PASSWORD, ALLOWED);
|
||||
CHANGE_PASSWORD_BASE.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
CHANGE_PASSWORD_BASE.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
||||
final CommandDescription CHANGE_PASSWORD_BASE = CommandDescription.builder()
|
||||
.executableCommand(new ChangePasswordCommand())
|
||||
.parent(null)
|
||||
.labels("changepassword", "changepass", "cp")
|
||||
.description("Change password Command")
|
||||
.detailedDescription("Command to change your password using AuthMeReloaded.")
|
||||
.permissions(ALLOWED, PlayerPermission.CHANGE_PASSWORD)
|
||||
.withArgument("password", "Password", false)
|
||||
.withArgument("verifyPassword", "Verify password.", false)
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription changePasswordHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
"View help", "View detailed help pages about AuthMeReloaded change password commands.", CHANGE_PASSWORD_BASE);
|
||||
changePasswordHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription changePasswordHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(CHANGE_PASSWORD_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded changepassword commands.")
|
||||
.permissions(ALLOWED)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Register the base Dungeon Maze command
|
||||
CommandDescription EMAIL_BASE = new CommandDescription(helpCommandExecutable, new ArrayList<String>() {
|
||||
{
|
||||
add("email");
|
||||
add("mail");
|
||||
}
|
||||
}, "E-mail command", "The AuthMe Reloaded E-mail command. The root for all E-mail commands.", null);
|
||||
// Register the base Email command
|
||||
CommandDescription EMAIL_BASE = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(null)
|
||||
.labels("email", "mail")
|
||||
.description("Email command")
|
||||
.detailedDescription("The AuthMeReloaded Email command base.")
|
||||
.permissions(ALLOWED)
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription emailHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
"View help", "View detailed help pages about AuthMeReloaded help commands.", EMAIL_BASE);
|
||||
emailHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription emailHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(EMAIL_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded email commands.")
|
||||
.permissions(ALLOWED)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Register the add command
|
||||
CommandDescription addEmailCommand = new CommandDescription(new AddEmailCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("add");
|
||||
add("addemail");
|
||||
add("addmail");
|
||||
}
|
||||
}, "Add E-mail", "Add an new E-Mail address to your account.", EMAIL_BASE);
|
||||
addEmailCommand.setCommandPermissions(PlayerPermission.ADD_EMAIL, ALLOWED);
|
||||
addEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||
addEmailCommand.addArgument(new CommandArgumentDescription("verifyEmail", "Email address verification", false));
|
||||
CommandDescription addEmailCommand = CommandDescription.builder()
|
||||
.executableCommand(new AddEmailCommand())
|
||||
.parent(EMAIL_BASE)
|
||||
.labels("add", "addemail", "addmail")
|
||||
.description("Add Email")
|
||||
.detailedDescription("Add a new Email address to your account.")
|
||||
.permissions(ALLOWED, PlayerPermission.ADD_EMAIL)
|
||||
.withArgument("email", "Email address", false)
|
||||
.withArgument("verifyEmail", "Email address verification", false)
|
||||
.build();
|
||||
|
||||
// Register the change command
|
||||
CommandDescription changeEmailCommand = new CommandDescription(new ChangeEmailCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("change");
|
||||
add("changeemail");
|
||||
add("changemail");
|
||||
}
|
||||
}, "Change E-mail", "Change an E-Mail address of your account.", EMAIL_BASE);
|
||||
changeEmailCommand.setCommandPermissions(PlayerPermission.CHANGE_EMAIL, ALLOWED);
|
||||
changeEmailCommand.addArgument(new CommandArgumentDescription("oldEmail", "Old email address", false));
|
||||
changeEmailCommand.addArgument(new CommandArgumentDescription("newEmail", "New email address", false));
|
||||
CommandDescription changeEmailCommand = CommandDescription.builder()
|
||||
.executableCommand(new ChangeEmailCommand())
|
||||
.parent(EMAIL_BASE)
|
||||
.labels("change", "changeemail", "changemail")
|
||||
.description("Change Email")
|
||||
.detailedDescription("Change an Email address of your account.")
|
||||
.permissions(ALLOWED, PlayerPermission.CHANGE_EMAIL)
|
||||
.withArgument("oldEmail", "Old email address", false)
|
||||
.withArgument("newEmail", "New email address", false)
|
||||
.build();
|
||||
|
||||
|
||||
// Register the recover command
|
||||
CommandDescription recoverEmailCommand = new CommandDescription(new RecoverEmailCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("recover");
|
||||
add("recovery");
|
||||
add("recoveremail");
|
||||
add("recovermail");
|
||||
}
|
||||
}, "Recover using E-mail", "Recover your account using an E-mail address.", EMAIL_BASE);
|
||||
recoverEmailCommand.setCommandPermissions(PlayerPermission.RECOVER_EMAIL, ALLOWED);
|
||||
recoverEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||
CommandDescription recoverEmailCommand = CommandDescription.builder()
|
||||
.executableCommand(new RecoverEmailCommand())
|
||||
.parent(EMAIL_BASE)
|
||||
.labels("recover", "recovery", "recoveremail", "recovermail")
|
||||
.description("Recover password using Email")
|
||||
.detailedDescription("Recover your account using an Email address by sending a mail containing a new password.")
|
||||
.permissions(ALLOWED, PlayerPermission.RECOVER_EMAIL)
|
||||
.withArgument("email", "Email address", false)
|
||||
.build();
|
||||
|
||||
// Register the base captcha command
|
||||
CommandDescription CAPTCHA_BASE = new CommandDescription(new CaptchaCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("captcha");
|
||||
add("capt");
|
||||
}
|
||||
}, "Captcha command", "Captcha command for AuthMeReloaded.", null);
|
||||
CAPTCHA_BASE.setCommandPermissions(PlayerPermission.CAPTCHA, ALLOWED);
|
||||
CAPTCHA_BASE.addArgument(new CommandArgumentDescription("captcha", "The captcha", false));
|
||||
CommandDescription CAPTCHA_BASE = CommandDescription.builder()
|
||||
.executableCommand(new CaptchaCommand())
|
||||
.parent(null)
|
||||
.labels("captcha", "capt")
|
||||
.description("Captcha Command")
|
||||
.detailedDescription("Captcha command for AuthMeRelaoded.")
|
||||
.permissions(ALLOWED, PlayerPermission.CAPTCHA)
|
||||
.withArgument("captcha", "The Captcha", false)
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription captchaHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
"View help", "View detailed help pages about AuthMeReloaded change captcha commands.", CAPTCHA_BASE);
|
||||
captchaHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription captchaHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(CAPTCHA_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded captcha commands.")
|
||||
.permissions(ALLOWED)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Register the base converter command
|
||||
CommandDescription CONVERTER_BASE = new CommandDescription(new ConverterCommand(), new ArrayList<String>() {
|
||||
{
|
||||
add("converter");
|
||||
add("convert");
|
||||
add("conv");
|
||||
}
|
||||
}, "Convert command", "Convert command for AuthMeReloaded.", null);
|
||||
CONVERTER_BASE.setCommandPermissions(AdminPermission.CONVERTER, OP_ONLY);
|
||||
CONVERTER_BASE.addArgument(new CommandArgumentDescription("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / royalauth / vauth / sqltoflat", false));
|
||||
CommandDescription CONVERTER_BASE = CommandDescription.builder()
|
||||
.executableCommand(new ConverterCommand())
|
||||
.parent(null)
|
||||
.labels("converter", "convert", "conv")
|
||||
.description("Converter Command")
|
||||
.detailedDescription("Converter command for AuthMeRelaoded.")
|
||||
.permissions(OP_ONLY, AdminPermission.CONVERTER)
|
||||
.withArgument("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / royalauth / vauth / sqltoflat", false)
|
||||
.build();
|
||||
|
||||
// Register the help command
|
||||
CommandDescription converterHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
"View help", "View detailed help pages about AuthMeReloaded change captcha commands.", CONVERTER_BASE);
|
||||
converterHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
CommandDescription converterHelpCommand = CommandDescription.builder()
|
||||
.executableCommand(helpCommandExecutable)
|
||||
.parent(CONVERTER_BASE)
|
||||
.labels(helpCommandLabels)
|
||||
.description("View help")
|
||||
.detailedDescription("View detailed help pages about AuthMeReloaded converter commands.")
|
||||
.permissions(OP_ONLY)
|
||||
.withArgument("query", "The command or query to view help for.", true)
|
||||
.build();
|
||||
|
||||
// Add the base commands to the commands array
|
||||
baseCommands = new HashSet<>(Arrays.asList(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.permission.DefaultPermission;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.PermissionNode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -22,18 +23,6 @@ public class CommandPermissions {
|
||||
*/
|
||||
private DefaultPermission defaultPermission;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param permissionNode The permission node required to execute a command.
|
||||
* @param defaultPermission The default permission if the permission nodes couldn't be used.
|
||||
*/
|
||||
public CommandPermissions(PermissionNode permissionNode, DefaultPermission defaultPermission) {
|
||||
this.permissionNodes = new ArrayList<>();
|
||||
this.permissionNodes.add(permissionNode);
|
||||
this.defaultPermission = defaultPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -54,16 +43,6 @@ public class CommandPermissions {
|
||||
return this.permissionNodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of permission nodes set.
|
||||
*
|
||||
* @return Permission node count.
|
||||
*/
|
||||
public int getPermissionNodeCount() {
|
||||
return this.permissionNodes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this command requires any permission to be executed. This is based on the getPermission() method.
|
||||
*
|
||||
@@ -73,31 +52,28 @@ public class CommandPermissions {
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
// Make sure any permission node is set
|
||||
if (getPermissionNodeCount() == 0)
|
||||
if (permissionNodes.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the default permission
|
||||
PermissionsManager permissionsManager = AuthMe.getInstance().getPermissionsManager();
|
||||
final boolean defaultPermission = getDefaultPermissionCommandSender(sender);
|
||||
|
||||
// Make sure the command sender is a player, if not use the default
|
||||
if (!(sender instanceof Player))
|
||||
if (!(sender instanceof Player)) {
|
||||
return defaultPermission;
|
||||
}
|
||||
|
||||
// Get the player instance
|
||||
Player player = (Player) sender;
|
||||
|
||||
// Get the permissions manager, and make sure it's instance is valid
|
||||
PermissionsManager permissionsManager = AuthMe.getInstance().getPermissionsManager();
|
||||
|
||||
if (permissionsManager == null)
|
||||
return false;
|
||||
|
||||
// Check whether the player has permission, return the result
|
||||
for (PermissionNode node : this.permissionNodes) {
|
||||
if (!permissionsManager.hasPermission(player, node, defaultPermission)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return permissionsManager.hasPermission(player, this.permissionNodes, defaultPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,14 +85,6 @@ public class CommandPermissions {
|
||||
return this.defaultPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default permission used if the permission nodes couldn't be used.
|
||||
*
|
||||
* @param defaultPermission The default permission.
|
||||
*/
|
||||
public void setDefaultPermission(DefaultPermission defaultPermission) {
|
||||
this.defaultPermission = defaultPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default permission for a specified command sender.
|
||||
@@ -138,12 +106,4 @@ public class CommandPermissions {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public enum DefaultPermission {
|
||||
NOT_ALLOWED,
|
||||
OP_ONLY,
|
||||
ALLOWED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,12 @@ public class RegisterAdminCommand extends ExecutableCommand {
|
||||
final String playerPassLowerCase = playerPass.toLowerCase();
|
||||
|
||||
// Command logic
|
||||
if (playerPassLowerCase.contains("delete") || playerPassLowerCase.contains("where") || playerPassLowerCase.contains("insert") || playerPassLowerCase.contains("modify") || playerPassLowerCase.contains("from") || playerPassLowerCase.contains("select") || playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null") || !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
||||
m.send(sender, MessageKey.PASSWORD_IS_USERNAME_ERROR);
|
||||
if (playerPassLowerCase.contains("delete") || playerPassLowerCase.contains("where")
|
||||
|| playerPassLowerCase.contains("insert") || playerPassLowerCase.contains("modify")
|
||||
|| playerPassLowerCase.contains("from") || playerPassLowerCase.contains("select")
|
||||
|| playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null")
|
||||
|| !playerPassLowerCase.matches(Settings.getPassRegex)) {
|
||||
m.send(sender, MessageKey.PASSWORD_MATCH_ERROR);
|
||||
return true;
|
||||
}
|
||||
if (playerPassLowerCase.equalsIgnoreCase(playerName)) {
|
||||
|
||||
@@ -6,12 +6,14 @@ import fr.xephi.authme.command.CommandDescription;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.CommandPermissions;
|
||||
import fr.xephi.authme.permission.PermissionNode;
|
||||
import fr.xephi.authme.util.CollectionUtils;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -85,14 +87,11 @@ public class HelpPrinter {
|
||||
* @param command The command to print the permissions help for.
|
||||
*/
|
||||
public static void printPermissions(CommandSender sender, CommandDescription command) {
|
||||
// Get the permissions and make sure it isn't null
|
||||
// Get the permissions and make sure they aren't missing
|
||||
CommandPermissions permissions = command.getCommandPermissions();
|
||||
if (permissions == null)
|
||||
return;
|
||||
|
||||
// Make sure any permission node is set
|
||||
if (permissions.getPermissionNodeCount() <= 0)
|
||||
if (permissions == null || CollectionUtils.isEmpty(permissions.getPermissionNodes())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Print the header
|
||||
sender.sendMessage(ChatColor.GOLD + "Permissions:");
|
||||
@@ -107,13 +106,16 @@ public class HelpPrinter {
|
||||
}
|
||||
|
||||
// Print the default permission
|
||||
// TODO ljacqu 20151205: This is duplicating the logic in PermissionsManager#evaluateDefaultPermission
|
||||
// Either use the command manager here, or if that's too heavy, look into moving certain permissions logic
|
||||
// into a Utils class
|
||||
switch (permissions.getDefaultPermission()) {
|
||||
case ALLOWED:
|
||||
sender.sendMessage(ChatColor.GOLD + " Default: " + ChatColor.GRAY + ChatColor.ITALIC + "Permission!");
|
||||
break;
|
||||
|
||||
case OP_ONLY:
|
||||
final String defaultPermsString = ChatColor.GRAY + (permissions.getDefaultPermissionCommandSender(sender) ? ChatColor.ITALIC + " (Permission!)" : ChatColor.ITALIC + " (No Permission!)");
|
||||
final String defaultPermsString = ChatColor.GRAY + (sender.isOp() ? ChatColor.ITALIC + " (Permission!)" : ChatColor.ITALIC + " (No Permission!)");
|
||||
sender.sendMessage(ChatColor.GOLD + " Default: " + ChatColor.YELLOW + ChatColor.ITALIC + "OP's Only!" + defaultPermsString);
|
||||
break;
|
||||
|
||||
|
||||
@@ -8,112 +8,108 @@ public enum AdminPermission implements PermissionNode {
|
||||
/**
|
||||
* Administrator command to register a new user.
|
||||
*/
|
||||
REGISTER("authme.command.admin.register"),
|
||||
REGISTER("authme.admin.register"),
|
||||
|
||||
/**
|
||||
* Administrator command to unregister an existing user.
|
||||
*/
|
||||
UNREGISTER("authme.command.admin.unregister"),
|
||||
UNREGISTER("authme.admin.unregister"),
|
||||
|
||||
/**
|
||||
* Administrator command to force-login an existing user.
|
||||
*/
|
||||
FORCE_LOGIN("authme.command.admin.forcelogin"),
|
||||
FORCE_LOGIN("authme.admin.forcelogin"),
|
||||
|
||||
/**
|
||||
* Administrator command to change the password of a user.
|
||||
*/
|
||||
CHANGE_PASSWORD("authme.command.admin.changepassword"),
|
||||
CHANGE_PASSWORD("authme.admin.changepassword"),
|
||||
|
||||
/**
|
||||
* Administrator command to see the last login date and time of an user.
|
||||
* Administrator command to see the last login date and time of a user.
|
||||
*/
|
||||
LAST_LOGIN("authme.command.admin.lastlogin"),
|
||||
LAST_LOGIN("authme.admin.lastlogin"),
|
||||
|
||||
/**
|
||||
* Administrator command to see all accounts associated with an user.
|
||||
* Administrator command to see all accounts associated with a user.
|
||||
*/
|
||||
ACCOUNTS("authme.command.admin.accounts"),
|
||||
ACCOUNTS("authme.admin.accounts"),
|
||||
|
||||
/**
|
||||
* Administrator command to get the email address of an user, if set.
|
||||
* Administrator command to get the email address of a user, if set.
|
||||
*/
|
||||
GET_EMAIL("authme.command.admin.getemail"),
|
||||
GET_EMAIL("authme.admin.getemail"),
|
||||
|
||||
/**
|
||||
* Administrator command to set or change the email adress of an user.
|
||||
* Administrator command to set or change the email address of a user.
|
||||
*/
|
||||
CHANGE_EMAIL("authme.command.admin.changemail"),
|
||||
CHANGE_EMAIL("authme.admin.changemail"),
|
||||
|
||||
/**
|
||||
* Administrator command to get the last known IP of an user.
|
||||
* Administrator command to get the last known IP of a user.
|
||||
*/
|
||||
GET_IP("authme.command.admin.getip"),
|
||||
GET_IP("authme.admin.getip"),
|
||||
|
||||
/**
|
||||
* Administrator command to teleport to the AuthMe spawn.
|
||||
*/
|
||||
SPAWN("authme.command.admin.spawn"),
|
||||
SPAWN("authme.admin.spawn"),
|
||||
|
||||
/**
|
||||
* Administrator command to set the AuthMe spawn.
|
||||
*/
|
||||
SET_SPAWN("authme.command.admin.setspawn"),
|
||||
SET_SPAWN("authme.admin.setspawn"),
|
||||
|
||||
/**
|
||||
* Administrator command to teleport to the first AuthMe spawn.
|
||||
*/
|
||||
FIRST_SPAWN("authme.command.admin.firstspawn"),
|
||||
FIRST_SPAWN("authme.admin.firstspawn"),
|
||||
|
||||
/**
|
||||
* Administrator command to set the first AuthMe spawn.
|
||||
*/
|
||||
SET_FIRST_SPAWN("authme.command.admin.setfirstspawn"),
|
||||
SET_FIRST_SPAWN("authme.admin.setfirstspawn"),
|
||||
|
||||
/**
|
||||
* Administrator command to purge old user data.
|
||||
*/
|
||||
PURGE("authme.command.admin.purge"),
|
||||
PURGE("authme.admin.purge"),
|
||||
|
||||
/**
|
||||
* Administrator command to purge the last position of an user.
|
||||
* Administrator command to purge the last position of a user.
|
||||
*/
|
||||
PURGE_LAST_POSITION("authme.command.admin.purgelastpos"),
|
||||
PURGE_LAST_POSITION("authme.admin.purgelastpos"),
|
||||
|
||||
/**
|
||||
* Administrator command to purge all data associated with banned players.
|
||||
*/
|
||||
PURGE_BANNED_PLAYERS("authme.command.admin.purgebannedplayers"),
|
||||
PURGE_BANNED_PLAYERS("authme.admin.purgebannedplayers"),
|
||||
|
||||
/**
|
||||
* Administrator command to toggle the AntiBot protection status.
|
||||
*/
|
||||
SWITCH_ANTIBOT("authme.command.admin.switchantibot"),
|
||||
SWITCH_ANTIBOT("authme.admin.switchantibot"),
|
||||
|
||||
/**
|
||||
* Administrator command to convert old or other data to AuthMe data.
|
||||
*/
|
||||
CONVERTER("authme.command.admin.converter"),
|
||||
CONVERTER("authme.admin.converter"),
|
||||
|
||||
/**
|
||||
* Administrator command to reload the plugin configuration.
|
||||
*/
|
||||
RELOAD("authme.command.admin.reload");
|
||||
RELOAD("authme.admin.reload"),
|
||||
|
||||
/**
|
||||
* Give access to all admin commands.
|
||||
*/
|
||||
ADMIN_ALL("authme.admin.*");
|
||||
|
||||
/**
|
||||
* Permission node.
|
||||
* The permission node.
|
||||
*/
|
||||
private String node;
|
||||
|
||||
/**
|
||||
* Get the permission node.
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -122,4 +118,14 @@ public enum AdminPermission implements PermissionNode {
|
||||
AdminPermission(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionNode getWildcardNode() {
|
||||
return ADMIN_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package fr.xephi.authme.permission;
|
||||
|
||||
/**
|
||||
* The default permission for a command if there is no support for permission nodes.
|
||||
*/
|
||||
public enum DefaultPermission {
|
||||
|
||||
/** No one can execute the command. */
|
||||
NOT_ALLOWED,
|
||||
|
||||
/** Only players with the OP status may execute the command. */
|
||||
OP_ONLY,
|
||||
|
||||
/** The command can be executed by anyone. */
|
||||
ALLOWED
|
||||
}
|
||||
@@ -5,7 +5,18 @@ package fr.xephi.authme.permission;
|
||||
*/
|
||||
public interface PermissionNode {
|
||||
|
||||
/** Return the node of the permission, e.g. "authme.unregister". */
|
||||
/**
|
||||
* Return the node of the permission, e.g. "authme.player.unregister".
|
||||
*
|
||||
* @return The name of the permission node
|
||||
*/
|
||||
String getNode();
|
||||
|
||||
/**
|
||||
* Return the wildcard node that also grants the permission.
|
||||
*
|
||||
* @return The wildcard permission node (e.g. "authme.player.*")
|
||||
*/
|
||||
PermissionNode getWildcardNode();
|
||||
|
||||
}
|
||||
|
||||
@@ -5,11 +5,14 @@ import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import de.bananaco.bpermissions.api.ApiLayer;
|
||||
import de.bananaco.bpermissions.api.CalculableType;
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import fr.xephi.authme.util.CollectionUtils;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
@@ -38,7 +41,7 @@ import java.util.logging.Logger;
|
||||
* @author Tim Visée, http://timvisee.com
|
||||
* @version 0.2.1
|
||||
*/
|
||||
public class PermissionsManager {
|
||||
public class PermissionsManager implements PermissionsService {
|
||||
|
||||
/**
|
||||
* Vault instance.
|
||||
@@ -100,8 +103,8 @@ public class PermissionsManager {
|
||||
*
|
||||
* @return The name of the permissions system used.
|
||||
*/
|
||||
public String getUsedPermissionsSystemType() {
|
||||
return this.permsType.getName();
|
||||
public PermissionsSystemType getSystem() {
|
||||
return permsType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +263,6 @@ public class PermissionsManager {
|
||||
*
|
||||
* @param event Event instance.
|
||||
*/
|
||||
// TODO ljacqu 20151129: Misleading name since onPluginEnable is a typical event-based method name
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
// Get the plugin and it's name
|
||||
Plugin plugin = event.getPlugin();
|
||||
@@ -296,35 +298,7 @@ public class PermissionsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the logger instance.
|
||||
*
|
||||
* @return Logger instance.
|
||||
*/
|
||||
public Logger getLogger() {
|
||||
return this.log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the logger instance.
|
||||
*
|
||||
* @param log Logger instance.
|
||||
*/
|
||||
public void setLogger(Logger log) {
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player has permission. If no permissions system is used, the player has to be OP.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param permsNode Permissions node.
|
||||
*
|
||||
* @return True if the player has permission.
|
||||
*/
|
||||
public boolean hasPermission(Player player, String permsNode) {
|
||||
return hasPermission(player, permsNode, player.isOp());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player has permission for the given permissions node. If no permissions system is used,
|
||||
@@ -340,7 +314,41 @@ public class PermissionsManager {
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, PermissionNode permissionNode, boolean def) {
|
||||
return hasPermission(player, permissionNode.getNode(), def);
|
||||
return hasPermission(player, permissionNode.getNode(), def)
|
||||
|| hasPermission(player, permissionNode.getWildcardNode().getNode(), def);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, Iterable<PermissionNode> nodes, boolean def) {
|
||||
for (PermissionNode node : nodes) {
|
||||
if (!hasPermission(player, node, def)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, CommandDescription command) {
|
||||
if (CollectionUtils.isEmpty(command.getCommandPermissions().getPermissionNodes())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DefaultPermission defaultPermission = command.getCommandPermissions().getDefaultPermission();
|
||||
boolean def = evaluateDefaultPermission(defaultPermission, player);
|
||||
return hasPermission(player, command.getCommandPermissions().getPermissionNodes(), def);
|
||||
}
|
||||
|
||||
public static boolean evaluateDefaultPermission(DefaultPermission defaultPermission, CommandSender sender) {
|
||||
switch (defaultPermission) {
|
||||
case ALLOWED:
|
||||
return true;
|
||||
|
||||
case OP_ONLY:
|
||||
return sender.isOp();
|
||||
|
||||
case NOT_ALLOWED:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -352,7 +360,7 @@ public class PermissionsManager {
|
||||
*
|
||||
* @return True if the player has permission.
|
||||
*/
|
||||
public boolean hasPermission(Player player, String permsNode, boolean def) {
|
||||
private boolean hasPermission(Player player, String permsNode, boolean def) {
|
||||
// If no permissions system is used, return the default value
|
||||
if (!isEnabled())
|
||||
return def;
|
||||
@@ -915,34 +923,5 @@ public class PermissionsManager {
|
||||
return removeGroups(player, groupNames);
|
||||
}
|
||||
|
||||
private enum PermissionsSystemType {
|
||||
NONE("None"),
|
||||
PERMISSIONS_EX("PermissionsEx"),
|
||||
PERMISSIONS_BUKKIT("Permissions Bukkit"),
|
||||
B_PERMISSIONS("bPermissions"),
|
||||
ESSENTIALS_GROUP_MANAGER("Essentials Group Manager"),
|
||||
Z_PERMISSIONS("zPermissions"),
|
||||
VAULT("Vault"),
|
||||
PERMISSIONS("Permissions");
|
||||
|
||||
public final String name;
|
||||
|
||||
/**
|
||||
* Constructor for PermissionsSystemType.
|
||||
*
|
||||
* @param name String
|
||||
*/
|
||||
PermissionsSystemType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getName.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package fr.xephi.authme.permission;
|
||||
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Interface for dealing with permissions.
|
||||
*/
|
||||
public interface PermissionsService {
|
||||
|
||||
/**
|
||||
* Check if the player has the given permission.
|
||||
*
|
||||
* @param player The player
|
||||
* @param permission The permission node to check
|
||||
* @param def Default returned if no permissions system is used
|
||||
*
|
||||
* @return True if the player has permission
|
||||
*/
|
||||
boolean hasPermission(Player player, PermissionNode permission, boolean def);
|
||||
|
||||
/**
|
||||
* Check if the player has the permissions for the given command.
|
||||
*
|
||||
* @param player The player
|
||||
* @param command The command whose permissions should be checked
|
||||
*
|
||||
* @return True if the player may execute the command
|
||||
*/
|
||||
boolean hasPermission(Player player, CommandDescription command);
|
||||
|
||||
/**
|
||||
* Return the permission system the service is working with.
|
||||
*
|
||||
* @return The permission system AuthMe is hooked into
|
||||
*/
|
||||
PermissionsSystemType getSystem();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package fr.xephi.authme.permission;
|
||||
|
||||
/**
|
||||
* Enum representing the permissions systems AuthMe supports.
|
||||
*/
|
||||
public enum PermissionsSystemType {
|
||||
|
||||
NONE("None"),
|
||||
|
||||
PERMISSIONS_EX("PermissionsEx"),
|
||||
|
||||
PERMISSIONS_BUKKIT("Permissions Bukkit"),
|
||||
|
||||
B_PERMISSIONS("bPermissions"),
|
||||
|
||||
ESSENTIALS_GROUP_MANAGER("Essentials Group Manager"),
|
||||
|
||||
Z_PERMISSIONS("zPermissions"),
|
||||
|
||||
VAULT("Vault"),
|
||||
|
||||
PERMISSIONS("Permissions");
|
||||
|
||||
public final String name;
|
||||
|
||||
/**
|
||||
* Constructor for PermissionsSystemType.
|
||||
*
|
||||
* @param name The name the permissions manager goes by
|
||||
*/
|
||||
PermissionsSystemType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -18,47 +18,47 @@ public enum PlayerPermission implements PermissionNode {
|
||||
/**
|
||||
* Command permission to login.
|
||||
*/
|
||||
LOGIN("authme.command.player.login"),
|
||||
LOGIN("authme.player.login"),
|
||||
|
||||
/**
|
||||
* Command permission to logout.
|
||||
*/
|
||||
LOGOUT("authme.command.player.logout"),
|
||||
LOGOUT("authme.player.logout"),
|
||||
|
||||
/**
|
||||
* Command permission to register.
|
||||
*/
|
||||
REGISTER("authme.command.player.register"),
|
||||
REGISTER("authme.player.register"),
|
||||
|
||||
/**
|
||||
* Command permission to unregister.
|
||||
*/
|
||||
UNREGISTER("authme.command.player.unregister"),
|
||||
UNREGISTER("authme.player.unregister"),
|
||||
|
||||
/**
|
||||
* Command permission to change the password.
|
||||
*/
|
||||
CHANGE_PASSWORD("authme.command.player.changepassword"),
|
||||
CHANGE_PASSWORD("authme.player.changepassword"),
|
||||
|
||||
/**
|
||||
* Command permission to add an email address.
|
||||
*/
|
||||
ADD_EMAIL("authme.command.player.email.add"),
|
||||
ADD_EMAIL("authme.player.email.add"),
|
||||
|
||||
/**
|
||||
* Command permission to change the email address.
|
||||
*/
|
||||
CHANGE_EMAIL("authme.command.player.email.change"),
|
||||
CHANGE_EMAIL("authme.player.email.change"),
|
||||
|
||||
/**
|
||||
* Command permission to recover an account using it's email address.
|
||||
*/
|
||||
RECOVER_EMAIL("authme.command.player.email.recover"),
|
||||
RECOVER_EMAIL("authme.player.email.recover"),
|
||||
|
||||
/**
|
||||
* Command permission to use captcha.
|
||||
*/
|
||||
CAPTCHA("authme.command.player.captcha"),
|
||||
CAPTCHA("authme.player.captcha"),
|
||||
|
||||
/**
|
||||
* Permission for users a login can be forced to.
|
||||
@@ -68,33 +68,28 @@ public enum PlayerPermission implements PermissionNode {
|
||||
/**
|
||||
* Permission for users to bypass force-survival mode.
|
||||
*/
|
||||
BYPASS_FORCE_SURVIVAL("authme.command.player.bypassforcesurvival"),
|
||||
BYPASS_FORCE_SURVIVAL("authme.player.bypassforcesurvival"),
|
||||
|
||||
/**
|
||||
* Permission for users to allow two accounts.
|
||||
*/
|
||||
ALLOW_MULTIPLE_ACCOUNTS("authme.command.player.allow2accounts"),
|
||||
ALLOW_MULTIPLE_ACCOUNTS("authme.player.allow2accounts"),
|
||||
|
||||
/**
|
||||
* Permission for user to see other accounts.
|
||||
*/
|
||||
SEE_OTHER_ACCOUNTS("authme.command.player.seeotheraccounts");
|
||||
SEE_OTHER_ACCOUNTS("authme.player.seeotheraccounts"),
|
||||
|
||||
/**
|
||||
* Permission to use all player (non-admin) commands.
|
||||
*/
|
||||
PLAYER_ALL("authme.player.*");
|
||||
|
||||
/**
|
||||
* Permission node.
|
||||
* The permission node.
|
||||
*/
|
||||
private String node;
|
||||
|
||||
/**
|
||||
* Get the permission node.
|
||||
*
|
||||
* @return Permission node.
|
||||
*/
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -103,4 +98,14 @@ public enum PlayerPermission implements PermissionNode {
|
||||
PlayerPermission(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionNode getWildcardNode() {
|
||||
return PLAYER_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,13 @@ public class AsynchronousLogin {
|
||||
m.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Settings.preventOtherCase && !player.getName().equals(pAuth.getRealName()))
|
||||
{
|
||||
// TODO: Add a message like : MessageKey.INVALID_NAME_CASE
|
||||
m.send(player, MessageKey.USERNAME_ALREADY_ONLINE_ERROR);
|
||||
return null;
|
||||
}
|
||||
AuthMeAsyncPreLoginEvent event = new AuthMeAsyncPreLoginEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.canLogin())
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class Settings {
|
||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
|
||||
customAttributes, generateImage, isRemoveSpeedEnabled;
|
||||
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
|
||||
public static String helpHeader, getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
||||
getMySQLTablename, getMySQLColumnName, getMySQLColumnPassword,
|
||||
@@ -294,6 +294,7 @@ public final class Settings {
|
||||
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
|
||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||
generateImage = configFile.getBoolean("Email.generateImage", false);
|
||||
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
||||
|
||||
// Load the welcome message
|
||||
getWelcomeMessage();
|
||||
@@ -713,6 +714,12 @@ public final class Settings {
|
||||
changes = true;
|
||||
}
|
||||
|
||||
if (!contains("settings.preventOtherCase"))
|
||||
{
|
||||
set("settings.preventOtherCase", false);
|
||||
changes = true;
|
||||
}
|
||||
|
||||
if (contains("Email.mailText"))
|
||||
{
|
||||
set("Email.mailText", null);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,7 @@ public final class CollectionUtils {
|
||||
* @return The sublist consisting at most of {@code count} elements (less if the parameters
|
||||
* exceed the size of the list)
|
||||
*/
|
||||
public static List<String> getRange(List<String> list, int start, int count) {
|
||||
public static <T> List<T> getRange(List<T> list, int start, int count) {
|
||||
if (start >= list.size() || count <= 0) {
|
||||
return new ArrayList<>();
|
||||
} else if (start < 0) {
|
||||
@@ -38,10 +39,14 @@ public final class CollectionUtils {
|
||||
* @return The sublist of all elements from index {@code start} and on; empty list
|
||||
* if the start index exceeds the list's size
|
||||
*/
|
||||
public static List<String> getRange(List<String> list, int start) {
|
||||
public static <T> List<T> getRange(List<T> list, int start) {
|
||||
if (start >= list.size()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getRange(list, start, list.size() - start);
|
||||
}
|
||||
|
||||
public static <T> boolean isEmpty(Collection<T> coll) {
|
||||
return coll == null || coll.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user