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

Add multilingual support

Add multilingual support
parent 86e6eef4
...@@ -25,11 +25,11 @@ public final class KillCharacterCommand implements CommandHandler { ...@@ -25,11 +25,11 @@ public final class KillCharacterCommand implements CommandHandler {
try { try {
target = Integer.parseInt(args.get(0)); target = Integer.parseInt(args.get(0));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
CommandHandler.sendMessage(null, "Invalid player id."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Invalid_playerId);
return; return;
} }
} else { } else {
CommandHandler.sendMessage(null, "Usage: /killcharacter [playerId]"); CommandHandler.sendMessage(null, Grasscutter.getLanguage().KillCharacter_usage);
return; return;
} }
} else { } else {
...@@ -40,7 +40,7 @@ public final class KillCharacterCommand implements CommandHandler { ...@@ -40,7 +40,7 @@ public final class KillCharacterCommand implements CommandHandler {
target = sender.getUid(); target = sender.getUid();
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
CommandHandler.sendMessage(sender, "Invalid player id."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_playerId);
return; return;
} }
} else { } else {
...@@ -50,7 +50,7 @@ public final class KillCharacterCommand implements CommandHandler { ...@@ -50,7 +50,7 @@ public final class KillCharacterCommand implements CommandHandler {
Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found or offline."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Player_not_found_or_offline);
return; return;
} }
...@@ -63,6 +63,6 @@ public final class KillCharacterCommand implements CommandHandler { ...@@ -63,6 +63,6 @@ public final class KillCharacterCommand implements CommandHandler {
targetPlayer.getScene().removeEntity(entity); targetPlayer.getScene().removeEntity(entity);
entity.onDeath(0); entity.onDeath(0);
CommandHandler.sendMessage(sender, "Killed " + targetPlayer.getNickname() + " current character."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().KillCharacter_kill_current_character, targetPlayer.getNickname()));
} }
} }
...@@ -21,7 +21,7 @@ public final class ListCommand implements CommandHandler { ...@@ -21,7 +21,7 @@ public final class ListCommand implements CommandHandler {
needUID = args.get(0).equals("uid"); needUID = args.get(0).equals("uid");
} }
CommandHandler.sendMessage(sender, String.format("There are %s player(s) online:", playersMap.size())); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().List_message, playersMap.size()));
if (playersMap.size() != 0) { if (playersMap.size() != 0) {
StringBuilder playerSet = new StringBuilder(); StringBuilder playerSet = new StringBuilder();
......
...@@ -15,7 +15,7 @@ public final class PermissionCommand implements CommandHandler { ...@@ -15,7 +15,7 @@ public final class PermissionCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (args.size() < 3) { if (args.size() < 3) {
CommandHandler.sendMessage(sender, "Usage: permission <add|remove> <username> <permission>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_usage);
return; return;
} }
...@@ -25,23 +25,23 @@ public final class PermissionCommand implements CommandHandler { ...@@ -25,23 +25,23 @@ public final class PermissionCommand implements CommandHandler {
Account account = Grasscutter.getGameServer().getAccountByName(username); Account account = Grasscutter.getGameServer().getAccountByName(username);
if (account == null) { if (account == null) {
CommandHandler.sendMessage(sender, "Account not found."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Account_not_find);
return; return;
} }
switch (action) { switch (action) {
default: default:
CommandHandler.sendMessage(sender, "Usage: permission <add|remove> <username> <permission>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_usage);
break; break;
case "add": case "add":
if (account.addPermission(permission)) { if (account.addPermission(permission)) {
CommandHandler.sendMessage(sender, "Permission added."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_add);
} else CommandHandler.sendMessage(sender, "They already have this permission!"); } else CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_have_permission);
break; break;
case "remove": case "remove":
if (account.removePermission(permission)) { if (account.removePermission(permission)) {
CommandHandler.sendMessage(sender, "Permission removed."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_remove);
} else CommandHandler.sendMessage(sender, "They don't have this permission!"); } else CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_not_have_permission);
break; break;
} }
......
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
...@@ -13,11 +14,11 @@ public final class PositionCommand implements CommandHandler { ...@@ -13,11 +14,11 @@ public final class PositionCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
sender.dropMessage(String.format("Coord: %.3f, %.3f, %.3f\nScene id: %d", sender.dropMessage(String.format(Grasscutter.getLanguage().Position_message,
sender.getPos().getX(), sender.getPos().getY(), sender.getPos().getZ(), sender.getSceneId())); sender.getPos().getX(), sender.getPos().getY(), sender.getPos().getZ(), sender.getSceneId()));
} }
} }
...@@ -13,12 +13,13 @@ public final class ReloadCommand implements CommandHandler { ...@@ -13,12 +13,13 @@ public final class ReloadCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
CommandHandler.sendMessage(sender, "Reloading config."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Reload_reload_start);
Grasscutter.loadConfig(); Grasscutter.loadConfig();
Grasscutter.loadLanguage();
Grasscutter.getGameServer().getGachaManager().load(); Grasscutter.getGameServer().getGachaManager().load();
Grasscutter.getGameServer().getDropManager().load(); Grasscutter.getGameServer().getDropManager().load();
Grasscutter.getGameServer().getShopManager().load(); Grasscutter.getGameServer().getShopManager().load();
Grasscutter.getDispatchServer().loadQueries(); Grasscutter.getDispatchServer().loadQueries();
CommandHandler.sendMessage(sender, "Reload complete."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Reload_reload_done);
} }
} }
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.game.avatar.Avatar;
...@@ -16,13 +17,13 @@ public final class ResetConstCommand implements CommandHandler { ...@@ -16,13 +17,13 @@ public final class ResetConstCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")) { if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")) {
sender.getAvatars().forEach(this::resetConstellation); sender.getAvatars().forEach(this::resetConstellation);
sender.dropMessage("Reset all avatars' constellations."); sender.dropMessage(Grasscutter.getLanguage().ResetConst_reset_all);
} else { } else {
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
if (entity == null) { if (entity == null) {
...@@ -32,7 +33,7 @@ public final class ResetConstCommand implements CommandHandler { ...@@ -32,7 +33,7 @@ public final class ResetConstCommand implements CommandHandler {
Avatar avatar = entity.getAvatar(); Avatar avatar = entity.getAvatar();
this.resetConstellation(avatar); this.resetConstellation(avatar);
sender.dropMessage("Constellations for " + avatar.getAvatarData().getName() + " have been reset. Please relog to see changes."); sender.dropMessage(String.format(Grasscutter.getLanguage().ResetConst_reset_all_done, avatar.getAvatarData().getName()));
} }
} }
......
...@@ -13,19 +13,19 @@ public final class ResetShopLimitCommand implements CommandHandler { ...@@ -13,19 +13,19 @@ public final class ResetShopLimitCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (args.size() < 1) { if (args.size() < 1) {
CommandHandler.sendMessage(sender,"Usage: /resetshop <player id>"); CommandHandler.sendMessage(sender,Grasscutter.getLanguage().ResetShopLimit_usage);
return; return;
} }
int target = Integer.parseInt(args.get(0)); int target = Integer.parseInt(args.get(0));
Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Player_not_found);
return; return;
} }
targetPlayer.getShopLimit().forEach(x -> x.setNextRefreshTime(0)); targetPlayer.getShopLimit().forEach(x -> x.setNextRefreshTime(0));
targetPlayer.save(); targetPlayer.save();
CommandHandler.sendMessage(sender, "Success"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Success);
} }
} }
...@@ -45,16 +45,16 @@ public final class SendMailCommand implements CommandHandler { ...@@ -45,16 +45,16 @@ public final class SendMailCommand implements CommandHandler {
if (DatabaseHelper.getPlayerById(Integer.parseInt(args.get(0))) != null) { if (DatabaseHelper.getPlayerById(Integer.parseInt(args.get(0))) != null) {
mailBuilder = new MailBuilder(Integer.parseInt(args.get(0)), new Mail()); mailBuilder = new MailBuilder(Integer.parseInt(args.get(0)), new Mail());
} else { } else {
CommandHandler.sendMessage(sender, "The user with an id of '" + args.get(0) + "' does not exist"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_user_not_exist, args.get(0)));
return; return;
} }
} }
} }
mailBeingConstructed.put(senderId, mailBuilder); mailBeingConstructed.put(senderId, mailBuilder);
CommandHandler.sendMessage(sender, "Starting composition of message.\nPlease use `/sendmail <title>` to continue.\nYou can use `/sendmail stop` at any time"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_start_composition);
} }
case 2 -> CommandHandler.sendMessage(sender, "Mail templates coming soon implemented..."); case 2 -> CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_templates);
default -> CommandHandler.sendMessage(sender, "Invalid arguments.\nUsage `/sendmail <userId|all|help> [templateId]`"); default -> CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_invalid_arguments);
} }
} else { } else {
MailBuilder mailBuilder = mailBeingConstructed.get(senderId); MailBuilder mailBuilder = mailBeingConstructed.get(senderId);
...@@ -63,28 +63,28 @@ public final class SendMailCommand implements CommandHandler { ...@@ -63,28 +63,28 @@ public final class SendMailCommand implements CommandHandler {
switch (args.get(0).toLowerCase()) { switch (args.get(0).toLowerCase()) {
case "stop" -> { case "stop" -> {
mailBeingConstructed.remove(senderId); mailBeingConstructed.remove(senderId);
CommandHandler.sendMessage(sender, "Message sending cancelled"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_send_cancel);
return; return;
} }
case "finish" -> { case "finish" -> {
if (mailBuilder.constructionStage == 3) { if (mailBuilder.constructionStage == 3) {
if (!mailBuilder.sendToAll) { if (!mailBuilder.sendToAll) {
Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail); Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail);
CommandHandler.sendMessage(sender, "Message sent to user " + mailBuilder.recipient + "!"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_send_done, mailBuilder.recipient));
} else { } else {
for (Player player : DatabaseHelper.getAllPlayers()) { for (Player player : DatabaseHelper.getAllPlayers()) {
Grasscutter.getGameServer().getPlayerByUid(player.getUid(), true).sendMail(mailBuilder.mail); Grasscutter.getGameServer().getPlayerByUid(player.getUid(), true).sendMail(mailBuilder.mail);
} }
CommandHandler.sendMessage(sender, "Message sent to all users!"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_send_all_done);
} }
mailBeingConstructed.remove(senderId); mailBeingConstructed.remove(senderId);
} else { } else {
CommandHandler.sendMessage(sender, "Message composition not at final stage.\nPlease use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage) + "` or `/sendmail stop` to cancel"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_not_composition_end, getConstructionArgs(mailBuilder.constructionStage)));
} }
return; return;
} }
case "help" -> { case "help" -> {
CommandHandler.sendMessage(sender, "Please use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage) + "`"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_Please_use, getConstructionArgs(mailBuilder.constructionStage)));
return; return;
} }
default -> { default -> {
...@@ -92,19 +92,19 @@ public final class SendMailCommand implements CommandHandler { ...@@ -92,19 +92,19 @@ public final class SendMailCommand implements CommandHandler {
case 0 -> { case 0 -> {
String title = String.join(" ", args.subList(0, args.size())); String title = String.join(" ", args.subList(0, args.size()));
mailBuilder.mail.mailContent.title = title; mailBuilder.mail.mailContent.title = title;
CommandHandler.sendMessage(sender, "Message title set as '" + title + "'.\nUse '/sendmail <content>' to continue."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_set_title, title));
mailBuilder.constructionStage++; mailBuilder.constructionStage++;
} }
case 1 -> { case 1 -> {
String contents = String.join(" ", args.subList(0, args.size())); String contents = String.join(" ", args.subList(0, args.size()));
mailBuilder.mail.mailContent.content = contents; mailBuilder.mail.mailContent.content = contents;
CommandHandler.sendMessage(sender, "Message contents set as '" + contents + "'.\nUse '/sendmail <sender>' to continue."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_set_contents, contents));
mailBuilder.constructionStage++; mailBuilder.constructionStage++;
} }
case 2 -> { case 2 -> {
String msgSender = String.join(" ", args.subList(0, args.size())); String msgSender = String.join(" ", args.subList(0, args.size()));
mailBuilder.mail.mailContent.sender = msgSender; mailBuilder.mail.mailContent.sender = msgSender;
CommandHandler.sendMessage(sender, "Message sender set as '" + msgSender + "'.\nUse '/sendmail <itemId|itemName|finish> [amount] [level]' to continue."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_set_message_sender, msgSender));
mailBuilder.constructionStage++; mailBuilder.constructionStage++;
} }
case 3 -> { case 3 -> {
...@@ -112,7 +112,7 @@ public final class SendMailCommand implements CommandHandler { ...@@ -112,7 +112,7 @@ public final class SendMailCommand implements CommandHandler {
int item, lvl, amount = 1; int item, lvl, amount = 1;
switch (args.size()) { switch (args.size()) {
default -> { // *No args* default -> { // *No args*
CommandHandler.sendMessage(sender, "Usage: give [player] <itemId|itemName> [amount]"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SendMail_usage);
return; return;
} }
case 1 -> { // <itemId|itemName> case 1 -> { // <itemId|itemName>
...@@ -121,7 +121,7 @@ public final class SendMailCommand implements CommandHandler { ...@@ -121,7 +121,7 @@ public final class SendMailCommand implements CommandHandler {
lvl = 1; lvl = 1;
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
// TODO: Parse from item name using GM Handbook. // TODO: Parse from item name using GM Handbook.
CommandHandler.sendMessage(sender, "Invalid item id."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_item_id);
return; return;
} }
} }
...@@ -138,19 +138,19 @@ public final class SendMailCommand implements CommandHandler { ...@@ -138,19 +138,19 @@ public final class SendMailCommand implements CommandHandler {
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
// TODO: Parse from item name using GM Handbook. // TODO: Parse from item name using GM Handbook.
CommandHandler.sendMessage(sender, "Invalid item or player ID."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_item_or_player_id);
return; return;
} }
} }
} }
mailBuilder.mail.itemList.add(new Mail.MailItem(item, amount, lvl)); mailBuilder.mail.itemList.add(new Mail.MailItem(item, amount, lvl));
CommandHandler.sendMessage(sender, String.format("Attached %s of %s (level %s) to the message.\nContinue adding more items or use `/sendmail finish` to send the message.", amount, item, lvl)); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_send, amount, item, lvl));
} }
} }
} }
} }
} else { } else {
CommandHandler.sendMessage(sender, "Invalid arguments \n Please use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage)); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SendMail_invalid_arguments_please_use, getConstructionArgs(mailBuilder.constructionStage)));
} }
} }
} }
...@@ -158,21 +158,21 @@ public final class SendMailCommand implements CommandHandler { ...@@ -158,21 +158,21 @@ public final class SendMailCommand implements CommandHandler {
private String getConstructionArgs(int stage) { private String getConstructionArgs(int stage) {
switch (stage) { switch (stage) {
case 0 -> { case 0 -> {
return "<title>"; return Grasscutter.getLanguage().SendMail_title;
} }
case 1 -> { case 1 -> {
return "<message>"; return Grasscutter.getLanguage().SendMail_message;
} }
case 2 -> { case 2 -> {
return "<sender>"; return Grasscutter.getLanguage().SendMail_sender;
} }
case 3 -> { case 3 -> {
return "<itemId|itemName|finish> [amount] [level]"; return Grasscutter.getLanguage().SendMail_arguments;
} }
default -> { default -> {
Thread.dumpStack(); Thread.dumpStack();
return "ERROR: invalid construction stage " + stage + ". Check console for stacktrace."; return String.format(Grasscutter.getLanguage().SendMail_error, stage);
} }
} }
} }
......
...@@ -14,7 +14,7 @@ public final class SendMessageCommand implements CommandHandler { ...@@ -14,7 +14,7 @@ public final class SendMessageCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (args.size() < 2) { if (args.size() < 2) {
CommandHandler.sendMessage(null, "Usage: sendmessage <player> <message>"); CommandHandler.sendMessage(null, Grasscutter.getLanguage().SendMessage_usage);
return; return;
} }
...@@ -24,14 +24,14 @@ public final class SendMessageCommand implements CommandHandler { ...@@ -24,14 +24,14 @@ public final class SendMessageCommand implements CommandHandler {
Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Player_not_found);
return; return;
} }
CommandHandler.sendMessage(targetPlayer, message); CommandHandler.sendMessage(targetPlayer, message);
CommandHandler.sendMessage(sender, "Message sent."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SenaMessage_message_sent);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid player ID."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_playerId);
} }
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package emu.grasscutter.command.commands; ...@@ -2,6 +2,7 @@ package emu.grasscutter.command.commands;
import java.util.List; import java.util.List;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
...@@ -17,19 +18,19 @@ public final class SetFetterLevelCommand implements CommandHandler { ...@@ -17,19 +18,19 @@ public final class SetFetterLevelCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
if (args.size() < 1) { if (args.size() < 1) {
CommandHandler.sendMessage(sender, "Usage: setfetterlevel <level>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_usage);
return; return;
} }
try { try {
int fetterLevel = Integer.parseInt(args.get(0)); int fetterLevel = Integer.parseInt(args.get(0));
if (fetterLevel < 0 || fetterLevel > 10) { if (fetterLevel < 0 || fetterLevel > 10) {
CommandHandler.sendMessage(sender, "Fetter level must be between 0 and 10."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_fetter_level_must_between_0_and_10);
return; return;
} }
Avatar avatar = sender.getTeamManager().getCurrentAvatarEntity().getAvatar(); Avatar avatar = sender.getTeamManager().getCurrentAvatarEntity().getAvatar();
...@@ -41,9 +42,9 @@ public final class SetFetterLevelCommand implements CommandHandler { ...@@ -41,9 +42,9 @@ public final class SetFetterLevelCommand implements CommandHandler {
avatar.save(); avatar.save();
sender.sendPacket(new PacketAvatarFetterDataNotify(avatar)); sender.sendPacket(new PacketAvatarFetterDataNotify(avatar));
CommandHandler.sendMessage(sender, "Fetter level set to " + fetterLevel); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetFetterLevel_fetter_set_level, fetterLevel));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid fetter level."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_invalid_fetter_level);
} }
} }
......
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
...@@ -16,20 +17,20 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -16,20 +17,20 @@ public final class SetStatsCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
if (args.size() < 2){ if (args.size() < 2){
CommandHandler.sendMessage(sender, "Usage: setstats|stats <stat> <value>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_usage);
return; return;
} }
String stat = args.get(0); String stat = args.get(0);
switch (stat) { switch (stat) {
default: default:
CommandHandler.sendMessage(sender, "Usage: /setstats|stats <hp | mhp | def | atk | em | er | crate | cdmg> <value> for basic stats"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_setstats_help_message);
CommandHandler.sendMessage(sender, "Usage: /stats <epyro | ecryo | ehydro | egeo | edend | eelec | ephys> <amount> for elemental bonus"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_stats_help_message);
return; return;
case "mhp": case "mhp":
try { try {
...@@ -37,9 +38,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -37,9 +38,9 @@ public final class SetStatsCommand implements CommandHandler {
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
entity.setFightProperty(FightProperty.FIGHT_PROP_MAX_HP, health); entity.setFightProperty(FightProperty.FIGHT_PROP_MAX_HP, health);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_MAX_HP)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_MAX_HP));
CommandHandler.sendMessage(sender, "MAX HP set to " + health + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_max_hp, health));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Max HP value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_max_hp_error);
return; return;
} }
break; break;
...@@ -49,9 +50,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -49,9 +50,9 @@ public final class SetStatsCommand implements CommandHandler {
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, health); entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, health);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_HP)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_HP));
CommandHandler.sendMessage(sender, "HP set to " + health + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_hp, health));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid HP value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_hp_error);
return; return;
} }
break; break;
...@@ -61,9 +62,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -61,9 +62,9 @@ public final class SetStatsCommand implements CommandHandler {
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, def); entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, def);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_DEFENSE)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_DEFENSE));
CommandHandler.sendMessage(sender, "DEF set to " + def + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_def, def));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid DEF value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_def_error);
return; return;
} }
break; break;
...@@ -73,9 +74,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -73,9 +74,9 @@ public final class SetStatsCommand implements CommandHandler {
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, atk); entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, atk);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_ATTACK)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_ATTACK));
CommandHandler.sendMessage(sender, "ATK set to " + atk + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_atk, atk));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid ATK value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_atk_error);
return; return;
} }
break; break;
...@@ -85,9 +86,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -85,9 +86,9 @@ public final class SetStatsCommand implements CommandHandler {
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
entity.setFightProperty(FightProperty.FIGHT_PROP_ELEMENT_MASTERY, em); entity.setFightProperty(FightProperty.FIGHT_PROP_ELEMENT_MASTERY, em);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ELEMENT_MASTERY)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ELEMENT_MASTERY));
CommandHandler.sendMessage(sender, "Elemental Mastery set to " + em + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_em, em));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid EM value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_em_error);
return; return;
} }
break; break;
...@@ -99,9 +100,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -99,9 +100,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, erecharge); entity.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, erecharge);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY));
float iger = erecharge * 100; float iger = erecharge * 100;
CommandHandler.sendMessage(sender, "Energy recharge set to " + iger + "%."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_er, iger));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid ER value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_er_error);
return; return;
} }
break; break;
...@@ -113,9 +114,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -113,9 +114,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, crate); entity.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, crate);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CRITICAL)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CRITICAL));
float igcrate = crate * 100; float igcrate = crate * 100;
CommandHandler.sendMessage(sender, "Crit Rate set to " + igcrate + "%."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_cr, igcrate));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Crit Rate value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_cr_error);
return; return;
} }
break; break;
...@@ -127,9 +128,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -127,9 +128,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, cdamage); entity.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, cdamage);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CRITICAL_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CRITICAL_HURT));
float igcdmg = cdamage * 100; float igcdmg = cdamage * 100;
CommandHandler.sendMessage(sender, "Crit DMG set to " + igcdmg + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_cd, igcdmg));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Crit DMG value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_cd_error);
return; return;
} }
break; break;
...@@ -141,9 +142,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -141,9 +142,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_FIRE_ADD_HURT, pyro); entity.setFightProperty(FightProperty.FIGHT_PROP_FIRE_ADD_HURT, pyro);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_FIRE_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_FIRE_ADD_HURT));
float igpyro = pyro * 100; float igpyro = pyro * 100;
CommandHandler.sendMessage(sender, "Pyro DMG Bonus set to " + igpyro + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_pdb, igpyro));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Pyro DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_pdb_error);
return; return;
} }
break; break;
...@@ -155,9 +156,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -155,9 +156,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_ICE_ADD_HURT, cryo); entity.setFightProperty(FightProperty.FIGHT_PROP_ICE_ADD_HURT, cryo);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ICE_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ICE_ADD_HURT));
float igcyro = cryo * 100; float igcyro = cryo * 100;
CommandHandler.sendMessage(sender, "Cyro DMG Bonus set to " + igcyro + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_cdb, igcyro));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Cryo DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_cdb_error);
return; return;
} }
break; break;
...@@ -169,9 +170,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -169,9 +170,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_WATER_ADD_HURT, hydro); entity.setFightProperty(FightProperty.FIGHT_PROP_WATER_ADD_HURT, hydro);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_WATER_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_WATER_ADD_HURT));
float ighydro = hydro * 100; float ighydro = hydro * 100;
CommandHandler.sendMessage(sender, "Hydro DMG Bonus set to " + ighydro + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_hdb, ighydro));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Hydro DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_hdb_error);
return; return;
} }
break; break;
...@@ -183,9 +184,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -183,9 +184,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_WIND_ADD_HURT, anemo); entity.setFightProperty(FightProperty.FIGHT_PROP_WIND_ADD_HURT, anemo);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_WIND_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_WIND_ADD_HURT));
float iganemo = anemo * 100; float iganemo = anemo * 100;
CommandHandler.sendMessage(sender, "Anemo DMG Bonus set to " + iganemo + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_adb, iganemo));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Anemo DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_adb_error);
return; return;
} }
break; break;
...@@ -197,9 +198,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -197,9 +198,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_ROCK_ADD_HURT, geo); entity.setFightProperty(FightProperty.FIGHT_PROP_ROCK_ADD_HURT, geo);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ROCK_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ROCK_ADD_HURT));
float iggeo = geo * 100; float iggeo = geo * 100;
CommandHandler.sendMessage(sender, "Geo DMG Bonus set to " + iggeo + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_gdb, iggeo));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Geo DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_gdb_error);
return; return;
} }
break; break;
...@@ -212,9 +213,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -212,9 +213,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_ELEC_ADD_HURT, elec); entity.setFightProperty(FightProperty.FIGHT_PROP_ELEC_ADD_HURT, elec);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ELEC_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_ELEC_ADD_HURT));
float igelec = elec * 100; float igelec = elec * 100;
CommandHandler.sendMessage(sender, "Electro DMG Bonus set to " + igelec + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_edb, igelec));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Electro DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_edb_error);
return; return;
} }
break; break;
...@@ -226,9 +227,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -226,9 +227,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT, phys); entity.setFightProperty(FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT, phys);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_PHYSICAL_ADD_HURT));
float igphys = phys * 100; float igphys = phys * 100;
CommandHandler.sendMessage(sender, "Physical DMG Bonus set to " + igphys + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_physdb, igphys));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Physical DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_physdb_error);
return; return;
} }
break; break;
...@@ -240,9 +241,9 @@ public final class SetStatsCommand implements CommandHandler { ...@@ -240,9 +241,9 @@ public final class SetStatsCommand implements CommandHandler {
entity.setFightProperty(FightProperty.FIGHT_PROP_GRASS_ADD_HURT, dend); entity.setFightProperty(FightProperty.FIGHT_PROP_GRASS_ADD_HURT, dend);
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_GRASS_ADD_HURT)); entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_GRASS_ADD_HURT));
float igdend = dend * 100; float igdend = dend * 100;
CommandHandler.sendMessage(sender, "Dendro DMG Bonus set to " + igdend + "%"); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().SetStats_set_ddb, igdend));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid Dendro DMG Bonus value."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetStats_set_ddb_error);
return; return;
} }
break; break;
......
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
...@@ -14,19 +15,19 @@ public final class SetWorldLevelCommand implements CommandHandler { ...@@ -14,19 +15,19 @@ public final class SetWorldLevelCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; // TODO: set player's world level from console or other players return; // TODO: set player's world level from console or other players
} }
if (args.size() < 1) { if (args.size() < 1) {
CommandHandler.sendMessage(sender, "Usage: setworldlevel <level>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetWorldLevel_usage);
return; return;
} }
try { try {
int level = Integer.parseInt(args.get(0)); int level = Integer.parseInt(args.get(0));
if (level > 8 || level < 0) { if (level > 8 || level < 0) {
sender.dropMessage("World level must be between 0-8"); sender.dropMessage(Grasscutter.getLanguage().SetWorldLevel_world_level_must_between_0_and_8);
return; return;
} }
...@@ -34,9 +35,9 @@ public final class SetWorldLevelCommand implements CommandHandler { ...@@ -34,9 +35,9 @@ public final class SetWorldLevelCommand implements CommandHandler {
sender.getWorld().setWorldLevel(level); sender.getWorld().setWorldLevel(level);
sender.setWorldLevel(level); sender.setWorldLevel(level);
sender.dropMessage("World level set to " + level + "."); sender.dropMessage(String.format(Grasscutter.getLanguage().SetWorldLevel_set_world_level, level));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(null, "Invalid world level."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().SetWorldLevel_invalid_world_level);
} }
} }
} }
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
...@@ -25,12 +26,12 @@ public final class SpawnCommand implements CommandHandler { ...@@ -25,12 +26,12 @@ public final class SpawnCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
if (args.size() < 1) { if (args.size() < 1) {
CommandHandler.sendMessage(sender, "Usage: spawn <entityId> [amount] [level(monster only)]"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Spawn_usage);
return; return;
} }
...@@ -43,7 +44,7 @@ public final class SpawnCommand implements CommandHandler { ...@@ -43,7 +44,7 @@ public final class SpawnCommand implements CommandHandler {
GadgetData gadgetData = GameData.getGadgetDataMap().get(id); GadgetData gadgetData = GameData.getGadgetDataMap().get(id);
ItemData itemData = GameData.getItemDataMap().get(id); ItemData itemData = GameData.getItemDataMap().get(id);
if (monsterData == null && gadgetData == null && itemData == null) { if (monsterData == null && gadgetData == null && itemData == null) {
CommandHandler.sendMessage(sender, "Invalid entity id."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_entity_id);
return; return;
} }
...@@ -78,9 +79,9 @@ public final class SpawnCommand implements CommandHandler { ...@@ -78,9 +79,9 @@ public final class SpawnCommand implements CommandHandler {
sender.getScene().addEntity(entity); sender.getScene().addEntity(entity);
} }
CommandHandler.sendMessage(sender, String.format("Spawned %s of %s.", amount, id)); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Spawn_message, amount, id));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid entity ID."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_entity_id);
} }
} }
......
...@@ -13,9 +13,9 @@ public final class StopCommand implements CommandHandler { ...@@ -13,9 +13,9 @@ public final class StopCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
CommandHandler.sendMessage(null, "Server shutting down..."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Stop_message);
for (Player p : Grasscutter.getGameServer().getPlayers().values()) { for (Player p : Grasscutter.getGameServer().getPlayers().values()) {
CommandHandler.sendMessage(p, "Server shutting down..."); CommandHandler.sendMessage(p, Grasscutter.getLanguage().Stop_message);
} }
System.exit(1); System.exit(1);
......
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.def.AvatarSkillDepotData; import emu.grasscutter.data.def.AvatarSkillDepotData;
...@@ -18,23 +19,23 @@ public final class TalentCommand implements CommandHandler { ...@@ -18,23 +19,23 @@ public final class TalentCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
if (args.size() < 1){ if (args.size() < 1){
CommandHandler.sendMessage(sender, "To set talent level: /talent set <talentID> <value>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_1);
CommandHandler.sendMessage(sender, "Another way to set talent level: /talent <n or e or q> <value>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_2);
CommandHandler.sendMessage(sender, "To get talent ID: /talent getid"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_3);
return; return;
} }
String cmdSwitch = args.get(0); String cmdSwitch = args.get(0);
switch (cmdSwitch) { switch (cmdSwitch) {
default: default:
CommandHandler.sendMessage(sender, "To set talent level: /talent set <talentID> <value>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_1);
CommandHandler.sendMessage(sender, "Another way to set talent level: /talent <n or e or q> <value>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_2);
CommandHandler.sendMessage(sender, "To get talent ID: /talent getid"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_3);
return; return;
case "set": case "set":
try { try {
...@@ -49,12 +50,12 @@ public final class TalentCommand implements CommandHandler { ...@@ -49,12 +50,12 @@ public final class TalentCommand implements CommandHandler {
int currentLevelE = avatar.getSkillLevelMap().get(skillIdE); int currentLevelE = avatar.getSkillLevelMap().get(skillIdE);
int currentLevelQ = avatar.getSkillLevelMap().get(skillIdQ); int currentLevelQ = avatar.getSkillLevelMap().get(skillIdQ);
if (args.size() < 2){ if (args.size() < 2){
CommandHandler.sendMessage(sender, "To set talent level: /talent set <talentID> <value>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_1);
CommandHandler.sendMessage(sender, "To get talent ID: /talent getid"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_3);
return; return;
} }
if (nextLevel >= 16){ if (nextLevel >= 16){
CommandHandler.sendMessage(sender, "Invalid talent level. Level should be lower than 16"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_lower_16);
return; return;
} }
if (skillId == skillIdNorAtk){ if (skillId == skillIdNorAtk){
...@@ -65,7 +66,7 @@ public final class TalentCommand implements CommandHandler { ...@@ -65,7 +66,7 @@ public final class TalentCommand implements CommandHandler {
// Packet // Packet
sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillIdNorAtk, currentLevelNorAtk, nextLevel)); sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillIdNorAtk, currentLevelNorAtk, nextLevel));
sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillIdNorAtk, currentLevelNorAtk, nextLevel)); sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillIdNorAtk, currentLevelNorAtk, nextLevel));
CommandHandler.sendMessage(sender, "Set talent Normal ATK to " + nextLevel + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Talent_set_atk, nextLevel));
} }
if (skillId == skillIdE){ if (skillId == skillIdE){
// Upgrade skill // Upgrade skill
...@@ -75,7 +76,7 @@ public final class TalentCommand implements CommandHandler { ...@@ -75,7 +76,7 @@ public final class TalentCommand implements CommandHandler {
// Packet // Packet
sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillIdE, currentLevelE, nextLevel)); sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillIdE, currentLevelE, nextLevel));
sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillIdE, currentLevelE, nextLevel)); sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillIdE, currentLevelE, nextLevel));
CommandHandler.sendMessage(sender, "Set talent E to " + nextLevel + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Talent_set_e, nextLevel));
} }
if (skillId == skillIdQ){ if (skillId == skillIdQ){
// Upgrade skill // Upgrade skill
...@@ -85,11 +86,11 @@ public final class TalentCommand implements CommandHandler { ...@@ -85,11 +86,11 @@ public final class TalentCommand implements CommandHandler {
// Packet // Packet
sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillIdQ, currentLevelQ, nextLevel)); sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillIdQ, currentLevelQ, nextLevel));
sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillIdQ, currentLevelQ, nextLevel)); sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillIdQ, currentLevelQ, nextLevel));
CommandHandler.sendMessage(sender, "Set talent Q to " + nextLevel + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Talent_set_q, nextLevel));
} }
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid skill ID."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_invalid_skill_id);
return; return;
} }
...@@ -114,11 +115,11 @@ public final class TalentCommand implements CommandHandler { ...@@ -114,11 +115,11 @@ public final class TalentCommand implements CommandHandler {
int nextLevel = Integer.parseInt(args.get(1)); int nextLevel = Integer.parseInt(args.get(1));
int currentLevel = avatar.getSkillLevelMap().get(skillId); int currentLevel = avatar.getSkillLevelMap().get(skillId);
if (args.size() < 1){ if (args.size() < 1){
CommandHandler.sendMessage(sender, "To set talent level: /talent <n or e or q> <value>"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_usage_2);
return; return;
} }
if (nextLevel >= 16){ if (nextLevel >= 16){
CommandHandler.sendMessage(sender, "Invalid talent level. Level should be lower than 16"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_lower_16);
return; return;
} }
// Upgrade skill // Upgrade skill
...@@ -127,9 +128,9 @@ public final class TalentCommand implements CommandHandler { ...@@ -127,9 +128,9 @@ public final class TalentCommand implements CommandHandler {
// Packet // Packet
sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillId, currentLevel, nextLevel)); sender.sendPacket(new PacketAvatarSkillChangeNotify(avatar, skillId, currentLevel, nextLevel));
sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillId, currentLevel, nextLevel)); sender.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillId, currentLevel, nextLevel));
CommandHandler.sendMessage(sender, "Set this talent to " + nextLevel + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Talent_set_this, nextLevel));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid talent level."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Talent_invalid_talent_level);
return; return;
} }
break; break;
...@@ -140,9 +141,9 @@ public final class TalentCommand implements CommandHandler { ...@@ -140,9 +141,9 @@ public final class TalentCommand implements CommandHandler {
int skillIdE = avatar.getData().getSkillDepot().getSkills().get(1); int skillIdE = avatar.getData().getSkillDepot().getSkills().get(1);
int skillIdQ = avatar.getData().getSkillDepot().getEnergySkill(); int skillIdQ = avatar.getData().getSkillDepot().getEnergySkill();
CommandHandler.sendMessage(sender, "Normal Attack ID " + skillIdNorAtk + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Talent_normal_attack_id, skillIdNorAtk));
CommandHandler.sendMessage(sender, "E skill ID " + skillIdE + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Talent_e_skill_id, skillIdE));
CommandHandler.sendMessage(sender, "Q skill ID " + skillIdQ + "."); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Talent_q_skill_id, skillIdQ));
break; break;
} }
} }
......
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
...@@ -13,12 +14,12 @@ public final class TeleportAllCommand implements CommandHandler { ...@@ -13,12 +14,12 @@ public final class TeleportAllCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
if (!sender.getWorld().isMultiplayer()) { if (!sender.getWorld().isMultiplayer()) {
CommandHandler.sendMessage(sender, "You only can use this command in MP mode."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().TeleportAll_message);
return; return;
} }
......
...@@ -16,20 +16,20 @@ public final class TeleportCommand implements CommandHandler { ...@@ -16,20 +16,20 @@ public final class TeleportCommand implements CommandHandler {
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
int target; int target;
if (args.size() < (sender == null ? 4 : 3)) { if (args.size() < (sender == null ? 4 : 3)) {
CommandHandler.sendMessage(sender, sender == null ? "Usage: /tp @<player id> <x> <y> <z> [scene id]" : CommandHandler.sendMessage(sender, sender == null ? Grasscutter.getLanguage().Teleport_usage_server :
"Usage: /tp [@<player id>] <x> <y> <z> [scene id]"); Grasscutter.getLanguage().Teleport_usage);
return; return;
} }
if (args.get(0).startsWith("@")) { if (args.get(0).startsWith("@")) {
try { try {
target = Integer.parseInt(args.get(0).substring(1)); target = Integer.parseInt(args.get(0).substring(1));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
CommandHandler.sendMessage(sender, "Invalid player id."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_playerId);
return; return;
} }
} else { } else {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "You must specify a player id."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Teleport_specify_player_id);
return; return;
} }
target = sender.getUid(); target = sender.getUid();
...@@ -37,7 +37,7 @@ public final class TeleportCommand implements CommandHandler { ...@@ -37,7 +37,7 @@ public final class TeleportCommand implements CommandHandler {
Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found or offline."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Player_not_found_or_offline);
return; return;
} }
args = args.subList(args.get(0).startsWith("@") ? 1 : 0, args.size()); args = args.subList(args.get(0).startsWith("@") ? 1 : 0, args.size());
...@@ -80,12 +80,12 @@ public final class TeleportCommand implements CommandHandler { ...@@ -80,12 +80,12 @@ public final class TeleportCommand implements CommandHandler {
Position target_pos = new Position(x, y, z); Position target_pos = new Position(x, y, z);
boolean result = targetPlayer.getWorld().transferPlayerToScene(targetPlayer, sceneId, target_pos); boolean result = targetPlayer.getWorld().transferPlayerToScene(targetPlayer, sceneId, target_pos);
if (!result) { if (!result) {
CommandHandler.sendMessage(sender, "Invalid position."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Teleport_invalid_position);
} else { } else {
CommandHandler.sendMessage(sender, "Teleported " + targetPlayer.getNickname() + " to " + x + "," + y + "," + z + " in scene " + sceneId); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Teleport_message, targetPlayer.getNickname(), x, y, z, sceneId));
} }
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid position."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Teleport_invalid_position);
} }
} }
} }
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
...@@ -15,12 +16,12 @@ public final class WeatherCommand implements CommandHandler { ...@@ -15,12 +16,12 @@ public final class WeatherCommand implements CommandHandler {
@Override @Override
public void execute(Player sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, Grasscutter.getLanguage().Run_this_command_in_game);
return; return;
} }
if (args.size() < 1) { if (args.size() < 1) {
CommandHandler.sendMessage(sender, "Usage: weather <weatherId> [climateId]"); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_usage);
return; return;
} }
...@@ -33,9 +34,9 @@ public final class WeatherCommand implements CommandHandler { ...@@ -33,9 +34,9 @@ public final class WeatherCommand implements CommandHandler {
sender.getScene().setWeather(weatherId); sender.getScene().setWeather(weatherId);
sender.getScene().setClimate(climate); sender.getScene().setClimate(climate);
sender.getScene().broadcastPacket(new PacketSceneAreaWeatherNotify(sender)); sender.getScene().broadcastPacket(new PacketSceneAreaWeatherNotify(sender));
CommandHandler.sendMessage(sender, "Changed weather to " + weatherId + " with climate " + climateId); CommandHandler.sendMessage(sender, String.format(Grasscutter.getLanguage().Weather_message, weatherId, climateId));
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid ID."); CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_invalid_id);
} }
} }
} }
...@@ -32,7 +32,7 @@ public final class DispatchHttpJsonHandler implements HttpContextHandler { ...@@ -32,7 +32,7 @@ public final class DispatchHttpJsonHandler implements HttpContextHandler {
public void handle(Request req, Response res) throws IOException { public void handle(Request req, Response res) throws IOException {
// Checking for ALL here isn't required as when ALL is enabled enableDevLogging() gets enabled // Checking for ALL here isn't required as when ALL is enabled enableDevLogging() gets enabled
if(Grasscutter.getConfig().DebugMode == ServerDebugMode.MISSING && Arrays.stream(missingRoutes).anyMatch(x -> x == req.baseUrl())) { if(Grasscutter.getConfig().DebugMode == ServerDebugMode.MISSING && Arrays.stream(missingRoutes).anyMatch(x -> x == req.baseUrl())) {
Grasscutter.getLogger().info(String.format("[Dispatch] Client %s %s request: %s", req.ip(), req.method(), req.baseUrl()) + (Grasscutter.getConfig().DebugMode == ServerDebugMode.MISSING ? "(MISSING)" : "")); Grasscutter.getLogger().info(String.format(Grasscutter.getLanguage().Client_request, req.ip(), req.method(), req.baseUrl()) + (Grasscutter.getConfig().DebugMode == ServerDebugMode.MISSING ? "(MISSING)" : ""));
} }
res.send(response); res.send(response);
} }
......
...@@ -211,21 +211,21 @@ public final class DispatchServer { ...@@ -211,21 +211,21 @@ public final class DispatchServer {
sslContextFactory.setKeyStorePassword(Grasscutter.getConfig().getDispatchOptions().KeystorePassword); sslContextFactory.setKeyStorePassword(Grasscutter.getConfig().getDispatchOptions().KeystorePassword);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Grasscutter.getLogger().warn("[Dispatch] Unable to load keystore. Trying default keystore password..."); Grasscutter.getLogger().warn(Grasscutter.getLanguage().Not_load_keystore);
try { try {
sslContextFactory.setKeyStorePath(keystoreFile.getPath()); sslContextFactory.setKeyStorePath(keystoreFile.getPath());
sslContextFactory.setKeyStorePassword("123456"); sslContextFactory.setKeyStorePassword("123456");
Grasscutter.getLogger().warn("[Dispatch] The default keystore password was loaded successfully. Please consider setting the password to 123456 in config.json."); Grasscutter.getLogger().warn(Grasscutter.getLanguage().Use_default_keystore);
} catch (Exception e2) { } catch (Exception e2) {
Grasscutter.getLogger().warn("[Dispatch] Error while loading keystore!"); Grasscutter.getLogger().warn(Grasscutter.getLanguage().Load_keystore_error);
e2.printStackTrace(); e2.printStackTrace();
} }
} }
serverConnector = new ServerConnector(server, sslContextFactory); serverConnector = new ServerConnector(server, sslContextFactory);
} else { } else {
Grasscutter.getLogger().warn("[Dispatch] No SSL cert found! Falling back to HTTP server."); Grasscutter.getLogger().warn(Grasscutter.getLanguage().Not_find_ssl_cert);
Grasscutter.getConfig().getDispatchOptions().UseSSL = false; Grasscutter.getConfig().getDispatchOptions().UseSSL = false;
serverConnector = new ServerConnector(server); serverConnector = new ServerConnector(server);
...@@ -245,11 +245,11 @@ public final class DispatchServer { ...@@ -245,11 +245,11 @@ public final class DispatchServer {
} }
}); });
httpServer.get("/", (req, res) -> res.send("Welcome to Grasscutter")); httpServer.get("/", (req, res) -> res.send(Grasscutter.getLanguage().Welcome));
httpServer.raw().error(404, ctx -> { httpServer.raw().error(404, ctx -> {
if(Grasscutter.getConfig().DebugMode == ServerDebugMode.MISSING) { if(Grasscutter.getConfig().DebugMode == ServerDebugMode.MISSING) {
Grasscutter.getLogger().info(String.format("[Dispatch] Potential unhandled %s request: %s", ctx.method(), ctx.url())); Grasscutter.getLogger().info(String.format(Grasscutter.getLanguage().Potential_unhandled_request, ctx.method(), ctx.url()));
} }
ctx.contentType("text/html"); ctx.contentType("text/html");
ctx.result("<!doctype html><html lang=\"en\"><body><img src=\"https://http.cat/404\" /></body></html>"); // I'm like 70% sure this won't break anything. ctx.result("<!doctype html><html lang=\"en\"><body><img src=\"https://http.cat/404\" /></body></html>"); // I'm like 70% sure this won't break anything.
...@@ -327,7 +327,7 @@ public final class DispatchServer { ...@@ -327,7 +327,7 @@ public final class DispatchServer {
return; return;
} }
LoginResultJson responseData = new LoginResultJson(); LoginResultJson responseData = new LoginResultJson();
Grasscutter.getLogger().info(String.format("[Dispatch] Client %s is trying to log in via token", req.ip())); Grasscutter.getLogger().info(String.format(Grasscutter.getLanguage().Client_login_token, req.ip()));
// Login // Login
Account account = DatabaseHelper.getAccountById(requestData.uid); Account account = DatabaseHelper.getAccountById(requestData.uid);
...@@ -335,17 +335,17 @@ public final class DispatchServer { ...@@ -335,17 +335,17 @@ public final class DispatchServer {
// Test // Test
if (account == null || !account.getSessionKey().equals(requestData.token)) { if (account == null || !account.getSessionKey().equals(requestData.token)) {
responseData.retcode = -111; responseData.retcode = -111;
responseData.message = "Game account cache information error"; responseData.message = Grasscutter.getLanguage().Game_account_cache_error;
Grasscutter.getLogger() Grasscutter.getLogger()
.info(String.format("[Dispatch] Client %s failed to log in via token", req.ip())); .info(String.format(Grasscutter.getLanguage().Client_token_login_failed, req.ip()));
} else { } else {
responseData.message = "OK"; responseData.message = "OK";
responseData.data.account.uid = requestData.uid; responseData.data.account.uid = requestData.uid;
responseData.data.account.token = requestData.token; responseData.data.account.token = requestData.token;
responseData.data.account.email = account.getEmail(); responseData.data.account.email = account.getEmail();
Grasscutter.getLogger().info(String.format("[Dispatch] Client %s logged in via token as %s", Grasscutter.getLogger().info(String.format(Grasscutter.getLanguage().Client_login_in_token,
req.ip(), responseData.data.account.uid)); req.ip(), responseData.data.account.uid));
} }
...@@ -376,10 +376,10 @@ public final class DispatchServer { ...@@ -376,10 +376,10 @@ public final class DispatchServer {
// Test // Test
if (account == null || !account.getSessionKey().equals(loginData.token)) { if (account == null || !account.getSessionKey().equals(loginData.token)) {
responseData.retcode = -201; responseData.retcode = -201;
responseData.message = "Wrong session key."; responseData.message = Grasscutter.getLanguage().Wrong_session_key;
Grasscutter.getLogger().info( Grasscutter.getLogger().info(
String.format("[Dispatch] Client %s failed to exchange combo token", req.ip())); String.format(Grasscutter.getLanguage().Client_failed_exchange_combo_token, req.ip()));
} else { } else {
responseData.message = "OK"; responseData.message = "OK";
responseData.data.open_id = loginData.uid; responseData.data.open_id = loginData.uid;
...@@ -387,7 +387,7 @@ public final class DispatchServer { ...@@ -387,7 +387,7 @@ public final class DispatchServer {
responseData.data.combo_token = account.generateLoginToken(); responseData.data.combo_token = account.generateLoginToken();
Grasscutter.getLogger().info( Grasscutter.getLogger().info(
String.format("[Dispatch] Client %s succeed to exchange combo token", req.ip())); String.format(Grasscutter.getLanguage().Client_exchange_combo_token, req.ip()));
} }
res.send(responseData); res.send(responseData);
...@@ -453,7 +453,7 @@ public final class DispatchServer { ...@@ -453,7 +453,7 @@ public final class DispatchServer {
httpServer.get("/gcstatic/*", new StaticFileHandler()); httpServer.get("/gcstatic/*", new StaticFileHandler());
httpServer.listen(Grasscutter.getConfig().getDispatchOptions().Port); httpServer.listen(Grasscutter.getConfig().getDispatchOptions().Port);
Grasscutter.getLogger().info("[Dispatch] Dispatch server started on port " + httpServer.raw().port()); Grasscutter.getLogger().info(String.format(Grasscutter.getLanguage().Dispatch_start_server_port, httpServer.raw().port()));
} }
private Map<String, String> parseQueryString(String qs) { private Map<String, String> parseQueryString(String qs) {
......
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