Commit a495333e authored by Akka's avatar Akka Committed by GitHub
Browse files

Merge pull request #4 from Grasscutters/development

Development
parents f2231349 bf0d0177
......@@ -8,6 +8,7 @@ import emu.grasscutter.game.Account;
import emu.grasscutter.game.combine.CombineManger;
import emu.grasscutter.game.drop.DropManager;
import emu.grasscutter.game.dungeons.DungeonManager;
import emu.grasscutter.game.expedition.ExpeditionManager;
import emu.grasscutter.game.gacha.GachaManager;
import emu.grasscutter.game.managers.ChatManager;
import emu.grasscutter.game.managers.InventoryManager;
......@@ -28,6 +29,11 @@ import java.net.InetSocketAddress;
import java.time.OffsetDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static emu.grasscutter.utils.Language.translate;
public final class GameServer extends KcpServer {
private final InetSocketAddress address;
......@@ -42,12 +48,20 @@ public final class GameServer extends KcpServer {
private final ShopManager shopManager;
private final MultiplayerManager multiplayerManager;
private final DungeonManager dungeonManager;
private final ExpeditionManager expeditionManager;
private final CommandMap commandMap;
private final TaskMap taskMap;
private final DropManager dropManager;
private final CombineManger combineManger;
public GameServer() {
this(new InetSocketAddress(
Grasscutter.getConfig().getGameServerOptions().Ip,
Grasscutter.getConfig().getGameServerOptions().Port
));
}
public GameServer(InetSocketAddress address) {
super(address);
......@@ -66,21 +80,9 @@ public final class GameServer extends KcpServer {
this.commandMap = new CommandMap(true);
this.taskMap = new TaskMap(true);
this.dropManager = new DropManager(this);
this.expeditionManager = new ExpeditionManager(this);
this.combineManger = new CombineManger(this);
// Schedule game loop.
Timer gameLoop = new Timer();
gameLoop.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
try {
onTick();
} catch (Exception e) {
Grasscutter.getLogger().error(Grasscutter.getLanguage().An_error_occurred_during_game_update, e);
}
}
}, new Date(), 1000L);
// Hook into shutdown event.
Runtime.getRuntime().addShutdownHook(new Thread(this::onServerShutdown));
}
......@@ -125,6 +127,10 @@ public final class GameServer extends KcpServer {
return dungeonManager;
}
public ExpeditionManager getExpeditionManager() {
return expeditionManager;
}
public CommandMap getCommandMap() {
return this.commandMap;
}
......@@ -132,6 +138,7 @@ public final class GameServer extends KcpServer {
public CombineManger getCombineManger(){
return this.combineManger;
}
public TaskMap getTaskMap() {
return this.taskMap;
}
......@@ -212,10 +219,28 @@ public final class GameServer extends KcpServer {
}
@Override
public synchronized void start() {
// Schedule game loop.
Timer gameLoop = new Timer();
gameLoop.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
try {
onTick();
} catch (Exception e) {
Grasscutter.getLogger().error(translate("messages.game.game_update_error"), e);
}
}
}, new Date(), 1000L);
super.start();
}
@Override
public void onStartFinish() {
Grasscutter.getLogger().info(Grasscutter.getLanguage().Grasscutter_is_free);
Grasscutter.getLogger().info(Grasscutter.getLanguage().Game_start_port.replace("{port}", Integer.toString(address.getPort())));
Grasscutter.getLogger().info(translate("messages.status.free_software"));
Grasscutter.getLogger().info(translate("messages.game.port_bind", Integer.toString(address.getPort())));
ServerStartEvent event = new ServerStartEvent(ServerEvent.Type.GAME, OffsetDateTime.now()); event.call();
}
......
......@@ -14,6 +14,7 @@ import emu.grasscutter.server.game.GameSession.SessionState;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@SuppressWarnings("unchecked")
public class GameServerPacketHandler {
private final Int2ObjectMap<PacketHandler> handlers;
......
......@@ -22,6 +22,8 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import static emu.grasscutter.utils.Language.translate;
public class GameSession extends KcpChannel {
private GameServer server;
......@@ -113,21 +115,21 @@ public class GameSession extends KcpChannel {
@Override
protected void onConnect() {
Grasscutter.getLogger().info(Grasscutter.getLanguage().Client_connect.replace("{address}", getAddress().getHostString().toLowerCase()));
Grasscutter.getLogger().info(translate("messages.game.connect", this.getAddress().getHostString().toLowerCase()));
}
@Override
protected synchronized void onDisconnect() { // Synchronize so we dont add character at the same time
Grasscutter.getLogger().info(Grasscutter.getLanguage().Client_disconnect.replace("{address}", getAddress().getHostString().toLowerCase()));
protected synchronized void onDisconnect() { // Synchronize so we don't add character at the same time.
Grasscutter.getLogger().info(translate("messages.game.disconnect", this.getAddress().getHostString().toLowerCase()));
// Set state so no more packets can be handled
this.setState(SessionState.INACTIVE);
// Save after disconnecting
if (this.isLoggedIn()) {
// Save
// Call logout event.
getPlayer().onLogout();
// Remove from gameserver
// Remove from server.
getServer().getPlayers().remove(getPlayer().getUid());
}
}
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionAllDataRsp;
@Opcodes(PacketOpcodes.AvatarExpeditionAllDataReq)
public class HandlerAvatarExpeditionAllDataReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
session.send(new PacketAvatarExpeditionAllDataRsp(session.getPlayer()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionCallBackReqOuterClass.AvatarExpeditionCallBackReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionCallBackRsp;
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionStartRsp;
import emu.grasscutter.utils.Utils;
@Opcodes(PacketOpcodes.AvatarExpeditionCallBackReq)
public class HandlerAvatarExpeditionCallBackReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
AvatarExpeditionCallBackReq req = AvatarExpeditionCallBackReq.parseFrom(payload);
for (int i = 0; i < req.getAvatarGuidCount(); i++) {
session.getPlayer().removeExpeditionInfo(req.getAvatarGuid(i));
}
session.getPlayer().save();
session.send(new PacketAvatarExpeditionCallBackRsp(session.getPlayer()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.drop.DropData;
import emu.grasscutter.game.expedition.ExpeditionInfo;
import emu.grasscutter.game.expedition.ExpeditionRewardData;
import emu.grasscutter.game.expedition.ExpeditionRewardDataList;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionGetRewardReqOuterClass.AvatarExpeditionGetRewardReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionCallBackRsp;
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionGetRewardRsp;
import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
import emu.grasscutter.utils.Utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@Opcodes(PacketOpcodes.AvatarExpeditionGetRewardReq)
public class HandlerAvatarExpeditionGetRewardReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
AvatarExpeditionGetRewardReq req = AvatarExpeditionGetRewardReq.parseFrom(payload);
ExpeditionInfo expInfo = session.getPlayer().getExpeditionInfo(req.getAvatarGuid());
List<GameItem> items = new LinkedList<>();
if (session.getServer().getExpeditionManager().getExpeditionRewardDataList().containsKey(expInfo.getExpId())) {
for (ExpeditionRewardDataList RewardDataList : session.getServer().getExpeditionManager().getExpeditionRewardDataList().get(expInfo.getExpId())) {
if(RewardDataList.getHourTime() == expInfo.getHourTime()){
if(!RewardDataList.getExpeditionRewardData().isEmpty()){
for (ExpeditionRewardData RewardData :RewardDataList.getExpeditionRewardData()) {
int num = RewardData.getMinCount();
if(RewardData.getMinCount() != RewardData.getMaxCount()){
num = Utils.randomRange(RewardData.getMinCount(), RewardData.getMaxCount());
}
items.add(new GameItem(RewardData.getItemId(), num));
}
}
}
}
}
session.getPlayer().getInventory().addItems(items);
session.getPlayer().sendPacket(new PacketItemAddHintNotify(items, ActionReason.ExpeditionReward));
session.getPlayer().removeExpeditionInfo(req.getAvatarGuid());
session.getPlayer().save();
session.send(new PacketAvatarExpeditionGetRewardRsp(session.getPlayer(), items));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionStartReqOuterClass.AvatarExpeditionStartReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketAvatarExpeditionStartRsp;
import emu.grasscutter.utils.Utils;
@Opcodes(PacketOpcodes.AvatarExpeditionStartReq)
public class HandlerAvatarExpeditionStartReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
AvatarExpeditionStartReq req = AvatarExpeditionStartReq.parseFrom(payload);
int startTime = Utils.getCurrentSeconds();
session.getPlayer().addExpeditionInfo(req.getAvatarGuid(), req.getExpId(), req.getHourTime(), startTime);
session.getPlayer().save();
session.send(new PacketAvatarExpeditionStartRsp(session.getPlayer()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.managers.SotSManager.SotSManager;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.server.game.GameSession;
@Opcodes(PacketOpcodes.ExitTransPointRegionNotify)
public class HandlerExitTransPointRegionNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception{
Player player = session.getPlayer();
SotSManager sotsManager = player.getSotSManager();
sotsManager.cancelAutoRecover();
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.expedition.ExpeditionInfo;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionAllDataRspOuterClass.AvatarExpeditionAllDataRsp;
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
import java.util.*;
public class PacketAvatarExpeditionAllDataRsp extends BasePacket {
public PacketAvatarExpeditionAllDataRsp(Player player) {
super(PacketOpcodes.AvatarExpeditionAllDataRsp);
List<Integer> openExpeditionList = new ArrayList<>(List.of(306,305,304,303,302,301,206,105,204,104,203,103,202,101,102,201,106,205));
Map<Long, AvatarExpeditionInfo> avatarExpeditionInfoList = new HashMap<Long, AvatarExpeditionInfo>();
var expeditionInfo = player.getExpeditionInfo();
for (Long key : player.getExpeditionInfo().keySet()) {
ExpeditionInfo e = expeditionInfo.get(key);
avatarExpeditionInfoList.put(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
};
AvatarExpeditionAllDataRsp.Builder proto = AvatarExpeditionAllDataRsp.newBuilder()
.addAllOpenExpeditionList(openExpeditionList)
.setExpeditionCountLimit(5)
.putAllExpeditionInfoMap(avatarExpeditionInfoList);
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.expedition.ExpeditionInfo;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionCallBackRspOuterClass.AvatarExpeditionCallBackRsp;
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
public class PacketAvatarExpeditionCallBackRsp extends BasePacket {
public PacketAvatarExpeditionCallBackRsp(Player player) {
super(PacketOpcodes.AvatarExpeditionCallBackRsp);
AvatarExpeditionCallBackRsp.Builder proto = AvatarExpeditionCallBackRsp.newBuilder();
var expeditionInfo = player.getExpeditionInfo();
for (Long key : player.getExpeditionInfo().keySet()) {
ExpeditionInfo e = expeditionInfo.get(key);
proto.putExpeditionInfoMap(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
};
this.setData(proto.build());
}
}
\ No newline at end of file
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.expedition.ExpeditionInfo;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionDataNotifyOuterClass.AvatarExpeditionDataNotify;
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
import java.util.*;
public class PacketAvatarExpeditionDataNotify extends BasePacket {
public PacketAvatarExpeditionDataNotify(Player player) {
super(PacketOpcodes.AvatarExpeditionDataNotify);
Map<Long, AvatarExpeditionInfo> avatarExpeditionInfoList = new HashMap<Long, AvatarExpeditionInfo>();
var expeditionInfo = player.getExpeditionInfo();
for (Long key : player.getExpeditionInfo().keySet()) {
ExpeditionInfo e = expeditionInfo.get(key);
avatarExpeditionInfoList.put(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
};
AvatarExpeditionDataNotify.Builder proto = AvatarExpeditionDataNotify.newBuilder()
.putAllExpeditionInfoMap(avatarExpeditionInfoList);
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.expedition.ExpeditionInfo;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionGetRewardRspOuterClass.AvatarExpeditionGetRewardRsp;
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
import java.util.Collection;
public class PacketAvatarExpeditionGetRewardRsp extends BasePacket {
public PacketAvatarExpeditionGetRewardRsp(Player player, Collection<GameItem> items) {
super(PacketOpcodes.AvatarExpeditionGetRewardRsp);
AvatarExpeditionGetRewardRsp.Builder proto = AvatarExpeditionGetRewardRsp.newBuilder();
var expeditionInfo = player.getExpeditionInfo();
for (Long key : player.getExpeditionInfo().keySet()) {
ExpeditionInfo e = expeditionInfo.get(key);
proto.putExpeditionInfoMap(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
};
for (GameItem item : items) {
proto.addItemList(item.toItemParam());
}
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.expedition.ExpeditionInfo;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarExpeditionInfoOuterClass.AvatarExpeditionInfo;
import emu.grasscutter.net.proto.AvatarExpeditionStartRspOuterClass.AvatarExpeditionStartRsp;
public class PacketAvatarExpeditionStartRsp extends BasePacket {
public PacketAvatarExpeditionStartRsp(Player player) {
super(PacketOpcodes.AvatarExpeditionStartRsp);
AvatarExpeditionStartRsp.Builder proto = AvatarExpeditionStartRsp.newBuilder();
var expeditionInfo = player.getExpeditionInfo();
for (Long key : player.getExpeditionInfo().keySet()) {
ExpeditionInfo e = expeditionInfo.get(key);
proto.putExpeditionInfoMap(key, AvatarExpeditionInfo.newBuilder().setStateValue(e.getState()).setExpId(e.getExpId()).setHourTime(e.getHourTime()).setStartTime(e.getStartTime()).build());
};
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
......@@ -18,13 +19,13 @@ public class PacketGetPlayerFriendListRsp extends BasePacket {
FriendBrief serverFriend = FriendBrief.newBuilder()
.setUid(GameConstants.SERVER_CONSOLE_UID)
.setNickname(GameConstants.SERVER_AVATAR_NAME)
.setLevel(1)
.setProfilePicture(ProfilePicture.newBuilder().setAvatarId(GameConstants.SERVER_AVATAR_ID))
.setWorldLevel(0)
.setSignature("")
.setNickname(Grasscutter.getConfig().getGameServerOptions().ServerNickname)
.setLevel(Grasscutter.getConfig().getGameServerOptions().ServerLevel)
.setProfilePicture(ProfilePicture.newBuilder().setAvatarId(Grasscutter.getConfig().getGameServerOptions().ServerAvatarId))
.setWorldLevel(Grasscutter.getConfig().getGameServerOptions().ServerWorldLevel)
.setSignature(Grasscutter.getConfig().getGameServerOptions().ServerSignature)
.setLastActiveTime((int) (System.currentTimeMillis() / 1000f))
.setNameCardId(210001)
.setNameCardId(Grasscutter.getConfig().getGameServerOptions().ServerNameCardId)
.setOnlineState(FriendOnlineState.FRIEND_ONLINE)
.setParam(1)
.setIsGameSource(true)
......
package emu.grasscutter.tools;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
......@@ -30,13 +32,73 @@ import emu.grasscutter.data.def.SceneData;
import emu.grasscutter.utils.Utils;
public final class Tools {
public static void createGmHandbook() throws Exception {
ToolsWithLanguageOption.createGmHandbook(getLanguageOption());
}
public static void createGachaMapping(String location) throws Exception {
ToolsWithLanguageOption.createGachaMapping(location, getLanguageOption());
}
public static List<String> getAvailableLanguage() throws Exception {
File textMapFolder = new File(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMap");
List<String> availableLangList = new ArrayList<String>();
for (String textMapFileName : textMapFolder.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if (name.startsWith("TextMap") && name.endsWith(".json")){
return true;
}
return false;
}
})) {
availableLangList.add(textMapFileName.replace("TextMap","").replace(".json","").toLowerCase());
}
return availableLangList;
}
public static String getLanguageOption() throws Exception {
List<String> availableLangList = getAvailableLanguage();
// Use system out for better format
if (availableLangList.size() == 1) {
return availableLangList.get(0).toUpperCase();
}
System.out.println("The following languages mappings are available, please select one: [default: EN]");
String groupedLangList = "> ";
int groupedLangCount = 0;
String input = "";
for (String availableLanguage: availableLangList){
groupedLangCount++;
groupedLangList = groupedLangList + "" + availableLanguage + "\t";
if (groupedLangCount == 6) {
System.out.println(groupedLangList);
groupedLangCount = 0;
groupedLangList = "> ";
}
}
if (groupedLangCount > 0) {
System.out.println(groupedLangList);
}
System.out.print("\nYour choice:[EN] ");
input = new BufferedReader(new InputStreamReader(System.in)).readLine();
if (availableLangList.contains(input.toLowerCase())) {
return input.toUpperCase();
}
Grasscutter.getLogger().info("Invalid option. Will use EN(English) as fallback");
return "EN";
}
}
final class ToolsWithLanguageOption {
@SuppressWarnings("deprecation")
public static void createGmHandbook() throws Exception {
public static void createGmHandbook(String language) throws Exception {
ResourceLoader.loadResources();
Map<Long, String> map;
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMap/TextMapEN.json")), StandardCharsets.UTF_8)) {
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMap/TextMap"+language+".json")), StandardCharsets.UTF_8)) {
map = Grasscutter.getGsonFactory().fromJson(fileReader, new TypeToken<Map<Long, String>>() {}.getType());
}
......@@ -96,11 +158,11 @@ public final class Tools {
}
@SuppressWarnings("deprecation")
public static void createGachaMapping(String location) throws Exception {
public static void createGachaMapping(String location, String language) throws Exception {
ResourceLoader.loadResources();
Map<Long, String> map;
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMap/TextMapEN.json")), StandardCharsets.UTF_8)) {
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(Utils.toFilePath(Grasscutter.getConfig().RESOURCE_FOLDER + "TextMap/TextMap"+language+".json")), StandardCharsets.UTF_8)) {
map = Grasscutter.getGsonFactory().fromJson(fileReader, new TypeToken<Map<Long, String>>() {}.getType());
}
......@@ -113,6 +175,9 @@ public final class Tools {
list = new ArrayList<>(GameData.getAvatarDataMap().keySet());
Collections.sort(list);
// if the user made choices for language, I assume it's okay to assign his/her selected language to "en-us"
// since it's the fallback language and there will be no difference in the gacha record page.
// The enduser can still modify the `gacha_mappings.js` directly to enable multilingual for the gacha record system.
writer.println("mappings = {\"en-us\": {");
// Avatars
......@@ -140,10 +205,10 @@ public final class Tools {
default:
color = "blue";
}
// Got the magic number 4233146695 from manually search in the json file
writer.println(
"\"" + (avatarID % 1000 + 1000) + "\" : [\""
+ map.get(data.getNameTextMapHash()) + "(Avatar)\", \""
+ map.get(data.getNameTextMapHash()) + "(" + map.get(4233146695L)+ ")\", \""
+ color + "\"]");
}
......@@ -173,13 +238,17 @@ public final class Tools {
default:
continue; // skip unnecessary entries
}
// Got the magic number 4231343903 from manually search in the json file
writer.println(",\"" + data.getId() +
"\" : [\"" + map.get(data.getNameTextMapHash()).replaceAll("\"", "")
+ "(Weapon)\",\""+ color + "\"]");
+ "("+ map.get(4231343903L)+")\",\""+ color + "\"]");
}
writer.println(",\"200\": \"Standard\", \"301\": \"Avatar Event\", \"302\": \"Weapon event\"");
writer.println(",\"200\": \""+map.get(332935371L)+"\", \"301\": \""+ map.get(2272170627L) + "\", \"302\": \""+map.get(2864268523L)+"\"");
writer.println("}\n}");
}
Grasscutter.getLogger().info("Mappings generated!");
}
}
package emu.grasscutter.utils;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import emu.grasscutter.Grasscutter;
import javax.annotation.Nullable;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
public final class Language {
private final JsonObject languageData;
private final Map<String, String> cachedTranslations = new HashMap<>();
/**
* Creates a language instance from a code.
* @param langCode The language code.
* @return A language instance.
*/
public static Language getLanguage(String langCode) {
return new Language(langCode + ".json");
}
/**
* Returns the translated value from the key while substituting arguments.
* @param key The key of the translated value to return.
* @param args The arguments to substitute.
* @return A translated value with arguments substituted.
*/
public static String translate(String key, Object... args) {
String translated = Grasscutter.getLanguage().get(key);
try {
return translated.formatted(args);
} catch (Exception exception) {
Grasscutter.getLogger().error("Failed to format string: " + key, exception);
return translated;
}
}
/**
* creates a language instance.
* @param fileName The name of the language file.
*/
private Language(String fileName) {
@Nullable JsonObject languageData = null;
languageData = loadLanguage(fileName);
if (languageData == null) {
Grasscutter.getLogger().info("Now switch to default language");
languageData = loadDefaultLanguage();
}
assert languageData != null : "languageData is null";
this.languageData = languageData;
}
/**
* Load default language file and creates a language instance.
* @return language data
*/
private JsonObject loadDefaultLanguage() {
var fileName = Grasscutter.getConfig().DefaultLanguage.toLanguageTag() + ".json";
return loadLanguage(fileName);
}
/**
* Reads a file and creates a language instance.
* @param fileName The name of the language file.
* @return language data
*/
private JsonObject loadLanguage(String fileName) {
@Nullable JsonObject languageData = null;
try {
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
languageData = Grasscutter.getGsonFactory().fromJson(Utils.readFromInputStream(file), JsonObject.class);
} catch (Exception exception) {
Grasscutter.getLogger().warn("Failed to load language file: " + fileName);
}
return languageData;
}
/**
* Returns the value (as a string) from a nested key.
* @param key The key to look for.
* @return The value (as a string) from a nested key.
*/
public String get(String key) {
if(this.cachedTranslations.containsKey(key)) {
return this.cachedTranslations.get(key);
}
String[] keys = key.split("\\.");
JsonObject object = this.languageData;
int index = 0;
String result = "This value does not exist. Please report this to the Discord: " + key;
while (true) {
if(index == keys.length) break;
String currentKey = keys[index++];
if(object.has(currentKey)) {
JsonElement element = object.get(currentKey);
if(element.isJsonObject())
object = element.getAsJsonObject();
else {
result = element.getAsString(); break;
}
} else break;
}
this.cachedTranslations.put(key, result); return result;
}
}
......@@ -5,6 +5,8 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.time.*;
import java.time.temporal.TemporalAdjusters;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import emu.grasscutter.Config;
......@@ -15,6 +17,8 @@ import io.netty.buffer.Unpooled;
import org.slf4j.Logger;
import static emu.grasscutter.utils.Language.translate;
@SuppressWarnings({"UnusedReturnValue", "BooleanMethodIsAlwaysInverted"})
public final class Utils {
public static final Random random = new Random();
......@@ -176,15 +180,15 @@ public final class Utils {
// Check for resources folder.
if(!fileExists(resourcesFolder)) {
logger.info(Grasscutter.getLanguage().Create_resources_folder);
logger.info(Grasscutter.getLanguage().Place_copy);
logger.info(translate("messages.status.create_resources"));
logger.info(translate("messages.status.resources_error"));
createFolder(resourcesFolder); exit = true;
}
// Check for BinOutput + ExcelBinOuput.
// Check for BinOutput + ExcelBinOutput.
if(!fileExists(resourcesFolder + "BinOutput") ||
!fileExists(resourcesFolder + "ExcelBinOutput")) {
logger.info(Grasscutter.getLanguage().Place_copy);
logger.info(translate("messages.status.resources_error"));
exit = true;
}
......@@ -195,7 +199,11 @@ public final class Utils {
if(exit) System.exit(1);
}
public static int GetNextTimestampOfThisHour(int hour, String timeZone, int param) {
/**
* Gets the timestamp of the next hour.
* @return The timestamp in UNIX seconds.
*/
public static int getNextTimestampOfThisHour(int hour, String timeZone, int param) {
ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone));
for (int i = 0; i < param; i ++){
if (zonedDateTime.getHour() < hour) {
......@@ -204,10 +212,14 @@ public final class Utils {
zonedDateTime = zonedDateTime.plusDays(1).withHour(hour).withMinute(0).withSecond(0);
}
}
return (int)zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
return (int) zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
}
public static int GetNextTimestampOfThisHourInNextWeek(int hour, String timeZone, int param) {
/**
* Gets the timestamp of the next hour in a week.
* @return The timestamp in UNIX seconds.
*/
public static int getNextTimestampOfThisHourInNextWeek(int hour, String timeZone, int param) {
ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone));
for (int i = 0; i < param; i++) {
if (zonedDateTime.getDayOfWeek() == DayOfWeek.MONDAY && zonedDateTime.getHour() < hour) {
......@@ -216,10 +228,14 @@ public final class Utils {
zonedDateTime = zonedDateTime.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).withHour(hour).withMinute(0).withSecond(0);
}
}
return (int)zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
return (int) zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
}
public static int GetNextTimestampOfThisHourInNextMonth(int hour, String timeZone, int param) {
/**
* Gets the timestamp of the next hour in a month.
* @return The timestamp in UNIX seconds.
*/
public static int getNextTimestampOfThisHourInNextMonth(int hour, String timeZone, int param) {
ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone));
for (int i = 0; i < param; i++) {
if (zonedDateTime.getDayOfMonth() == 1 && zonedDateTime.getHour() < hour) {
......@@ -228,6 +244,59 @@ public final class Utils {
zonedDateTime = zonedDateTime.with(TemporalAdjusters.firstDayOfNextMonth()).withHour(hour).withMinute(0).withSecond(0);
}
}
return (int)zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
return (int) zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
}
/**
* Retrieves a string from an input stream.
* @param stream The input stream.
* @return The string.
*/
public static String readFromInputStream(InputStream stream) {
StringBuilder stringBuilder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream,"UTF-8"))) {
String line; while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
} stream.close();
} catch (IOException e) {
Grasscutter.getLogger().warn("Failed to read from input stream.");
} return stringBuilder.toString();
}
/**
* Switch properties from upper case to lower case?
*/
public static Map<String, Object> switchPropertiesUpperLowerCase(Map<String, Object> objMap, Class<?> cls) {
Map<String, Object> map = new HashMap<>(objMap.size());
for (String key : objMap.keySet()) {
try {
char c = key.charAt(0);
if (c >= 'a' && c <= 'z') {
try {
cls.getDeclaredField(key);
map.put(key, objMap.get(key));
} catch (NoSuchFieldException e) {
String s1 = String.valueOf(c).toUpperCase();
String after = key.length() > 1 ? s1 + key.substring(1) : s1;
cls.getDeclaredField(after);
map.put(after, objMap.get(key));
}
} else if (c >= 'A' && c <= 'Z') {
try {
cls.getDeclaredField(key);
map.put(key, objMap.get(key));
} catch (NoSuchFieldException e) {
String s1 = String.valueOf(c).toLowerCase();
String after = key.length() > 1 ? s1 + key.substring(1) : s1;
cls.getDeclaredField(after);
map.put(after, objMap.get(key));
}
}
} catch (NoSuchFieldException e) {
map.put(key, objMap.get(key));
}
}
return map;
}
}
{
"messages": {
"game": {
"port_bind": "Game Server started on port %s",
"connect": "Client connected from %s",
"disconnect": "Client disconnected from %s",
"game_update_error": "An error occurred during game update.",
"command_error": "Command error:"
},
"dispatch": {
"port_bind": "[Dispatch] Dispatch server started on port %s",
"request": "[Dispatch] Client %s %s request: %s",
"keystore": {
"general_error": "[Dispatch] Error while loading keystore!",
"password_error": "[Dispatch] Unable to load keystore. Trying default keystore password...",
"no_keystore_error": "[Dispatch] No SSL cert found! Falling back to HTTP server.",
"default_password": "[Dispatch] The default keystore password was loaded successfully. Please consider setting the password to 123456 in config.json."
},
"no_commands_error": "Commands are not supported in dispatch only mode.",
"unhandled_request_error": "[Dispatch] Potential unhandled %s request: %s",
"account": {
"login_attempt": "[Dispatch] Client %s is trying to log in",
"login_success": "[Dispatch] Client %s logged in as %s",
"login_token_attempt": "[Dispatch] Client %s is trying to log in via token",
"login_token_error": "[Dispatch] Client %s failed to log in via token",
"login_token_success": "[Dispatch] Client %s logged in via token as %s",
"combo_token_success": "[Dispatch] Client %s succeed to exchange combo token",
"combo_token_error": "[Dispatch] Client %s failed to exchange combo token",
"account_login_create_success": "[Dispatch] Client %s failed to log in: Account %s created",
"account_login_create_error": "[Dispatch] Client %s failed to log in: Account create failed",
"account_login_exist_error": "[Dispatch] Client %s failed to log in: Account no found",
"account_cache_error": "Game account cache information error",
"session_key_error": "Wrong session key.",
"username_error": "Username not found.",
"username_create_error": "Username not found, create failed."
}
},
"status": {
"free_software": "Grasscutter is FREE software. If you have paid for this, you may have been scammed. Homepage: https://github.com/Grasscutters/Grasscutter",
"starting": "Starting Grasscutter...",
"shutdown": "Shutting down...",
"done": "Done! For help, type \"help\"",
"error": "An error occurred.",
"welcome": "Welcome to Grasscutter",
"run_mode_error": "Invalid server run mode: %s.",
"run_mode_help": "Server run mode must be 'HYBRID', 'DISPATCH_ONLY', or 'GAME_ONLY'. Unable to start Grasscutter...",
"create_resources": "Creating resources folder...",
"resources_error": "Place a copy of 'BinOutput' and 'ExcelBinOutput' in the resources folder."
}
},
"commands": {
"generic": {
"not_specified": "No command specified.",
"unknown_command": "Unknown command: %s",
"permission_error": "You do not have permission to run this command.",
"console_execute_error": "This command can only be run from the console.",
"player_execute_error": "Run this command in-game.",
"command_exist_error": "No command found.",
"invalid": {
"amount": "Invalid amount.",
"artifactId": "Invalid artifactId.",
"avatarId": "Invalid avatarId.",
"avatarLevel": "Invalid avatarLevel.",
"entityId": "Invalid entityId.",
"itemId": "Invalid itemId.",
"itemLevel": "Invalid itemLevel.",
"itemRefinement": "Invalid itemRefinement.",
"playerId": "Invalid playerId.",
"uid": "Invalid UID."
}
},
"execution": {
"uid_error": "Invalid UID.",
"player_exist_error": "Player not found.",
"player_offline_error": "Player is not online.",
"item_id_error": "Invalid item ID.",
"item_player_exist_error": "Invalid item or UID.",
"entity_id_error": "Invalid entity ID.",
"player_exist_offline_error": "Player not found or is not online.",
"argument_error": "Invalid arguments.",
"clear_target": "Target cleared.",
"set_target": "Subsequent commands will target @%s by default.",
"need_target": "This command requires a target UID. Add a <@UID> argument or set a persistent target with /target @UID."
},
"status": {
"enabled": "Enabled",
"disabled": "Disabled",
"help": "Help",
"success": "Success"
},
"account": {
"modify": "Modify user accounts",
"invalid": "Invalid UID.",
"exists": "Account already exists.",
"create": "Account created with UID %s.",
"delete": "Account deleted.",
"no_account": "Account not found.",
"command_usage": "Usage: account <create|delete> <username> [uid]"
},
"broadcast": {
"command_usage": "Usage: broadcast <message>",
"message_sent": "Message sent."
},
"changescene": {
"usage": "Usage: changescene <sceneId>",
"already_in_scene": "You are already in that scene.",
"success": "Changed to scene %s.",
"exists_error": "The specified scene does not exist."
},
"clear": {
"command_usage": "Usage: clear <all|wp|art|mat>",
"weapons": "Cleared weapons for %s.",
"artifacts": "Cleared artifacts for %s.",
"materials": "Cleared materials for %s.",
"furniture": "Cleared furniture for %s.",
"displays": "Cleared displays for %s.",
"virtuals": "Cleared virtuals for %s.",
"everything": "Cleared everything for %s."
},
"coop": {
"usage": "Usage: coop <playerId> <target playerId>",
"success": "Summoned %s to %s's world."
},
"enter_dungeon": {
"usage": "Usage: enterdungeon <dungeon id>",
"changed": "Changed to dungeon %s",
"not_found_error": "Dungeon does not exist",
"in_dungeon_error": "You are already in that dungeon"
},
"giveAll": {
"usage": "Usage: giveall [player] [amount]",
"started": "Receiving all items...",
"success": "Successfully gave all items to %s.",
"invalid_amount_or_playerId": "Invalid amount or player ID."
},
"giveArtifact": {
"usage": "Usage: giveart|gart [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]",
"id_error": "Invalid artifact ID.",
"success": "Given %s to %s."
},
"giveChar": {
"usage": "Usage: givechar <player> <itemId|itemName> [amount]",
"given": "Given %s with level %s to %s.",
"invalid_avatar_id": "Invalid avatar id.",
"invalid_avatar_level": "Invalid avatar level.",
"invalid_avatar_or_player_id": "Invalid avatar or player ID."
},
"give": {
"usage": "Usage: give <player> <itemId|itemName> [amount] [level]",
"refinement_only_applicable_weapons": "Refinement is only applicable to weapons.",
"refinement_must_between_1_and_5": "Refinement must be between 1 and 5.",
"given": "Given %s of %s to %s.",
"given_with_level_and_refinement": "Given %s with level %s, refinement %s %s times to %s",
"given_level": "Given %s with level %s %s times to %s"
},
"godmode": {
"success": "Godmode is now %s for %s."
},
"heal": {
"success": "All characters have been healed."
},
"kick": {
"player_kick_player": "Player [%s:%s] has kicked player [%s:%s]",
"server_kick_player": "Kicking player [%s:%s]"
},
"kill": {
"usage": "Usage: killall [playerUid] [sceneId]",
"scene_not_found_in_player_world": "Scene not found in player world",
"kill_monsters_in_scene": "Killing %s monsters in scene %s"
},
"killCharacter": {
"usage": "Usage: /killcharacter [playerId]",
"success": "Killed %s's current character."
},
"list": {
"success": "There are %s player(s) online:"
},
"permission": {
"usage": "Usage: permission <add|remove> <username> <permission>",
"add": "Permission added.",
"has_error": "They already have this permission!",
"remove": "Permission removed.",
"not_have_error": "They don't have this permission!",
"account_error": "The account cannot be found."
},
"position": {
"success": "Coordinates: %.3f, %.3f, %.3f\nScene id: %d"
},
"reload": {
"reload_start": "Reloading config.",
"reload_done": "Reload complete."
},
"resetConst": {
"reset_all": "Reset all avatars' constellations.",
"success": "Constellations for %s have been reset. Please relog to see changes."
},
"resetShopLimit": {
"usage": "Usage: /resetshop <player id>"
},
"sendMail": {
"usage": "Usage: give [player] <itemId|itemName> [amount]",
"user_not_exist": "The user with an id of '%s' does not exist",
"start_composition": "Starting composition of message.\nPlease use `/sendmail <title>` to continue.\nYou can use `/sendmail stop` at any time",
"templates": "Mail templates coming soon implemented...",
"invalid_arguments": "Invalid arguments.\nUsage `/sendmail <userId|all|help> [templateId]`",
"send_cancel": "Message sending cancelled",
"send_done": "Message sent to user %s!",
"send_all_done": "Message sent to all users!",
"not_composition_end": "Message composition not at final stage.\nPlease use `/sendmail %s` or `/sendmail stop` to cancel",
"please_use": "Please use `/sendmail %s`",
"set_title": "Message title set as '%s'.\nUse '/sendmail <content>' to continue.",
"set_contents": "Message contents set as '%s'.\nUse '/sendmail <sender>' to continue.",
"set_message_sender": "Message sender set as '%s'.\nUse '/sendmail <itemId|itemName|finish> [amount] [level]' to continue.",
"send": "Attached %s of %s (level %s) to the message.\nContinue adding more items or use `/sendmail finish` to send the message.",
"invalid_arguments_please_use": "Invalid arguments \n Please use `/sendmail %s`",
"title": "<title>",
"message": "<message>",
"sender": "<sender>",
"arguments": "<itemId|itemName|finish> [amount] [level]",
"error": "ERROR: invalid construction stage %s. Check console for stacktrace."
},
"sendMessage": {
"usage": "Usage: sendmessage <player> <message>",
"success": "Message sent."
},
"setFetterLevel": {
"usage": "Usage: setfetterlevel <level>",
"range_error": "Fetter level must be between 0 and 10.",
"success": "Fetter level set to %s",
"level_error": "Invalid fetter level."
},
"setStats": {
"usage_console": "Usage: setstats|stats @<UID> <stat> <value>",
"usage_ingame": "Usage: setstats|stats [@UID] <stat> <value>",
"help_message": "\n\tValues for <stat>: hp | maxhp | def | atk | em | er | crate | cdmg | cdr | heal | heali | shield | defi\n\t(cont.) Elemental DMG Bonus: epyro | ecryo | ehydro | egeo | edendro | eelectro | ephys\n\t(cont.) Elemental RES: respyro | rescryo | reshydro | resgeo | resdendro | reselectro | resphys\n",
"value_error": "Invalid stat value.",
"uid_error": "Invalid UID.",
"player_error": "Player not found or offline.",
"set_self": "%s set to %s.",
"set_for_uid": "%s for %s set to %s.",
"set_max_hp": "MAX HP set to %s."
},
"setWorldLevel": {
"usage": "Usage: setworldlevel <level>",
"value_error": "World level must be between 0-8",
"success": "World level set to %s.",
"invalid_world_level": "Invalid world level."
},
"spawn": {
"usage": "Usage: spawn <entityId> [amount] [level(monster only)]",
"success": "Spawned %s of %s."
},
"stop": {
"success": "Server shutting down..."
},
"talent": {
"usage_1": "To set talent level: /talent set <talentID> <value>",
"usage_2": "Another way to set talent level: /talent <n or e or q> <value>",
"usage_3": "To get talent ID: /talent getid",
"lower_16": "Invalid talent level. Level should be lower than 16",
"set_id": "Set talent to %s.",
"set_atk": "Set talent Normal ATK to %s.",
"set_e": "Set talent E to %s.",
"set_q": "Set talent Q to %s.",
"invalid_skill_id": "Invalid skill ID.",
"set_this": "Set this talent to %s.",
"invalid_level": "Invalid talent level.",
"normal_attack_id": "Normal Attack ID %s.",
"e_skill_id": "E skill ID %s.",
"q_skill_id": "Q skill ID %s."
},
"teleportAll": {
"success": "Summoned all players to your location.",
"error": "You only can use this command in MP mode."
},
"teleport": {
"usage_server": "Usage: /tp @<player id> <x> <y> <z> [scene id]",
"usage": "Usage: /tp [@<player id>] <x> <y> <z> [scene id]",
"specify_player_id": "You must specify a player id.",
"invalid_position": "Invalid position.",
"success": "Teleported %s to %s, %s, %s in scene %s"
},
"weather": {
"usage": "Usage: weather <weatherId> [climateId]",
"success": "Changed weather to %s with climate %s",
"invalid_id": "Invalid ID."
},
"drop": {
"command_usage": "Usage: drop <itemId|itemName> [amount]",
"success": "Dropped %s of %s."
},
"help": {
"usage": "Usage: ",
"aliases": "Aliases: ",
"available_commands": "Available commands: "
}
}
}
\ No newline at end of file
{
"messages": {
"game": {
"port_bind": "遊戲伺服器已成功啟動。端口號:%s",
"connect": "客戶端已連接至 %s",
"disconnect": "客戶端 %s 已斷開連接。",
"game_update_error": "遊戲更新時發生了錯誤。",
"command_error": "指令發生錯誤:"
},
"dispatch": {
"port_bind": "[Dispatch] 伺服器已在端口 %s 上開啟。",
"request": "[Dispatch] 客戶端 %s 請求: %s %s",
"keystore": {
"general_error": "[Dispatch] 加載keystore文件時發生錯誤!",
"password_error": "[Dispatch] 加載 keystore 失敗。正在嘗試使用預設 keystore 密碼...",
"no_keystore_error": "[Dispatch] 未找到 SSL 憑證!已後降到 HTTP 伺服器。",
"default_password": "[Dispatch] 默認的 keystore 密碼加載成功。請考慮將 config.json 的憑證密碼設定成 123456。"
},
"no_commands_error": "此指令不適用於Dispatch-only模式。",
"unhandled_request_error": "[Dispatch] 潛在的未處理請求 %s 請求:%s",
"account": {
"login_attempt": "[Dispatch] 客戶端 %s 正在嘗試登入",
"login_success": "[Dispatch] 客戶端 %s 已登入,UID為 %s",
"login_token_attempt": "[Dispatch] 客戶端 %s 正在嘗試用憑證登入",
"login_token_error": "[Dispatch] 客戶端 %s 使用憑證登入失敗",
"login_token_success": "[Dispatch] 客戶端 %s 已透過憑證登入,UID為 %s",
"combo_token_success": "[Dispatch] 客戶端 %s 交換憑證成功",
"combo_token_error": "[Dispatch] 客戶端 %s 交換憑證失敗",
"account_login_create_success": "[Dispatch] 客戶端 %s 登入失敗: 已註冊UID為 %s 的帳號",
"account_login_create_error": "[Dispatch] 客戶端 %s 登入失敗:帳號建立失敗。",
"account_login_exist_error": "[Dispatch] 客戶端 %s 登入失敗: 帳號不存在",
"account_cache_error": "遊戲帳號緩存資訊錯誤",
"session_key_error": "對話密鑰不符。",
"username_error": "未找到此用戶名。",
"username_create_error": "未找到用戶名,建立失敗。"
}
},
"status": {
"free_software": "Grasscutter 是免費開源軟體。如果你已經付錢了,那你可能被騙了。主頁:https://github.com/Grasscutters/Grasscutter",
"starting": "正在啟動 Grasscutter...",
"shutdown": "正在關閉...",
"done": "加載完成!需要指令幫助請輸入 \"help\"",
"error": "發生了一個錯誤。",
"welcome": "歡迎使用 Grasscutter",
"run_mode_error": "無效的伺服器運行模式: %s。",
"run_mode_help": "伺服器運行模式必須為 HYBRID 或者 DISPATCH_ONLY 或者 GAME_ONLY。Grasscutter 啟動失敗...",
"create_resources": "正在建立 resources 資料夾...",
"resources_error": "請將 BinOutput 和 ExcelBinOutput 複製到 resources 資料夾。"
}
},
"commands": {
"generic": {
"not_specified": "沒有指定指令。",
"unknown_command": "未知的指令:%s",
"permission_error": "您沒有執行此指令的權限。",
"console_execute_error": "此指令只能在伺服器的命令提示字元執行。",
"player_execute_error": "請在遊戲裡使用這條指令。",
"command_exist_error": "找不到指令。",
"invalid": {
"amount": "無效的 數量.",
"artifactId": "無效的聖遺物ID。",
"avatarId": "無效的角色ID。",
"avatarLevel": "無效的角色等級。",
"entityId": "無效的實體ID。",
"itemId": "無效的物品ID。",
"itemLevel": "無效的物品等級。",
"itemRefinement": "無效的物品精煉度。",
"playerId": "無效的玩家ID。",
"uid": "無效的UID。"
}
},
"execution": {
"uid_error": "無效的UID。",
"player_exist_error": "用戶不存在。",
"player_offline_error": "玩家已離線。",
"item_id_error": "無效的物品ID。.",
"item_player_exist_error": "無效的物品/玩家UID。",
"entity_id_error": "無效的實體ID。",
"player_exist_offline_error": "玩家不存在或已離線。",
"argument_error": "無效的參數。",
"clear_target": "目標已清除.",
"set_target": "隨後的指令都會以@%s為預設。",
"need_target": "此指令需要一個目標 UID。添加 <@UID> 引數或者使用 /target @UID 來設定持久目標。"
},
"status": {
"enabled": "已啟用",
"disabled": "未啟用",
"help": "幫助",
"success": "成功"
},
"account": {
"modify": "修改使用者帳號",
"invalid": "無效的UID。",
"exists": "帳號已存在。",
"create": "已建立帳號,UID 為 %s 。",
"delete": "帳號已刪除。",
"no_account": "帳號不存在。",
"command_usage": "用法:account <create|delete> <username> [uid]"
},
"broadcast": {
"command_usage": "用法:broadcast <message>",
"message_sent": "公告已發送。"
},
"changescene": {
"usage": "用法:changescene <scene id>",
"already_in_scene": "你已經在這個場景中了。",
"success": "已切換至場景 %s.",
"exists_error": "此場景不存在。"
},
"clear": {
"command_usage": "用法: clear <all|wp|art|mat>",
"weapons": "已將 %s 的武器清空。",
"artifacts": "已將 %s 的聖遺物清空。",
"materials": "已將 %s 的材料清空。",
"furniture": "已將 %s 的塵歌壺家具清空。",
"displays": "已清除 %s 的顯示。",
"virtuals": "已將 %s 的所有貨幣和經驗值清空。",
"everything": "已將 %s 的所有物品清空。"
},
"coop": {
"usage": "用法:coop <playerId> <target playerId>",
"success": "Summoned %s to %s's world."
},
"enter_dungeon": {
"usage": "用法:enterdungeon <dungeon id>",
"changed": "已進入副本 %s",
"not_found_error": "此副本不存在。",
"in_dungeon_error": "你已經在祕境中了。"
},
"giveAll": {
"usage": "用法:giveall [player] [amount]",
"started": "正在賦予全部物品...",
"success": "已賦予全部物品。",
"invalid_amount_or_playerId": "無效的數量/玩家ID。"
},
"giveArtifact": {
"usage": "用法:giveart|gart [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]",
"id_error": "無效的聖遺物ID。",
"success": "已把 %s 給予 %s。"
},
"giveChar": {
"usage": "用法:givechar <player> <itemId|itemName> [amount]",
"given": "Given %s with level %s to %s.",
"invalid_avatar_id": "無效的角色ID。",
"invalid_avatar_level": "無效的角色等級。.",
"invalid_avatar_or_player_id": "無效的角色ID/玩家ID。"
},
"give": {
"usage": "用法:give <player> <itemId|itemName> [amount] [level]",
"refinement_only_applicable_weapons": "精煉度只能施加在武器上面。",
"refinement_must_between_1_and_5": "精煉度必需在 1 到 5 之間。",
"given": "已經將 %s 個 %s 給予 %s。",
"given_with_level_and_refinement": "已將 %s [等級%s, 精煉%s] %s個給予 %s",
"given_level": "已將 %s 等級 %s %s 個給予 %s"
},
"godmode": {
"success": "上帝模式設定為 %s 。 [用戶:%s]"
},
"heal": {
"success": "所有角色已被治療。"
},
"kick": {
"player_kick_player": "玩家 [%s:%s] 已把 [%s:%s] 踢出",
"server_kick_player": "正在踢出玩家 [%s:%s]"
},
"kill": {
"usage": "用法:killall [playerUid] [sceneId]",
"scene_not_found_in_player_world": "未在玩家世界中找到此場景",
"kill_monsters_in_scene": "已殺死 %s 個怪物。 [場景ID: %s]"
},
"killCharacter": {
"usage": "用法:/killcharacter [playerId]",
"success": "已殺死 %s 目前的場上角色。"
},
"list": {
"message": "目前總線上人數:%s"
},
"permission": {
"usage": "用法:permission <add|remove> <username> <permission>",
"add": "已指派權限。",
"has_error": "此玩家已擁有權限!",
"remove": "權限已移除。",
"not_have_error": "此玩家未擁有權限!",
"account_error": "The account cannot be found."
},
"position": {
"success": "坐標:%.3f, %.3f, %.3f\n場景ID:%d"
},
"reload": {
"reload_start": "正在重新加載設定檔。",
"reload_done": "重新加載已完成。"
},
"resetConst": {
"reset_all": "重設所有角色的命座。",
"success": "已重設 %s 的命座,重新登入後將會生效。"
},
"resetShopLimit": {
"usage": "用法:/resetshop <player id>"
},
"sendMail": {
"usage": "用法:give [player] <itemId|itemName> [amount]",
"user_not_exist": "ID '%s' 的使用者不存在。",
"start_composition": "發送郵件流程。\n請使用`/send <郵件標題>`來進到下一步。\n你可以在任何時間使用`/sendmail stop`來停止發送。",
"templates": "郵件模板尚未實裝...",
"invalid_arguments": "無效的參數。\n指令使用方法 `/sendmail <userId|all|help> [templateId]`",
"send_cancel": "取消傳送信息",
"send_done": "已將消息發送給 %s!",
"send_all_done": "消息已發送給全體用戶!",
"not_composition_end": "現在郵件發送未到最後階段。\n請使用 `/sendmail %s` 繼續發送郵件,或者 `/sendmail stop` 來停止發送郵件。",
"please_use": "請使用 `/sendmail %s`",
"set_title": "成功將郵件標題設定成 '%s'。\n接下來請繼續使用 '/sendmail <content>' 來設定郵件內容。",
"set_contents": "成功將'%s'為郵件內容。\n接下來請打出 '/sendmail <寄件者名稱>' 來設定郵件寄件者名稱。",
"set_message_sender": "郵件寄件者已設為 '%s'。\n使用 '/sendmail <itemId|itemName|finish> [amount] [level]' 以繼續操作。",
"send": "已添加 %s 個 %s (等級為 %s) 到郵件附件。\n如果沒有要繼續添加道具請使用 `/sendmail finish` 來完成郵件發送。",
"invalid_arguments_please_use": "Invalid arguments \n Please use `/sendmail %s`",
"title": "<標題>",
"message": "<正文>",
"sender": "<寄件者>",
"arguments": "<itemId|itemName|finish> [數量] [等級]",
"error": "錯誤:無效的編寫階段 %s。需要 stacktrace 請查看伺服器命令提示字元。"
},
"sendMessage": {
"usage": "用法:sendmessage <player> <message>",
"success": "訊息已發送。"
},
"setFetterLevel": {
"usage": "用法:setfetterlevel <level>",
"range_error": "好感度必須在 0 到 10 之間。",
"fetter_set_level": "好感等級已設定為 %s",
"level_error": "無效的好感度。"
},
"setStats": {
"usage_console": "用法:setstats|stats @<UID> <stat> <value>",
"usage_ingame": "用法:setstats|stats [@UID] <stat> <value>",
"help_message": "\n\t可使用的數據類型:hp (生命值)| maxhp (最大生命值) | def(防禦力) | atk (攻擊力)| em (元素精通) | er (元素充能效率) | crate(暴擊率) | cdmg (暴擊傷害)| cdr (冷卻縮減) | heal(治療加成)| heali (受治療加成)| shield (護盾強效)| defi (無視防禦)\n\t(cont.) 元素增傷類:epyro (火傷) | ecryo (冰傷) | ehydro (水傷) | egeo (岩傷) | edendro (草傷) | eelectro (雷傷) | ephys (物傷)(cont.) 元素減傷類:respyro (火抗) | rescryo (冰抗) | reshydro (水抗) | resgeo (岩抗) | resdendro (草抗) | reselectro (雷抗) | resphys (物抗)\n",
"value_error": "無效的數據值。",
"uid_error": "無效的UID。",
"player_error": "玩家不存在或已離線。",
"set_self": "%s 已經設為 %s。",
"set_for_uid": "%s 的使用者 %s 更改為 %s。",
"set_max_hp": "最大生命值更改為 %s。"
},
"setWorldLevel": {
"usage": "用法:setworldlevel <level>",
"value_error": "世界等級必須設定在0-8之間。",
"success": "已將世界等級設為%s。",
"invalid_world_level": "無效的世界等級。"
},
"spawn": {
"usage": "用法:spawn <entityId> [amount] [level(僅限怪物)]",
"success": "已生成 %s 個 %s。"
},
"stop": {
"success": "正在關閉伺服器..."
},
"talent": {
"usage_1": "設定天賦等級:/talent set <talentID> <value>",
"usage_2": "另一種設定天賦等級的指令使用方法:/talent <n or e or q> <value>",
"usage_3": "獲取天賦ID指令用法:/talent getid",
"lower_16": "無效的技能等級,技能等級應低於 16。",
"set_id": "將天賦等級設為%s。",
"set_atk": "將普通攻擊等級設為 %s。",
"set_e": "設定天賦E等級至 %s。",
"set_q": "設定天賦Q等級至 %s。",
"invalid_skill_id": "無效的技能ID。",
"set_this": "將天賦等級設為 %s。",
"invalid_level": "無效的天賦等級。",
"normal_attack_id": "普通攻擊的 ID 為 %s。",
"e_skill_id": "E技能ID %s。",
"q_skill_id": "Q技能ID %s。"
},
"teleportAll": {
"success": "Summoned all players to your location.",
"error": "此指令僅可在多人遊戲下可用。"
},
"teleport": {
"usage_server": "用法:/tp @<player id> <x> <y> <z> [scene id]",
"usage": "用法:/tp [@<player id>] <x> <y> <z> [scene id]",
"specify_player_id": "你必須指定一個玩家ID。",
"invalid_position": "無效的位置。",
"success": "傳送 %s 到坐標 %s,%s,%s ,場景為 %s"
},
"weather": {
"usage": "用法:weather <weatherId> [climateId]",
"success": "已將當前天氣設定為 %s ,氣候則為 %s 。",
"invalid_id": "無效的ID。"
},
"drop": {
"command_usage": "用法:drop <itemId|itemName> [amount]",
"success": "已將 %s x %s 丟在附近。"
},
"help": {
"usage": "用法:",
"aliases": "別名:",
"available_commands": "可用指令:"
}
}
}
\ No newline at end of file
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