From 077a1504986629bd6bba136cae74ec1af2463575 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Tue, 1 Sep 2020 11:16:01 +0300 Subject: [PATCH] Lang implemented for RegistrationCommands --- .../subcommands/DatabaseCommands.java | 8 ++++---- .../subcommands/RegistrationCommands.java | 19 ++++++++++--------- .../settings/locale/lang/CommandLang.java | 6 +++++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java index 47259f04a..b758c15ba 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java @@ -188,7 +188,7 @@ public class DatabaseCommands { if (choice) { performRestore(sender, backupDBFile, toDB); } else { - sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED)); + sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); } }); } @@ -241,7 +241,7 @@ public class DatabaseCommands { if (choice) { performMove(sender, fromDB, toDB); } else { - sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED)); + sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); } }); } @@ -297,7 +297,7 @@ public class DatabaseCommands { if (choice) { performClear(sender, fromDB); } else { - sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED)); + sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); } }); } @@ -355,7 +355,7 @@ public class DatabaseCommands { if (choice) { performRemoval(sender, database, playerUUID); } else { - sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED)); + sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); } }); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java index ba96f7e75..fe4216b54 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java @@ -89,7 +89,7 @@ public class RegistrationCommands { if (arguments.isEmpty()) { String address = linkCommands.getAddress(sender) + "/register"; sender.buildMessage() - .addPart(colors.getMainColor() + "Register page: ") + .addPart(colors.getMainColor() + locale.getString(CommandLang.LINK_REGISTER)) .apply(builder -> linkCommands.linkTo(builder, sender, address)) .send(); } else { @@ -117,7 +117,7 @@ public class RegistrationCommands { .orElseThrow(() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 1, ""))); String passwordHash = PassEncryptUtil.createHash(password); int permissionLevel = arguments.getInteger(2) - .filter(arg -> sender.hasPermission("plan.register.other")) // argument only allowed with plan.webmanage + .filter(arg -> sender.hasPermission(Permissions.REGISTER_OTHER)) // argument only allowed with register other permission .orElseGet(() -> getPermissionLevel(sender)); if (sender.getUUID().isPresent() && sender.getPlayerName().isPresent()) { @@ -196,15 +196,16 @@ public class RegistrationCommands { if (sender.supportsChatEvents()) { sender.buildMessage() - .addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine() - .addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover("Accept") + .addPart(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_UNREGISTER, presentUser.getUsername(), presentUser.getLinkedTo())).newLine() + .addPart(colors.getTertiaryColor() + locale.getString(CommandLang.CONFIRM)) + .addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover(locale.getString(CommandLang.CONFIRM_ACCEPT)) .addPart(" ") - .addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel") + .addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover(locale.getString(CommandLang.CONFIRM_DENY)) .send(); } else { sender.buildMessage() - .addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine() - .addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§a/" + mainCommand + " accept") + .addPart(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_UNREGISTER, presentUser.getUsername(), presentUser.getLinkedTo())).newLine() + .addPart(colors.getTertiaryColor() + locale.getString(CommandLang.CONFIRM)).addPart("§a/" + mainCommand + " accept") .addPart(" ") .addPart("§c/" + mainCommand + " cancel") .send(); @@ -213,7 +214,7 @@ public class RegistrationCommands { confirmation.confirm(sender, choice -> { if (choice) { try { - sender.send(colors.getMainColor() + "Unregistering '" + presentUser.getUsername() + "'.."); + sender.send(colors.getMainColor() + locale.getString(CommandLang.UNREGISTER, presentUser.getUsername())); database.executeTransaction(new RemoveWebUserTransaction(username)) .get(); // Wait for completion sender.send(locale.getString(CommandLang.PROGRESS_SUCCESS)); @@ -223,7 +224,7 @@ public class RegistrationCommands { errorLogger.log(L.WARN, e, ErrorContext.builder().related("unregister command", sender, sender.getPlayerName().orElse("console"), arguments).build()); } } else { - sender.send(colors.getMainColor() + "Cancelled. '" + presentUser.getUsername() + "' was not unregistered."); + sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_UNREGISTER, presentUser.getUsername())); } }); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java index 9dfde5532..1cce4273c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java @@ -31,7 +31,9 @@ public enum CommandLang implements Lang { CONFIRM_OVERWRITE_DB("Cmd Confirm - overwriting db", "You are about to overwrite data in Plan ${0} with data in ${1}"), CONFIRM_CLEAR_DB("Cmd Confirm - clearing db", "You are about to remove all Plan-data in ${0}"), CONFIRM_REMOVE_PLAYER_DB("Cmd Confirm - remove player db", "You are about to remove data of ${0} from ${1}"), - CONFIRM_CANCELLED("Cmd Confirm - cancelled, no data change", "Cancelled. No data was changed."), + CONFIRM_UNREGISTER("Cmd Confirm - unregister", "You are about to unregister '${0}' linked to ${1}"), + CONFIRM_CANCELLED_DATA("Cmd Confirm - cancelled, no data change", "Cancelled. No data was changed."), + CONFIRM_CANCELLED_UNREGISTER("Cmd Confirm - cancelled, unregister", "Cancelled. '${0}' was not unregistered"), FAIL_PLAYER_NOT_FOUND("Cmd FAIL - No player", "Player '${0}' was not found, they have no UUID."), FAIL_PLAYER_NOT_FOUND_REGISTER("Cmd FAIL - No player register", "Player '${0}' was not found in the database."), @@ -67,6 +69,7 @@ public enum CommandLang implements Lang { LINK_PLAYERS("Cmd - Link Players", "Players page: "), LINK_NETWORK("Cmd - Link Network", "Network page: "), LINK_JSON("Cmd - Link Player JSON", "Player json: "), + LINK_REGISTER("Cmd - Link Register", "Register page: "), HEADER_SEARCH("Cmd Header - Search", "> §2${0} Results for §f${1}§2:"), HEADER_ANALYSIS("Cmd Header - Analysis", "> §2Analysis Results"), @@ -102,6 +105,7 @@ public enum CommandLang implements Lang { DB_REMOVAL("Cmd db - removal", "Removing Plan-data from ${0}.."), DB_REMOVAL_PLAYER("Cmd db - removal player", "Removing data of ${0} from ${1}.."), DB_UNINSTALLED("Cmd db - server uninstalled", "§aIf the server is still installed, it will automatically set itself as installed in the database."), + UNREGISTER("Cmd unregister - unregistering", "Unregistering '${0}'.."), DISABLE_DISABLED("Cmd Disable - Disabled", "§aPlan systems are now disabled. You can still use /planbungee reload to restart the plugin."),