mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-13 12:54:36 +01:00
Support JP and TW clients
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
42
src/main/java/emu/nebula/RegionConfig.java
Normal file
42
src/main/java/emu/nebula/RegionConfig.java
Normal 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));
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user