mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] GetConnectUUIDCommand, shardId
This commit is contained in:
parent
3152758d31
commit
666644c9e0
5 changed files with 40 additions and 4 deletions
|
@ -115,11 +115,12 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
||||||
public final AtomicBoolean started = new AtomicBoolean(false);
|
public final AtomicBoolean started = new AtomicBoolean(false);
|
||||||
public final LauncherModuleLoader launcherModuleLoader;
|
public final LauncherModuleLoader launcherModuleLoader;
|
||||||
private final Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
public final int shardId;
|
||||||
public LaunchServerConfig config;
|
public LaunchServerConfig config;
|
||||||
// Updates and profiles
|
// Updates and profiles
|
||||||
private volatile Set<ClientProfile> profilesList;
|
private volatile Set<ClientProfile> profilesList;
|
||||||
|
|
||||||
public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, LaunchServerConfig config, LaunchServerRuntimeConfig runtimeConfig, LaunchServerConfigManager launchServerConfigManager, LaunchServerModulesManager modulesManager, KeyAgreementManager keyAgreementManager, CommandHandler commandHandler, CertificateManager certificateManager) throws IOException {
|
public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, LaunchServerConfig config, LaunchServerRuntimeConfig runtimeConfig, LaunchServerConfigManager launchServerConfigManager, LaunchServerModulesManager modulesManager, KeyAgreementManager keyAgreementManager, CommandHandler commandHandler, CertificateManager certificateManager, int shardId) throws IOException {
|
||||||
this.dir = directories.dir;
|
this.dir = directories.dir;
|
||||||
this.tmpDir = directories.tmpDir;
|
this.tmpDir = directories.tmpDir;
|
||||||
this.env = env;
|
this.env = env;
|
||||||
|
@ -136,6 +137,7 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
||||||
launcherLibraries = directories.launcherLibrariesDir;
|
launcherLibraries = directories.launcherLibrariesDir;
|
||||||
launcherLibrariesCompile = directories.launcherLibrariesCompileDir;
|
launcherLibrariesCompile = directories.launcherLibrariesCompileDir;
|
||||||
launcherPack = directories.launcherPackDir;
|
launcherPack = directories.launcherPackDir;
|
||||||
|
this.shardId = shardId;
|
||||||
if(!Files.isDirectory(launcherPack)) {
|
if(!Files.isDirectory(launcherPack)) {
|
||||||
Files.createDirectories(launcherPack);
|
Files.createDirectories(launcherPack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class LaunchServerBuilder {
|
||||||
private KeyAgreementManager keyAgreementManager;
|
private KeyAgreementManager keyAgreementManager;
|
||||||
private CertificateManager certificateManager;
|
private CertificateManager certificateManager;
|
||||||
private LaunchServer.LaunchServerConfigManager launchServerConfigManager;
|
private LaunchServer.LaunchServerConfigManager launchServerConfigManager;
|
||||||
|
private Integer shardId;
|
||||||
|
|
||||||
public LaunchServerBuilder setConfig(LaunchServerConfig config) {
|
public LaunchServerBuilder setConfig(LaunchServerConfig config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -55,6 +56,11 @@ public LaunchServerBuilder setDir(Path dir) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LaunchServerBuilder setShardId(Integer shardId) {
|
||||||
|
this.shardId = shardId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public LaunchServerBuilder setLaunchServerConfigManager(LaunchServer.LaunchServerConfigManager launchServerConfigManager) {
|
public LaunchServerBuilder setLaunchServerConfigManager(LaunchServer.LaunchServerConfigManager launchServerConfigManager) {
|
||||||
this.launchServerConfigManager = launchServerConfigManager;
|
this.launchServerConfigManager = launchServerConfigManager;
|
||||||
return this;
|
return this;
|
||||||
|
@ -68,7 +74,10 @@ public LaunchServer build() throws Exception {
|
||||||
if (keyAgreementManager == null) {
|
if (keyAgreementManager == null) {
|
||||||
keyAgreementManager = new KeyAgreementManager(directories.keyDirectory);
|
keyAgreementManager = new KeyAgreementManager(directories.keyDirectory);
|
||||||
}
|
}
|
||||||
return new LaunchServer(directories, env, config, runtimeConfig, launchServerConfigManager, modulesManager, keyAgreementManager, commandHandler, certificateManager);
|
if(shardId == null) {
|
||||||
|
shardId = Integer.parseInt(System.getProperty("launchserver.shardId", "0"));
|
||||||
|
}
|
||||||
|
return new LaunchServer(directories, env, config, runtimeConfig, launchServerConfigManager, modulesManager, keyAgreementManager, commandHandler, certificateManager, shardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LaunchServerBuilder setCertificateManager(CertificateManager certificateManager) {
|
public LaunchServerBuilder setCertificateManager(CertificateManager certificateManager) {
|
||||||
|
|
|
@ -13,6 +13,6 @@ public String getType() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
sendResult(new GetConnectUUIDRequestEvent(connectUUID));
|
sendResult(new GetConnectUUIDRequestEvent(connectUUID, server.shardId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package pro.gravit.launcher.runtime.console;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.base.request.management.GetConnectUUIDRequest;
|
||||||
|
import pro.gravit.utils.command.Command;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
public class GetConnectUUIDCommand extends Command {
|
||||||
|
@Override
|
||||||
|
public String getArgsDescription() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsageDescription() {
|
||||||
|
return "Get your connectUUID";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(String... args) throws Exception {
|
||||||
|
var response = new GetConnectUUIDRequest().request();
|
||||||
|
LogHelper.info("Your connectUUID: %s | shardId %d", response.connectUUID.toString(), response.shardId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,9 +6,11 @@
|
||||||
|
|
||||||
public class GetConnectUUIDRequestEvent extends RequestEvent {
|
public class GetConnectUUIDRequestEvent extends RequestEvent {
|
||||||
public UUID connectUUID;
|
public UUID connectUUID;
|
||||||
|
public int shardId;
|
||||||
|
|
||||||
public GetConnectUUIDRequestEvent(UUID connectUUID) {
|
public GetConnectUUIDRequestEvent(UUID connectUUID, int shardId) {
|
||||||
this.connectUUID = connectUUID;
|
this.connectUUID = connectUUID;
|
||||||
|
this.shardId = shardId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue