mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[ANY] Рефакторинг.
This commit is contained in:
parent
7755891139
commit
b17c70255f
54 changed files with 179 additions and 308 deletions
|
@ -38,7 +38,6 @@
|
|||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.managers.ConfigManager;
|
||||
import pro.gravit.launcher.managers.GarbageManager;
|
||||
import pro.gravit.launcher.modules.LauncherModulesManager;
|
||||
import pro.gravit.launcher.modules.events.ClosePhase;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
|
@ -50,7 +49,10 @@
|
|||
import pro.gravit.launchserver.binary.SimpleEXELauncherBinary;
|
||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
|
||||
import pro.gravit.launchserver.manangers.*;
|
||||
import pro.gravit.launchserver.manangers.CertificateManager;
|
||||
import pro.gravit.launchserver.manangers.MirrorManager;
|
||||
import pro.gravit.launchserver.manangers.ReconfigurableManager;
|
||||
import pro.gravit.launchserver.manangers.SessionManager;
|
||||
import pro.gravit.launchserver.manangers.hook.AuthHookManager;
|
||||
import pro.gravit.launchserver.manangers.hook.BuildHookManager;
|
||||
import pro.gravit.launchserver.modules.events.LaunchServerFullInitEvent;
|
||||
|
@ -59,7 +61,9 @@
|
|||
import pro.gravit.launchserver.modules.events.NewLaunchServerInstanceEvent;
|
||||
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
|
||||
import pro.gravit.utils.command.*;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package pro.gravit.launchserver;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
|
||||
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
||||
public class LaunchServerBuilder {
|
||||
private LaunchServerConfig config;
|
||||
private LaunchServerRuntimeConfig runtimeConfig;
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
package pro.gravit.launchserver;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.hwid.HWIDProvider;
|
||||
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||
|
@ -24,16 +34,6 @@
|
|||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
||||
public class LaunchServerStarter {
|
||||
public static void main(String[] args) throws Exception {
|
||||
JVMHelper.checkStackTrace(LaunchServerStarter.class);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.gravit.launchserver;
|
||||
|
||||
import pro.gravit.utils.command.Command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import pro.gravit.utils.command.Command;
|
||||
|
||||
/**
|
||||
* Allows calling commands using the config command
|
||||
*/
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package pro.gravit.launchserver.auth;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.postgresql.ds.PGSimpleDataSource;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import org.postgresql.ds.PGSimpleDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public final class PostgreSQLSourceConfig implements AutoCloseable {
|
||||
public static final int TIMEOUT = VerifyHelper.verifyInt(
|
||||
Integer.parseUnsignedInt(System.getProperty("launcher.postgresql.idleTimeout", Integer.toString(5000))),
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.*;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection, Reconfigurable {
|
||||
public static final class Entry {
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package pro.gravit.launchserver.auth.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.postgresql.util.PGobject;
|
||||
|
||||
import pro.gravit.launchserver.auth.PostgreSQLSourceConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class PostgreSQLAuthHandler extends CachedAuthHandler {
|
||||
private PostgreSQLSourceConfig postgreSQLHolder;
|
||||
private String uuidColumn;
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
|
|
|
@ -9,7 +9,13 @@
|
|||
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.binary.tasks.*;
|
||||
import pro.gravit.launchserver.binary.tasks.AdditionalFixesApplyTask;
|
||||
import pro.gravit.launchserver.binary.tasks.AttachJarsTask;
|
||||
import pro.gravit.launchserver.binary.tasks.CompressBuildTask;
|
||||
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
||||
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
|
||||
import pro.gravit.launchserver.binary.tasks.PrepareBuildTask;
|
||||
import pro.gravit.launchserver.binary.tasks.ProGuardBuildTask;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
|
@ -12,15 +13,10 @@
|
|||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.TypeInsnNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import pro.gravit.launcher.AutogenConfig;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.LauncherConfig;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModulesManager;
|
||||
import pro.gravit.launcher.modules.Module;
|
||||
import pro.gravit.launcher.modules.ModulesManager;
|
||||
import pro.gravit.launchserver.asm.ClassMetadataReader;
|
||||
import pro.gravit.launchserver.asm.SafeClassWriter;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package pro.gravit.launchserver.binary;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class SimpleEXELauncherBinary extends LauncherBinary {
|
||||
public Path exeTemplate;
|
||||
public SimpleEXELauncherBinary(LaunchServer server) {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package pro.gravit.launchserver.binary.tasks;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.zip.Deflater;
|
||||
|
@ -10,6 +7,9 @@
|
|||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
public class CompressBuildTask implements LauncherBuildTask {
|
||||
public transient final LaunchServer server;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.gravit.launchserver.command;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
|
||||
public abstract class Command extends pro.gravit.utils.command.Command {
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,13 @@
|
|||
import pro.gravit.launchserver.command.install.MultiCommand;
|
||||
import pro.gravit.launchserver.command.modules.LoadModuleCommand;
|
||||
import pro.gravit.launchserver.command.modules.ModulesCommand;
|
||||
import pro.gravit.launchserver.command.service.*;
|
||||
import pro.gravit.launchserver.command.service.ClientsCommand;
|
||||
import pro.gravit.launchserver.command.service.ComponentCommand;
|
||||
import pro.gravit.launchserver.command.service.ConfigCommand;
|
||||
import pro.gravit.launchserver.command.service.GetModulusCommand;
|
||||
import pro.gravit.launchserver.command.service.GetPermissionsCommand;
|
||||
import pro.gravit.launchserver.command.service.GivePermissionsCommand;
|
||||
import pro.gravit.launchserver.command.service.ServerStatusCommand;
|
||||
import pro.gravit.utils.command.BaseCommandCategory;
|
||||
import pro.gravit.utils.command.basic.ClearCommand;
|
||||
import pro.gravit.utils.command.basic.DebugCommand;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launchserver.command.modules;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package pro.gravit.launchserver.components;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import pro.gravit.launcher.NeedGarbageCollection;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package pro.gravit.launchserver.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
|
@ -24,12 +30,6 @@
|
|||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class LaunchServerConfig {
|
||||
private transient LaunchServer server = null;
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package pro.gravit.launchserver.dao.provider;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.launchserver.dao.UserHWID;
|
||||
|
@ -8,8 +11,6 @@
|
|||
import pro.gravit.launchserver.dao.impl.HibernateUserDAOImpl;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class HibernateDaoProvider extends DaoProvider {
|
||||
public String driver;
|
||||
public String url;
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package pro.gravit.launchserver.modules;
|
||||
|
||||
import pro.gravit.launcher.modules.Module;
|
||||
import pro.gravit.launcher.modules.ModuleContext;
|
||||
import pro.gravit.utils.Version;
|
||||
|
||||
public class CoreModule implements Module {
|
||||
@Override
|
||||
public void close() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "LaunchServer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return Version.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ModuleContext context) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(ModuleContext context) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preInit(ModuleContext context) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package pro.gravit.launchserver.modules;
|
||||
|
||||
import pro.gravit.launcher.managers.SimpleModulesConfigManager;
|
||||
import pro.gravit.launcher.modules.ModuleContext;
|
||||
import pro.gravit.launcher.modules.ModulesConfigManager;
|
||||
import pro.gravit.launcher.modules.ModulesManager;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.PublicURLClassLoader;
|
||||
|
||||
public class LaunchServerModuleContext implements ModuleContext {
|
||||
public final LaunchServer launchServer;
|
||||
public final PublicURLClassLoader classloader;
|
||||
public final SimpleModulesConfigManager modulesConfigManager;
|
||||
|
||||
public LaunchServerModuleContext(LaunchServer server, PublicURLClassLoader classloader, SimpleModulesConfigManager modulesConfigManager) {
|
||||
launchServer = server;
|
||||
this.classloader = classloader;
|
||||
this.modulesConfigManager = modulesConfigManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.LAUNCHSERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModulesManager getModulesManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModulesConfigManager getModulesConfigManager() {
|
||||
return modulesConfigManager;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package pro.gravit.launchserver.modules;
|
||||
|
||||
import pro.gravit.launcher.modules.Module;
|
||||
import pro.gravit.launcher.modules.ModuleContext;
|
||||
import pro.gravit.utils.Version;
|
||||
|
||||
public class SimpleModule implements Module {
|
||||
@Override
|
||||
public void close() {
|
||||
// on stop
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SimpleModule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return new Version(1, 0, 0, 0, Version.Type.UNKNOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ModuleContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(ModuleContext context) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preInit(ModuleContext context) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launchserver.modules.events;
|
||||
|
||||
import pro.gravit.launcher.modules.events.InitPhase;
|
||||
import pro.gravit.launcher.modules.events.PostInitPhase;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
import pro.gravit.launcher.modules.events.InitPhase;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class LaunchServerCoreModule extends LauncherModule {
|
||||
public LaunchServerCoreModule() {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package pro.gravit.launchserver.modules.impl;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LaunchServerModulesManager extends SimpleModuleManager {
|
||||
public LaunchServerCoreModule coreModule;
|
||||
public LaunchServerModulesManager(Path modulesDir, Path configDir) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package pro.gravit.launchserver.socket;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
|
@ -42,7 +41,6 @@
|
|||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class WebSocketService {
|
||||
public final ChannelGroup channels;
|
||||
public static ProviderMap<WebSocketServerResponse> providers = new ProviderMap<>();
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.auth.AuthException;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package pro.gravit.launchserver.socket.response.auth;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
|
||||
public class RegisterResponse extends SimpleResponse {
|
||||
public String login;
|
||||
public String password;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
package pro.gravit.launchserver;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.managers.SimpleModulesConfigManager;
|
||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
|
||||
import pro.gravit.launchserver.manangers.LaunchServerGsonManager;
|
||||
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||
import pro.gravit.utils.command.StdCommandHandler;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
|
||||
import pro.gravit.launchserver.manangers.LaunchServerGsonManager;
|
||||
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||
import pro.gravit.utils.command.StdCommandHandler;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public class StartLaunchServerTest {
|
||||
@TempDir
|
||||
public static Path modulesDir;
|
||||
|
@ -30,7 +30,6 @@ public class StartLaunchServerTest {
|
|||
public static void prepare() throws Exception
|
||||
{
|
||||
LaunchServerModulesManager modulesManager = new LaunchServerModulesManager(modulesDir, configDir);
|
||||
SimpleModulesConfigManager configManager = new SimpleModulesConfigManager(configDir);
|
||||
LaunchServerConfig config = LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST);
|
||||
Launcher.gsonManager = new LaunchServerGsonManager(modulesManager);
|
||||
Launcher.gsonManager.initGson();
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
import pro.gravit.launcher.managers.ClientGsonManager;
|
||||
import pro.gravit.launcher.managers.ClientHookManager;
|
||||
import pro.gravit.launcher.managers.ConsoleManager;
|
||||
import pro.gravit.launcher.modules.LauncherModulesManager;
|
||||
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
import pro.gravit.launcher.request.RequestException;
|
||||
import pro.gravit.launcher.request.auth.RestoreSessionRequest;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package pro.gravit.launcher.client;
|
||||
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
|
||||
public class ClientModuleManager extends SimpleModuleManager {
|
||||
public ClientModuleManager() {
|
||||
super(null, null);
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.LauncherAPI;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.guard.LauncherGuardManager;
|
||||
import pro.gravit.launcher.hasher.FileNameMatcher;
|
||||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWIDProvider;
|
||||
import pro.gravit.launcher.managers.ConsoleManager;
|
||||
import pro.gravit.launcher.managers.HasherManager;
|
||||
import pro.gravit.launcher.managers.HasherStore;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class FunctionalBridge {
|
||||
@LauncherAPI
|
||||
|
|
|
@ -11,7 +11,12 @@
|
|||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import pro.gravit.launcher.*;
|
||||
import pro.gravit.launcher.JSApplication;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.LauncherAPI;
|
||||
import pro.gravit.launcher.LauncherConfig;
|
||||
import pro.gravit.launcher.LauncherEngine;
|
||||
import pro.gravit.launcher.NewLauncherSettings;
|
||||
import pro.gravit.launcher.client.ClientLauncher;
|
||||
import pro.gravit.launcher.client.DirBridge;
|
||||
import pro.gravit.launcher.client.FunctionalBridge;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import pro.gravit.launcher.managers.GsonManager;
|
||||
import pro.gravit.launcher.modules.ModulesManager;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.serialize.HInput;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
|
|
@ -8,9 +8,15 @@
|
|||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
@ -22,7 +28,10 @@
|
|||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.client.LaxRedirectStrategy;
|
||||
|
||||
import pro.gravit.utils.helper.*;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public class ListDownloader {
|
||||
private static final AtomicInteger COUNTER_THR = new AtomicInteger(0);
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
public abstract class LauncherModule {
|
||||
private LauncherModulesContext context;
|
||||
|
||||
private Map<Class<? extends Event>, EventHandler> eventMap = new HashMap<>();
|
||||
@SuppressWarnings("rawtypes")
|
||||
private Map<Class<? extends Event>, EventHandler> eventMap = new HashMap<>();
|
||||
protected LauncherModulesManager modulesManager;
|
||||
protected final LauncherModuleInfo moduleInfo;
|
||||
protected ModulesConfigManager modulesConfigManager;
|
||||
|
@ -154,7 +155,7 @@ protected <T extends Event> boolean registerEvent(EventHandler<T> handle, Class<
|
|||
public final <T extends Event> void callEvent(T event)
|
||||
{
|
||||
Class<? extends Event> tClass = event.getClass();
|
||||
for(Map.Entry<Class<? extends Event>, EventHandler> e : eventMap.entrySet())
|
||||
for(@SuppressWarnings("rawtypes") Map.Entry<Class<? extends Event>, EventHandler> e : eventMap.entrySet())
|
||||
{
|
||||
|
||||
if(e.getKey().isAssignableFrom(tClass))
|
||||
|
|
|
@ -13,7 +13,7 @@ public LauncherModuleInfo(String name, Version version) {
|
|||
this.name = name;
|
||||
this.version = version;
|
||||
this.priority = 0;
|
||||
this.dependencies = new String[]{};
|
||||
this.dependencies = new String[0];
|
||||
providers = new String[0];
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public LauncherModuleInfo(String name) {
|
|||
this.name = name;
|
||||
this.version = new Version(1,0,0);
|
||||
this.priority = 0;
|
||||
this.dependencies = new String[]{};
|
||||
this.dependencies = new String[0];
|
||||
providers = new String[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package pro.gravit.launcher.modules;
|
||||
|
||||
import pro.gravit.utils.Version;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import pro.gravit.utils.Version;
|
||||
|
||||
public interface LauncherModulesManager {
|
||||
|
||||
LauncherModule loadModule(LauncherModule module);
|
||||
|
@ -23,6 +23,7 @@ default <T extends LauncherModule> boolean containsModule(Class<? extends T> cl
|
|||
return getModule(clazz) != null;
|
||||
}
|
||||
ClassLoader getModuleClassLoader();
|
||||
ModulesConfigManager getConfigManager();
|
||||
<T extends LauncherModule> T getModule(Class<? extends T> clazz);
|
||||
<T> T getModuleByInterface(Class<T> clazz);
|
||||
<T> List<T> getModulesByInterface(Class<T> clazz);
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package pro.gravit.launcher.modules;
|
||||
|
||||
import pro.gravit.utils.Version;
|
||||
@Deprecated
|
||||
public interface Module extends AutoCloseable {
|
||||
|
||||
String getName();
|
||||
|
||||
Version getVersion();
|
||||
|
||||
int getPriority();
|
||||
|
||||
void init(ModuleContext context);
|
||||
|
||||
void postInit(ModuleContext context);
|
||||
|
||||
void preInit(ModuleContext context);
|
||||
|
||||
default void finish(ModuleContext context) {
|
||||
// NOP
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package pro.gravit.launcher.modules;
|
||||
@Deprecated
|
||||
public interface ModuleContext {
|
||||
enum Type {
|
||||
SERVER, CLIENT, LAUNCHSERVER
|
||||
}
|
||||
|
||||
Type getType();
|
||||
|
||||
ModulesManager getModulesManager();
|
||||
|
||||
ModulesConfigManager getModulesConfigManager();
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package pro.gravit.launcher.modules;
|
||||
|
||||
import java.net.URL;
|
||||
@Deprecated
|
||||
public interface ModulesManager extends AutoCloseable {
|
||||
void initModules();
|
||||
|
||||
void load(Module module);
|
||||
|
||||
void loadModule(URL jarpath) throws Exception;
|
||||
|
||||
void loadModule(URL jarpath, String classname) throws Exception;
|
||||
|
||||
void postInitModules();
|
||||
|
||||
void preInitModules();
|
||||
|
||||
void finishModules();
|
||||
|
||||
void printModules();
|
||||
|
||||
void sort();
|
||||
|
||||
void registerModule(Module module);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package pro.gravit.launcher.modules.events;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
|
||||
public class PreGsonPhase extends LauncherModule.Event {
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package pro.gravit.launcher.modules.impl;
|
||||
|
||||
import pro.gravit.launcher.managers.SimpleModulesConfigManager;
|
||||
import pro.gravit.launcher.modules.*;
|
||||
import pro.gravit.utils.PublicURLClassLoader;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.FileVisitResult;
|
||||
|
@ -20,6 +13,17 @@
|
|||
import java.util.function.Predicate;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import pro.gravit.launcher.managers.SimpleModulesConfigManager;
|
||||
import pro.gravit.launcher.modules.LauncherInitContext;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
import pro.gravit.launcher.modules.LauncherModulesManager;
|
||||
import pro.gravit.launcher.modules.ModulesConfigManager;
|
||||
import pro.gravit.utils.PublicURLClassLoader;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class SimpleModuleManager implements LauncherModulesManager {
|
||||
protected final List<LauncherModule> modules = new ArrayList<>();
|
||||
protected final List<String> moduleNames = new ArrayList<>();
|
||||
|
@ -219,4 +223,9 @@ public <T extends LauncherModule.Event> void invokeEvent(T event) {
|
|||
if(event.isCancel()) return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModulesConfigManager getConfigManager() {
|
||||
return modulesConfigManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package pro.gravit.launcher;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import pro.gravit.launcher.impl.*;
|
||||
|
||||
import pro.gravit.launcher.impl.Cyclic2DependModule;
|
||||
import pro.gravit.launcher.impl.CyclicDependModule;
|
||||
import pro.gravit.launcher.impl.Depend1Module;
|
||||
import pro.gravit.launcher.impl.Depend2Module;
|
||||
import pro.gravit.launcher.impl.Depend3Module;
|
||||
import pro.gravit.launcher.impl.MainModule;
|
||||
import pro.gravit.launcher.impl.TestModule;
|
||||
import pro.gravit.launcher.impl.event.CancelEvent;
|
||||
import pro.gravit.launcher.impl.event.NormalEvent;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ModulesTest {
|
||||
@TempDir
|
||||
public static Path configDir;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package pro.gravit.launcher.impl;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import pro.gravit.launcher.modules.LauncherInitContext;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launcher.impl;
|
||||
|
||||
import pro.gravit.launcher.ModulesTest;
|
||||
import pro.gravit.launcher.modules.LauncherInitContext;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launcher.impl;
|
||||
|
||||
import pro.gravit.launcher.ModulesTest;
|
||||
import pro.gravit.launcher.modules.LauncherInitContext;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package pro.gravit.launcher.impl;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import pro.gravit.launcher.ModulesTest;
|
||||
|
||||
import pro.gravit.launcher.modules.LauncherInitContext;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package pro.gravit.utils.command;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jline.reader.Candidate;
|
||||
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class Command {
|
||||
|
|
|
@ -32,9 +32,6 @@ public Category(CommandCategory category, String name, String description) {
|
|||
|
||||
public void eval(String line, boolean bell) {
|
||||
LogHelper.info("Command '%s'", line);
|
||||
|
||||
// Parse line to tokens
|
||||
String[] args;
|
||||
try {
|
||||
evalNative(line, bell);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
|
||||
public class StdCommandHandler extends CommandHandler {
|
||||
private final BufferedReader reader;
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.gravit.launcher.impl.Test2Command;
|
||||
import pro.gravit.launcher.impl.TestCommand;
|
||||
import pro.gravit.utils.command.*;
|
||||
import pro.gravit.utils.command.BaseCommandCategory;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
import pro.gravit.utils.command.StdCommandHandler;
|
||||
|
||||
|
||||
public class CommandHandlerTest {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package pro.gravit.launcher;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import pro.gravit.utils.ProviderMap;
|
||||
import pro.gravit.utils.UniversalJsonAdapter;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package pro.gravit.launcher.server;
|
||||
|
||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
|
||||
public class ServerWrapperModulesManager extends SimpleModuleManager {
|
||||
public ServerWrapperModulesManager(Path modulesDir, Path configDir) {
|
||||
super(modulesDir, configDir);
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit 03cb8cb081fe48755e691f5ed56f0d2da6a1ca2f
|
||||
Subproject commit 577d7c53dd972d8a5988bd02357b7d4458e30bbf
|
Loading…
Reference in a new issue