mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-12 21:34:35 +01:00
Move hotfix urls into their own file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -71,6 +71,7 @@ tmp/
|
||||
# Lunar Core extra
|
||||
Lunar Core Handbook.txt
|
||||
config.json
|
||||
hotfix.json
|
||||
*.mv
|
||||
*.exe
|
||||
BuildConfig.java
|
||||
|
||||
@@ -25,7 +25,6 @@ public class Config {
|
||||
public ServerTime serverTime = new ServerTime();
|
||||
public ServerRates serverRates = new ServerRates();
|
||||
public LogOptions logOptions = new LogOptions();
|
||||
public DownloadData downloadData = new DownloadData();
|
||||
|
||||
public String resourceDir = "./resources";
|
||||
public String dataDir = "./data";
|
||||
@@ -193,14 +192,6 @@ public class Config {
|
||||
public boolean packets = false;
|
||||
public boolean filterLoopingPackets = false;
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DownloadData {
|
||||
public String assetBundleUrl = null;
|
||||
public String exResourceUrl = null;
|
||||
public String luaUrl = null;
|
||||
public String ifixUrl = null;
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
if (this.gameServer.kcpTimeout == null) {
|
||||
|
||||
31
src/main/java/emu/lunarcore/HotfixData.java
Normal file
31
src/main/java/emu/lunarcore/HotfixData.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package emu.lunarcore;
|
||||
|
||||
public class HotfixData {
|
||||
public String assetBundleUrl = "";
|
||||
public String exResourceUrl = "";
|
||||
public String luaUrl = "";
|
||||
public String ifixUrl = "";
|
||||
|
||||
private int customMdkResVersion = 0;
|
||||
private int customIfixVersion = 0;
|
||||
|
||||
public String getMdkResVersion() {
|
||||
if (this.customMdkResVersion != 0) {
|
||||
return Integer.toString(this.customMdkResVersion);
|
||||
} else if (this.luaUrl != null && !this.luaUrl.isBlank()) {
|
||||
return this.luaUrl.split("/")[this.luaUrl.split("/").length - 1].split("_")[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getIfixVersion() {
|
||||
if (this.customIfixVersion != 0) {
|
||||
return Integer.toString(this.customIfixVersion);
|
||||
} else if (this.ifixUrl != null && !this.ifixUrl.isBlank()) {
|
||||
return this.ifixUrl.split("/")[this.ifixUrl.split("/").length - 1].split("_")[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,11 @@ import lombok.Getter;
|
||||
|
||||
public class LunarCore {
|
||||
private static final Logger log = LoggerFactory.getLogger(LunarCore.class);
|
||||
private static File configFile = new File("./config.json");
|
||||
|
||||
private static final File configFile = new File("./config.json");
|
||||
private static final File hotfixFile = new File("./hotfix.json");
|
||||
@Getter private static Config config;
|
||||
@Getter private static HotfixData hotfixData;
|
||||
|
||||
@Getter private static DatabaseManager accountDatabase;
|
||||
@Getter private static DatabaseManager gameDatabase;
|
||||
@@ -81,6 +84,9 @@ public class LunarCore {
|
||||
} catch (Exception exception) {
|
||||
LunarCore.getLogger().error("Unable to load plugins.", exception);
|
||||
}
|
||||
|
||||
// Load hotfix data
|
||||
LunarCore.loadHotfixData();
|
||||
|
||||
// Parse arguments
|
||||
for (String arg : args) {
|
||||
@@ -177,7 +183,7 @@ public class LunarCore {
|
||||
}
|
||||
}
|
||||
|
||||
// Config
|
||||
// Config/Hotfix
|
||||
|
||||
public static void loadConfig() {
|
||||
// Load from file
|
||||
@@ -211,6 +217,31 @@ public class LunarCore {
|
||||
getLogger().error("Config save error");
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadHotfixData() {
|
||||
// Load from hotfix file
|
||||
try (FileReader file = new FileReader(hotfixFile)) {
|
||||
LunarCore.hotfixData = JsonUtils.loadToClass(file, HotfixData.class);
|
||||
} catch (Exception e) {
|
||||
LunarCore.hotfixData = null;
|
||||
}
|
||||
|
||||
if (LunarCore.hotfixData == null) {
|
||||
LunarCore.hotfixData = new HotfixData();
|
||||
|
||||
// Save hotfix data
|
||||
Gson gson = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.serializeNulls()
|
||||
.create();
|
||||
|
||||
try (FileWriter fw = new FileWriter(hotfixFile)) {
|
||||
fw.write(gson.toJson(hotfixData));
|
||||
} catch (Exception ex) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build Config
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ public class ReloadCommand implements CommandHandler {
|
||||
@Override
|
||||
public void execute(CommandArgs args) {
|
||||
LunarCore.loadConfig();
|
||||
LunarCore.loadHotfixData();
|
||||
args.sendMessage("Reloaded the server config");
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class QueryGatewayHandler implements Handler {
|
||||
@Override
|
||||
public void handle(@NotNull Context ctx) throws Exception {
|
||||
// Get streaming data from config
|
||||
var data = LunarCore.getConfig().getDownloadData();
|
||||
var data = LunarCore.getHotfixData();
|
||||
|
||||
// Build gateserver proto
|
||||
Gateserver gateserver = Gateserver.newInstance()
|
||||
@@ -31,25 +31,30 @@ public class QueryGatewayHandler implements Handler {
|
||||
.setUnk4(true)
|
||||
.setUnk5(true);
|
||||
|
||||
if (data.assetBundleUrl != null) {
|
||||
// Set hotfix urls
|
||||
if (data.assetBundleUrl != null && !data.assetBundleUrl.isBlank()) {
|
||||
gateserver.setAssetBundleUrl(data.assetBundleUrl);
|
||||
}
|
||||
if (data.exResourceUrl != null) {
|
||||
if (data.exResourceUrl != null && !data.exResourceUrl.isBlank()) {
|
||||
gateserver.setExResourceUrl(data.exResourceUrl);
|
||||
}
|
||||
if (data.luaUrl != null) {
|
||||
if (data.luaUrl != null && !data.luaUrl.isBlank()) {
|
||||
gateserver.setLuaUrl(data.luaUrl);
|
||||
gateserver.setMdkResVersion(
|
||||
data.luaUrl.split("/")[data.luaUrl.split("/").length - 1].split("_")[1]
|
||||
);
|
||||
}
|
||||
if (data.ifixUrl != null) {
|
||||
if (data.ifixUrl != null && !data.ifixUrl.isBlank()) {
|
||||
gateserver.setIfixUrl(data.ifixUrl);
|
||||
gateserver.setIfixVersion(
|
||||
data.ifixUrl.split("/")[data.ifixUrl.split("/").length - 1].split("_")[1]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Set hotfix versions
|
||||
String mdkResVersion = data.getMdkResVersion();
|
||||
String ifixVersion = data.getIfixVersion();
|
||||
if (mdkResVersion != null) {
|
||||
gateserver.setMdkResVersion(mdkResVersion);
|
||||
}
|
||||
if (ifixVersion != null) {
|
||||
gateserver.setIfixVersion(ifixVersion);
|
||||
}
|
||||
|
||||
// Log
|
||||
if (LunarCore.getConfig().getLogOptions().connections) {
|
||||
LunarCore.getLogger().info("Client request: query_gateway");
|
||||
|
||||
Reference in New Issue
Block a user