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