Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@ printWelcomeScreen();

loadServerData(
(data) => {
const { scriptName } = data as Config;
const { scriptName, ram, jarName } = data as Config;

const serverProcess = spawn('bash', [`${scriptName}`]);
let serverProcess;

if (scriptName == null) {
const start: string = `-Xms${ram} -Xmx${ram} -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Daikars.new.flags=true -Dusing.aikars.flags=https://mcflags.emc.gs -jar ${jarName} nogui`;

console.log(chalk.yellowBright('No start script found! Starting with the follwing command:'));
console.log(chalk.whiteBright('java ' + start));

serverProcess = spawn('java', start.split(' '));
} else {
serverProcess = spawn('bash', [`${scriptName}`]);
}

serverProcess.stdout.pipe(process.stdout);

serverProcess.on('exit', () => {
console.log('The server has stopped.');
});
Expand Down
23 changes: 14 additions & 9 deletions src/questions/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,30 @@ export const promptCreateStartScript = (): void => {
initial: true,
})
.run()
.then((answer: string) => {
if (!answer) {
// bruh
}

promptServerRam();
.then((answer: boolean) => {
promptServerRam(answer);
});
};

const promptServerRam = (): void => {
const promptServerRam = (createScript: boolean = true): void => {
let scriptInfo: string = ' (This will be used for starting the server with startcraft';
if (createScript) {
scriptInfo += ' and your startup script';
}
scriptInfo += '.)';
new Input({
name: 'serverRam',
message: 'How much RAM would you like to run the server with? (i.e. 10G, 900M)',
message: 'How much RAM would you like to run the server with? (i.e. 10G, 900M)' + scriptInfo,
initial: '10G',
})
.run()
.then((answer: string) => {
server.ram = answer;
createServerScript();
if (createScript) {
createServerScript();
} else {
standard.promptSaveSettings();
}
});
};

Expand Down
6 changes: 6 additions & 0 deletions src/type/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
type Config = {
serverType: string;
jarName: string;
scriptName: string;
ram: string;
version: any; // I don't know what version does yet
createdDate: Date;
lastLaunchDate: any; // I don't know what lastLaunchDate does yet
};

export default Config;