mirror of
https://github.com/Melledy/LunarCore.git
synced 2026-02-05 17:46:32 +01:00
Rename project to Lunar Core
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -58,17 +58,17 @@ tmp/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.directory
|
.directory
|
||||||
|
|
||||||
# Lunar Rail generated/resource/log folders
|
# Lunar Core generated/resource/log folders
|
||||||
/resources
|
/resources
|
||||||
/logs
|
/logs
|
||||||
/proto
|
/proto
|
||||||
|
|
||||||
# Lunar Rail compiled
|
# Lunar Core compiled
|
||||||
/*.jar
|
/*.jar
|
||||||
/*.sh
|
/*.sh
|
||||||
|
|
||||||
# Lunar Rail extra
|
# Lunar Core extra
|
||||||
Star Rail Handbook.txt
|
Lunar Core Handbook.txt
|
||||||
config.json
|
config.json
|
||||||
*.mv
|
*.mv
|
||||||
*.exe
|
*.exe
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Lunar Rail
|
# Lunar Core
|
||||||
A WIP server emulator for version 1.4.0 of a certain turn based anime game.
|
A server emulator for version 1.4.0 of a certain turn based anime game.
|
||||||
|
|
||||||
# Running the server and client
|
# Running the server and client
|
||||||
|
|
||||||
|
|||||||
@@ -98,18 +98,18 @@ clean {
|
|||||||
|
|
||||||
application {
|
application {
|
||||||
// Define the main class for the application
|
// Define the main class for the application
|
||||||
mainClassName = 'emu.lunarcore.LunarRail'
|
mainClassName = 'emu.lunarcore.LunarCore'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
exclude '*.proto'
|
exclude '*.proto'
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Main-Class': 'emu.lunarcore.LunarRail'
|
attributes 'Main-Class': 'emu.lunarcore.LunarCore'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
archiveBaseName = 'LunarRail'
|
archiveBaseName = 'LunarCore'
|
||||||
archiveVersion = ''
|
archiveVersion = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,4 @@
|
|||||||
* in the user manual at https://docs.gradle.org/5.6.3/userguide/multi_project_builds.html
|
* in the user manual at https://docs.gradle.org/5.6.3/userguide/multi_project_builds.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rootProject.name = 'Lunar Rail'
|
rootProject.name = 'Lunar Core'
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class Config {
|
|||||||
@Getter
|
@Getter
|
||||||
public static class DatabaseInfo {
|
public static class DatabaseInfo {
|
||||||
public String uri = "mongodb://localhost:27017";
|
public String uri = "mongodb://localhost:27017";
|
||||||
public String collection = "lunarrail";
|
public String collection = "lunarcore";
|
||||||
public boolean useInternal = true;
|
public boolean useInternal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import emu.lunarcore.util.Handbook;
|
|||||||
import emu.lunarcore.util.JsonUtils;
|
import emu.lunarcore.util.JsonUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public class LunarRail {
|
public class LunarCore {
|
||||||
private static Logger log = (Logger) LoggerFactory.getLogger(LunarRail.class);
|
private static Logger log = (Logger) LoggerFactory.getLogger(LunarCore.class);
|
||||||
private static File configFile = new File("./config.json");
|
private static File configFile = new File("./config.json");
|
||||||
private static Config config;
|
private static Config config;
|
||||||
|
|
||||||
@@ -39,16 +39,16 @@ public class LunarRail {
|
|||||||
|
|
||||||
// Load config first before doing anything
|
// Load config first before doing anything
|
||||||
static {
|
static {
|
||||||
LunarRail.loadConfig();
|
LunarCore.loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Start Server
|
// Start Server
|
||||||
LunarRail.getLogger().info("Starting Lunar Rail...");
|
LunarCore.getLogger().info("Starting Lunar Core...");
|
||||||
boolean generateHandbook = true;
|
boolean generateHandbook = true;
|
||||||
|
|
||||||
// Load commands
|
// Load commands
|
||||||
LunarRail.commandManager = new CommandManager();
|
LunarCore.commandManager = new CommandManager();
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
@@ -66,10 +66,10 @@ public class LunarRail {
|
|||||||
case "-database":
|
case "-database":
|
||||||
// Database only
|
// Database only
|
||||||
DatabaseManager databaseManager = new DatabaseManager();
|
DatabaseManager databaseManager = new DatabaseManager();
|
||||||
databaseManager.startInternalMongoServer(LunarRail.getConfig().getInternalMongoServer());
|
databaseManager.startInternalMongoServer(LunarCore.getConfig().getInternalMongoServer());
|
||||||
LunarRail.getLogger().info("Running local mongo server at " + databaseManager.getServer().getConnectionString());
|
LunarCore.getLogger().info("Running local mongo server at " + databaseManager.getServer().getConnectionString());
|
||||||
// Console
|
// Console
|
||||||
LunarRail.startConsole();
|
LunarCore.startConsole();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class LunarRail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start Database(s)
|
// Start Database(s)
|
||||||
LunarRail.initDatabases();
|
LunarCore.initDatabases();
|
||||||
|
|
||||||
// Always run http server as it is needed by for dispatch and gateserver
|
// Always run http server as it is needed by for dispatch and gateserver
|
||||||
httpServer = new HttpServer(serverType);
|
httpServer = new HttpServer(serverType);
|
||||||
@@ -99,7 +99,7 @@ public class LunarRail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start console
|
// Start console
|
||||||
LunarRail.startConsole();
|
LunarCore.startConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Config getConfig() {
|
public static Config getConfig() {
|
||||||
@@ -113,19 +113,19 @@ public class LunarRail {
|
|||||||
// Database
|
// Database
|
||||||
|
|
||||||
private static void initDatabases() {
|
private static void initDatabases() {
|
||||||
if (LunarRail.getConfig().useSameDatabase) {
|
if (LunarCore.getConfig().useSameDatabase) {
|
||||||
// Setup account and game database
|
// Setup account and game database
|
||||||
accountDatabase = new DatabaseManager(LunarRail.getConfig().getAccountDatabase(), serverType);
|
accountDatabase = new DatabaseManager(LunarCore.getConfig().getAccountDatabase(), serverType);
|
||||||
// Optimization: Dont run a 2nd database manager if we are not running a gameserver
|
// Optimization: Dont run a 2nd database manager if we are not running a gameserver
|
||||||
if (serverType.runGame()) {
|
if (serverType.runGame()) {
|
||||||
gameDatabase = accountDatabase;
|
gameDatabase = accountDatabase;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Run separate databases
|
// Run separate databases
|
||||||
accountDatabase = new DatabaseManager(LunarRail.getConfig().getAccountDatabase(), ServerType.DISPATCH);
|
accountDatabase = new DatabaseManager(LunarCore.getConfig().getAccountDatabase(), ServerType.DISPATCH);
|
||||||
// Optimization: Dont run a 2nd database manager if we are not running a gameserver
|
// Optimization: Dont run a 2nd database manager if we are not running a gameserver
|
||||||
if (serverType.runGame()) {
|
if (serverType.runGame()) {
|
||||||
gameDatabase = new DatabaseManager(LunarRail.getConfig().getGameDatabase(), ServerType.GAME);
|
gameDatabase = new DatabaseManager(LunarCore.getConfig().getGameDatabase(), ServerType.GAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ public class LunarRail {
|
|||||||
try (FileReader file = new FileReader(configFile)) {
|
try (FileReader file = new FileReader(configFile)) {
|
||||||
config = JsonUtils.loadToClass(file, Config.class);
|
config = JsonUtils.loadToClass(file, Config.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LunarRail.config = new Config();
|
LunarCore.config = new Config();
|
||||||
}
|
}
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
@@ -164,13 +164,13 @@ public class LunarRail {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LunarRail.getCommandManager().invoke(null, input);
|
LunarCore.getCommandManager().invoke(null, input);
|
||||||
}
|
}
|
||||||
} catch (UserInterruptException | EndOfFileException e) {
|
} catch (UserInterruptException | EndOfFileException e) {
|
||||||
// CTRL + C / CTRL + D
|
// CTRL + C / CTRL + D
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LunarRail.getLogger().error("Terminal error: ", e);
|
LunarCore.getLogger().error("Terminal error: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.command;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.util.Utils;
|
import emu.lunarcore.util.Utils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -59,8 +59,8 @@ public class CommandArgs {
|
|||||||
|
|
||||||
// Get target player
|
// Get target player
|
||||||
if (targetUid != 0) {
|
if (targetUid != 0) {
|
||||||
if (LunarRail.getGameServer() != null) {
|
if (LunarCore.getGameServer() != null) {
|
||||||
target = LunarRail.getGameServer().getOnlinePlayerByUid(targetUid);
|
target = LunarCore.getGameServer().getOnlinePlayerByUid(targetUid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
target = sender;
|
target = sender;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package emu.lunarcore.command;
|
package emu.lunarcore.command;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
|
|
||||||
public interface CommandHandler {
|
public interface CommandHandler {
|
||||||
@@ -13,7 +13,7 @@ public interface CommandHandler {
|
|||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
} else {
|
} else {
|
||||||
LunarRail.getLogger().info(message);
|
LunarCore.getLogger().info(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
@@ -118,8 +118,8 @@ public class CommandManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Log
|
// Log
|
||||||
if (sender != null && LunarRail.getConfig().getLogOptions().commands) {
|
if (sender != null && LunarCore.getConfig().getLogOptions().commands) {
|
||||||
LunarRail.getLogger().info("[UID: " + sender.getUid() + "] " + sender.getName() + " used command: " + message);
|
LunarCore.getLogger().info("[UID: " + sender.getUid() + "] " + sender.getName() + " used command: " + message);
|
||||||
}
|
}
|
||||||
// Run command
|
// Run command
|
||||||
handler.execute(sender, cmdArgs);
|
handler.execute(sender, cmdArgs);
|
||||||
@@ -130,7 +130,7 @@ public class CommandManager {
|
|||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
sender.sendMessage("Inavlid Command!");
|
sender.sendMessage("Inavlid Command!");
|
||||||
} else {
|
} else {
|
||||||
LunarRail.getLogger().info("Inavlid Command!");
|
LunarCore.getLogger().info("Inavlid Command!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package emu.lunarcore.command.commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.bwaldvogel.mongo.backend.Utils;
|
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package emu.lunarcore.command.commands;
|
package emu.lunarcore.command.commands;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
@@ -11,7 +11,7 @@ public class ReloadCommand implements CommandHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, CommandArgs args) {
|
public void execute(Player sender, CommandArgs args) {
|
||||||
LunarRail.loadConfig();
|
LunarCore.loadConfig();
|
||||||
this.sendMessage(sender, "Reloaded the server config");
|
this.sendMessage(sender, "Reloaded the server config");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package emu.lunarcore.command.commands;
|
package emu.lunarcore.command.commands;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.command.CommandArgs;
|
import emu.lunarcore.command.CommandArgs;
|
||||||
import emu.lunarcore.command.CommandHandler;
|
import emu.lunarcore.command.CommandHandler;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.game.player.PlayerGender;
|
|
||||||
import emu.lunarcore.server.packet.send.PacketGetHeroBasicTypeInfoScRsp;
|
|
||||||
|
|
||||||
@Command(label = "unstuck", permission = "admin.unstuck", desc = "/unstuck @[player id]. Unstucks an offline player if theyre in a scene that doesnt load.")
|
@Command(label = "unstuck", permission = "admin.unstuck", desc = "/unstuck @[player id]. Unstucks an offline player if theyre in a scene that doesnt load.")
|
||||||
public class UnstuckCommand implements CommandHandler {
|
public class UnstuckCommand implements CommandHandler {
|
||||||
@@ -14,7 +12,7 @@ public class UnstuckCommand implements CommandHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, CommandArgs args) {
|
public void execute(Player sender, CommandArgs args) {
|
||||||
// Make sure were on the game server
|
// Make sure were on the game server
|
||||||
if (LunarRail.getGameDatabase() == null) {
|
if (LunarCore.getGameDatabase() == null) {
|
||||||
this.sendMessage(sender, "Error: Game database not connected");
|
this.sendMessage(sender, "Error: Game database not connected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -26,7 +24,7 @@ public class UnstuckCommand implements CommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get player from the database
|
// Get player from the database
|
||||||
Player player = LunarRail.getGameDatabase().getObjectByField(Player.class, "_id", args.getTargetUid());
|
Player player = LunarCore.getGameDatabase().getObjectByField(Player.class, "_id", args.getTargetUid());
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
// Reset position for the player
|
// Reset position for the player
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.google.gson.JsonParseException;
|
|||||||
|
|
||||||
public class ResourceDeserializers {
|
public class ResourceDeserializers {
|
||||||
|
|
||||||
protected static class LunarRailDoubleDeserializer implements JsonDeserializer<Double> {
|
protected static class LunarCoreDoubleDeserializer implements JsonDeserializer<Double> {
|
||||||
@Override
|
@Override
|
||||||
public Double deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public Double deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
if (json.isJsonPrimitive()) {
|
if (json.isJsonPrimitive()) {
|
||||||
@@ -22,7 +22,7 @@ public class ResourceDeserializers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class LunarRailHashDeserializer implements JsonDeserializer<Long> {
|
protected static class LunarCoreHashDeserializer implements JsonDeserializer<Long> {
|
||||||
@Override
|
@Override
|
||||||
public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
if (json.isJsonPrimitive()) {
|
if (json.isJsonPrimitive()) {
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package emu.lunarcore.data;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -16,9 +14,9 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.ResourceDeserializers.LunarRailDoubleDeserializer;
|
import emu.lunarcore.data.ResourceDeserializers.LunarCoreDoubleDeserializer;
|
||||||
import emu.lunarcore.data.ResourceDeserializers.LunarRailHashDeserializer;
|
import emu.lunarcore.data.ResourceDeserializers.LunarCoreHashDeserializer;
|
||||||
import emu.lunarcore.data.config.FloorInfo;
|
import emu.lunarcore.data.config.FloorInfo;
|
||||||
import emu.lunarcore.data.config.FloorInfo.FloorGroupSimpleInfo;
|
import emu.lunarcore.data.config.FloorInfo.FloorGroupSimpleInfo;
|
||||||
import emu.lunarcore.data.config.GroupInfo;
|
import emu.lunarcore.data.config.GroupInfo;
|
||||||
@@ -30,8 +28,8 @@ public class ResourceLoader {
|
|||||||
|
|
||||||
// Special gson factory we create for loading resources
|
// Special gson factory we create for loading resources
|
||||||
private static final Gson gson = new GsonBuilder()
|
private static final Gson gson = new GsonBuilder()
|
||||||
.registerTypeAdapter(double.class, new LunarRailDoubleDeserializer())
|
.registerTypeAdapter(double.class, new LunarCoreDoubleDeserializer())
|
||||||
.registerTypeAdapter(long.class, new LunarRailHashDeserializer())
|
.registerTypeAdapter(long.class, new LunarCoreHashDeserializer())
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
// Load all resources
|
// Load all resources
|
||||||
@@ -83,7 +81,7 @@ public class ResourceLoader {
|
|||||||
try {
|
try {
|
||||||
loadFromResource(resourceDefinition, type, map);
|
loadFromResource(resourceDefinition, type, map);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LunarRail.getLogger().error("Error loading resource file: " + Arrays.toString(type.name()), e);
|
LunarCore.getLogger().error("Error loading resource file: " + Arrays.toString(type.name()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,12 +94,12 @@ public class ResourceLoader {
|
|||||||
count += loadFromResource(c, type, name, map);
|
count += loadFromResource(c, type, name, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
LunarRail.getLogger().info("Loaded " + count + " " + c.getSimpleName() + "s.");
|
LunarCore.getLogger().info("Loaded " + count + " " + c.getSimpleName() + "s.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
private static <T> int loadFromResource(Class<T> c, ResourceType type, String fileName, Int2ObjectMap map) throws Exception {
|
private static <T> int loadFromResource(Class<T> c, ResourceType type, String fileName, Int2ObjectMap map) throws Exception {
|
||||||
String file = LunarRail.getConfig().getResourceDir() + "/ExcelOutput/" + fileName;
|
String file = LunarCore.getConfig().getResourceDir() + "/ExcelOutput/" + fileName;
|
||||||
|
|
||||||
// Load reader from file
|
// Load reader from file
|
||||||
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
|
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) {
|
||||||
@@ -169,10 +167,10 @@ public class ResourceLoader {
|
|||||||
// Might be better to cache
|
// Might be better to cache
|
||||||
private static void loadFloorInfos() {
|
private static void loadFloorInfos() {
|
||||||
// Load floor infos
|
// Load floor infos
|
||||||
File floorDir = new File(LunarRail.getConfig().getResourceDir() + "/Config/LevelOutput/Floor/");
|
File floorDir = new File(LunarCore.getConfig().getResourceDir() + "/Config/LevelOutput/Floor/");
|
||||||
|
|
||||||
if (!floorDir.exists()) {
|
if (!floorDir.exists()) {
|
||||||
LunarRail.getLogger().warn("Floor infos are missing, please check your resources.");
|
LunarCore.getLogger().warn("Floor infos are missing, please check your resources.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +188,7 @@ public class ResourceLoader {
|
|||||||
// Load group infos
|
// Load group infos
|
||||||
for (FloorInfo floor : GameData.getFloorInfos().values()) {
|
for (FloorInfo floor : GameData.getFloorInfos().values()) {
|
||||||
for (FloorGroupSimpleInfo simpleGroup : floor.getSimpleGroupList()) {
|
for (FloorGroupSimpleInfo simpleGroup : floor.getSimpleGroupList()) {
|
||||||
File file = new File(LunarRail.getConfig().getResourceDir() + "/" + simpleGroup.getGroupPath());
|
File file = new File(LunarCore.getConfig().getResourceDir() + "/" + simpleGroup.getGroupPath());
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -211,7 +209,7 @@ public class ResourceLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
LunarRail.getLogger().info("Loaded " + GameData.getFloorInfos().size() + " FloorInfos.");
|
LunarCore.getLogger().info("Loaded " + GameData.getFloorInfos().size() + " FloorInfos.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Might be better to cache
|
// Might be better to cache
|
||||||
@@ -220,7 +218,7 @@ public class ResourceLoader {
|
|||||||
|
|
||||||
for (var avatarExcel : GameData.getAvatarExcelMap().values()) {
|
for (var avatarExcel : GameData.getAvatarExcelMap().values()) {
|
||||||
// Get file
|
// Get file
|
||||||
File file = new File(LunarRail.getConfig().getResourceDir() + "/Config/ConfigAdventureAbility/LocalPlayer/LocalPlayer_" + avatarExcel.getNameKey() + "_Ability.json");
|
File file = new File(LunarCore.getConfig().getResourceDir() + "/Config/ConfigAdventureAbility/LocalPlayer/LocalPlayer_" + avatarExcel.getNameKey() + "_Ability.json");
|
||||||
if (!file.exists()) continue;
|
if (!file.exists()) continue;
|
||||||
|
|
||||||
try (FileReader reader = new FileReader(file)) {
|
try (FileReader reader = new FileReader(file)) {
|
||||||
@@ -235,11 +233,11 @@ public class ResourceLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
LunarRail.getLogger().info("Loaded " + count + " maze abilities for avatars.");
|
LunarCore.getLogger().info("Loaded " + count + " maze abilities for avatars.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadRogueMapGen() {
|
private static void loadRogueMapGen() {
|
||||||
File file = new File(LunarRail.getConfig().getDataDir() + "/RogueMapGen.json");
|
File file = new File(LunarCore.getConfig().getDataDir() + "/RogueMapGen.json");
|
||||||
if (!file.exists()) return;
|
if (!file.exists()) return;
|
||||||
|
|
||||||
try (FileReader reader = new FileReader(file)) {
|
try (FileReader reader = new FileReader(file)) {
|
||||||
@@ -253,6 +251,6 @@ public class ResourceLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
LunarRail.getLogger().info("Loaded rogue maps");
|
LunarCore.getLogger().info("Loaded rogue maps");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package emu.lunarcore.data.excel;
|
|||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
|
||||||
import emu.lunarcore.data.GameResource;
|
import emu.lunarcore.data.GameResource;
|
||||||
import emu.lunarcore.data.ResourceType;
|
import emu.lunarcore.data.ResourceType;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import dev.morphia.mapping.MapperOptions;
|
|||||||
import dev.morphia.query.filters.Filters;
|
import dev.morphia.query.filters.Filters;
|
||||||
import emu.lunarcore.Config.DatabaseInfo;
|
import emu.lunarcore.Config.DatabaseInfo;
|
||||||
import emu.lunarcore.Config.InternalMongoInfo;
|
import emu.lunarcore.Config.InternalMongoInfo;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.LunarRail.ServerType;
|
import emu.lunarcore.LunarCore.ServerType;
|
||||||
|
|
||||||
public final class DatabaseManager {
|
public final class DatabaseManager {
|
||||||
private MongoServer server;
|
private MongoServer server;
|
||||||
@@ -42,8 +42,8 @@ public final class DatabaseManager {
|
|||||||
|
|
||||||
// Local mongo server
|
// Local mongo server
|
||||||
if (info.isUseInternal()) {
|
if (info.isUseInternal()) {
|
||||||
connectionString = startInternalMongoServer(LunarRail.getConfig().getInternalMongoServer());
|
connectionString = startInternalMongoServer(LunarCore.getConfig().getInternalMongoServer());
|
||||||
LunarRail.getLogger().info("Using local mongo server at " + server.getConnectionString());
|
LunarCore.getLogger().info("Using local mongo server at " + server.getConnectionString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
@@ -59,7 +59,7 @@ public final class DatabaseManager {
|
|||||||
datastore = Morphia.createDatastore(gameMongoClient, info.getCollection(), mapperOptions);
|
datastore = Morphia.createDatastore(gameMongoClient, info.getCollection(), mapperOptions);
|
||||||
|
|
||||||
// Map classes
|
// Map classes
|
||||||
var entities = new Reflections(LunarRail.class.getPackageName())
|
var entities = new Reflections(LunarCore.class.getPackageName())
|
||||||
.getTypesAnnotatedWith(Entity.class)
|
.getTypesAnnotatedWith(Entity.class)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(cls -> {
|
.filter(cls -> {
|
||||||
@@ -105,7 +105,7 @@ public final class DatabaseManager {
|
|||||||
try {
|
try {
|
||||||
datastore.ensureIndexes();
|
datastore.ensureIndexes();
|
||||||
} catch (MongoCommandException exception) {
|
} catch (MongoCommandException exception) {
|
||||||
LunarRail.getLogger().warn("Mongo index error: ", exception);
|
LunarCore.getLogger().warn("Mongo index error: ", exception);
|
||||||
// Duplicate index error
|
// Duplicate index error
|
||||||
if (exception.getCode() == 85) {
|
if (exception.getCode() == 85) {
|
||||||
// Drop all indexes and re add them
|
// Drop all indexes and re add them
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.*;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import dev.morphia.annotations.*;
|
import dev.morphia.annotations.*;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.database.AccountDatabaseOnly;
|
import emu.lunarcore.database.AccountDatabaseOnly;
|
||||||
import emu.lunarcore.util.Crypto;
|
import emu.lunarcore.util.Crypto;
|
||||||
import emu.lunarcore.util.Snowflake32;
|
import emu.lunarcore.util.Snowflake32;
|
||||||
@@ -99,7 +99,7 @@ public class Account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default permissions
|
// Default permissions
|
||||||
var defaultPermissions = LunarRail.getConfig().getServerOptions().getDefaultPermissions();
|
var defaultPermissions = LunarCore.getConfig().getServerOptions().getDefaultPermissions();
|
||||||
|
|
||||||
if (defaultPermissions.contains("*")) {
|
if (defaultPermissions.contains("*")) {
|
||||||
return true;
|
return true;
|
||||||
@@ -151,6 +151,6 @@ public class Account {
|
|||||||
// Database
|
// Database
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
LunarRail.getAccountDatabase().save(this);
|
LunarCore.getAccountDatabase().save(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package emu.lunarcore.game.account;
|
package emu.lunarcore.game.account;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for handling account related stuff
|
* Helper class for handling account related stuff
|
||||||
@@ -8,7 +8,7 @@ import emu.lunarcore.LunarRail;
|
|||||||
public class AccountHelper {
|
public class AccountHelper {
|
||||||
|
|
||||||
public static boolean createAccount(String username, String password, int reservedUid) {
|
public static boolean createAccount(String username, String password, int reservedUid) {
|
||||||
Account account = LunarRail.getAccountDatabase().getObjectByField(Account.class, "username", username);
|
Account account = LunarCore.getAccountDatabase().getObjectByField(Account.class, "username", username);
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -22,13 +22,13 @@ public class AccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean deleteAccount(String username) {
|
public static boolean deleteAccount(String username) {
|
||||||
Account account = LunarRail.getAccountDatabase().getObjectByField(Account.class, "username", username);
|
Account account = LunarCore.getAccountDatabase().getObjectByField(Account.class, "username", username);
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return LunarRail.getAccountDatabase().delete(account);
|
return LunarCore.getAccountDatabase().delete(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.Iterator;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.excel.AvatarExcel;
|
import emu.lunarcore.data.excel.AvatarExcel;
|
||||||
import emu.lunarcore.data.excel.HeroExcel;
|
import emu.lunarcore.data.excel.HeroExcel;
|
||||||
@@ -94,7 +94,7 @@ public class AvatarStorage extends BasePlayerManager implements Iterable<GameAva
|
|||||||
|
|
||||||
public void loadFromDatabase() {
|
public void loadFromDatabase() {
|
||||||
// Load hero paths
|
// Load hero paths
|
||||||
Stream<HeroPath> heroStream = LunarRail.getGameDatabase().getObjects(HeroPath.class, "ownerUid", this.getPlayer().getUid());
|
Stream<HeroPath> heroStream = LunarCore.getGameDatabase().getObjects(HeroPath.class, "ownerUid", this.getPlayer().getUid());
|
||||||
|
|
||||||
heroStream.forEach(heroPath -> {
|
heroStream.forEach(heroPath -> {
|
||||||
// Load avatar excel data
|
// Load avatar excel data
|
||||||
@@ -109,7 +109,7 @@ public class AvatarStorage extends BasePlayerManager implements Iterable<GameAva
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Load avatars
|
// Load avatars
|
||||||
Stream<GameAvatar> stream = LunarRail.getGameDatabase().getObjects(GameAvatar.class, "ownerUid", this.getPlayer().getUid());
|
Stream<GameAvatar> stream = LunarCore.getGameDatabase().getObjects(GameAvatar.class, "ownerUid", this.getPlayer().getUid());
|
||||||
|
|
||||||
stream.forEach(avatar -> {
|
stream.forEach(avatar -> {
|
||||||
// Should never happen
|
// Should never happen
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import dev.morphia.annotations.Id;
|
|||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.excel.AvatarExcel;
|
import emu.lunarcore.data.excel.AvatarExcel;
|
||||||
import emu.lunarcore.game.inventory.GameItem;
|
import emu.lunarcore.game.inventory.GameItem;
|
||||||
@@ -374,7 +374,7 @@ public class GameAvatar implements GameEntity {
|
|||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
// Save avatar
|
// Save avatar
|
||||||
LunarRail.getGameDatabase().save(this);
|
LunarCore.getGameDatabase().save(this);
|
||||||
// Save hero path
|
// Save hero path
|
||||||
if (this.getHeroPath() != null) {
|
if (this.getHeroPath() != null) {
|
||||||
this.getHeroPath().save();
|
this.getHeroPath().save();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import dev.morphia.annotations.Entity;
|
|||||||
import dev.morphia.annotations.Id;
|
import dev.morphia.annotations.Id;
|
||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.excel.AvatarExcel;
|
import emu.lunarcore.data.excel.AvatarExcel;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.proto.AvatarSkillTreeOuterClass.AvatarSkillTree;
|
import emu.lunarcore.proto.AvatarSkillTreeOuterClass.AvatarSkillTree;
|
||||||
@@ -70,6 +70,6 @@ public class HeroPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
LunarRail.getGameDatabase().save(this);
|
LunarCore.getGameDatabase().save(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.bson.types.ObjectId;
|
|||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
import dev.morphia.annotations.Id;
|
import dev.morphia.annotations.Id;
|
||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.proto.ChallengeOuterClass.Challenge;
|
import emu.lunarcore.proto.ChallengeOuterClass.Challenge;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -42,10 +42,10 @@ public class ChallengeHistory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
LunarRail.getGameDatabase().delete(this);
|
LunarCore.getGameDatabase().delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
LunarRail.getGameDatabase().save(this);
|
LunarCore.getGameDatabase().save(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.game.challenge;
|
|||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.excel.ChallengeExcel;
|
import emu.lunarcore.data.excel.ChallengeExcel;
|
||||||
import emu.lunarcore.game.player.BasePlayerManager;
|
import emu.lunarcore.game.player.BasePlayerManager;
|
||||||
@@ -85,7 +85,7 @@ public class ChallengeManager extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromDatabase() {
|
public void loadFromDatabase() {
|
||||||
Stream<ChallengeHistory> stream = LunarRail.getGameDatabase().getObjects(ChallengeHistory.class, "ownerUid", this.getPlayer().getUid());
|
Stream<ChallengeHistory> stream = LunarCore.getGameDatabase().getObjects(ChallengeHistory.class, "ownerUid", this.getPlayer().getUid());
|
||||||
|
|
||||||
stream.forEach(info -> {
|
stream.forEach(info -> {
|
||||||
this.getHistory().put(info.getChallengeId(), info);
|
this.getHistory().put(info.getChallengeId(), info);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package emu.lunarcore.game.chat;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.player.BasePlayerManager;
|
import emu.lunarcore.game.player.BasePlayerManager;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.server.packet.send.PacketRevcMsgScNotify;
|
import emu.lunarcore.server.packet.send.PacketRevcMsgScNotify;
|
||||||
@@ -52,7 +52,7 @@ public class ChatManager extends BasePlayerManager {
|
|||||||
|
|
||||||
// Check if command
|
// Check if command
|
||||||
if (text.charAt(0) == '!' || text.charAt(0) == '/') {
|
if (text.charAt(0) == '!' || text.charAt(0) == '/') {
|
||||||
LunarRail.getCommandManager().invoke(getPlayer(), text);
|
LunarCore.getCommandManager().invoke(getPlayer(), text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package emu.lunarcore.game.enums;
|
package emu.lunarcore.game.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public enum PropType {
|
public enum PropType {
|
||||||
PROP_NONE (0),
|
PROP_NONE (0),
|
||||||
PROP_ORDINARY (1),
|
PROP_ORDINARY (1),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.excel.ItemExcel;
|
import emu.lunarcore.data.excel.ItemExcel;
|
||||||
import emu.lunarcore.game.avatar.GameAvatar;
|
import emu.lunarcore.game.avatar.GameAvatar;
|
||||||
@@ -58,14 +58,14 @@ public class GachaService extends BaseGameService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void load() {
|
public synchronized void load() {
|
||||||
try (FileReader fileReader = new FileReader(LunarRail.getConfig().getDataDir() + "/Banners.json")) {
|
try (FileReader fileReader = new FileReader(LunarCore.getConfig().getDataDir() + "/Banners.json")) {
|
||||||
List<GachaBanner> banners = JsonUtils.loadToList(fileReader, GachaBanner.class);
|
List<GachaBanner> banners = JsonUtils.loadToList(fileReader, GachaBanner.class);
|
||||||
for (GachaBanner banner : banners) {
|
for (GachaBanner banner : banners) {
|
||||||
getGachaBanners().put(banner.getId(), banner);
|
getGachaBanners().put(banner.getId(), banner);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
LunarRail.getLogger().warn("No gacha banners loaded!");
|
LunarCore.getLogger().warn("No gacha banners loaded!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.bson.types.ObjectId;
|
|||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
import dev.morphia.annotations.Id;
|
import dev.morphia.annotations.Id;
|
||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.GameDepot;
|
import emu.lunarcore.data.GameDepot;
|
||||||
import emu.lunarcore.data.excel.ItemExcel;
|
import emu.lunarcore.data.excel.ItemExcel;
|
||||||
@@ -210,9 +210,9 @@ public class GameItem {
|
|||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (this.count > 0 && this.ownerUid > 0) {
|
if (this.count > 0 && this.ownerUid > 0) {
|
||||||
LunarRail.getGameDatabase().save(this);
|
LunarCore.getGameDatabase().save(this);
|
||||||
} else if (this.getId() != null) {
|
} else if (this.getId() != null) {
|
||||||
LunarRail.getGameDatabase().delete(this);
|
LunarCore.getGameDatabase().delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.common.ItemParam;
|
import emu.lunarcore.data.common.ItemParam;
|
||||||
import emu.lunarcore.data.common.ItemParam.ItemParamType;
|
import emu.lunarcore.data.common.ItemParam.ItemParamType;
|
||||||
@@ -428,7 +428,7 @@ public class Inventory extends BasePlayerManager {
|
|||||||
// Database
|
// Database
|
||||||
|
|
||||||
public void loadFromDatabase() {
|
public void loadFromDatabase() {
|
||||||
Stream<GameItem> stream = LunarRail.getGameDatabase().getObjects(GameItem.class, "ownerUid", this.getPlayer().getUid());
|
Stream<GameItem> stream = LunarCore.getGameDatabase().getObjects(GameItem.class, "ownerUid", this.getPlayer().getUid());
|
||||||
|
|
||||||
stream.forEach(item -> {
|
stream.forEach(item -> {
|
||||||
// Should never happen
|
// Should never happen
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.bson.types.ObjectId;
|
|||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
import dev.morphia.annotations.Id;
|
import dev.morphia.annotations.Id;
|
||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.inventory.GameItem;
|
import emu.lunarcore.game.inventory.GameItem;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.proto.ClientMailOuterClass.ClientMail;
|
import emu.lunarcore.proto.ClientMailOuterClass.ClientMail;
|
||||||
@@ -66,11 +66,11 @@ public class Mail {
|
|||||||
// Database
|
// Database
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
LunarRail.getGameDatabase().save(this);
|
LunarCore.getGameDatabase().save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
LunarRail.getGameDatabase().delete(this);
|
LunarCore.getGameDatabase().delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proto
|
// Proto
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.inventory.GameItem;
|
import emu.lunarcore.game.inventory.GameItem;
|
||||||
import emu.lunarcore.game.player.BasePlayerManager;
|
import emu.lunarcore.game.player.BasePlayerManager;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
@@ -130,7 +130,7 @@ public class Mailbox extends BasePlayerManager implements Iterable<Mail> {
|
|||||||
// Database
|
// Database
|
||||||
|
|
||||||
public void loadFromDatabase() {
|
public void loadFromDatabase() {
|
||||||
Stream<Mail> stream = LunarRail.getGameDatabase().getObjects(Mail.class, "ownerUid", this.getPlayer().getUid());
|
Stream<Mail> stream = LunarCore.getGameDatabase().getObjects(Mail.class, "ownerUid", this.getPlayer().getUid());
|
||||||
|
|
||||||
stream.forEach(this::putMail);
|
stream.forEach(this::putMail);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import dev.morphia.annotations.Id;
|
|||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.config.AnchorInfo;
|
import emu.lunarcore.data.config.AnchorInfo;
|
||||||
import emu.lunarcore.data.config.FloorInfo;
|
import emu.lunarcore.data.config.FloorInfo;
|
||||||
@@ -277,8 +277,8 @@ public class Player {
|
|||||||
nextUid = 0;
|
nextUid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (nextUid == 0 || LunarRail.getGameDatabase().checkIfObjectExists(Player.class, nextUid)) {
|
while (nextUid == 0 || LunarCore.getGameDatabase().checkIfObjectExists(Player.class, nextUid)) {
|
||||||
nextUid = LunarRail.getGameDatabase().getNextObjectId(Player.class);
|
nextUid = LunarCore.getGameDatabase().getNextObjectId(Player.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.uid = nextUid;
|
this.uid = nextUid;
|
||||||
@@ -516,11 +516,11 @@ public class Player {
|
|||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (this.uid <= 0) {
|
if (this.uid <= 0) {
|
||||||
LunarRail.getLogger().error("Tried to save a player object without a uid!");
|
LunarCore.getLogger().error("Tried to save a player object without a uid!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LunarRail.getGameDatabase().save(this);
|
LunarCore.getGameDatabase().save(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLogin() {
|
public void onLogin() {
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package emu.lunarcore.game.player;
|
package emu.lunarcore.game.player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
public class PlayerExtraLineup extends PlayerLineup {
|
public class PlayerExtraLineup extends PlayerLineup {
|
||||||
private int extraLineupType;
|
private int extraLineupType;
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package emu.lunarcore.game.scene.entity;
|
package emu.lunarcore.game.scene.entity;
|
||||||
|
|
||||||
import emu.lunarcore.data.excel.NpcMonsterExcel;
|
import emu.lunarcore.data.excel.NpcMonsterExcel;
|
||||||
import emu.lunarcore.data.excel.StageExcel;
|
|
||||||
import emu.lunarcore.game.scene.Scene;
|
import emu.lunarcore.game.scene.Scene;
|
||||||
import emu.lunarcore.game.scene.triggers.PropTriggerType;
|
import emu.lunarcore.game.scene.triggers.PropTriggerType;
|
||||||
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
|
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
|
||||||
import emu.lunarcore.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
import emu.lunarcore.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||||
import emu.lunarcore.proto.SceneNpcMonsterInfoOuterClass.SceneNpcMonsterInfo;
|
import emu.lunarcore.proto.SceneNpcMonsterInfoOuterClass.SceneNpcMonsterInfo;
|
||||||
import emu.lunarcore.proto.VectorOuterClass.Vector;
|
|
||||||
import emu.lunarcore.util.Position;
|
import emu.lunarcore.util.Position;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package emu.lunarcore.game.scene.triggers;
|
package emu.lunarcore.game.scene.triggers;
|
||||||
|
|
||||||
import emu.lunarcore.game.enums.PropState;
|
import emu.lunarcore.game.enums.PropState;
|
||||||
import emu.lunarcore.game.enums.PropType;
|
|
||||||
import emu.lunarcore.game.scene.Scene;
|
import emu.lunarcore.game.scene.Scene;
|
||||||
import emu.lunarcore.game.scene.entity.EntityProp;
|
import emu.lunarcore.game.scene.entity.EntityProp;
|
||||||
import emu.lunarcore.game.scene.entity.GameEntity;
|
import emu.lunarcore.game.scene.entity.GameEntity;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import emu.lunarcore.Config.GameServerConfig;
|
import emu.lunarcore.Config.GameServerConfig;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.battle.BattleService;
|
import emu.lunarcore.game.battle.BattleService;
|
||||||
import emu.lunarcore.game.gacha.GachaService;
|
import emu.lunarcore.game.gacha.GachaService;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
@@ -89,10 +89,10 @@ public class GameServer extends KcpServer {
|
|||||||
// Setup region info
|
// Setup region info
|
||||||
this.info.setUp(true);
|
this.info.setUp(true);
|
||||||
this.info.save();
|
this.info.save();
|
||||||
LunarRail.getHttpServer().forceRegionListRefresh();
|
LunarCore.getHttpServer().forceRegionListRefresh();
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
LunarRail.getLogger().info("Game Server started on " + address.getPort());
|
LunarCore.getLogger().info("Game Server started on " + address.getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onShutdown() {
|
private void onShutdown() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
import emu.lunarcore.server.packet.Opcodes;
|
import emu.lunarcore.server.packet.Opcodes;
|
||||||
import emu.lunarcore.server.packet.PacketHandler;
|
import emu.lunarcore.server.packet.PacketHandler;
|
||||||
@@ -39,7 +39,7 @@ public class GameServerPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerHandlers() {
|
public void registerHandlers() {
|
||||||
Reflections reflections = new Reflections(LunarRail.class.getPackageName());
|
Reflections reflections = new Reflections(LunarCore.class.getPackageName());
|
||||||
Set<?> handlerClasses = reflections.getSubTypesOf(PacketHandler.class);
|
Set<?> handlerClasses = reflections.getSubTypesOf(PacketHandler.class);
|
||||||
|
|
||||||
for (Object obj : handlerClasses) {
|
for (Object obj : handlerClasses) {
|
||||||
@@ -47,7 +47,7 @@ public class GameServerPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
LunarRail.getLogger().info("Game Server registered " + this.handlers.size() + " packet handlers");
|
LunarCore.getLogger().info("Game Server registered " + this.handlers.size() + " packet handlers");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(GameSession session, int opcode, byte[] header, byte[] data) {
|
public void handle(GameSession session, int opcode, byte[] header, byte[] data) {
|
||||||
@@ -68,15 +68,7 @@ public class GameServerPacketHandler {
|
|||||||
if (state != SessionState.WAITING_FOR_LOGIN) {
|
if (state != SessionState.WAITING_FOR_LOGIN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
/*
|
|
||||||
else if (opcode == PacketOpcodes.SetPlayerBornDataReq) {
|
|
||||||
if (state != SessionState.PICKING_CHARACTER) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
else {
|
|
||||||
if (state != SessionState.ACTIVE) {
|
if (state != SessionState.ACTIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -92,6 +84,6 @@ public class GameServerPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log unhandled packets
|
// Log unhandled packets
|
||||||
//LunarRail.getLogger().info("Unhandled packet (" + opcode + "): " + CmdIdUtils.getOpcodeName(opcode));
|
//LunarCore.getLogger().info("Unhandled packet (" + opcode + "): " + CmdIdUtils.getOpcodeName(opcode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.server.game;
|
|||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.account.Account;
|
import emu.lunarcore.game.account.Account;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
import emu.lunarcore.server.packet.BasePacket;
|
||||||
@@ -65,14 +65,14 @@ public class GameSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onConnect() {
|
public void onConnect() {
|
||||||
if (LunarRail.getConfig().getLogOptions().connections) {
|
if (LunarCore.getConfig().getLogOptions().connections) {
|
||||||
LunarRail.getLogger().info("Client connected from " + address.getHostString());
|
LunarCore.getLogger().info("Client connected from " + address.getHostString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnect() {
|
public void onDisconnect() {
|
||||||
if (LunarRail.getConfig().getLogOptions().connections) {
|
if (LunarCore.getConfig().getLogOptions().connections) {
|
||||||
LunarRail.getLogger().info("Client disconnected from " + address.getHostString());
|
LunarCore.getLogger().info("Client disconnected from " + address.getHostString());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = SessionState.INACTIVE;
|
this.state = SessionState.INACTIVE;
|
||||||
@@ -120,7 +120,7 @@ public class GameSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log packet
|
// Log packet
|
||||||
if (LunarRail.getConfig().getLogOptions().packets) {
|
if (LunarCore.getConfig().getLogOptions().packets) {
|
||||||
logPacket("RECV", opcode, data);
|
logPacket("RECV", opcode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ public class GameSession {
|
|||||||
public void send(BasePacket packet) {
|
public void send(BasePacket packet) {
|
||||||
// Test
|
// Test
|
||||||
if (packet.getOpcode() <= 0) {
|
if (packet.getOpcode() <= 0) {
|
||||||
LunarRail.getLogger().warn("Tried to send packet with missing cmd id!");
|
LunarCore.getLogger().warn("Tried to send packet with missing cmd id!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ public class GameSession {
|
|||||||
this.send(packet.build());
|
this.send(packet.build());
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
if (LunarRail.getConfig().getLogOptions().packets) {
|
if (LunarCore.getConfig().getLogOptions().packets) {
|
||||||
logPacket("SEND", packet.getOpcode(), packet.getData());
|
logPacket("SEND", packet.getOpcode(), packet.getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ public class GameSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void logPacket(String sendOrRecv, int opcode, byte[] payload) {
|
public void logPacket(String sendOrRecv, int opcode, byte[] payload) {
|
||||||
LunarRail.getLogger().info(sendOrRecv + ": " + CmdIdUtils.getOpcodeName(opcode) + " (" + opcode + ")");
|
LunarCore.getLogger().info(sendOrRecv + ": " + CmdIdUtils.getOpcodeName(opcode) + " (" + opcode + ")");
|
||||||
System.out.println(Utils.bytesToHex(payload));
|
System.out.println(Utils.bytesToHex(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.server.game;
|
|||||||
|
|
||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
import dev.morphia.annotations.Id;
|
import dev.morphia.annotations.Id;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.database.AccountDatabaseOnly;
|
import emu.lunarcore.database.AccountDatabaseOnly;
|
||||||
import emu.lunarcore.proto.RegionEntryOuterClass.RegionEntry;
|
import emu.lunarcore.proto.RegionEntryOuterClass.RegionEntry;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -29,7 +29,7 @@ public class RegionInfo {
|
|||||||
this.id = server.getServerConfig().getId();
|
this.id = server.getServerConfig().getId();
|
||||||
this.name = server.getServerConfig().getName();
|
this.name = server.getServerConfig().getName();
|
||||||
this.desc = server.getServerConfig().getDescription();
|
this.desc = server.getServerConfig().getDescription();
|
||||||
this.gateAddress = LunarRail.getHttpServer().getServerConfig().getDisplayAddress();
|
this.gateAddress = LunarCore.getHttpServer().getServerConfig().getDisplayAddress();
|
||||||
this.up = true;
|
this.up = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +44,6 @@ public class RegionInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
LunarRail.getAccountDatabase().save(this);
|
LunarCore.getAccountDatabase().save(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import org.eclipse.jetty.server.ServerConnector;
|
|||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
|
|
||||||
import emu.lunarcore.Config.HttpServerConfig;
|
import emu.lunarcore.Config.HttpServerConfig;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.LunarRail.ServerType;
|
import emu.lunarcore.LunarCore.ServerType;
|
||||||
import emu.lunarcore.proto.DispatchRegionDataOuterClass.DispatchRegionData;
|
import emu.lunarcore.proto.DispatchRegionDataOuterClass.DispatchRegionData;
|
||||||
import emu.lunarcore.server.game.RegionInfo;
|
import emu.lunarcore.server.game.RegionInfo;
|
||||||
import emu.lunarcore.server.http.handlers.*;
|
import emu.lunarcore.server.http.handlers.*;
|
||||||
@@ -52,7 +52,7 @@ public class HttpServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HttpServerConfig getServerConfig() {
|
public HttpServerConfig getServerConfig() {
|
||||||
return LunarRail.getConfig().getHttpServer();
|
return LunarCore.getConfig().getHttpServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpConnectionFactory getHttpFactory() {
|
private HttpConnectionFactory getHttpFactory() {
|
||||||
@@ -65,8 +65,8 @@ public class HttpServer {
|
|||||||
|
|
||||||
private SslContextFactory.Server getSSLContextFactory() {
|
private SslContextFactory.Server getSSLContextFactory() {
|
||||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||||
sslContextFactory.setKeyStorePath(LunarRail.getConfig().getKeystore().getPath());
|
sslContextFactory.setKeyStorePath(LunarCore.getConfig().getKeystore().getPath());
|
||||||
sslContextFactory.setKeyStorePassword(LunarRail.getConfig().getKeystore().getPassword());
|
sslContextFactory.setKeyStorePassword(LunarCore.getConfig().getKeystore().getPassword());
|
||||||
sslContextFactory.setSniRequired(false);
|
sslContextFactory.setSniRequired(false);
|
||||||
sslContextFactory.setRenegotiationAllowed(false);
|
sslContextFactory.setRenegotiationAllowed(false);
|
||||||
return sslContextFactory;
|
return sslContextFactory;
|
||||||
@@ -84,7 +84,7 @@ public class HttpServer {
|
|||||||
this.regions.clear();
|
this.regions.clear();
|
||||||
|
|
||||||
// Pull region infos from database
|
// Pull region infos from database
|
||||||
LunarRail.getAccountDatabase().getObjects(RegionInfo.class)
|
LunarCore.getAccountDatabase().getObjects(RegionInfo.class)
|
||||||
.forEach(region -> {
|
.forEach(region -> {
|
||||||
this.regions.put(region.getId(), region);
|
this.regions.put(region.getId(), region);
|
||||||
});
|
});
|
||||||
@@ -119,8 +119,8 @@ public class HttpServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
LunarRail.getLogger().info("Http Server running as: " + this.modes.stream().collect(Collectors.joining(", ")));
|
LunarCore.getLogger().info("Http Server running as: " + this.modes.stream().collect(Collectors.joining(", ")));
|
||||||
LunarRail.getLogger().info("Http Server started on " + getServerConfig().getPort());
|
LunarCore.getLogger().info("Http Server started on " + getServerConfig().getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRoutes() {
|
private void addRoutes() {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.server.http.handlers;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.account.Account;
|
import emu.lunarcore.game.account.Account;
|
||||||
import emu.lunarcore.server.http.objects.ComboTokenReqJson;
|
import emu.lunarcore.server.http.objects.ComboTokenReqJson;
|
||||||
import emu.lunarcore.server.http.objects.ComboTokenReqJson.LoginTokenData;
|
import emu.lunarcore.server.http.objects.ComboTokenReqJson.LoginTokenData;
|
||||||
@@ -45,7 +45,7 @@ public class ComboTokenGranterHandler implements Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
Account account = LunarRail.getAccountDatabase().getObjectByField(Account.class, "_id", data.uid);
|
Account account = LunarCore.getAccountDatabase().getObjectByField(Account.class, "_id", data.uid);
|
||||||
|
|
||||||
if (account == null || !account.getDispatchToken().equals(data.token)) {
|
if (account == null || !account.getDispatchToken().equals(data.token)) {
|
||||||
res.retcode = -201;
|
res.retcode = -201;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.server.http.handlers;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.server.http.HttpServer;
|
import emu.lunarcore.server.http.HttpServer;
|
||||||
|
|
||||||
import io.javalin.http.Context;
|
import io.javalin.http.Context;
|
||||||
@@ -18,8 +18,8 @@ public class QueryDispatchHandler implements Handler {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(@NotNull Context ctx) throws Exception {
|
public void handle(@NotNull Context ctx) throws Exception {
|
||||||
// Log
|
// Log
|
||||||
if (LunarRail.getConfig().getLogOptions().connections) {
|
if (LunarCore.getConfig().getLogOptions().connections) {
|
||||||
LunarRail.getLogger().info("Client request: query_dispatch");
|
LunarCore.getLogger().info("Client request: query_dispatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send region list to client
|
// Send region list to client
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package emu.lunarcore.server.http.handlers;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.proto.GateserverOuterClass.Gateserver;
|
import emu.lunarcore.proto.GateserverOuterClass.Gateserver;
|
||||||
import emu.lunarcore.util.Utils;
|
import emu.lunarcore.util.Utils;
|
||||||
import io.javalin.http.Context;
|
import io.javalin.http.Context;
|
||||||
@@ -19,16 +19,16 @@ public class QueryGatewayHandler implements Handler {
|
|||||||
public void handle(@NotNull Context ctx) throws Exception {
|
public void handle(@NotNull Context ctx) throws Exception {
|
||||||
// Build gateserver proto
|
// Build gateserver proto
|
||||||
Gateserver gateserver = Gateserver.newInstance()
|
Gateserver gateserver = Gateserver.newInstance()
|
||||||
.setRegionName(LunarRail.getConfig().getGameServer().getId())
|
.setRegionName(LunarCore.getConfig().getGameServer().getId())
|
||||||
.setIp(LunarRail.getConfig().getGameServer().getPublicAddress())
|
.setIp(LunarCore.getConfig().getGameServer().getPublicAddress())
|
||||||
.setPort(LunarRail.getConfig().getGameServer().getPort())
|
.setPort(LunarCore.getConfig().getGameServer().getPort())
|
||||||
.setUnk1(true)
|
.setUnk1(true)
|
||||||
.setUnk2(true)
|
.setUnk2(true)
|
||||||
.setUnk3(true)
|
.setUnk3(true)
|
||||||
.setMdkResVersion(GameConstants.MDK_VERSION);
|
.setMdkResVersion(GameConstants.MDK_VERSION);
|
||||||
|
|
||||||
// Set streaming data urls
|
// Set streaming data urls
|
||||||
var data = LunarRail.getConfig().getDownloadData();
|
var data = LunarCore.getConfig().getDownloadData();
|
||||||
|
|
||||||
if (data.assetBundleUrl != null) {
|
if (data.assetBundleUrl != null) {
|
||||||
gateserver.setAssetBundleUrl(data.assetBundleUrl);
|
gateserver.setAssetBundleUrl(data.assetBundleUrl);
|
||||||
@@ -44,8 +44,8 @@ public class QueryGatewayHandler implements Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
if (LunarRail.getConfig().getLogOptions().connections) {
|
if (LunarCore.getConfig().getLogOptions().connections) {
|
||||||
LunarRail.getLogger().info("Client request: query_gateway");
|
LunarCore.getLogger().info("Client request: query_gateway");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode to base64 and send to client
|
// Encode to base64 and send to client
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.server.http.handlers;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.account.Account;
|
import emu.lunarcore.game.account.Account;
|
||||||
import emu.lunarcore.server.http.objects.LoginResJson;
|
import emu.lunarcore.server.http.objects.LoginResJson;
|
||||||
import emu.lunarcore.server.http.objects.LoginResJson.VerifyData;
|
import emu.lunarcore.server.http.objects.LoginResJson.VerifyData;
|
||||||
@@ -34,7 +34,7 @@ public class TokenLoginHandler implements Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
Account account = LunarRail.getAccountDatabase().getObjectByField(Account.class, "_id", req.uid);
|
Account account = LunarCore.getAccountDatabase().getObjectByField(Account.class, "_id", req.uid);
|
||||||
|
|
||||||
if (account == null || !account.getDispatchToken().equals(req.token)) {
|
if (account == null || !account.getDispatchToken().equals(req.token)) {
|
||||||
res.retcode = -201;
|
res.retcode = -201;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.server.http.handlers;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.account.Account;
|
import emu.lunarcore.game.account.Account;
|
||||||
import emu.lunarcore.server.http.objects.LoginAccountReqJson;
|
import emu.lunarcore.server.http.objects.LoginAccountReqJson;
|
||||||
import emu.lunarcore.server.http.objects.LoginResJson;
|
import emu.lunarcore.server.http.objects.LoginResJson;
|
||||||
@@ -34,7 +34,7 @@ public class UsernameLoginHandler implements Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
Account account = LunarRail.getAccountDatabase().getObjectByField(Account.class, "username", req.account);
|
Account account = LunarCore.getAccountDatabase().getObjectByField(Account.class, "username", req.account);
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
res.retcode = -201;
|
res.retcode = -201;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.TreeMap;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.util.JsonUtils;
|
import emu.lunarcore.util.JsonUtils;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
@@ -45,7 +45,7 @@ public class CmdIdUtils {
|
|||||||
.collect(Collectors.toMap(Int2ObjectMap.Entry::getIntKey, Int2ObjectMap.Entry::getValue, (k, v) -> v, TreeMap::new));
|
.collect(Collectors.toMap(Int2ObjectMap.Entry::getIntKey, Int2ObjectMap.Entry::getValue, (k, v) -> v, TreeMap::new));
|
||||||
// Write to file
|
// Write to file
|
||||||
writer.write(JsonUtils.encode(packetIds));
|
writer.write(JsonUtils.encode(packetIds));
|
||||||
LunarRail.getLogger().info("Dumped packet ids.");
|
LunarCore.getLogger().info("Dumped packet ids.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package emu.lunarcore.server.packet.recv;
|
|||||||
|
|
||||||
import emu.lunarcore.proto.DressAvatarCsReqOuterClass.DressAvatarCsReq;
|
import emu.lunarcore.proto.DressAvatarCsReqOuterClass.DressAvatarCsReq;
|
||||||
import emu.lunarcore.server.game.GameSession;
|
import emu.lunarcore.server.game.GameSession;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
import emu.lunarcore.server.packet.Opcodes;
|
import emu.lunarcore.server.packet.Opcodes;
|
||||||
import emu.lunarcore.server.packet.PacketHandler;
|
import emu.lunarcore.server.packet.PacketHandler;
|
||||||
@@ -15,7 +14,7 @@ public class HandlerDressAvatarCsReq extends PacketHandler {
|
|||||||
var req = DressAvatarCsReq.parseFrom(data);
|
var req = DressAvatarCsReq.parseFrom(data);
|
||||||
|
|
||||||
session.getPlayer().getInventory().equipItem(req.getBaseAvatarId(), req.getEquipmentUniqueId());
|
session.getPlayer().getInventory().equipItem(req.getBaseAvatarId(), req.getEquipmentUniqueId());
|
||||||
session.send(new BasePacket(CmdId.DressAvatarScRsp));
|
session.send(CmdId.DressAvatarScRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package emu.lunarcore.server.packet.recv;
|
|||||||
|
|
||||||
import emu.lunarcore.proto.DressRelicAvatarCsReqOuterClass.DressRelicAvatarCsReq;
|
import emu.lunarcore.proto.DressRelicAvatarCsReqOuterClass.DressRelicAvatarCsReq;
|
||||||
import emu.lunarcore.server.game.GameSession;
|
import emu.lunarcore.server.game.GameSession;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
import emu.lunarcore.server.packet.Opcodes;
|
import emu.lunarcore.server.packet.Opcodes;
|
||||||
import emu.lunarcore.server.packet.PacketHandler;
|
import emu.lunarcore.server.packet.PacketHandler;
|
||||||
@@ -18,7 +17,7 @@ public class HandlerDressRelicAvatarCsReq extends PacketHandler {
|
|||||||
session.getPlayer().getInventory().equipItem(req.getBaseAvatarId(), param.getRelicUniqueId());
|
session.getPlayer().getInventory().equipItem(req.getBaseAvatarId(), param.getRelicUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
session.send(new BasePacket(CmdId.DressRelicAvatarScRsp));
|
session.send(CmdId.DressRelicAvatarScRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import emu.lunarcore.server.packet.send.PacketGetPlayerDetailInfoScRsp;
|
|||||||
@Opcodes(CmdId.GetPlayerDetailInfoCsReq)
|
@Opcodes(CmdId.GetPlayerDetailInfoCsReq)
|
||||||
public class HandlerGetPlayerDetailInfoCsReq extends PacketHandler {
|
public class HandlerGetPlayerDetailInfoCsReq extends PacketHandler {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Override
|
@Override
|
||||||
public void handle(GameSession session, byte[] header, byte[] data) throws Exception {
|
public void handle(GameSession session, byte[] header, byte[] data) throws Exception {
|
||||||
var req = GetPlayerDetailInfoCsReq.parseFrom(data);
|
var req = GetPlayerDetailInfoCsReq.parseFrom(data);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package emu.lunarcore.server.packet.recv;
|
package emu.lunarcore.server.packet.recv;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.game.account.Account;
|
import emu.lunarcore.game.account.Account;
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.proto.PlayerGetTokenCsReqOuterClass.PlayerGetTokenCsReq;
|
import emu.lunarcore.proto.PlayerGetTokenCsReqOuterClass.PlayerGetTokenCsReq;
|
||||||
@@ -20,7 +20,7 @@ public class HandlerPlayerGetTokenCsReq extends PacketHandler {
|
|||||||
var req = PlayerGetTokenCsReq.parseFrom(data);
|
var req = PlayerGetTokenCsReq.parseFrom(data);
|
||||||
|
|
||||||
// Authenticate
|
// Authenticate
|
||||||
Account account = LunarRail.getAccountDatabase().getObjectByField(Account.class, "_id", req.getAccountUid());
|
Account account = LunarCore.getAccountDatabase().getObjectByField(Account.class, "_id", req.getAccountUid());
|
||||||
if (account == null || !account.getComboToken().equals(req.getToken())) {
|
if (account == null || !account.getComboToken().equals(req.getToken())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -29,11 +29,11 @@ public class HandlerPlayerGetTokenCsReq extends PacketHandler {
|
|||||||
session.setAccount(account);
|
session.setAccount(account);
|
||||||
|
|
||||||
// Get player from database, if it doesnt exist, we create it
|
// Get player from database, if it doesnt exist, we create it
|
||||||
Player player = LunarRail.getGameDatabase().getObjectByField(Player.class, "accountUid", account.getUid());
|
Player player = LunarCore.getGameDatabase().getObjectByField(Player.class, "accountUid", account.getUid());
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
player = new Player(session);
|
player = new Player(session);
|
||||||
LunarRail.getGameDatabase().save(player);
|
LunarCore.getGameDatabase().save(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dont let people log on to the same player at the same time
|
// Dont let people log on to the same player at the same time
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package emu.lunarcore.server.packet.recv;
|
package emu.lunarcore.server.packet.recv;
|
||||||
|
|
||||||
import emu.lunarcore.server.game.GameSession;
|
import emu.lunarcore.server.game.GameSession;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
import emu.lunarcore.server.packet.Opcodes;
|
import emu.lunarcore.server.packet.Opcodes;
|
||||||
import emu.lunarcore.server.packet.PacketHandler;
|
import emu.lunarcore.server.packet.PacketHandler;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package emu.lunarcore.server.packet.recv;
|
|||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.proto.TakeOffEquipmentCsReqOuterClass.TakeOffEquipmentCsReq;
|
import emu.lunarcore.proto.TakeOffEquipmentCsReqOuterClass.TakeOffEquipmentCsReq;
|
||||||
import emu.lunarcore.server.game.GameSession;
|
import emu.lunarcore.server.game.GameSession;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
import emu.lunarcore.server.packet.Opcodes;
|
import emu.lunarcore.server.packet.Opcodes;
|
||||||
import emu.lunarcore.server.packet.PacketHandler;
|
import emu.lunarcore.server.packet.PacketHandler;
|
||||||
@@ -16,7 +15,7 @@ public class HandlerTakeOffEquipmentCsReq extends PacketHandler {
|
|||||||
var req = TakeOffEquipmentCsReq.parseFrom(data);
|
var req = TakeOffEquipmentCsReq.parseFrom(data);
|
||||||
|
|
||||||
session.getPlayer().getInventory().unequipItem(req.getBaseAvatarId(), GameConstants.EQUIPMENT_SLOT_ID);
|
session.getPlayer().getInventory().unequipItem(req.getBaseAvatarId(), GameConstants.EQUIPMENT_SLOT_ID);
|
||||||
session.send(new BasePacket(CmdId.TakeOffEquipmentScRsp));
|
session.send(CmdId.TakeOffEquipmentScRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package emu.lunarcore.server.packet.recv;
|
|||||||
|
|
||||||
import emu.lunarcore.proto.TakeOffRelicCsReqOuterClass.TakeOffRelicCsReq;
|
import emu.lunarcore.proto.TakeOffRelicCsReqOuterClass.TakeOffRelicCsReq;
|
||||||
import emu.lunarcore.server.game.GameSession;
|
import emu.lunarcore.server.game.GameSession;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
import emu.lunarcore.server.packet.Opcodes;
|
import emu.lunarcore.server.packet.Opcodes;
|
||||||
import emu.lunarcore.server.packet.PacketHandler;
|
import emu.lunarcore.server.packet.PacketHandler;
|
||||||
@@ -18,7 +17,7 @@ public class HandlerTakeOffRelicCsReq extends PacketHandler {
|
|||||||
session.getPlayer().getInventory().unequipItem(req.getBaseAvatarId(), slot);
|
session.getPlayer().getInventory().unequipItem(req.getBaseAvatarId(), slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.send(new BasePacket(CmdId.TakeOffRelicScRsp));
|
session.send(CmdId.TakeOffRelicScRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import emu.lunarcore.server.game.GameSession;
|
|||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
import emu.lunarcore.server.packet.Opcodes;
|
import emu.lunarcore.server.packet.Opcodes;
|
||||||
import emu.lunarcore.server.packet.PacketHandler;
|
import emu.lunarcore.server.packet.PacketHandler;
|
||||||
import emu.lunarcore.server.packet.send.PacketTakePromotionRewardScRsp;
|
|
||||||
|
|
||||||
@Opcodes(CmdId.TakePromotionRewardCsReq)
|
@Opcodes(CmdId.TakePromotionRewardCsReq)
|
||||||
public class HandlerTakePromotionRewardCsReq extends PacketHandler {
|
public class HandlerTakePromotionRewardCsReq extends PacketHandler {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package emu.lunarcore.server.packet.send;
|
package emu.lunarcore.server.packet.send;
|
||||||
|
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.proto.ArchiveDataOuterClass.ArchiveData;
|
|
||||||
import emu.lunarcore.proto.GetArchiveDataScRspOuterClass.GetArchiveDataScRsp;
|
import emu.lunarcore.proto.GetArchiveDataScRspOuterClass.GetArchiveDataScRsp;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
import emu.lunarcore.server.packet.BasePacket;
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package emu.lunarcore.server.packet.send;
|
|||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
|
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
|
||||||
import emu.lunarcore.proto.SceneEntityMoveScNotifyOuterClass.SceneEntityMoveScNotify;
|
import emu.lunarcore.proto.SceneEntityMoveScNotifyOuterClass.SceneEntityMoveScNotify;
|
||||||
import emu.lunarcore.proto.VectorOuterClass.Vector;
|
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
import emu.lunarcore.server.packet.BasePacket;
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package emu.lunarcore.server.packet.send;
|
package emu.lunarcore.server.packet.send;
|
||||||
|
|
||||||
import emu.lunarcore.game.player.Player;
|
import emu.lunarcore.game.player.Player;
|
||||||
import emu.lunarcore.proto.ChallengeInfoOuterClass.ChallengeInfo;
|
|
||||||
import emu.lunarcore.proto.ChallengeStatusOuterClass.ChallengeStatus;
|
|
||||||
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
|
|
||||||
import emu.lunarcore.proto.StartChallengeScRspOuterClass.StartChallengeScRsp;
|
import emu.lunarcore.proto.StartChallengeScRspOuterClass.StartChallengeScRsp;
|
||||||
import emu.lunarcore.server.packet.BasePacket;
|
import emu.lunarcore.server.packet.BasePacket;
|
||||||
import emu.lunarcore.server.packet.CmdId;
|
import emu.lunarcore.server.packet.CmdId;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package emu.lunarcore.util;
|
|||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
|
|
||||||
public final class Crypto {
|
public final class Crypto {
|
||||||
private static final SecureRandom secureRandom = new SecureRandom();
|
private static final SecureRandom secureRandom = new SecureRandom();
|
||||||
@@ -13,7 +13,7 @@ public final class Crypto {
|
|||||||
packet[i] ^= key[i % key.length];
|
packet[i] ^= key[i % key.length];
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LunarRail.getLogger().error("Crypto error.", e);
|
LunarCore.getLogger().error("Crypto error.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
public static void write(String dest, byte[] bytes) {
|
public static void write(String dest, byte[] bytes) {
|
||||||
@@ -15,7 +15,7 @@ public class FileUtils {
|
|||||||
try {
|
try {
|
||||||
Files.write(path, bytes);
|
Files.write(path, bytes);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LunarRail.getLogger().warn("Failed to write file: " + dest);
|
LunarCore.getLogger().warn("Failed to write file: " + dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ public class FileUtils {
|
|||||||
try {
|
try {
|
||||||
return Files.readAllBytes(path);
|
return Files.readAllBytes(path);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LunarRail.getLogger().warn("Failed to read file: " + path);
|
LunarCore.getLogger().warn("Failed to read file: " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import emu.lunarcore.GameConstants;
|
import emu.lunarcore.GameConstants;
|
||||||
import emu.lunarcore.LunarRail;
|
import emu.lunarcore.LunarCore;
|
||||||
import emu.lunarcore.command.Command;
|
import emu.lunarcore.command.Command;
|
||||||
import emu.lunarcore.data.GameData;
|
import emu.lunarcore.data.GameData;
|
||||||
import emu.lunarcore.data.excel.*;
|
import emu.lunarcore.data.excel.*;
|
||||||
@@ -24,14 +24,14 @@ public class Handbook {
|
|||||||
List<Integer> list = null;
|
List<Integer> list = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
textMap = JsonUtils.loadToMap(LunarRail.getConfig().getResourceDir() + "/TextMap/TextMapEN.json", Long.class, String.class);
|
textMap = JsonUtils.loadToMap(LunarCore.getConfig().getResourceDir() + "/TextMap/TextMapEN.json", Long.class, String.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save to file
|
// Save to file
|
||||||
String file = "./Star Rail Handbook.txt";
|
String file = "./Lunar Core Handbook.txt";
|
||||||
|
|
||||||
try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), true)) {
|
try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), true)) {
|
||||||
// Format date for header
|
// Format date for header
|
||||||
@@ -46,7 +46,7 @@ public class Handbook {
|
|||||||
writer.println(System.lineSeparator());
|
writer.println(System.lineSeparator());
|
||||||
writer.println("# Commands");
|
writer.println("# Commands");
|
||||||
list = GameData.getAvatarExcelMap().keySet().intStream().sorted().boxed().toList();
|
list = GameData.getAvatarExcelMap().keySet().intStream().sorted().boxed().toList();
|
||||||
for (var entry : LunarRail.getCommandManager().getLabels().entrySet()) {
|
for (var entry : LunarCore.getCommandManager().getLabels().entrySet()) {
|
||||||
Command command = entry.getValue().getClass().getAnnotation(Command.class);
|
Command command = entry.getValue().getClass().getAnnotation(Command.class);
|
||||||
if (command == null) continue;
|
if (command == null) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import emu.lunarcore.Config;
|
|
||||||
|
|
||||||
public class JsonUtils {
|
public class JsonUtils {
|
||||||
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
private static final Gson gsonCompact = new GsonBuilder().create();
|
private static final Gson gsonCompact = new GsonBuilder().create();
|
||||||
|
|||||||
Reference in New Issue
Block a user