mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-16 06:15:20 +01:00
Improve how the data version is handled
This commit is contained in:
@@ -22,8 +22,8 @@ public class Config {
|
|||||||
public ServerRates serverRates = new ServerRates();
|
public ServerRates serverRates = new ServerRates();
|
||||||
public LogOptions logOptions = new LogOptions();
|
public LogOptions logOptions = new LogOptions();
|
||||||
|
|
||||||
|
public int customDataVersion = 0;
|
||||||
public String resourceDir = "./resources";
|
public String resourceDir = "./resources";
|
||||||
public String dataDir = "./data";
|
|
||||||
public String patchListPath = "./patchlist.json";
|
public String patchListPath = "./patchlist.json";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package emu.nebula;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
|
||||||
public class GameConstants {
|
public class GameConstants {
|
||||||
public static final int DATA_VERSION = 46;
|
private static final int DATA_VERSION = 46;
|
||||||
public static final String VERSION = "1.0.0." + DATA_VERSION;
|
private static final String VERSION = "1.0.0";
|
||||||
|
|
||||||
public static final ZoneId UTC_ZONE = ZoneId.of("UTC");
|
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_FRIENDSHIPS = 50;
|
||||||
public static final int MAX_PENDING_FRIENDSHIPS = 30;
|
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 ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ public class Nebula {
|
|||||||
@Getter private static PluginManager pluginManager;
|
@Getter private static PluginManager pluginManager;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
// Load config first
|
||||||
|
Nebula.loadConfig();
|
||||||
|
|
||||||
// Start Server
|
// Start Server
|
||||||
Nebula.getLogger().info("Starting Nebula " + getJarVersion());
|
Nebula.getLogger().info("Starting Nebula " + getJarVersion());
|
||||||
Nebula.getLogger().info("Git hash: " + getGitHash());
|
Nebula.getLogger().info("Git hash: " + getGitHash());
|
||||||
Nebula.getLogger().info("Game version: " + GameConstants.VERSION);
|
Nebula.getLogger().info("Game version: " + GameConstants.getGameVersion());
|
||||||
|
|
||||||
boolean generateHandbook = true;
|
boolean generateHandbook = true;
|
||||||
|
|
||||||
// Load config + commands
|
|
||||||
Nebula.loadConfig();
|
|
||||||
|
|
||||||
// Load plugin manager
|
// Load plugin manager
|
||||||
Nebula.pluginManager = new PluginManager();
|
Nebula.pluginManager = new PluginManager();
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class NetMsgIdUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void dumpPacketIds() {
|
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
|
// Create sorted tree map
|
||||||
Map<Integer, String> packetIds = msgIdMap.int2ObjectEntrySet().stream()
|
Map<Integer, String> packetIds = msgIdMap.int2ObjectEntrySet().stream()
|
||||||
.filter(e -> e.getIntKey() > 0)
|
.filter(e -> e.getIntKey() > 0)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class HttpServer {
|
|||||||
// Patch list
|
// Patch list
|
||||||
|
|
||||||
public long getDataVersion() {
|
public long getDataVersion() {
|
||||||
return getPatchlist() != null ? getPatchlist().getVersion() : GameConstants.DATA_VERSION;
|
return getPatchlist() != null ? getPatchlist().getVersion() : GameConstants.getDataVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void loadPatchList() {
|
public synchronized void loadPatchList() {
|
||||||
@@ -89,7 +89,7 @@ public class HttpServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.patchlist != null) {
|
if (this.patchlist != null) {
|
||||||
Nebula.getLogger().info("Loaded patchlist version " + patchlist.getVersion());
|
Nebula.getLogger().info("Loaded patchlist (Data version: " + patchlist.getVersion() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class Handbook {
|
|||||||
var time = Instant.ofEpochMilli(System.currentTimeMillis()).atZone(ZoneId.systemDefault()).format(dtf);
|
var time = Instant.ofEpochMilli(System.currentTimeMillis()).atZone(ZoneId.systemDefault()).format(dtf);
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
writer.println("# Nebula " + GameConstants.VERSION + " Handbook");
|
writer.println("# Nebula " + GameConstants.getGameVersion() + " Handbook");
|
||||||
writer.println("# Created " + time);
|
writer.println("# Created " + time);
|
||||||
|
|
||||||
// Dump characters
|
// Dump characters
|
||||||
|
|||||||
Reference in New Issue
Block a user