Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into command-perms-refactor
Conflicts: src/main/java/fr/xephi/authme/command/CommandDescription.java src/main/java/fr/xephi/authme/command/CommandInitializer.java
This commit is contained in:
@@ -590,14 +590,14 @@ public class CommandDescription {
|
||||
this.permissions = new CommandPermissions(permissionNode, defaultPermission);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static CommandBuilder builder() {
|
||||
return new CommandBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for initializing CommandDescription objects.
|
||||
*/
|
||||
public static final class Builder {
|
||||
public static final class CommandBuilder {
|
||||
private List<String> labels;
|
||||
private String description;
|
||||
private String detailedDescription;
|
||||
@@ -626,31 +626,31 @@ public class CommandDescription {
|
||||
);
|
||||
}
|
||||
|
||||
public Builder labels(List<String> labels) {
|
||||
public CommandBuilder labels(List<String> labels) {
|
||||
this.labels = labels;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder labels(String... labels) {
|
||||
public CommandBuilder labels(String... labels) {
|
||||
return labels(asMutableList(labels));
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
public CommandBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder detailedDescription(String detailedDescription) {
|
||||
public CommandBuilder detailedDescription(String detailedDescription) {
|
||||
this.detailedDescription = detailedDescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder executableCommand(ExecutableCommand executableCommand) {
|
||||
public CommandBuilder executableCommand(ExecutableCommand executableCommand) {
|
||||
this.executableCommand = executableCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder parent(CommandDescription parent) {
|
||||
public CommandBuilder parent(CommandDescription parent) {
|
||||
this.parent = parent;
|
||||
return this;
|
||||
}
|
||||
@@ -665,18 +665,18 @@ public class CommandDescription {
|
||||
*
|
||||
* @return The builder
|
||||
*/
|
||||
public Builder withArgument(String label, String description, boolean isOptional) {
|
||||
public CommandBuilder withArgument(String label, String description, boolean isOptional) {
|
||||
arguments.add(new CommandArgumentDescription(label, description, isOptional));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder noArgumentMaximum(boolean noArgumentMaximum) {
|
||||
public CommandBuilder noArgumentMaximum(boolean noArgumentMaximum) {
|
||||
this.noArgumentMaximum = noArgumentMaximum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder permissions(CommandPermissions.DefaultPermission defaultPermission,
|
||||
PermissionNode... permissionNodes) {
|
||||
public CommandBuilder permissions(CommandPermissions.DefaultPermission defaultPermission,
|
||||
PermissionNode... permissionNodes) {
|
||||
this.permissions = new CommandPermissions(asMutableList(permissionNodes), defaultPermission);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import fr.xephi.authme.command.executable.email.RecoverEmailCommand;
|
||||
import fr.xephi.authme.command.executable.login.LoginCommand;
|
||||
import fr.xephi.authme.command.executable.logout.LogoutCommand;
|
||||
import fr.xephi.authme.permission.AdminPermission;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -87,6 +87,8 @@ public final class CommandInitializer {
|
||||
.labels("register", "reg", "r")
|
||||
.description("Register a player")
|
||||
.detailedDescription("Register the specified player with the specified password.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, PlayerPermission.REGISTER)
|
||||
.withArgument("player", "Player name", false)
|
||||
.withArgument("password", "Password", false)
|
||||
.permissions(OP_ONLY, UserPermission.REGISTER)
|
||||
@@ -99,6 +101,8 @@ public final class CommandInitializer {
|
||||
.labels("unregister", "unreg", "unr")
|
||||
.description("Unregister a player")
|
||||
.detailedDescription("Unregister the specified player.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, PlayerPermission.UNREGISTER)
|
||||
.withArgument("player", "Player name", false)
|
||||
.permissions(OP_ONLY, UserPermission.UNREGISTER)
|
||||
.executableCommand(new UnregisterCommand())
|
||||
@@ -110,6 +114,8 @@ public final class CommandInitializer {
|
||||
.labels("forcelogin", "login")
|
||||
.description("Enforce login player")
|
||||
.detailedDescription("Enforce the specified player to login.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, PlayerPermission.CAN_LOGIN_BE_FORCED)
|
||||
.withArgument("player", "Online player name", true)
|
||||
.permissions(OP_ONLY, UserPermission.CAN_LOGIN_BE_FORCED)
|
||||
.executableCommand(new ForceLoginCommand())
|
||||
@@ -121,6 +127,8 @@ public final class CommandInitializer {
|
||||
.labels("password", "changepassword", "changepass", "cp")
|
||||
.description("Change a player's password")
|
||||
.detailedDescription("Change the password of a player.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, PlayerPermission.CHANGE_PASSWORD)
|
||||
.withArgument("player", "Player name", false)
|
||||
.withArgument("pwd", "New password", false)
|
||||
.permissions(OP_ONLY, UserPermission.CHANGE_PASSWORD)
|
||||
@@ -150,33 +158,30 @@ public final class CommandInitializer {
|
||||
.build();
|
||||
|
||||
// Register the getemail command
|
||||
CommandDescription.builder()
|
||||
.parent(AUTHME_BASE)
|
||||
CommandDescription getEmailCommand = CommandDescription.builder()
|
||||
.executableCommand(new GetEmailCommand())
|
||||
.labels("getemail", "getmail", "email", "mail")
|
||||
.description("Display player's email")
|
||||
.detailedDescription("Display the email address of the specified player if set.")
|
||||
.withArgument("player", "Player name", true)
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, AdminPermission.GET_EMAIL)
|
||||
.executableCommand(new GetEmailCommand())
|
||||
.withArgument("player", "Player name", true)
|
||||
.build();
|
||||
|
||||
// Register the setemail command
|
||||
CommandDescription setEmailCommand = new CommandDescription(new SetEmailCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("chgemail");
|
||||
add("chgmail");
|
||||
add("setemail");
|
||||
add("setmail");
|
||||
}
|
||||
}, "Change player's email", "Change the email address of the specified player.", AUTHME_BASE);
|
||||
setEmailCommand.setCommandPermissions(AdminPermission.CHANGE_EMAIL, OP_ONLY);
|
||||
setEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", false));
|
||||
setEmailCommand.addArgument(new CommandArgumentDescription("email", "Player email", false));
|
||||
CommandDescription setEmailCommand = CommandDescription.builder()
|
||||
.executableCommand(new SetEmailCommand())
|
||||
.labels("chgemail", "chgmail", "setemail", "setmail")
|
||||
.description("Change player's email")
|
||||
.detailedDescription("Change the email address of the specified player.")
|
||||
.parent(authMeBaseCommand)
|
||||
.permissions(OP_ONLY, AdminPermission.CHANGE_EMAIL)
|
||||
.withArgument("player", "Player name", false)
|
||||
.withArgument("email", "Player email", false)
|
||||
.build();
|
||||
|
||||
// Register the getip command
|
||||
CommandDescription getIpCommand = new CommandDescription(new GetIpCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("getip");
|
||||
add("ip");
|
||||
@@ -187,7 +192,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the spawn command
|
||||
CommandDescription spawnCommand = new CommandDescription(new SpawnCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("spawn");
|
||||
add("home");
|
||||
@@ -197,7 +201,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the setspawn command
|
||||
CommandDescription setSpawnCommand = new CommandDescription(new SetSpawnCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("setspawn");
|
||||
add("chgspawn");
|
||||
@@ -207,7 +210,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the firstspawn command
|
||||
CommandDescription firstSpawnCommand = new CommandDescription(new FirstSpawnCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("firstspawn");
|
||||
add("firsthome");
|
||||
@@ -217,7 +219,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the setfirstspawn command
|
||||
CommandDescription setFirstSpawnCommand = new CommandDescription(new SetFirstSpawnCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("setfirstspawn");
|
||||
add("chgfirstspawn");
|
||||
@@ -227,7 +228,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the purge command
|
||||
CommandDescription purgeCommand = new CommandDescription(new PurgeCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("purge");
|
||||
add("delete");
|
||||
@@ -238,7 +238,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the purgelastposition command
|
||||
CommandDescription purgeLastPositionCommand = new CommandDescription(new PurgeLastPositionCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("resetpos");
|
||||
add("purgelastposition");
|
||||
@@ -253,7 +252,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the purgebannedplayers command
|
||||
CommandDescription purgeBannedPlayersCommand = new CommandDescription(new PurgeBannedPlayersCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("purgebannedplayers");
|
||||
add("purgebannedplayer");
|
||||
@@ -265,7 +263,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the switchantibot command
|
||||
CommandDescription switchAntiBotCommand = new CommandDescription(new SwitchAntiBotCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("switchantibot");
|
||||
add("toggleantibot");
|
||||
@@ -290,7 +287,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the reload command
|
||||
CommandDescription reloadCommand = new CommandDescription(new ReloadCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("reload");
|
||||
add("rld");
|
||||
@@ -315,7 +311,7 @@ public final class CommandInitializer {
|
||||
.description("Login command")
|
||||
.detailedDescription("Command to log in using AuthMeReloaded.")
|
||||
.parent(null)
|
||||
.permissions(ALLOWED, UserPermission.LOGIN)
|
||||
.permissions(ALLOWED, PlayerPermission.LOGIN)
|
||||
.withArgument("password", "Login password", false)
|
||||
.build();
|
||||
|
||||
@@ -326,12 +322,11 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the base logout command
|
||||
CommandDescription logoutBaseCommand = new CommandDescription(new LogoutCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("logout");
|
||||
}
|
||||
}, "Logout command", "Command to logout using AuthMeReloaded.", null);
|
||||
logoutBaseCommand.setCommandPermissions(UserPermission.LOGOUT, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
logoutBaseCommand.setCommandPermissions(PlayerPermission.LOGOUT, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
|
||||
// Register the help command
|
||||
CommandDescription logoutHelpCommand = new CommandDescription(helpCommandExecutable, helpCommandLabels,
|
||||
@@ -340,13 +335,12 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the base register command
|
||||
CommandDescription registerBaseCommand = new CommandDescription(new fr.xephi.authme.command.executable.register.RegisterCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("register");
|
||||
add("reg");
|
||||
}
|
||||
}, "Registration command", "Command to register using AuthMeReloaded.", null);
|
||||
registerBaseCommand.setCommandPermissions(UserPermission.REGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
registerBaseCommand.setCommandPermissions(PlayerPermission.REGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
registerBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
registerBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
||||
|
||||
@@ -357,13 +351,12 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the base unregister command
|
||||
CommandDescription unregisterBaseCommand = new CommandDescription(new fr.xephi.authme.command.executable.unregister.UnregisterCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("unregister");
|
||||
add("unreg");
|
||||
}
|
||||
}, "Unregistration command", "Command to unregister using AuthMeReloaded.", null);
|
||||
unregisterBaseCommand.setCommandPermissions(UserPermission.UNREGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
unregisterBaseCommand.setCommandPermissions(PlayerPermission.UNREGISTER, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
unregisterBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
|
||||
// Register the help command
|
||||
@@ -372,13 +365,12 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the base changepassword command
|
||||
CommandDescription changePasswordBaseCommand = new CommandDescription(new fr.xephi.authme.command.executable.changepassword.ChangePasswordCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("changepassword");
|
||||
add("changepass");
|
||||
}
|
||||
}, "Change password command", "Command to change your password using AuthMeReloaded.", null);
|
||||
changePasswordBaseCommand.setCommandPermissions(UserPermission.CHANGE_PASSWORD, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changePasswordBaseCommand.setCommandPermissions(PlayerPermission.CHANGE_PASSWORD, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
changePasswordBaseCommand.addArgument(new CommandArgumentDescription("verifyPassword", "Verify password", false));
|
||||
|
||||
@@ -389,7 +381,6 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the base Dungeon Maze command
|
||||
CommandDescription emailBaseCommand = new CommandDescription(helpCommandExecutable, new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("email");
|
||||
add("mail");
|
||||
@@ -403,33 +394,30 @@ public final class CommandInitializer {
|
||||
|
||||
// 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.", emailBaseCommand);
|
||||
addEmailCommand.setCommandPermissions(UserPermission.ADD_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
addEmailCommand.setCommandPermissions(PlayerPermission.ADD_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
addEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||
addEmailCommand.addArgument(new CommandArgumentDescription("verifyEmail", "Email address verification", false));
|
||||
|
||||
// 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.", emailBaseCommand);
|
||||
changeEmailCommand.setCommandPermissions(UserPermission.CHANGE_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changeEmailCommand.setCommandPermissions(PlayerPermission.CHANGE_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
changeEmailCommand.addArgument(new CommandArgumentDescription("oldEmail", "Old email address", false));
|
||||
changeEmailCommand.addArgument(new CommandArgumentDescription("newEmail", "New email address", false));
|
||||
|
||||
// Register the recover command
|
||||
CommandDescription recoverEmailCommand = new CommandDescription(new RecoverEmailCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("recover");
|
||||
add("recovery");
|
||||
@@ -437,18 +425,17 @@ public final class CommandInitializer {
|
||||
add("recovermail");
|
||||
}
|
||||
}, "Recover using E-mail", "Recover your account using an E-mail address.", emailBaseCommand);
|
||||
recoverEmailCommand.setCommandPermissions(UserPermission.RECOVER_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
recoverEmailCommand.setCommandPermissions(PlayerPermission.RECOVER_EMAIL, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
recoverEmailCommand.addArgument(new CommandArgumentDescription("email", "Email address", false));
|
||||
|
||||
// Register the base captcha command
|
||||
CommandDescription captchaBaseCommand = new CommandDescription(new CaptchaCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("captcha");
|
||||
add("capt");
|
||||
}
|
||||
}, "Captcha command", "Captcha command for AuthMeReloaded.", null);
|
||||
captchaBaseCommand.setCommandPermissions(UserPermission.CAPTCHA, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
captchaBaseCommand.setCommandPermissions(PlayerPermission.CAPTCHA, CommandPermissions.DefaultPermission.ALLOWED);
|
||||
captchaBaseCommand.addArgument(new CommandArgumentDescription("captcha", "The captcha", false));
|
||||
|
||||
// Register the help command
|
||||
@@ -458,14 +445,13 @@ public final class CommandInitializer {
|
||||
|
||||
// Register the base converter command
|
||||
CommandDescription converterBaseCommand = new CommandDescription(new ConverterCommand(), new ArrayList<String>() {
|
||||
|
||||
{
|
||||
add("converter");
|
||||
add("convert");
|
||||
add("conv");
|
||||
}
|
||||
}, "Convert command", "Convert command for AuthMeReloaded.", null);
|
||||
converterBaseCommand.setCommandPermissions(UserPermission.CONVERTER, OP_ONLY);
|
||||
converterBaseCommand.setCommandPermissions(AdminPermission.CONVERTER, OP_ONLY);
|
||||
converterBaseCommand.addArgument(new CommandArgumentDescription("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / royalauth / vauth / sqltoflat", false));
|
||||
|
||||
// Register the help command
|
||||
|
||||
@@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.permission.UserPermission;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -30,7 +30,7 @@ public class ForceLoginCommand extends ExecutableCommand {
|
||||
sender.sendMessage("Player needs to be online!");
|
||||
return true;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, UserPermission.CAN_LOGIN_BE_FORCED)) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.CAN_LOGIN_BE_FORCED)) {
|
||||
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user