-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBatchFuncs.cs
34 lines (27 loc) · 1.08 KB
/
BatchFuncs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Diagnostics;
namespace PaperUpdater.Functions;
public static class BatchFuncs {
private const string BatchFileContents =
@"@ECHO OFF
title Personal Minecraft Server
:loop
java -Xmx2048M -Xms2048M -jar paper.jar -d64 -nogui
goto loop
";
public static void CreateFile(bool onlyCreating) {
if (File.Exists(Path.Combine(Environment.CurrentDirectory, "run.bat"))) {
Logger.Warn("run.bat already exists, skipping creation", false);
return;
}
if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "run.bat")))
File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "run.bat"), BatchFileContents);
if (onlyCreating)
Logger.Log("Successfully created your batch file.");
}
public static void RunServerFromFile() {
if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "run.bat")))
CreateFile(false);
Process.Start(Path.Combine(Environment.CurrentDirectory, "run.bat"));
Process.GetCurrentProcess().Kill();
}
}