mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-08-17 06:31:45 +02:00
.config
.run
.workdir
Agent
Common
Controller
Phantom.Controller
Phantom.Controller.Database
Phantom.Controller.Database.Postgres
Phantom.Controller.Minecraft
JvmArgumentsHelper.cs
MinecraftVersionApi.cs
MinecraftVersions.cs
Phantom.Controller.Minecraft.csproj
Phantom.Controller.Rpc
Phantom.Controller.Services
Docker
Utils
Web
.dockerignore
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
Directory.Build.props
Directory.Build.targets
Dockerfile
LICENSE
Packages.props
PhantomPanel.sln
README.md
global.json
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System.Collections.Immutable;
|
|
|
|
namespace Phantom.Controller.Minecraft;
|
|
|
|
public static class JvmArgumentsHelper {
|
|
public static ImmutableArray<string> Split(string arguments) {
|
|
return arguments.Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).ToImmutableArray();
|
|
}
|
|
|
|
public static string Join(ImmutableArray<string> arguments) {
|
|
return string.Join('\n', arguments);
|
|
}
|
|
|
|
public static ValidationError? Validate(string arguments) {
|
|
return Validate(Split(arguments));
|
|
}
|
|
|
|
private static ValidationError? Validate(ImmutableArray<string> arguments) {
|
|
if (!arguments.All(static argument => argument.StartsWith('-'))) {
|
|
return ValidationError.InvalidFormat;
|
|
}
|
|
|
|
// TODO not perfect, but good enough
|
|
if (arguments.Any(static argument => argument.Contains("-Xmx"))) {
|
|
return ValidationError.XmxNotAllowed;
|
|
}
|
|
|
|
if (arguments.Any(static argument => argument.Contains("-Xms"))) {
|
|
return ValidationError.XmsNotAllowed;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public enum ValidationError {
|
|
InvalidFormat,
|
|
XmxNotAllowed,
|
|
XmsNotAllowed
|
|
}
|
|
}
|