Improve how the data version is handled

This commit is contained in:
Melledy
2025-11-17 20:22:06 -08:00
parent 7c58d22771
commit dc293cd7ea
6 changed files with 21 additions and 11 deletions

View File

@@ -22,8 +22,8 @@ public class Config {
public ServerRates serverRates = new ServerRates();
public LogOptions logOptions = new LogOptions();
public int customDataVersion = 0;
public String resourceDir = "./resources";
public String dataDir = "./data";
public String patchListPath = "./patchlist.json";
@Getter

View File

@@ -3,8 +3,8 @@ package emu.nebula;
import java.time.ZoneId;
public class GameConstants {
public static final int DATA_VERSION = 46;
public static final String VERSION = "1.0.0." + DATA_VERSION;
private static final int DATA_VERSION = 46;
private static final String VERSION = "1.0.0";
public static final ZoneId UTC_ZONE = ZoneId.of("UTC");
@@ -33,4 +33,14 @@ public class GameConstants {
public static final int MAX_FRIENDSHIPS = 50;
public static final int MAX_PENDING_FRIENDSHIPS = 30;
// Helper functions
public static String getGameVersion() {
return VERSION + "." + getDataVersion();
}
public static int getDataVersion() {
return Nebula.getConfig().getCustomDataVersion() > 0 ? Nebula.getConfig().getCustomDataVersion() : DATA_VERSION ;
}
}

View File

@@ -42,16 +42,16 @@ public class Nebula {
@Getter private static PluginManager pluginManager;
public static void main(String[] args) {
// Load config first
Nebula.loadConfig();
// Start Server
Nebula.getLogger().info("Starting Nebula " + getJarVersion());
Nebula.getLogger().info("Git hash: " + getGitHash());
Nebula.getLogger().info("Game version: " + GameConstants.VERSION);
Nebula.getLogger().info("Game version: " + GameConstants.getGameVersion());
boolean generateHandbook = true;
// Load config + commands
Nebula.loadConfig();
// Load plugin manager
Nebula.pluginManager = new PluginManager();

View File

@@ -39,7 +39,7 @@ public class NetMsgIdUtils {
}
public static void dumpPacketIds() {
try (FileWriter writer = new FileWriter("./MsgIds_" + GameConstants.VERSION + ".json")) {
try (FileWriter writer = new FileWriter("./MsgIds_" + GameConstants.getGameVersion() + ".json")) {
// Create sorted tree map
Map<Integer, String> packetIds = msgIdMap.int2ObjectEntrySet().stream()
.filter(e -> e.getIntKey() > 0)

View File

@@ -63,7 +63,7 @@ public class HttpServer {
// Patch list
public long getDataVersion() {
return getPatchlist() != null ? getPatchlist().getVersion() : GameConstants.DATA_VERSION;
return getPatchlist() != null ? getPatchlist().getVersion() : GameConstants.getDataVersion();
}
public synchronized void loadPatchList() {
@@ -89,7 +89,7 @@ public class HttpServer {
}
if (this.patchlist != null) {
Nebula.getLogger().info("Loaded patchlist version " + patchlist.getVersion());
Nebula.getLogger().info("Loaded patchlist (Data version: " + patchlist.getVersion() + ")");
}
}

View File

@@ -34,7 +34,7 @@ public class Handbook {
var time = Instant.ofEpochMilli(System.currentTimeMillis()).atZone(ZoneId.systemDefault()).format(dtf);
// Header
writer.println("# Nebula " + GameConstants.VERSION + " Handbook");
writer.println("# Nebula " + GameConstants.getGameVersion() + " Handbook");
writer.println("# Created " + time);
// Dump characters