Compare commits

...

4 Commits

Author SHA1 Message Date
zhaodice
8819cca3e2
Fix connection bugs without removing binding address (#993)
* Fix connection bugs according to #921

Fix this for connect to game by local device or remote devices according to #921

* Fix connection bugs according to #921

same

* Update GameServer.java

* fix build

* Update GameServer.java
2022-05-19 08:35:14 -07:00
tester233
0dcf28141d Remove outdated text & update zh-CN.json 2022-05-19 08:34:58 -07:00
Melledy
c2bf663554 Add error message in case data files in resources could not be found 2022-05-19 03:06:07 -07:00
Melledy
d418d4e3e6 Fix dataloader not getting path correctly 2022-05-19 03:01:21 -07:00
6 changed files with 56 additions and 15 deletions

View File

@ -48,18 +48,20 @@ public class DataLoader {
}
public static void CheckAllFiles() {
String pathSplitter = "defaults" + Pattern.quote(FileSystems.getDefault().getSeparator()) + "data" + Pattern.quote(FileSystems.getDefault().getSeparator());
try {
List<Path> filenames = FileUtils.getPathsFromResource("/defaults/data/");
if (filenames == null) {
Grasscutter.getLogger().error("We were unable to locate your default data files.");
}
for (Path file : filenames) {
String relativePath = String.valueOf(file).split(pathSplitter)[1];
String relativePath = String.valueOf(file).split("defaults[\\\\\\/]data[\\\\\\/]")[1];
CheckAndCopyData(relativePath);
}
} catch (Exception e) {
Grasscutter.getLogger().error("An error occurred while trying to check the data folder. \n", e);
Grasscutter.getLogger().error("An error occurred while trying to check the data folder.", e);
}
GenerateGachaMappings();

View File

@ -58,13 +58,21 @@ public final class GameServer extends KcpServer {
private final CombineManger combineManger;
private final TowerScheduleManager towerScheduleManager;
public GameServer() {
this(new InetSocketAddress(
GAME_INFO.bindAddress,
GAME_INFO.bindPort
));
private static InetSocketAddress getAdapterInetSocketAddress(){
InetSocketAddress inetSocketAddress = null;
if(GAME_INFO.bindAddress.equals("")){
inetSocketAddress=new InetSocketAddress(GAME_INFO.bindPort);
}else{
inetSocketAddress=new InetSocketAddress(
GAME_INFO.bindAddress,
GAME_INFO.bindPort
);
}
return inetSocketAddress;
}
public GameServer() {
this(getAdapterInetSocketAddress());
}
public GameServer(InetSocketAddress address) {
super(address);

View File

@ -129,7 +129,11 @@ public final class HttpServer {
*/
public void start() {
// Attempt to start the HTTP server.
this.express.listen(HTTP_INFO.bindAddress, HTTP_INFO.bindPort);
if(HTTP_INFO.bindAddress.equals("")){
this.express.listen(HTTP_INFO.bindPort);
}else{
this.express.listen(HTTP_INFO.bindAddress, HTTP_INFO.bindPort);
}
// Log bind information.
Grasscutter.getLogger().info(translate("messages.dispatch.port_bind", Integer.toString(this.express.raw().port())));

View File

@ -9,6 +9,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -97,6 +98,11 @@ public final class FileUtils {
} catch (Exception e) {
// Eclipse puts resources in its bin folder
File f = new File(jarPath + "defaults/data/");
if (!f.exists() || f.listFiles().length == 0) {
return null;
}
result = Arrays.stream(f.listFiles()).map(File::toPath).toList();
}

View File

@ -383,8 +383,7 @@
"title": "Banner Details",
"available_five_stars": "Available 5-star Items",
"available_four_stars": "Available 4-star Items",
"available_three_stars": "Available 3-star Items",
"template_missing": "data/gacha_details.html is missing."
"available_three_stars": "Available 3-star Items"
}
},
"documentation": {

View File

@ -61,7 +61,7 @@
"console_execute_error": "此命令只能在服务器控制台执行呐~",
"player_execute_error": "此命令只能在游戏内执行哦~",
"command_exist_error": "这条命令...好像找不到呢?",
"no_description_specified": "没有指定说明",
"no_description_specified": "没有指定说明",
"invalid": {
"amount": "无效的数量。",
"artifactId": "无效的圣遗物ID。",
@ -229,7 +229,7 @@
"description": "添加或完成任务"
},
"reload": {
"reload_start": "正在重载配置文件和数据",
"reload_start": "正在重载配置文件和数据...",
"reload_done": "重载完成。",
"description": "重载配置文件和数据"
},
@ -385,5 +385,27 @@
"available_four_stars": "可获得的4星物品",
"available_three_stars": "可获得的3星物品"
}
},
"documentation": {
"handbook": {
"title": "GM Handbook",
"title_commands": "命令",
"title_avatars": "角色",
"title_items": "物品",
"title_scenes": "场景",
"title_monsters": "怪物",
"header_id": "ID",
"header_command": "命令",
"header_description": "说明",
"header_avatar": "角色",
"header_item": "物品",
"header_scene": "场景",
"header_monster": "怪物"
},
"index": {
"title": "文档",
"handbook": "GM Handbook",
"gacha_mapping": "祈愿映射 JSON"
}
}
}