Lang implemented for RegistrationCommands

This commit is contained in:
Risto Lahtela 2020-09-01 11:16:01 +03:00
parent 66b34b48a0
commit 077a150498
3 changed files with 19 additions and 14 deletions

View File

@ -188,7 +188,7 @@ public class DatabaseCommands {
if (choice) { if (choice) {
performRestore(sender, backupDBFile, toDB); performRestore(sender, backupDBFile, toDB);
} else { } 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) { if (choice) {
performMove(sender, fromDB, toDB); performMove(sender, fromDB, toDB);
} else { } 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) { if (choice) {
performClear(sender, fromDB); performClear(sender, fromDB);
} else { } 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) { if (choice) {
performRemoval(sender, database, playerUUID); performRemoval(sender, database, playerUUID);
} else { } else {
sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED)); sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA));
} }
}); });
} }

View File

@ -89,7 +89,7 @@ public class RegistrationCommands {
if (arguments.isEmpty()) { if (arguments.isEmpty()) {
String address = linkCommands.getAddress(sender) + "/register"; String address = linkCommands.getAddress(sender) + "/register";
sender.buildMessage() sender.buildMessage()
.addPart(colors.getMainColor() + "Register page: ") .addPart(colors.getMainColor() + locale.getString(CommandLang.LINK_REGISTER))
.apply(builder -> linkCommands.linkTo(builder, sender, address)) .apply(builder -> linkCommands.linkTo(builder, sender, address))
.send(); .send();
} else { } else {
@ -117,7 +117,7 @@ public class RegistrationCommands {
.orElseThrow(() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 1, "<password>"))); .orElseThrow(() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 1, "<password>")));
String passwordHash = PassEncryptUtil.createHash(password); String passwordHash = PassEncryptUtil.createHash(password);
int permissionLevel = arguments.getInteger(2) 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)); .orElseGet(() -> getPermissionLevel(sender));
if (sender.getUUID().isPresent() && sender.getPlayerName().isPresent()) { if (sender.getUUID().isPresent() && sender.getPlayerName().isPresent()) {
@ -196,15 +196,16 @@ public class RegistrationCommands {
if (sender.supportsChatEvents()) { if (sender.supportsChatEvents()) {
sender.buildMessage() sender.buildMessage()
.addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine() .addPart(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_UNREGISTER, presentUser.getUsername(), presentUser.getLinkedTo())).newLine()
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover("Accept") .addPart(colors.getTertiaryColor() + locale.getString(CommandLang.CONFIRM))
.addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover(locale.getString(CommandLang.CONFIRM_ACCEPT))
.addPart(" ") .addPart(" ")
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel") .addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover(locale.getString(CommandLang.CONFIRM_DENY))
.send(); .send();
} else { } else {
sender.buildMessage() sender.buildMessage()
.addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine() .addPart(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_UNREGISTER, presentUser.getUsername(), presentUser.getLinkedTo())).newLine()
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§a/" + mainCommand + " accept") .addPart(colors.getTertiaryColor() + locale.getString(CommandLang.CONFIRM)).addPart("§a/" + mainCommand + " accept")
.addPart(" ") .addPart(" ")
.addPart("§c/" + mainCommand + " cancel") .addPart("§c/" + mainCommand + " cancel")
.send(); .send();
@ -213,7 +214,7 @@ public class RegistrationCommands {
confirmation.confirm(sender, choice -> { confirmation.confirm(sender, choice -> {
if (choice) { if (choice) {
try { try {
sender.send(colors.getMainColor() + "Unregistering '" + presentUser.getUsername() + "'.."); sender.send(colors.getMainColor() + locale.getString(CommandLang.UNREGISTER, presentUser.getUsername()));
database.executeTransaction(new RemoveWebUserTransaction(username)) database.executeTransaction(new RemoveWebUserTransaction(username))
.get(); // Wait for completion .get(); // Wait for completion
sender.send(locale.getString(CommandLang.PROGRESS_SUCCESS)); 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()); errorLogger.log(L.WARN, e, ErrorContext.builder().related("unregister command", sender, sender.getPlayerName().orElse("console"), arguments).build());
} }
} else { } else {
sender.send(colors.getMainColor() + "Cancelled. '" + presentUser.getUsername() + "' was not unregistered."); sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_UNREGISTER, presentUser.getUsername()));
} }
}); });
} }

View File

@ -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_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_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_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("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."), 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_PLAYERS("Cmd - Link Players", "Players page: "),
LINK_NETWORK("Cmd - Link Network", "Network page: "), LINK_NETWORK("Cmd - Link Network", "Network page: "),
LINK_JSON("Cmd - Link Player JSON", "Player json: "), 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_SEARCH("Cmd Header - Search", "> §2${0} Results for §f${1}§2:"),
HEADER_ANALYSIS("Cmd Header - Analysis", "> §2Analysis Results"), 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("Cmd db - removal", "Removing Plan-data from ${0}.."),
DB_REMOVAL_PLAYER("Cmd db - removal player", "Removing data of ${0} from ${1}.."), 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."), 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."), DISABLE_DISABLED("Cmd Disable - Disabled", "§aPlan systems are now disabled. You can still use /planbungee reload to restart the plugin."),