Commit b8f52999 authored by 方块君's avatar 方块君 Committed by Melledy
Browse files

Optimize multilingualism (using variables)

Optimize multilingualism (using variables)
parent 8733812e
......@@ -142,7 +142,7 @@ public final class Grasscutter {
}
public static void loadLanguage() {
try (FileReader file = new FileReader(String.format(getConfig().LANGUAGE_FOLDER + "%s.json", Grasscutter.config.Language))) {
try (FileReader file = new FileReader(String.format("%s%s.json", getConfig().LANGUAGE_FOLDER, Grasscutter.config.Language))) {
language = gson.fromJson(file, Language.class);
} catch (Exception e) {
Grasscutter.language = new Language();
......
......@@ -11,28 +11,29 @@ public final class Language {
public String Command_error = "Command error:";
public String Error = "An error occurred.";
public String Grasscutter_is_free = "Grasscutter is FREE software. If you have paid for this, you may have been scammed. Homepage: https://github.com/Grasscutters/Grasscutter";
public String Game_start_port = "Game Server started on port %s";
public String Client_connect = "Client connected from %s";
public String Client_disconnect = "Client disconnected from %s";
public String Client_request = "[Dispatch] Client %s %s request: %s";
public String Game_start_port = "Game Server started on port {port}";
public String Client_connect = "Client connected from {address}";
public String Client_disconnect = "Client disconnected from {address}";
public String Client_request = "[Dispatch] Client {ip} {method} request: {url}";
public String Not_load_keystore = "[Dispatch] Unable to load keystore. Trying default keystore password...";
public String Use_default_keystore = "[Dispatch] The default keystore password was loaded successfully. Please consider setting the password to 123456 in config.json.";
public String Load_keystore_error = "[Dispatch] Error while loading keystore!";
public String Not_find_ssl_cert = "[Dispatch] No SSL cert found! Falling back to HTTP server.";
public String Welcome = "Welcome to Grasscutter";
public String Potential_unhandled_request = "[Dispatch] Potential unhandled %s request: %s";
public String Client_login_token = "[Dispatch] Client %s is trying to log in via token";
public String Client_token_login_failed = "[Dispatch] Client %s failed to log in via token";
public String Client_login_in_token = "[Dispatch] Client %s logged in via token as %s";
public String Potential_unhandled_request = "[Dispatch] Potential unhandled {method} request: {url}";
public String Client_try_login = "[Dispatch] Client {ip} is trying to log in";
public String Client_login_token = "[Dispatch] Client {ip} is trying to log in via token";
public String Client_token_login_failed = "[Dispatch] Client {ip} failed to log in via token";
public String Client_login_in_token = "[Dispatch] Client {ip} logged in via token as {uid}";
public String Game_account_cache_error = "Game account cache information error";
public String Wrong_session_key = "Wrong session key.";
public String Client_exchange_combo_token = "[Dispatch] Client %s succeed to exchange combo token";
public String Client_failed_exchange_combo_token = "[Dispatch] Client %s failed to exchange combo token";
public String Dispatch_start_server_port = "[Dispatch] Dispatch server started on port %s";
public String Client_failed_login_account_create = "[Dispatch] Client %s failed to log in: Account %s created";
public String Client_failed_login_account_create_failed = "[Dispatch] Client %s failed to log in: Account create failed";
public String Client_failed_login_account_no_found = "[Dispatch] Client %s failed to log in: Account no found";
public String Client_login = "[Dispatch] Client %s logged in as %s";
public String Client_exchange_combo_token = "[Dispatch] Client {ip} succeed to exchange combo token";
public String Client_failed_exchange_combo_token = "[Dispatch] Client {ip} failed to exchange combo token";
public String Dispatch_start_server_port = "[Dispatch] Dispatch server started on port {port}";
public String Client_failed_login_account_create = "[Dispatch] Client {ip} failed to log in: Account {uid} created";
public String Client_failed_login_account_create_failed = "[Dispatch] Client {ip} failed to log in: Account create failed";
public String Client_failed_login_account_no_found = "[Dispatch] Client {ip} failed to log in: Account no found";
public String Client_login = "[Dispatch] Client {ip} logged in as {uid}";
public String Username_not_found = "Username not found.";
public String Username_not_found_create_failed = "Username not found, create failed.";
......@@ -65,7 +66,7 @@ public final class Language {
public String Modify_user_account = "Modify user accounts";
public String Invalid_UID = "Invalid UID.";
public String Account_exists = "Account already exists.";
public String Account_create_UID = "Account created with UID %s.";
public String Account_create_UID = "Account created with UID {uid}.";
public String Account_delete = "Account deleted.";
public String Account_not_find = "Account not found.";
public String Account_command_usage = "Usage: account <create|delete> <username> [uid]";
......@@ -81,20 +82,20 @@ public final class Language {
public String Change_screen_not_exist = "Scene does not exist";
// Clear
public String Clear_weapons = "Cleared weapons for %s .";
public String Clear_artifacts = "Cleared artifacts for %s .";
public String Clear_materials = "Cleared materials for %s .";
public String Clear_furniture = "Cleared furniture for %s .";
public String Clear_displays = "Cleared displays for %s .";
public String Clear_virtuals = "Cleared virtuals for %s .";
public String Clear_everything = "Cleared everything for %s .";
public String Clear_weapons = "Cleared weapons for {name} .";
public String Clear_artifacts = "Cleared artifacts for {name} .";
public String Clear_materials = "Cleared materials for {name} .";
public String Clear_furniture = "Cleared furniture for {name} .";
public String Clear_displays = "Cleared displays for {name} .";
public String Clear_virtuals = "Cleared virtuals for {name} .";
public String Clear_everything = "Cleared everything for {name} .";
// Coop
public String Coop_usage = "Usage: coop <playerId> <target playerId>";
// Drop
public String Drop_usage = "Usage: drop <itemId|itemName> [amount]";
public String Drop_dropped_of = "Dropped %s of %s.";
public String Drop_dropped_of = "Dropped {amount} of {item}.";
// EnterDungeon
public String EnterDungeon_usage = "Usage: enterdungeon <dungeon id>";
......@@ -111,11 +112,11 @@ public final class Language {
// GiveArtifact
public String GiveArtifact_usage = "Usage: giveart|gart [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]";
public String GiveArtifact_invalid_artifact_id = "Invalid artifact ID.";
public String GiveArtifact_given = "Given %s to %s.";
public String GiveArtifact_given = "Given {itemId} to {target}.";
// GiveChar
public String GiveChar_usage = "Usage: givechar <player> <itemId|itemName> [amount]";
public String GiveChar_given = "Given %s with level %s to %s.";
public String GiveChar_given = "Given {avatarId} with level {level} to {target}.";
public String GiveChar_invalid_avatar_id = "Invalid avatar id.";
public String GiveChar_invalid_avatar_level = "Invalid avatar level.";
public String GiveChar_invalid_avatar_or_player_id = "Invalid avatar or player ID.";
......@@ -124,31 +125,31 @@ public final class Language {
public String Give_usage = "Usage: give <player> <itemId|itemName> [amount] [level]";
public String Give_refinement_only_applicable_weapons = "Refinement is only applicable to weapons.";
public String Give_refinement_must_between_1_and_5 = "Refinement must be between 1 and 5.";
public String Give_given = "Given %s of %s to %s.";
public String Give_given_with_level_and_refinement = "Given %s with level %s, refinement %s %s times to %s";
public String Give_given_level = "Given %s with level %s %s times to %s";
public String Give_given = "Given {amount} of {item} to {target}.";
public String Give_given_with_level_and_refinement = "Given {item} with level {lvl}, refinement {refinement} {amount} times to {target}";
public String Give_given_level = "Given {item} with level {lvl} {amount} times to {target}";
// GodMode
public String Godmode_status = "Godmode is now %s for %s .";
public String Godmode_status = "Godmode is now {status} for {name} .";
// Heal
public String Heal_message = "All characters have been healed.";
// Kick
public String Kick_player_kick_player = "Player [%s:%s] has kicked player [%s:%s]";
public String Kick_server_player = "Kicking player [%s:%s]";
public String Kick_player_kick_player = "Player [{sendUid}:{sendName}] has kicked player [{kickUid}:{kickName}]";
public String Kick_server_player = "Kicking player [{kickUid}:{kickName}]";
// Kill
public String Kill_usage = "Usage: killall [playerUid] [sceneId]";
public String Kill_scene_not_found_in_player_world = "Scene not found in player world";
public String Kill_kill_monsters_in_scene = "Killing %s monsters in scene %s";
public String Kill_kill_monsters_in_scene = "Killing {size} monsters in scene {id}";
// KillCharacter
public String KillCharacter_usage = "Usage: /killcharacter [playerId]";
public String KillCharacter_kill_current_character = "Killed %s current character.";
public String KillCharacter_kill_current_character = "Killed {name} current character.";
// List
public String List_message = "There are %s player(s) online:";
public String List_message = "There are {size} player(s) online:";
// Permission
public String Permission_usage = "Usage: permission <add|remove> <username> <permission>";
......@@ -158,7 +159,7 @@ public final class Language {
public String Permission_not_have_permission = "They don't have this permission!";
// Position
public String Position_message = "Coord: %.3f, %.3f, %.3f\nScene id: %d";
public String Position_message = "Coord: {x}, {y}, {z}\nScene id: {id}";
// Reload
public String Reload_reload_start = "Reloading config.";
......@@ -166,32 +167,32 @@ public final class Language {
// ResetConst
public String ResetConst_reset_all = "Reset all avatars' constellations.";
public String ResetConst_reset_all_done = "Constellations for %s have been reset. Please relog to see changes.";
public String ResetConst_reset_all_done = "Constellations for {name} have been reset. Please relog to see changes.";
// ResetShopLimit
public String ResetShopLimit_usage = "Usage: /resetshop <player id>";
// SendMail
public String SendMail_usage = "Usage: give [player] <itemId|itemName> [amount]";
public String SendMail_user_not_exist = "The user with an id of '%s' does not exist";
public String SendMail_user_not_exist = "The user with an id of '{id}' does not exist";
public String SendMail_start_composition = "Starting composition of message.\nPlease use `/sendmail <title>` to continue.\nYou can use `/sendmail stop` at any time";
public String SendMail_templates = "Mail templates coming soon implemented...";
public String SendMail_invalid_arguments = "Invalid arguments.\nUsage `/sendmail <userId|all|help> [templateId]`";
public String SendMail_send_cancel = "Message sending cancelled";
public String SendMail_send_done = "Message sent to user %s!";
public String SendMail_send_done = "Message sent to user {name}!";
public String SendMail_send_all_done = "Message sent to all users!";
public String SendMail_not_composition_end = "Message composition not at final stage.\nPlease use `/sendmail %s` or `/sendmail stop` to cancel";
public String SendMail_Please_use = "Please use `/sendmail %s`";
public String SendMail_set_title = "Message title set as '%s'.\nUse '/sendmail <content>' to continue.";
public String SendMail_set_contents = "Message contents set as '%s'.\nUse '/sendmail <sender>' to continue.";
public String SendMail_set_message_sender = "Message sender set as '%s'.\nUse '/sendmail <itemId|itemName|finish> [amount] [level]' to continue.";
public String SendMail_send = "Attached %s of %s (level %s) to the message.\nContinue adding more items or use `/sendmail finish` to send the message.";
public String SendMail_invalid_arguments_please_use = "Invalid arguments \n Please use `/sendmail %s`";
public String SendMail_not_composition_end = "Message composition not at final stage.\nPlease use `/sendmail {args}` or `/sendmail stop` to cancel";
public String SendMail_please_use = "Please use `/sendmail {args}`";
public String SendMail_set_title = "Message title set as '{title}'.\nUse '/sendmail <content>' to continue.";
public String SendMail_set_contents = "Message contents set as '{contents}'.\nUse '/sendmail <sender>' to continue.";
public String SendMail_set_message_sender = "Message sender set as '{send}'.\nUse '/sendmail <itemId|itemName|finish> [amount] [level]' to continue.";
public String SendMail_send = "Attached {amount} of {item} (level {lvl}) to the message.\nContinue adding more items or use `/sendmail finish` to send the message.";
public String SendMail_invalid_arguments_please_use = "Invalid arguments \n Please use `/sendmail {args}`";
public String SendMail_title = "<title>";
public String SendMail_message = "<message>";
public String SendMail_sender = "<sender>";
public String SendMail_arguments = "<itemId|itemName|finish> [amount] [level]";
public String SendMail_error = "ERROR: invalid construction stage %s. Check console for stacktrace.";
public String SendMail_error = "ERROR: invalid construction stage {stage}. Check console for stacktrace.";
// SendMessage
public String SendMessage_usage = "Usage: sendmessage <player> <message>";
......@@ -200,7 +201,7 @@ public final class Language {
// SetFetterLevel
public String SetFetterLevel_usage = "Usage: setfetterlevel <level>";
public String SetFetterLevel_fetter_level_must_between_0_and_10 = "Fetter level must be between 0 and 10.";
public String SetFetterLevel_fetter_set_level = "Fetter level set to %s";
public String SetFetterLevel_fetter_set_level = "Fetter level set to {level}";
public String SetFetterLevel_invalid_fetter_level = "Invalid fetter level.";
// SetStats
......@@ -214,9 +215,8 @@ public final class Language {
public String SetStats_value_error = "Invalid stat value.";
public String SetStats_uid_error = "Invalid UID.";
public String SetStats_player_error = "Player not found or offline.";
public String SetStats_set_self = "%s set to %s.";
public String SetStats_set_for_uid = "%s for %s set to %s.";
public String SetStats_set_max_hp = "MAX HP set to %s.";
public String SetStats_set_self = "{name} set to {value}.";
public String SetStats_set_for_uid = "{name} for {uid} set to {value}.";
public String Stats_FIGHT_PROP_MAX_HP = "Max HP";
public String Stats_FIGHT_PROP_CUR_HP = "Current HP";
public String Stats_FIGHT_PROP_CUR_ATTACK = "ATK";
......@@ -253,12 +253,12 @@ public final class Language {
// SetWorldLevel
public String SetWorldLevel_usage = "Usage: setworldlevel <level>";
public String SetWorldLevel_world_level_must_between_0_and_8 = "World level must be between 0-8";
public String SetWorldLevel_set_world_level = "World level set to %s.";
public String SetWorldLevel_set_world_level = "World level set to {level}.";
public String SetWorldLevel_invalid_world_level = "Invalid world level.";
// Spawn
public String Spawn_usage = "Usage: spawn <entityId> [amount] [level(monster only)]";
public String Spawn_message = "Spawned %s of %s.";
public String Spawn_message = "Spawned {amount} of {id}.";
// Stop
public String Stop_message = "Server shutting down...";
......@@ -268,15 +268,15 @@ public final class Language {
public String Talent_usage_2 = "Another way to set talent level: /talent <n or e or q> <value>";
public String Talent_usage_3 = "To get talent ID: /talent getid";
public String Talent_lower_16 = "Invalid talent level. Level should be lower than 16";
public String Talent_set_atk = "Set talent Normal ATK to %s.";
public String Talent_set_e = "Set talent E to %s.";
public String Talent_set_q = "Set talent Q to %s.";
public String Talent_set_atk = "Set talent Normal ATK to {level}.";
public String Talent_set_e = "Set talent E to {level}.";
public String Talent_set_q = "Set talent Q to {level}.";
public String Talent_invalid_skill_id = "Invalid skill ID.";
public String Talent_set_this = "Set this talent to %s.";
public String Talent_set_this = "Set this talent to {level}.";
public String Talent_invalid_talent_level = "Invalid talent level.";
public String Talent_normal_attack_id = "Normal Attack ID %s.";
public String Talent_e_skill_id = "E skill ID %s.";
public String Talent_q_skill_id = "Q skill ID %s.";
public String Talent_normal_attack_id = "Normal Attack ID {id}.";
public String Talent_e_skill_id = "E skill ID {id}.";
public String Talent_q_skill_id = "Q skill ID {id}.";
// TeleportAll
public String TeleportAll_message = "You only can use this command in MP mode.";
......@@ -286,10 +286,10 @@ public final class Language {
public String Teleport_usage = "Usage: /tp [@<player id>] <x> <y> <z> [scene id]";
public String Teleport_specify_player_id = "You must specify a player id.";
public String Teleport_invalid_position = "Invalid position.";
public String Teleport_message = "Teleported %s to %s,%s,%s in scene %s";
public String Teleport_message = "Teleported {name} to {x},{y},{z} in scene {id}";
// Weather
public String Weather_usage = "Usage: weather <weatherId> [climateId]";
public String Weather_message = "Changed weather to %s with climate %s";
public String Weather_message = "Changed weather to {weatherId} with climate {climateId}";
public String Weather_invalid_id = "Invalid ID.";
}
......@@ -49,7 +49,7 @@ public final class AccountCommand implements CommandHandler {
account.addPermission("*");
account.save(); // Save account to database.
CommandHandler.sendMessage(null, String.format(Grasscutter.getLanguage().Account_create_UID, account.getPlayerUid()));
CommandHandler.sendMessage(null, Grasscutter.getLanguage().Account_create_UID.replace("{uid}", Integer.toString(account.getPlayerUid())));
}
return;
case "delete":
......
......@@ -39,7 +39,7 @@ public final class ClearCommand implements CommandHandler {
.filter(item -> item.getItemType() == ItemType.ITEM_WEAPON)
.filter(item -> !item.isLocked() && !item.isEquipped())
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_weapons, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_weapons.replace("{name}", targetPlayer.getNickname()));
}
case "art" -> {
playerInventory.getItems().values().stream()
......@@ -47,7 +47,7 @@ public final class ClearCommand implements CommandHandler {
.filter(item -> item.getLevel() == 1 && item.getExp() == 0)
.filter(item -> !item.isLocked() && !item.isEquipped())
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_artifacts, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_artifacts.replace("{name}", targetPlayer.getNickname()));
}
case "mat" -> {
playerInventory.getItems().values().stream()
......@@ -55,7 +55,7 @@ public final class ClearCommand implements CommandHandler {
.filter(item -> item.getLevel() == 1 && item.getExp() == 0)
.filter(item -> !item.isLocked() && !item.isEquipped())
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_artifacts, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_artifacts.replace("{name}", targetPlayer.getNickname()));
}
case "all" -> {
playerInventory.getItems().values().stream()
......@@ -63,34 +63,34 @@ public final class ClearCommand implements CommandHandler {
.filter(item1 -> item1.getLevel() == 1 && item1.getExp() == 0)
.filter(item1 -> !item1.isLocked() && !item1.isEquipped())
.forEach(item1 -> playerInventory.removeItem(item1, item1.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_artifacts, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_artifacts.replace("{name}", targetPlayer.getNickname()));
playerInventory.getItems().values().stream()
.filter(item2 -> item2.getItemType() == ItemType.ITEM_MATERIAL)
.filter(item2 -> !item2.isLocked() && !item2.isEquipped())
.forEach(item2 -> playerInventory.removeItem(item2, item2.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_materials, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_artifacts.replace("{name}", targetPlayer.getNickname()));
playerInventory.getItems().values().stream()
.filter(item3 -> item3.getItemType() == ItemType.ITEM_WEAPON)
.filter(item3 -> item3.getLevel() == 1 && item3.getExp() == 0)
.filter(item3 -> !item3.isLocked() && !item3.isEquipped())
.forEach(item3 -> playerInventory.removeItem(item3, item3.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_artifacts, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_artifacts.replace("{name}", targetPlayer.getNickname()));
playerInventory.getItems().values().stream()
.filter(item4 -> item4.getItemType() == ItemType.ITEM_FURNITURE)
.filter(item4 -> !item4.isLocked() && !item4.isEquipped())
.forEach(item4 -> playerInventory.removeItem(item4, item4.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_furniture, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_furniture.replace("{name}", targetPlayer.getNickname()));
playerInventory.getItems().values().stream()
.filter(item5 -> item5.getItemType() == ItemType.ITEM_DISPLAY)
.filter(item5 -> !item5.isLocked() && !item5.isEquipped())
.forEach(item5 -> playerInventory.removeItem(item5, item5.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_displays, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_displays.replace("{name}", targetPlayer.getNickname()));
playerInventory.getItems().values().stream()
.filter(item6 -> item6.getItemType() == ItemType.ITEM_VIRTUAL)
.filter(item6 -> !item6.isLocked() && !item6.isEquipped())
.forEach(item6 -> playerInventory.removeItem(item6, item6.getCount()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_virtuals, targetPlayer.getNickname()));
sender.dropMessage(String.format(Grasscutter.getLanguage().Clear_everything, targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_virtuals.replace("{name}", targetPlayer.getNickname()));
sender.dropMessage(Grasscutter.getLanguage().Clear_everything.replace("{name}", targetPlayer.getNickname()));
}
}
} catch (NumberFormatException ignored) {
......
......@@ -49,7 +49,7 @@ public final class DropCommand implements CommandHandler {
EntityItem entity = new EntityItem(sender.getScene(), sender, itemData, sender.getPos().clone().addY(3f), amount);
sender.getScene().addEntity(entity);
}
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Drop_dropped_of, amount, item));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Drop_dropped_of.replace("{amount}", Integer.toString(amount)).replace("{item}", Integer.toString(item)));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_item_or_player_id);
}
......
......@@ -91,7 +91,7 @@ public final class GiveArtifactCommand implements CommandHandler {
item.getAppendPropIdList().addAll(appendPropIdList);
targetPlayer.getInventory().addItem(item, ActionReason.SubfieldDrop);
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().GiveArtifact_given, itemId, target));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().GiveArtifact_given.replace("{itemId}", Integer.toString(itemId)).replace("target", Integer.toString(target)));
}
}
......@@ -94,6 +94,6 @@ public final class GiveCharCommand implements CommandHandler {
avatar.recalcStats();
targetPlayer.addAvatar(avatar);
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().GiveChar_given, avatarId, level, target));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().GiveChar_given.replace("{avatarId}", Integer.toString(avatarId)).replace("{level}", Integer.toString(level)).replace("{target}", Integer.toString(target)));
}
}
......@@ -148,13 +148,11 @@ public final class GiveCommand implements CommandHandler {
this.item(targetPlayer, itemData, amount, lvl, refinement);
if (!itemData.isEquip()) {
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Give_given, amount, item, target));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Give_given.replace("{amount}", Integer.toString(amount)).replace("{item}", Integer.toString(item)).replace("{target}", Integer.toString(target)));
} else if (itemData.getItemType() == ItemType.ITEM_WEAPON) {
CommandHandler.sendMessage(sender,
String.format(Grasscutter.getLanguage().Give_given_with_level_and_refinement, item, lvl, refinement, amount, target));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Give_given_with_level_and_refinement.replace("{item}", Integer.toString(item)).replace("{lvl}", Integer.toString(lvl)).replace("{refinement}", Integer.toString(refinement)).replace("{amount}", Integer.toString(amount)).replace("{target}", Integer.toString(target)));
} else {
CommandHandler.sendMessage(sender,
String.format(Grasscutter.getLanguage().Give_given_level, item, lvl, amount, target));
CommandHandler.sendMessage(sender,Grasscutter.getLanguage().Give_given_level.replace("{item}", Integer.toString(item)).replace("{lvl}", Integer.toString(lvl)).replace("{amount}", Integer.toString(amount)));
}
}
......
......@@ -39,9 +39,6 @@ public final class GodModeCommand implements CommandHandler {
}
targetPlayer.setGodmode(!targetPlayer.inGodmode());
sender.dropMessage(String.format(Grasscutter.getLanguage().Godmode_status,
(targetPlayer.inGodmode() ? Grasscutter.getLanguage().Enabled : Grasscutter.getLanguage().Disabled),
targetPlayer.getNickname()
));
sender.dropMessage(Grasscutter.getLanguage().Godmode_status.replace("{status}", (targetPlayer.inGodmode() ? Grasscutter.getLanguage().Enabled : Grasscutter.getLanguage().Disabled)).replace("{name}", targetPlayer.getNickname()));
}
}
......@@ -22,9 +22,10 @@ public final class KickCommand implements CommandHandler {
}
if (sender != null) {
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Kick_player_kick_player, sender.getAccount().getPlayerUid(), sender.getAccount().getUsername(), target, targetPlayer.getAccount().getUsername()));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Kick_player_kick_player.replace("{sendUid}", Integer.toString(sender.getAccount().getPlayerUid())).replace("{sendName}", sender.getAccount().getUsername()).replace("kickUid", Integer.toString(target)).replace("{kickName}", targetPlayer.getAccount().getUsername()));
} else {
CommandHandler.sendMessage(null, Grasscutter.getLanguage().Kick_server_player.replace("{kickUid}", Integer.toString(target)).replace("{kickName}", targetPlayer.getAccount().getUsername()));
}
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Kick_server_player, target, targetPlayer.getAccount().getUsername()));
targetPlayer.getSession().close();
}
......
......@@ -59,7 +59,7 @@ public final class KillAllCommand implements CommandHandler {
.filter(entity -> entity instanceof EntityMonster)
.toList();
toKill.stream().forEach(entity -> mainScene.killEntity(entity, 0));
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Kill_kill_monsters_in_scene, toKill.size(), mainScene.getId()));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Kill_kill_monsters_in_scene.replace("{size}", Integer.toString(toKill.size())).replace("{id}", Integer.toString(mainScene.getId())));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_arguments);
}
......
......@@ -63,6 +63,6 @@ public final class KillCharacterCommand implements CommandHandler {
targetPlayer.getScene().removeEntity(entity);
entity.onDeath(0);
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().KillCharacter_kill_current_character, targetPlayer.getNickname()));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().KillCharacter_kill_current_character.replace("{name}", targetPlayer.getNickname()));
}
}
......@@ -21,7 +21,7 @@ public final class ListCommand implements CommandHandler {
needUID = args.get(0).equals("uid");
}
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().List_message, playersMap.size()));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().List_message.replace("{size}", Integer.toString(playersMap.size())));
if (playersMap.size() != 0) {
StringBuilder playerSet = new StringBuilder();
......
......@@ -18,7 +18,6 @@ public final class PositionCommand implements CommandHandler {
return;
}
sender.dropMessage(String.format(Grasscutter.getLanguage().Position_message,
sender.getPos().getX(), sender.getPos().getY(), sender.getPos().getZ(), sender.getSceneId()));
sender.dropMessage(Grasscutter.getLanguage().Position_message.replace("{x}", Float.toString(sender.getPos().getX())).replace("{y}", Float.toString(sender.getPos().getY())).replace("{z}", Float.toString(sender.getPos().getZ())).replace("{id}", Integer.toString(sender.getSceneId())));
}
}
......@@ -33,7 +33,7 @@ public final class ResetConstCommand implements CommandHandler {
Avatar avatar = entity.getAvatar();
this.resetConstellation(avatar);
sender.dropMessage(String.format(Grasscutter.getLanguage().ResetConst_reset_all_done, avatar.getAvatarData().getName()));
sender.dropMessage(Grasscutter.getLanguage().ResetConst_reset_all_done.replace("{name}", avatar.getAvatarData().getName()));
}
}
......
......@@ -45,7 +45,7 @@ public final class SendMailCommand implements CommandHandler {
if (DatabaseHelper.getPlayerById(Integer.parseInt(args.get(0))) != null) {
mailBuilder = new MailBuilder(Integer.parseInt(args.get(0)), new Mail());
} else {
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_user_not_exist, args.get(0)));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_user_not_exist.replace("{id}", args.get(0)));
return;
}
}
......@@ -70,7 +70,7 @@ public final class SendMailCommand implements CommandHandler {
if (mailBuilder.constructionStage == 3) {
if (!mailBuilder.sendToAll) {
Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail);
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_send_done, mailBuilder.recipient));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_send_done.replace("{name}", Integer.toString(mailBuilder.recipient)));
} else {
for (Player player : DatabaseHelper.getAllPlayers()) {
Grasscutter.getGameServer().getPlayerByUid(player.getUid(), true).sendMail(mailBuilder.mail);
......@@ -79,12 +79,12 @@ public final class SendMailCommand implements CommandHandler {
}
mailBeingConstructed.remove(senderId);
} else {
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_not_composition_end, getConstructionArgs(mailBuilder.constructionStage)));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_not_composition_end.replace("{args}", getConstructionArgs(mailBuilder.constructionStage)));
}
return;
}
case "help" -> {
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_Please_use, getConstructionArgs(mailBuilder.constructionStage)));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_please_use.replace("{args}", getConstructionArgs(mailBuilder.constructionStage)));
return;
}
default -> {
......@@ -92,19 +92,19 @@ public final class SendMailCommand implements CommandHandler {
case 0 -> {
String title = String.join(" ", args.subList(0, args.size()));
mailBuilder.mail.mailContent.title = title;
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_set_title, title));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_set_title.replace("{title}", title));
mailBuilder.constructionStage++;
}
case 1 -> {
String contents = String.join(" ", args.subList(0, args.size()));
mailBuilder.mail.mailContent.content = contents;
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_set_contents, contents));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_set_contents.replace("{contents}", contents));
mailBuilder.constructionStage++;
}
case 2 -> {
String msgSender = String.join(" ", args.subList(0, args.size()));
mailBuilder.mail.mailContent.sender = msgSender;
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_set_message_sender, msgSender));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_set_message_sender.replace("{send}", msgSender));
mailBuilder.constructionStage++;
}
case 3 -> {
......@@ -144,13 +144,13 @@ public final class SendMailCommand implements CommandHandler {
}
}
mailBuilder.mail.itemList.add(new Mail.MailItem(item, amount, lvl));
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_send, amount, item, lvl));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_send.replace("{amount}", Integer.toString(amount)).replace("{item}", Integer.toString(item)).replace("{lvl}", Integer.toString(lvl)));
}
}
}
}
} else {
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_invalid_arguments_please_use, getConstructionArgs(mailBuilder.constructionStage)));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_invalid_arguments_please_use.replace("{args}", getConstructionArgs(mailBuilder.constructionStage)));
}
}
}
......@@ -172,7 +172,7 @@ public final class SendMailCommand implements CommandHandler {
}
default -> {
Thread.dumpStack();
return String.format(Grasscutter.getLanguage().SendMail_error, stage);
return Grasscutter.getLanguage().SendMail_error.replace("{stage}", Integer.toString(stage));
}
}
}
......
......@@ -42,7 +42,7 @@ public final class SetFetterLevelCommand implements CommandHandler {
avatar.save();
sender.sendPacket(new PacketAvatarFetterDataNotify(avatar));
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetFetterLevel_fetter_set_level, fetterLevel));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_fetter_set_level.replace("{level}", Integer.toString(fetterLevel)));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_invalid_fetter_level);
}
......
......@@ -246,9 +246,9 @@ public final class SetStatsCommand implements CommandHandler {
valueStr = String.format("%.0f", value);
}
if (targetPlayer == sender) {
CommandHandler.sendMessage(sender, String.format(lang.SetStats_set_self, stat.name, valueStr));
CommandHandler.sendMessage(sender, lang.SetStats_set_self.replace("{name}", stat.name).replace("{value}", valueStr));
} else {
CommandHandler.sendMessage(sender, String.format(lang.SetStats_set_for_uid, stat.name, uidStr, valueStr));
CommandHandler.sendMessage(sender, lang.SetStats_set_for_uid.replace("{name}", stat.name).replace("{uid}", uidStr).replace("{value}", valueStr));
}
return;
} else {
......
......@@ -35,7 +35,7 @@ public final class SetWorldLevelCommand implements CommandHandler {
sender.getWorld().setWorldLevel(level);
sender.setWorldLevel(level);
sender.dropMessage(String.format(Grasscutter.getLanguage().SetWorldLevel_set_world_level, level));
sender.dropMessage(Grasscutter.getLanguage().SetWorldLevel_set_world_level.replace("{level}", Integer.toString(level)));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(null, Grasscutter.getLanguage().SetWorldLevel_invalid_world_level);
}
......
......@@ -79,7 +79,7 @@ public final class SpawnCommand implements CommandHandler {
sender.getScene().addEntity(entity);
}
CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Spawn_message, amount, id));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Spawn_message.replace("{amount}", Integer.toString(amount)).replace("{id}", Integer.toString(id)));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_entity_id);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment