Commit b3a91700 authored by KingRainbow44's avatar KingRainbow44
Browse files

Convert to the superior language system. (pt. 3)

parent c0b1ec1b
......@@ -7,6 +7,8 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "coop", usage = "coop [host UID]",
description = "Forces someone to join the world of others", permission = "server.coop")
public final class CoopCommand implements CommandHandler {
......@@ -20,26 +22,25 @@ public final class CoopCommand implements CommandHandler {
Player host = sender;
switch (args.size()) {
case 0: // Summon target to self
if (sender == null) { // Console doesn't have a self to summon to
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Coop_usage);
CommandHandler.sendMessage(sender, translate("commands.coop.usage"));
if (sender == null) // Console doesn't have a self to summon to
return;
}
break;
case 1: // Summon target to argument
try {
int hostId = Integer.parseInt(args.get(0));
host = Grasscutter.getGameServer().getPlayerByUid(hostId);
if (host == null) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Player_is_offline);
CommandHandler.sendMessage(sender, translate("commands.execution.player_offline_error"));
return;
}
break;
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_playerId);
CommandHandler.sendMessage(sender, translate("commands.execution.uid_error"));
return;
}
default:
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Coop_usage);
CommandHandler.sendMessage(sender, translate("commands.coop.usage"));
return;
}
......@@ -49,6 +50,6 @@ public final class CoopCommand implements CommandHandler {
}
host.getServer().getMultiplayerManager().applyEnterMp(targetPlayer, host.getUid());
targetPlayer.getServer().getMultiplayerManager().applyEnterMpReply(host, targetPlayer.getUid(), true);
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Coop_success.replace("{host}", host.getNickname()).replace("{target}", targetPlayer.getNickname()));
CommandHandler.sendMessage(sender, translate("commands.coop.success", targetPlayer.getNickname(), host.getNickname()));
}
}
......@@ -13,6 +13,8 @@ import emu.grasscutter.game.player.Player;
import java.util.*;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "giveall", usage = "giveall [amount]",
description = "Gives all items", aliases = {"givea"}, permission = "player.giveall", threading = true)
public final class GiveAllCommand implements CommandHandler {
......@@ -32,21 +34,21 @@ public final class GiveAllCommand implements CommandHandler {
try {
amount = Integer.parseInt(args.get(0));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_amount);
CommandHandler.sendMessage(sender, translate("commands.generic.invalid.amount"));
return;
}
break;
default: // invalid
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().GiveAll_usage);
CommandHandler.sendMessage(sender, translate("commands.giveAll.usage"));
return;
}
this.giveAllItems(targetPlayer, amount);
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().GiveAll_done);
CommandHandler.sendMessage(sender, translate("commands.giveAll.success", targetPlayer.getNickname()));
}
public void giveAllItems(Player player, int amount) {
CommandHandler.sendMessage(player, Grasscutter.getLanguage().GiveAll_item);
CommandHandler.sendMessage(player, translate("commands.giveAll.started"));
for (AvatarData avatarData: GameData.getAvatarDataMap().values()) {
//Exclude test avatar
......
......@@ -14,6 +14,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "giveart", usage = "giveart <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", description = "Gives the player a specified artifact", aliases = {"gart"}, permission = "player.giveart")
public final class GiveArtifactCommand implements CommandHandler {
@Override
......@@ -24,7 +26,7 @@ public final class GiveArtifactCommand implements CommandHandler {
}
if (args.size() < 2) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().GiveArtifact_usage);
CommandHandler.sendMessage(sender, translate("commands.giveArtifact.usage"));
return;
}
......@@ -32,12 +34,12 @@ public final class GiveArtifactCommand implements CommandHandler {
try {
itemId = Integer.parseInt(args.remove(0));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_artifact_id);
CommandHandler.sendMessage(sender, translate("commands.giveArtifact.id_error"));
return;
}
ItemData itemData = GameData.getItemDataMap().get(itemId);
if (itemData.getItemType() != ItemType.ITEM_RELIQUARY) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_artifact_id);
CommandHandler.sendMessage(sender, translate("commands.giveArtifact.id_error"));
return;
}
......@@ -45,7 +47,7 @@ public final class GiveArtifactCommand implements CommandHandler {
try {
mainPropId = Integer.parseInt(args.remove(0));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_arguments);
CommandHandler.sendMessage(sender, translate("commands.generic.execution.argument_error"));
return;
}
......@@ -59,7 +61,7 @@ public final class GiveArtifactCommand implements CommandHandler {
} catch (NumberFormatException ignored) { // Could be a stat,times string so no need to panic
}
ArrayList<Integer> appendPropIdList = new ArrayList<>();
List<Integer> appendPropIdList = new ArrayList<>();
try {
args.forEach(it -> {
String[] arr;
......@@ -74,7 +76,7 @@ public final class GiveArtifactCommand implements CommandHandler {
appendPropIdList.addAll(Collections.nCopies(n, Integer.parseInt(it)));
});
} catch (Exception ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_arguments);
CommandHandler.sendMessage(sender, translate("commands.execution.argument_error"));
return;
}
......@@ -85,7 +87,7 @@ public final class GiveArtifactCommand implements CommandHandler {
item.getAppendPropIdList().addAll(appendPropIdList);
targetPlayer.getInventory().addItem(item, ActionReason.SubfieldDrop);
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().GiveArtifact_given.replace("{itemId}", Integer.toString(itemId)).replace("target", Integer.toString(targetPlayer.getUid())));
CommandHandler.sendMessage(sender, translate("commands.giveArtifact.success", Integer.toString(itemId), Integer.toString(targetPlayer.getUid())));
}
}
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.entity.EntityAvatar;
......@@ -12,6 +11,8 @@ import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "killcharacter", usage = "killcharacter", aliases = {"suicide", "kill"},
description = "Kills the players current character", permission = "player.killcharacter")
public final class KillCharacterCommand implements CommandHandler {
......@@ -32,6 +33,6 @@ public final class KillCharacterCommand implements CommandHandler {
targetPlayer.getScene().removeEntity(entity);
entity.onDeath(0);
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().KillCharacter_kill_current_character.replace("{name}", targetPlayer.getNickname()));
CommandHandler.sendMessage(sender, translate("commands.killCharacter.success", targetPlayer.getNickname()));
}
}
......@@ -8,6 +8,8 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
import java.util.Map;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "list", usage = "list [uid]",
description = "List online players", aliases = {"players"})
public final class ListCommand implements CommandHandler {
......@@ -21,7 +23,7 @@ public final class ListCommand implements CommandHandler {
needUID = args.get(0).equals("uid");
}
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().List_message.replace("{size}", Integer.toString(playersMap.size())));
CommandHandler.sendMessage(sender, translate("commands.list.success", Integer.toString(playersMap.size())));
if (playersMap.size() != 0) {
StringBuilder playerSet = new StringBuilder();
......
......@@ -22,7 +22,7 @@ public final class PermissionCommand implements CommandHandler {
}
if (args.size() != 2) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_usage);
CommandHandler.sendMessage(sender, translate("commands.permission.usage"));
return;
}
......@@ -31,23 +31,23 @@ public final class PermissionCommand implements CommandHandler {
Account account = targetPlayer.getAccount();
if (account == null) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Account_not_find);
CommandHandler.sendMessage(sender, translate("commands.permission.account_error"));
return;
}
switch (action) {
default:
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_usage);
CommandHandler.sendMessage(sender, translate("commands.permission.usage"));
break;
case "add":
if (account.addPermission(permission)) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_add);
} else CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_have_permission);
CommandHandler.sendMessage(sender, translate("commands.permission.add"));
} else CommandHandler.sendMessage(sender, translate("commands.permission.has_error"));
break;
case "remove":
if (account.removePermission(permission)) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_remove);
} else CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Permission_not_have_permission);
CommandHandler.sendMessage(sender, translate("commands.permission.remove"));
} else CommandHandler.sendMessage(sender, translate("commands.permission.not_have_error"));
break;
}
......
......@@ -7,6 +7,8 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "resetshop", usage = "resetshop",
description = "Reset target player's shop refresh time.", permission = "server.resetshop")
public final class ResetShopLimitCommand implements CommandHandler {
......@@ -19,6 +21,6 @@ public final class ResetShopLimitCommand implements CommandHandler {
targetPlayer.getShopLimit().forEach(x -> x.setNextRefreshTime(0));
targetPlayer.save();
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Success);
CommandHandler.sendMessage(sender, translate("commands.status.success"));
}
}
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player;
......@@ -20,12 +19,12 @@ public final class SendMessageCommand implements CommandHandler {
return;
}
if (args.size() == 0) {
CommandHandler.sendMessage(null, Grasscutter.getLanguage().SendMessage_usage);
CommandHandler.sendMessage(null, translate("commands.sendMessage.usage"));
return;
}
String message = String.join(" ", args);
CommandHandler.sendMessage(targetPlayer, message);
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SenaMessage_message_sent);
CommandHandler.sendMessage(sender, translate("commands.sendMessage.success"));
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ package emu.grasscutter.command.commands;
import java.util.List;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData;
......@@ -10,6 +9,8 @@ import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "setfetterlevel", usage = "setfetterlevel <level>",
description = "Sets your fetter level for your current active character",
aliases = {"setfetterlvl", "setfriendship"}, permission = "player.setfetterlevel")
......@@ -23,14 +24,14 @@ public final class SetFetterLevelCommand implements CommandHandler {
}
if (args.size() != 1) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_usage);
CommandHandler.sendMessage(sender, translate("commands.setFetterLevel.usage"));
return;
}
try {
int fetterLevel = Integer.parseInt(args.get(0));
if (fetterLevel < 0 || fetterLevel > 10) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_fetter_level_must_between_0_and_10);
CommandHandler.sendMessage(sender, translate("commands.setFetterLevel.range_error"));
return;
}
Avatar avatar = targetPlayer.getTeamManager().getCurrentAvatarEntity().getAvatar();
......@@ -42,9 +43,9 @@ public final class SetFetterLevelCommand implements CommandHandler {
avatar.save();
targetPlayer.sendPacket(new PacketAvatarFetterDataNotify(avatar));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_fetter_set_level.replace("{level}", Integer.toString(fetterLevel)));
CommandHandler.sendMessage(sender, translate("commands.setFetterLevel.success", fetterLevel));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetFetterLevel_invalid_fetter_level);
CommandHandler.sendMessage(sender, translate("commands.setFetterLevel.level_error"));
}
}
......
......@@ -33,7 +33,6 @@ public final class SetStatsCommand implements CommandHandler {
Map<String, Stat> stats = new HashMap<>();
public SetStatsCommand() {
Language lang = Grasscutter.getLanguage();
// Default stats
stats.put("maxhp", new Stat(FightProperty.FIGHT_PROP_MAX_HP.toString(), FightProperty.FIGHT_PROP_MAX_HP, false));
stats.put("hp", new Stat(FightProperty.FIGHT_PROP_CUR_HP.toString(), FightProperty.FIGHT_PROP_CUR_HP, false));
......
......@@ -7,6 +7,8 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "setworldlevel", usage = "setworldlevel <level>",
description = "Sets your world level (Relog to see proper effects)",
aliases = {"setworldlvl"}, permission = "player.setworldlevel")
......@@ -20,14 +22,14 @@ public final class SetWorldLevelCommand implements CommandHandler {
}
if (args.size() < 1) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetWorldLevel_usage);
CommandHandler.sendMessage(sender, translate("commands.setWorldLevel.usage"));
return;
}
try {
int level = Integer.parseInt(args.get(0));
if (level > 8 || level < 0) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetWorldLevel_world_level_must_between_0_and_8);
CommandHandler.sendMessage(sender, translate("commands.setWorldLevel.value_error"));
return;
}
......@@ -35,9 +37,9 @@ public final class SetWorldLevelCommand implements CommandHandler {
targetPlayer.getWorld().setWorldLevel(level);
targetPlayer.setWorldLevel(level);
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().SetWorldLevel_set_world_level.replace("{level}", Integer.toString(level)));
CommandHandler.sendMessage(sender, translate("commands.setWorldLevel.success", Integer.toString(level)));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(null, Grasscutter.getLanguage().SetWorldLevel_invalid_world_level);
CommandHandler.sendMessage(null, translate("commands.setWorldLevel.invalid_world_level"));
}
}
}
......@@ -20,6 +20,8 @@ import javax.swing.text.html.parser.Entity;
import java.util.List;
import java.util.Random;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "spawn", usage = "spawn <entityId> [amount] [level(monster only)]",
description = "Spawns an entity near you", permission = "server.spawn")
public final class SpawnCommand implements CommandHandler {
......@@ -39,23 +41,23 @@ public final class SpawnCommand implements CommandHandler {
try {
level = Integer.parseInt(args.get(2));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_arguments);
CommandHandler.sendMessage(sender, translate("commands.execution.argument_error"));
} // Fallthrough
case 2:
try {
amount = Integer.parseInt(args.get(1));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_amount);
CommandHandler.sendMessage(sender, translate("commands.generic.error.amount"));
} // Fallthrough
case 1:
try {
id = Integer.parseInt(args.get(0));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_entity_id);
CommandHandler.sendMessage(sender, translate("commands.generic.error.entityId"));
}
break;
default:
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Spawn_usage);
CommandHandler.sendMessage(sender, translate("commands.spawn.usage"));
return;
}
......@@ -63,7 +65,7 @@ public final class SpawnCommand implements CommandHandler {
GadgetData gadgetData = GameData.getGadgetDataMap().get(id);
ItemData itemData = GameData.getItemDataMap().get(id);
if (monsterData == null && gadgetData == null && itemData == null) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_entity_id);
CommandHandler.sendMessage(sender, translate("commands.generic.error.entityId"));
return;
}
Scene scene = targetPlayer.getScene();
......@@ -99,7 +101,7 @@ public final class SpawnCommand implements CommandHandler {
scene.addEntity(entity);
}
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Spawn_message.replace("{amount}", Integer.toString(amount)).replace("{id}", Integer.toString(id)));
CommandHandler.sendMessage(sender, translate("commands.spawn.success", Integer.toString(amount), Integer.toString(id)));
}
private Position GetRandomPositionInCircle(Position origin, double radius){
......
......@@ -7,17 +7,19 @@ import emu.grasscutter.game.player.Player;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "stop", usage = "stop",
description = "Stops the server", permission = "server.stop")
public final class StopCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
CommandHandler.sendMessage(null, Grasscutter.getLanguage().Stop_message);
CommandHandler.sendMessage(null, translate("commands.stop.success"));
for (Player p : Grasscutter.getGameServer().getPlayers().values()) {
CommandHandler.sendMessage(p, Grasscutter.getLanguage().Stop_message);
CommandHandler.sendMessage(p, translate("commands.stop.success"));
}
System.exit(1);
System.exit(1000);
}
}
......@@ -8,6 +8,8 @@ import emu.grasscutter.utils.Position;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "tpall", usage = "tpall",
description = "Teleports all players in your world to your position", permission = "player.tpall")
public final class TeleportAllCommand implements CommandHandler {
......@@ -19,7 +21,7 @@ public final class TeleportAllCommand implements CommandHandler {
}
if (!targetPlayer.getWorld().isMultiplayer()) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().TeleportAll_message);
CommandHandler.sendMessage(sender, translate("commands.teleportAll.error"));
return;
}
......@@ -30,5 +32,7 @@ public final class TeleportAllCommand implements CommandHandler {
player.getWorld().transferPlayerToScene(player, targetPlayer.getSceneId(), pos);
}
CommandHandler.sendMessage(sender, translate("commands.teleportAll.success"));
}
}
......@@ -8,6 +8,8 @@ import emu.grasscutter.utils.Position;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "teleport", usage = "teleport <x> <y> <z> [scene id]", aliases = {"tp"},
description = "Change the player's position.", permission = "player.teleport")
public final class TeleportCommand implements CommandHandler {
......@@ -41,7 +43,7 @@ public final class TeleportCommand implements CommandHandler {
try {
sceneId = Integer.parseInt(args.get(3));
}catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Invalid_arguments);
CommandHandler.sendMessage(sender, translate("commands.execution.argument_error"));
} // Fallthrough
case 3:
try {
......@@ -49,20 +51,23 @@ public final class TeleportCommand implements CommandHandler {
y = parseRelative(args.get(1), y);
z = parseRelative(args.get(2), z);
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Teleport_invalid_position);
CommandHandler.sendMessage(sender, translate("commands.teleport.invalid_position"));
}
break;
default:
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Teleport_usage);
CommandHandler.sendMessage(sender, translate("commands.teleport.usage"));
return;
}
Position target_pos = new Position(x, y, z);
boolean result = targetPlayer.getWorld().transferPlayerToScene(targetPlayer, sceneId, target_pos);
if (!result) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Teleport_invalid_position);
CommandHandler.sendMessage(sender, translate("commands.teleport.invalid_position"));
} else {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Teleport_message.replace("{name}", targetPlayer.getNickname()).replace("{x}", Float.toString(x)).replace("{y}", Float.toString(y)).replace("{z}", Float.toString(z)).replace("{id}", Integer.toString(sceneId)));
CommandHandler.sendMessage(sender, translate("commands.teleport.success",
targetPlayer.getNickname(), Float.toString(x), Float.toString(y),
Float.toString(z), Integer.toString(sceneId))
);
}
}
......
......@@ -9,6 +9,8 @@ import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "weather", usage = "weather <weatherId> [climateId]",
description = "Changes the weather.", aliases = {"w"}, permission = "player.weather")
public final class WeatherCommand implements CommandHandler {
......@@ -27,17 +29,17 @@ public final class WeatherCommand implements CommandHandler {
try {
climateId = Integer.parseInt(args.get(1));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_invalid_id);
CommandHandler.sendMessage(sender, translate("commands.weather.invalid_id"));
}
case 1:
try {
weatherId = Integer.parseInt(args.get(0));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_invalid_id);
CommandHandler.sendMessage(sender, translate("commands.weather.invalid_id"));
}
break;
default:
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_usage);
CommandHandler.sendMessage(sender, translate("commands.weather.usage"));
return;
}
......@@ -46,7 +48,6 @@ public final class WeatherCommand implements CommandHandler {
targetPlayer.getScene().setWeather(weatherId);
targetPlayer.getScene().setClimate(climate);
targetPlayer.getScene().broadcastPacket(new PacketSceneAreaWeatherNotify(targetPlayer));
CommandHandler.sendMessage(sender, Grasscutter.getLanguage().Weather_message.replace("{weatherId}", Integer.toString(weatherId)).replace("{climateId}", Integer.toString(climateId)));
CommandHandler.sendMessage(sender, translate("commands.weather.success", Integer.toString(weatherId), Integer.toString(climateId)));
}
}
......@@ -8,6 +8,8 @@ import emu.grasscutter.server.dispatch.json.LoginResultJson;
import express.http.Request;
import express.http.Response;
import static emu.grasscutter.utils.Language.translate;
public class DefaultAuthenticationHandler implements AuthenticationHandler {
@Override
......@@ -34,11 +36,9 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
// Check if account exists, else create a new one.
if (account == null) {
// Account doesnt exist, so we can either auto create it if the config value is
// set
// Account doesn't exist, so we can either auto create it if the config value is set.
if (Grasscutter.getConfig().getDispatchOptions().AutomaticallyCreateAccounts) {
// This account has been created AUTOMATICALLY. There will be no permissions
// added.
// This account has been created AUTOMATICALLY. There will be no permissions added.
account = DatabaseHelper.createAccountWithId(requestData.account, 0);
for (String permission : Grasscutter.getConfig().getDispatchOptions().defaultPermissions) {
......@@ -51,19 +51,18 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
responseData.data.account.token = account.generateSessionKey();
responseData.data.account.email = account.getEmail();
Grasscutter.getLogger().info(Grasscutter.getLanguage().Client_failed_login_account_create.replace("{ip}", req.ip()).replace("{uid}", responseData.data.account.uid));
Grasscutter.getLogger().info(translate("messages.dispatch.account.account_login_create_success", req.ip(), responseData.data.account.uid));
} else {
responseData.retcode = -201;
responseData.message = Grasscutter.getLanguage().Username_not_found_create_failed;
responseData.message = translate("messages.dispatch.account.username_create_error");
Grasscutter.getLogger().info(Grasscutter.getLanguage().Client_failed_login_account_no_found.replace("{ip}", req.ip()));
Grasscutter.getLogger().info(translate("messages.dispatch.account.account_login_create_error", req.ip()));
}
} else {
responseData.retcode = -201;
responseData.message = Grasscutter.getLanguage().Username_not_found;
responseData.message = translate("messages.dispatch.account.username_error");
Grasscutter.getLogger().info(String
.format(Grasscutter.getLanguage().Client_failed_login_account_no_found, req.ip()));
Grasscutter.getLogger().info(translate("messages.dispatch.account.account_login_exist_error", req.ip()));
}
} else {
// Account was found, log the player in
......@@ -72,7 +71,7 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler {
responseData.data.account.token = account.generateSessionKey();
responseData.data.account.email = account.getEmail();
Grasscutter.getLogger().info(Grasscutter.getLanguage().Client_login.replace("{ip}", req.ip()).replace("{uid}", responseData.data.account.uid));
Grasscutter.getLogger().info(translate("messages.dispatch.account.login_success", req.ip(), responseData.data.account.uid));
}
return responseData;
......
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