mirror of
				https://github.com/chylex/Minecraft-Phantom-Panel.git
				synced 2025-11-04 03:40:15 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			7bac21c3a4
			...
			1855ff8062
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						1855ff8062
	
				 | 
					
					
						
@@ -1,4 +1,5 @@
 | 
				
			|||||||
using System.Text;
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
using Phantom.Agent.Minecraft.Instance;
 | 
					using Phantom.Agent.Minecraft.Instance;
 | 
				
			||||||
using Phantom.Agent.Minecraft.Java;
 | 
					using Phantom.Agent.Minecraft.Java;
 | 
				
			||||||
using Phantom.Agent.Minecraft.Server;
 | 
					using Phantom.Agent.Minecraft.Server;
 | 
				
			||||||
@@ -11,6 +12,7 @@ public abstract class BaseLauncher : IServerLauncher {
 | 
				
			|||||||
	private readonly InstanceProperties instanceProperties;
 | 
						private readonly InstanceProperties instanceProperties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	protected string MinecraftVersion => instanceProperties.ServerVersion;
 | 
						protected string MinecraftVersion => instanceProperties.ServerVersion;
 | 
				
			||||||
 | 
						protected string InstanceFolder => instanceProperties.InstanceFolder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private protected BaseLauncher(InstanceProperties instanceProperties) {
 | 
						private protected BaseLauncher(InstanceProperties instanceProperties) {
 | 
				
			||||||
		this.instanceProperties = instanceProperties;
 | 
							this.instanceProperties = instanceProperties;
 | 
				
			||||||
@@ -51,16 +53,14 @@ public abstract class BaseLauncher : IServerLauncher {
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		var processConfigurator = new ProcessConfigurator {
 | 
							var processConfigurator = new ProcessConfigurator {
 | 
				
			||||||
			FileName = javaRuntimeExecutable.ExecutablePath,
 | 
								FileName = javaRuntimeExecutable.ExecutablePath,
 | 
				
			||||||
			WorkingDirectory = instanceProperties.InstanceFolder,
 | 
								WorkingDirectory = InstanceFolder,
 | 
				
			||||||
			RedirectInput = true,
 | 
								RedirectInput = true,
 | 
				
			||||||
			UseShellExecute = false
 | 
								UseShellExecute = false
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		var processArguments = processConfigurator.ArgumentList;
 | 
							var processArguments = processConfigurator.ArgumentList;
 | 
				
			||||||
		PrepareJvmArguments(serverJar).Build(processArguments);
 | 
							PrepareJvmArguments(serverJar).Build(processArguments);
 | 
				
			||||||
		processArguments.Add("-jar");
 | 
							PrepareJavaProcessArguments(processArguments, serverJar.FilePath);
 | 
				
			||||||
		processArguments.Add(serverJar.FilePath);
 | 
					 | 
				
			||||||
		processArguments.Add("nogui");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		var process = processConfigurator.CreateProcess();
 | 
							var process = processConfigurator.CreateProcess();
 | 
				
			||||||
		var instanceProcess = new InstanceProcess(instanceProperties, process);
 | 
							var instanceProcess = new InstanceProcess(instanceProperties, process);
 | 
				
			||||||
@@ -99,6 +99,12 @@ public abstract class BaseLauncher : IServerLauncher {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	private protected virtual void CustomizeJvmArguments(JvmArgumentBuilder arguments) {}
 | 
						private protected virtual void CustomizeJvmArguments(JvmArgumentBuilder arguments) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						protected virtual void PrepareJavaProcessArguments(Collection<string> processArguments, string serverJarFilePath) {
 | 
				
			||||||
 | 
							processArguments.Add("-jar");
 | 
				
			||||||
 | 
							processArguments.Add(serverJarFilePath);
 | 
				
			||||||
 | 
							processArguments.Add("nogui");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private protected virtual Task<ServerJarInfo> PrepareServerJar(ILogger logger, string serverJarPath, CancellationToken cancellationToken) {
 | 
						private protected virtual Task<ServerJarInfo> PrepareServerJar(ILogger logger, string serverJarPath, CancellationToken cancellationToken) {
 | 
				
			||||||
		return Task.FromResult(new ServerJarInfo(serverJarPath));
 | 
							return Task.FromResult(new ServerJarInfo(serverJarPath));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using Phantom.Agent.Minecraft.Instance;
 | 
				
			||||||
 | 
					using Phantom.Agent.Minecraft.Java;
 | 
				
			||||||
 | 
					using Serilog;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Phantom.Agent.Minecraft.Launcher.Types; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public sealed class ForgeLauncher : BaseLauncher {
 | 
				
			||||||
 | 
						public ForgeLauncher(InstanceProperties instanceProperties) : base(instanceProperties) {}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private protected override void CustomizeJvmArguments(JvmArgumentBuilder arguments) {
 | 
				
			||||||
 | 
							arguments.AddProperty("terminal.ansi", "true"); // TODO
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						protected override void PrepareJavaProcessArguments(Collection<string> processArguments, string serverJarFilePath) {
 | 
				
			||||||
 | 
							if (OperatingSystem.IsWindows()) {
 | 
				
			||||||
 | 
								processArguments.Add("@libraries/net/minecraftforge/forge/1.20.1-47.2.0/win_args.txt");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else {
 | 
				
			||||||
 | 
								processArguments.Add("@libraries/net/minecraftforge/forge/1.20.1-47.2.0/unix_args.txt");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							processArguments.Add("nogui");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private protected override Task<ServerJarInfo> PrepareServerJar(ILogger logger, string serverJarPath, CancellationToken cancellationToken) {
 | 
				
			||||||
 | 
							return Task.FromResult(new ServerJarInfo(Path.Combine(InstanceFolder, "run.sh")));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -102,6 +102,7 @@ sealed class InstanceManagerActor : ReceiveActor<InstanceManagerActor.ICommand>
 | 
				
			|||||||
		IServerLauncher launcher = configuration.MinecraftServerKind switch {
 | 
							IServerLauncher launcher = configuration.MinecraftServerKind switch {
 | 
				
			||||||
			MinecraftServerKind.Vanilla => new VanillaLauncher(properties),
 | 
								MinecraftServerKind.Vanilla => new VanillaLauncher(properties),
 | 
				
			||||||
			MinecraftServerKind.Fabric  => new FabricLauncher(properties),
 | 
								MinecraftServerKind.Fabric  => new FabricLauncher(properties),
 | 
				
			||||||
 | 
								MinecraftServerKind.Forge   => new ForgeLauncher(properties),
 | 
				
			||||||
			_                           => InvalidLauncher.Instance
 | 
								_                           => InvalidLauncher.Instance
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,5 +2,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public enum MinecraftServerKind : ushort {
 | 
					public enum MinecraftServerKind : ushort {
 | 
				
			||||||
	Vanilla = 1,
 | 
						Vanilla = 1,
 | 
				
			||||||
	Fabric = 2
 | 
						Fabric = 2,
 | 
				
			||||||
 | 
						Forge = 3
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user