mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] ClientProcessBuilder events
This commit is contained in:
parent
eef76a2b4e
commit
30cd1f21f0
3 changed files with 24 additions and 5 deletions
|
@ -3,8 +3,10 @@
|
|||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.LauncherEngine;
|
||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||
import pro.gravit.launcher.guard.LauncherGuardInterface;
|
||||
import pro.gravit.launcher.guard.LauncherGuardManager;
|
||||
import pro.gravit.launcher.client.events.client.ClientProcessBuilderCreateEvent;
|
||||
import pro.gravit.launcher.client.events.client.ClientProcessBuilderLaunchedEvent;
|
||||
import pro.gravit.launcher.client.events.client.ClientProcessBuilderParamsWrittedEvent;
|
||||
import pro.gravit.launcher.client.events.client.ClientProcessBuilderPreLaunchEvent;
|
||||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||
|
@ -13,10 +15,7 @@
|
|||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
|
@ -87,6 +86,7 @@ private void applyClientProfile()
|
|||
this.jvmArgs.add("-Xmx" + params.ram + 'M');
|
||||
}
|
||||
this.params.session = Request.getSession();
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderCreateEvent(this));
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,6 +215,7 @@ private void addModernClientArgs(Collection<String> args) {
|
|||
public void start(boolean pipeOutput) throws IOException, InterruptedException {
|
||||
if(isStarted) throw new IllegalStateException("Process already started");
|
||||
if(LauncherEngine.guard != null) LauncherEngine.guard.applyGuardParams(this);
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderPreLaunchEvent(this));
|
||||
List<String> processArgs = new LinkedList<>();
|
||||
processArgs.add(executeFile.toString());
|
||||
processArgs.addAll(jvmArgs);
|
||||
|
@ -243,6 +244,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
|
|||
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE);
|
||||
}
|
||||
process = processBuilder.start();
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderLaunchedEvent(this));
|
||||
isStarted = true;
|
||||
}
|
||||
public void runWriteParams(SocketAddress address) throws IOException
|
||||
|
@ -265,6 +267,7 @@ public void runWriteParams(SocketAddress address) throws IOException
|
|||
params.javaHDir.write(output);
|
||||
}
|
||||
}
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderParamsWrittedEvent(this));
|
||||
}
|
||||
|
||||
public Process getProcess() {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package pro.gravit.launcher.client.events.client;
|
||||
|
||||
import pro.gravit.launcher.client.ClientLauncherProcess;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
|
||||
public class ClientProcessBuilderParamsWrittedEvent extends LauncherModule.Event {
|
||||
public final ClientLauncherProcess process;
|
||||
|
||||
public ClientProcessBuilderParamsWrittedEvent(ClientLauncherProcess process) {
|
||||
this.process = process;
|
||||
}
|
||||
}
|
|
@ -25,6 +25,10 @@ public void registerEventHandler(EventHandler handler)
|
|||
{
|
||||
eventHandlers.add(handler);
|
||||
}
|
||||
public void unregisterEventHandler(EventHandler handler)
|
||||
{
|
||||
eventHandlers.remove(handler);
|
||||
}
|
||||
public<T extends WebSocketEvent> void processEventHandlers(T event)
|
||||
{
|
||||
for(EventHandler handler : eventHandlers)
|
||||
|
|
Loading…
Reference in a new issue