From 913ba56343d5595a830cecb632ad8b343e0d2aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sun, 1 Nov 2015 19:03:23 +0100 Subject: [PATCH] Implemented the base of the resetname command --- .../xephi/authme/command/CommandManager.java | 12 ++++++ .../executable/authme/ResetNameCommand.java | 42 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/main/java/fr/xephi/authme/command/executable/authme/ResetNameCommand.java diff --git a/src/main/java/fr/xephi/authme/command/CommandManager.java b/src/main/java/fr/xephi/authme/command/CommandManager.java index 996ff901..e9668c7a 100644 --- a/src/main/java/fr/xephi/authme/command/CommandManager.java +++ b/src/main/java/fr/xephi/authme/command/CommandManager.java @@ -286,6 +286,18 @@ public class CommandManager { switchAntiBotCommand.setCommandPermissions("authme.admin.switchantibot", CommandPermissions.DefaultPermission.OP_ONLY); switchAntiBotCommand.addArgument(new CommandArgumentDescription("mode", "ON / OFF", true)); +// // Register the resetname command +// CommandDescription resetNameCommand = new CommandDescription( +// new SwitchAntiBotCommand(), +// new ArrayList() {{ +// add("resetname"); +// add("resetnames"); +// }}, +// "Reset name", +// "Reset name", +// authMeCommand); +// resetNameCommand.setCommandPermissions("authme.admin.resetname", CommandPermissions.DefaultPermission.OP_ONLY); + // Register the reload command CommandDescription reloadCommand = new CommandDescription( new ReloadCommand(), diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ResetNameCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ResetNameCommand.java new file mode 100644 index 00000000..900cd0b9 --- /dev/null +++ b/src/main/java/fr/xephi/authme/command/executable/authme/ResetNameCommand.java @@ -0,0 +1,42 @@ +package fr.xephi.authme.command.executable.authme; + +import fr.xephi.authme.AuthMe; +import fr.xephi.authme.cache.auth.PlayerAuth; +import fr.xephi.authme.command.CommandParts; +import fr.xephi.authme.command.ExecutableCommand; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + +import java.util.List; + +public class ResetNameCommand extends ExecutableCommand { + + /** + * Execute the command. + * + * @param sender The command sender. + * @param commandReference The command reference. + * @param commandArguments The command arguments. + * + * @return True if the command was executed successfully, false otherwise. + */ + @Override + public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { + // AuthMe plugin instance + final AuthMe plugin = AuthMe.getInstance(); + + // Command logic + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + List authentications = plugin.database.getAllAuths(); + for(PlayerAuth auth : authentications) { + auth.setRealName("Player"); + plugin.database.updateSession(auth); + } + } + }); + + return true; + } +}