Support JP and TW clients

This commit is contained in:
Melledy
2025-12-03 14:08:38 -08:00
parent 2c1e1ae2fb
commit 7ef7490c37
5 changed files with 113 additions and 39 deletions

View File

@@ -6,8 +6,23 @@ import emu.nebula.game.inventory.ItemParam;
import emu.nebula.util.WeightedList;
public class GameConstants {
private static final int DATA_VERSION = 60;
private static final String VERSION = "1.2.0";
public static final String VERSION = "1.2.0";
public static int DATA_VERSION = 0;
// Set data versions for each region
static {
RegionConfig.getRegion("global")
.setDataVersion(60);
RegionConfig.getRegion("kr")
.setDataVersion(67);
RegionConfig.getRegion("jp")
.setDataVersion(63);
RegionConfig.getRegion("tw")
.setDataVersion(61);
}
public static final ZoneId UTC_ZONE = ZoneId.of("UTC");
@@ -57,7 +72,14 @@ public class GameConstants {
// Helper functions
public static String getGameVersion() {
return VERSION + "." + getDataVersion() + " (" + Nebula.getConfig().getRegion().toUpperCase() + ")";
// Load data version
var region = RegionConfig.getRegion(Nebula.getConfig().getRegion());
// Set data version from region
GameConstants.DATA_VERSION = region.getDataVersion();
// Init game version string
return VERSION + "." + getDataVersion() + " (" + region.getName().toUpperCase() + ")";
}
public static int getDataVersion() {

View File

@@ -43,9 +43,8 @@ public class Nebula {
@Getter private static PluginManager pluginManager;
public static void main(String[] args) {
// Load config + keys first
// Load config first
Nebula.loadConfig();
AeadHelper.loadKeys();
// Start Server
Nebula.getLogger().info("Starting Nebula " + getJarVersion());
@@ -54,6 +53,9 @@ public class Nebula {
boolean generateHandbook = true;
// Load keys
AeadHelper.loadKeys();
// Load plugin manager
Nebula.pluginManager = new PluginManager();

View File

@@ -0,0 +1,42 @@
package emu.nebula;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter;
import lombok.Setter;
@Getter @Setter
public class RegionConfig {
private String name;
private int dataVersion;
private String serverMetaKey;
private String serverGarbleKey;
private static Object2ObjectMap<String, RegionConfig> REGIONS = new Object2ObjectOpenHashMap<>();
public RegionConfig(String name) {
this.name = name;
this.serverMetaKey = "";
this.serverGarbleKey = "";
}
public RegionConfig setDataVersion(int i) {
this.dataVersion = i;
return this;
}
public RegionConfig setServerMetaKey(String key) {
this.serverMetaKey = key;
return this;
}
public RegionConfig setServerGarbleKey(String key) {
this.serverGarbleKey = key;
return this;
}
public static RegionConfig getRegion(String name) {
String regionName = name.toLowerCase();
return REGIONS.computeIfAbsent(regionName, r -> new RegionConfig(regionName));
}
}

View File

@@ -19,8 +19,7 @@ import org.bouncycastle.crypto.generators.HKDFBytesGenerator;
import org.bouncycastle.crypto.params.*;
import emu.nebula.Nebula;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import emu.nebula.RegionConfig;
// Official Name: AeadTool
public class AeadHelper {
@@ -34,29 +33,31 @@ public class AeadHelper {
public static byte[] serverGarbleKey = null;
public static byte[] serverMetaKey = null;
private static final Object2ObjectMap<String, String[]> keys = new Object2ObjectOpenHashMap<>();
static {
RegionConfig.getRegion("global")
.setServerMetaKey("ma5Dn2FhC*Xhxy%c")
.setServerGarbleKey("xNdVF^XTa6T3HCUATMQ@sKMLzAw&%L!3");
RegionConfig.getRegion("kr")
.setServerMetaKey("U9cjHuwGDDx&$drn")
.setServerGarbleKey("25hdume9H#*6hHn@d9hSF7tekTwN#JYj");
RegionConfig.getRegion("jp")
.setServerMetaKey("ZnUFA@S9%4KyoryM")
.setServerGarbleKey("yX5Gt64PVvVH6$qwBXaPJC*LZKoK5mYh");
RegionConfig.getRegion("tw")
.setServerMetaKey("owGYVDmfHrxi^4pm")
.setServerGarbleKey("N&mfco452ZH5!nE3s&o5uxB57UGPENVo");
}
public static void loadKeys() {
// Load keys
keys.put("global", new String[] {
"ma5Dn2FhC*Xhxy%c",
"xNdVF^XTa6T3HCUATMQ@sKMLzAw&%L!3"
});
keys.put("kr", new String[] {
"U9cjHuwGDDx&$drn",
"25hdume9H#*6hHn@d9hSF7tekTwN#JYj"
});
// Get key data
var keyData = keys.get(Nebula.getConfig().getRegion().toLowerCase());
if (keyData == null) {
keyData = keys.get("global"); // Default region
}
var region = RegionConfig.getRegion(Nebula.getConfig().getRegion());
// Set keys
serverMetaKey = keyData[0].getBytes(StandardCharsets.US_ASCII);
serverGarbleKey = keyData[1].getBytes(StandardCharsets.US_ASCII);
serverMetaKey = region.getServerMetaKey().getBytes(StandardCharsets.US_ASCII);
serverGarbleKey = region.getServerGarbleKey().getBytes(StandardCharsets.US_ASCII);
}
public static byte[] generateBytes(int size) {