From c94b6223a110b016acae4e30ddd3617716894cb0 Mon Sep 17 00:00:00 2001 From: Xephi Date: Mon, 28 Dec 2015 11:50:16 +0100 Subject: [PATCH] Add wildcard to perform reset position for each players --- .../authme/command/CommandInitializer.java | 4 +- .../authme/PurgeLastPositionCommand.java | 45 +++++++++++++------ .../xephi/authme/hooks/BungeeCordMessage.java | 3 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/main/java/fr/xephi/authme/command/CommandInitializer.java b/src/main/java/fr/xephi/authme/command/CommandInitializer.java index 06ad2bd3b..0a52c7008 100644 --- a/src/main/java/fr/xephi/authme/command/CommandInitializer.java +++ b/src/main/java/fr/xephi/authme/command/CommandInitializer.java @@ -222,8 +222,8 @@ public final class CommandInitializer { .labels("resetpos", "purgelastposition", "purgelastpos", "resetposition", "resetlastposition", "resetlastpos") .description("Purge player's last position") - .detailedDescription("Purge the last know position of the specified player.") - .withArgument("player", "Player name", false) + .detailedDescription("Purge the last know position of the specified player or all of them.") + .withArgument("player/*", "Player name or * for all players", false) .permissions(OP_ONLY, AdminPermission.PURGE_LAST_POSITION) .executableCommand(new PurgeLastPositionCommand()) .build(); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java index 3c56f0554..15a6e80b1 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java @@ -15,21 +15,38 @@ public class PurgeLastPositionCommand implements ExecutableCommand { String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0); String playerNameLowerCase = playerName.toLowerCase(); - // Get the user auth and make sure the user exists - PlayerAuth auth = commandService.getDataSource().getAuth(playerNameLowerCase); - if (auth == null) { - commandService.send(sender, MessageKey.UNKNOWN_USER); - return; + if (playerNameLowerCase.equalsIgnoreCase("*")) + { + for (PlayerAuth auth : commandService.getDataSource().getAllAuths()) + { + // Set the last position + auth.setQuitLocX(0D); + auth.setQuitLocY(0D); + auth.setQuitLocZ(0D); + auth.setWorld("world"); + commandService.getDataSource().updateQuitLoc(auth); + } + sender.sendMessage("All players last position locations are now reset"); + } + else + { + // Get the user auth and make sure the user exists + PlayerAuth auth = commandService.getDataSource().getAuth(playerNameLowerCase); + if (auth == null) { + commandService.send(sender, MessageKey.UNKNOWN_USER); + return; + } + + // Set the last position + auth.setQuitLocX(0D); + auth.setQuitLocY(0D); + auth.setQuitLocZ(0D); + auth.setWorld("world"); + commandService.getDataSource().updateQuitLoc(auth); + + // Show a status message + sender.sendMessage(playerNameLowerCase + "'s last position location is now reset"); } - // Set the last position - auth.setQuitLocX(0D); - auth.setQuitLocY(0D); - auth.setQuitLocZ(0D); - auth.setWorld("world"); - commandService.getDataSource().updateQuitLoc(auth); - - // Show a status message - sender.sendMessage(playerNameLowerCase + "'s last position location is now reset"); } } diff --git a/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java b/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java index 11240003d..f5d3e0ae2 100644 --- a/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java +++ b/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java @@ -70,8 +70,7 @@ public class BungeeCordMessage implements PluginMessageListener { } else if ("register".equals(act)) { ConsoleLogger.info("Player " + auth.getNickname() + " has registered out from one of your server!"); - } - else if ("changepassword".equals(act)) { + } else if ("changepassword".equals(act)) { final String password = args[2]; auth.setHash(password); if (args.length == 4)