Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: checkout repository
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/actions/wrapper-validation@v3
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
with:
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 模组信息
- 加载器: Fabric (版本: ≥ 0.16.7)
- 支持版本:
- 1.16
- 1.18.2
- 1.19.2
- 1.19.4
Expand All @@ -11,42 +12,43 @@
- 1.20.6
- 1.21
- 1.21.1
- 1.21.11
- 前置模组: Fabric API

## 配置文件介绍
```json
{"address":"http://localhost:8080/","order":"default","updatePeriod":60}
{"ip":"http://localhost:8080/","order":"default","updatePeriod":60}
```
说明:
- `address`: 服务器列表同步地址
- `ip`: 服务器列表同步地址
- `order`: 服务器列表排序方式, 可选值: `default` (默认排序), `reverse` (倒序), `alphabetical` (字母序), `random` (随机排序)
- `updatePeriod`: 服务器列表更新间隔, 单位: 秒

## 服务器列表格式参照
此处的格式指的是上文配置文件中 `address` 字段中填写的地址所返回的服务器列表格式
此处的格式指的是上文配置文件中 `ip` 字段中填写的地址所返回的服务器列表格式
```json
{
"servers": [
{
"name": "Sample #1",
"address": "localhost:25565"
"ip": "localhost:25565"
},
{
"name": "Hypixel",
"address": "mc.hypixel.net"
"ip": "mc.hypixel.net"
}
]
}
```
说明:
- `servers`: 服务器列表,将所有需要添加的服务器放在这个列表里
- `name`: 服务器名称
- `address`: 服务器地址
- `ip`: 服务器地址

## 开源协议
- 本模组遵循 [LGPL-3.0](https://www.gnu.org/licenses/lgpl-3.0.html) 协议
- 最终解释权归 **MCJPG组织** 所有

## 贡献
- 本模组核心开发者为 **alazeprt**, 由 **MCJPG组织** 进行发行
- 本模组核心开发者为 **alazeprt,LonelySail**, 由 **MCJPG组织** 进行发行
- 欢迎提交 [Issue](https://github.com/MineJPGCraft/ServerListSync/issues) 或 [Pull Request](https://github.com/MineJPGCraft/ServerListSync/pulls)
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'fabric-loom' version '1.13-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -46,6 +46,9 @@ dependencies {
// Mod Menu
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"

// Apache HttpClient for HttpUtil
modImplementation include("org.apache.httpcomponents:httpclient:4.5.14")

}

processResources {
Expand Down Expand Up @@ -100,4 +103,4 @@ remapJar {

remapSourcesJar {
archiveFileName.set("serverlistsync-fabric-${minecraft_version}-${version}-sources.jar")
}
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.7
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.18.4

# Mod Properties
mod_version=1.0.2
mod_version=1.0.3
maven_group=top.alazeprt.sls
archives_base_name=serverlistsync

# Dependencies
fabric_version=0.106.0+1.21.1
fabric_version=0.141.3+1.21.11
modmenu_version=11.0.3
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
9 changes: 4 additions & 5 deletions gradlew
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 0 additions & 36 deletions serverlistsync.json

This file was deleted.

8 changes: 6 additions & 2 deletions src/client/java/top/alazeprt/sls/ServerListSyncClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public class ServerListSyncClient implements ClientModInitializer {
try {
ServerListSync.serverInfosJson.clear();
for (JsonElement element : result.getAsJsonArray("servers")) {
ServerListSync.serverInfosJson.add(element);
if (element.getAsJsonObject().has("ip") && element.getAsJsonObject().has("name")) {
ServerListSync.serverInfosJson.add(element);
continue;
}
threadLogger.error("Error occurred while parsing server information: {} ; ip or name is empty", new Gson().toJson(element));
}
synchronized (serverInfos) { serverInfos.clear(); }
updateServerInfos();
Expand All @@ -59,7 +63,7 @@ public void onInitializeClient() {
public static synchronized void updateServerInfos() {
for (JsonElement element : ServerListSync.serverInfosJson) {
serverInfos.add(new ServerInfo(element.getAsJsonObject().get("name").getAsString(),
element.getAsJsonObject().get("address").getAsString(), ServerInfo.ServerType.OTHER));
element.getAsJsonObject().get("ip").getAsString(), ServerInfo.ServerType.OTHER));
}
if (SLSConfig.order.equals(ServerOrder.REVERSE)) Collections.reverse(serverInfos);
if (SLSConfig.order.equals(ServerOrder.ALPHABETICAL)) {
Expand Down
6 changes: 5 additions & 1 deletion src/client/java/top/alazeprt/sls/screen/SLSConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ protected void init() {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
// 1. 先渲染所有子组件 (按钮、输入框等)
context.drawTextWithShadow(textRenderer, Text.literal("服务器地址"), width/2-170, height*2/9+5, 0xffffff);
context.drawTextWithShadow(textRenderer, Text.literal("排序方式"), width/2-170, (int) (height*3.5/9+5), 0xffffff);
context.drawTextWithShadow(textRenderer, Text.literal("更新时间"), width/2-170, height*5/9+5, 0xffffff);
context.drawCenteredTextWithShadow(textRenderer, Text.literal("ServerListSync 配置界面"), width/2, height/9, 0xffffff);

super.render(context, mouseX, mouseY, delta);

System.out.println("SLSConfigScreen.render() 被调用");
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/top/alazeprt/sls/ServerListSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public void onInitialize() {
if (result.get("error") == null) {
try {
for (JsonElement element : result.getAsJsonArray("servers")) {
serverInfosJson.add(element);
if (!element.getAsJsonObject().has("ip") || !element.getAsJsonObject().has("name")) {
serverInfosJson.add(element);
continue;
}
LOGGER.error("Error occurred while parsing server information: {} ; ip or name is empty", new Gson().toJson(element));
}
} catch (Exception e) {
LOGGER.error("Error occurred while parsing server information: {} ; Exception: {}", new Gson().toJson(result), e);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/top/alazeprt/sls/config/SLSConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SLSConfig {
private static final File configFile = new File("config", "serverlistsync.json");
private static final Gson gson = new Gson();

public static String address = "https://ghp.ci/https://raw.githubusercontent.com/MineJPGcraft/ServerListSync/refs/heads/master/serverlistsync.json";
public static String address = "https://serverlist.mcjpg.org/servers.json";
public static ServerOrder order = ServerOrder.RANDOM;
public static int updatePeriod = 60;

Expand All @@ -46,6 +46,6 @@ public static void save() throws IOException {

private static void initialize() throws IOException {
Files.createDirectories(configFile.getParentFile().toPath());
Files.writeString(configFile.toPath(), "{\"address\":\"https://ghp.ci/https://raw.githubusercontent.com/MineJPGcraft/ServerListSync/refs/heads/master/serverlistsync.json\",\"order\":\"random\",\"updatePeriod\":60}", StandardCharsets.UTF_8);
Files.writeString(configFile.toPath(), "{\"address\":\"https://serverlist.mcjpg.org/servers.json\",\"order\":\"random\",\"updatePeriod\":60}", StandardCharsets.UTF_8);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
}
],
"depends": {
"fabricloader": ">=0.15.12",
"minecraft": "~1.21.1",
"fabricloader": ">=0.18.4",
"minecraft": "~1.21.11",
"java": ">=21",
"fabric-api": "*"
},
Expand Down