From bc5f40207d614f08261cc91f5c70f20bde3c69b0 Mon Sep 17 00:00:00 2001 From: Vistril <38549907+Vistril@users.noreply.github.com> Date: Fri, 10 Apr 2020 23:15:03 -0600 Subject: [PATCH 1/6] made polished, user friendly so it shouldn't be hard to use anymore --- manager.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/manager.js b/manager.js index 4662aea..732be61 100755 --- a/manager.js +++ b/manager.js @@ -9,8 +9,20 @@ String.prototype.capitalize = function() { return this[0].toUpperCase() + this.substring(1); }; +//constantn'ts this is up here for scope reasons don't @ me +var StatusCycleCount = 0; +var OnlineServers = []; + +//constants var MAX_IDLE_MINUTES = 60; var CMD_PREFIX = '%'; +const DEFAULT_STATUS = `${CMD_PREFIX}help` +const STATUS_CYCLE = [ + "Servers running: " + OnlineServers.join(", "), + "%start to start a server!", + "servername.mc.jpdld.com!" +]; + class MinecraftServer extends EventEmitter { constructor (cwd, jar) { @@ -139,12 +151,14 @@ function commandHandler(input, priviledged) { if (!server) return `Unknown server ${serverName}` if (server.process) return `${serverName.capitalize()} server is already running.`; server.start(); + OnlineServers.push(serverName.capitalize()); return `Starting ${serverName} server.`; } else if (cmd == "stop") { if (!priviledged) return unauthorized; if (!server) return `Unknown server ${serverName}` if (!server.process) return `${serverName.capitalize()} server is not running.`; server.stop(); + OnlineServers.splice(serverName.capitalize()); return `Stopping ${serverName} server.`; } else if (cmd == "input") { if (!priviledged) return unauthorized; @@ -191,10 +205,15 @@ if (process.env.DISCORD_TOKEN) { var dClient = new Discord.Client(); dClient.login(process.env.DISCORD_TOKEN); dClient.on("error", error => console.error(colors.red("Discord client error: " + error.message))); - function setStatus() { - dClient.user.setActivity(`${CMD_PREFIX}help`); + function setStatus(status) { + dClient.user.setActivity(status); } - setInterval(setStatus, 1000*60*30); + //setInterval(setStatus, 1000*60*30); + setInterval(() => { + StatusCycleCount++; + if (StatusCycleCount >= STATUS_CYCLE.length) count = 0; + setStatus(`${DEFAULT_STATUS} | ${STATUS_CYCLE[StatusCycleCount]}`); + }, 3500); dClient.on("ready", () => { console.log("Discord client is ready.".green); setStatus(); -- 2.43.5 From 98aae0c617a45d95608fa5dddc1d5bec5b746e72 Mon Sep 17 00:00:00 2001 From: JPLand Date: Thu, 6 Aug 2020 05:59:15 +0200 Subject: [PATCH 2/6] Update regex for 1.16.1 --- manager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manager.js b/manager.js index 4662aea..2ddc349 100755 --- a/manager.js +++ b/manager.js @@ -20,10 +20,10 @@ class MinecraftServer extends EventEmitter { this.jar = jar; this.idleMinutes = 0; this.locked = false; - // for 1.14.4 (paper) // also working on 1.15 + // 1.16.1 this.listCommand = "minecraft:list"; - this.listEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are 0 of a max \d{1,} players online:$/; - this.listNotEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are [1-9]\d{0,} of a max \d{1,} players online:/; + this.listEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are 0 of a max of \d{1,} players online:$/; + this.listNotEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are [1-9]\d{0,} of a max of \d{1,} players online:/; } start() { -- 2.43.5 From 3a7a96045360256b19c362338247db54b19bc3eb Mon Sep 17 00:00:00 2001 From: Lamp Date: Mon, 17 Aug 2020 20:12:12 -0700 Subject: [PATCH 3/6] Update regex for 1.16.2 --- manager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manager.js b/manager.js index 2ddc349..05852da 100755 --- a/manager.js +++ b/manager.js @@ -20,10 +20,10 @@ class MinecraftServer extends EventEmitter { this.jar = jar; this.idleMinutes = 0; this.locked = false; - // 1.16.1 + // 1.16.2 this.listCommand = "minecraft:list"; - this.listEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are 0 of a max of \d{1,} players online:$/; - this.listNotEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are [1-9]\d{0,} of a max of \d{1,} players online:/; + this.listEmptyRegex = /^\[\d\d:\d\d:\d\d\] \[Server thread\/INFO\]: There are 0 of a max of \d{1,} players online:$/; + this.listNotEmptyRegex = /^\[\d\d:\d\d:\d\d\] \[Server thread\/INFO\]: There are [1-9]\d{0,} of a max of \d{1,} players online:/; } start() { -- 2.43.5 From 542abf9345e7afa6da8e5f492250114104400a82 Mon Sep 17 00:00:00 2001 From: Lamp Date: Sat, 5 Sep 2020 20:22:13 -0700 Subject: [PATCH 4/6] revert regex for paper it wasn't 1.16.2 but the change to spigot --- manager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manager.js b/manager.js index 05852da..a8a9adf 100755 --- a/manager.js +++ b/manager.js @@ -20,10 +20,10 @@ class MinecraftServer extends EventEmitter { this.jar = jar; this.idleMinutes = 0; this.locked = false; - // 1.16.2 + // paper 1.16.2 this.listCommand = "minecraft:list"; - this.listEmptyRegex = /^\[\d\d:\d\d:\d\d\] \[Server thread\/INFO\]: There are 0 of a max of \d{1,} players online:$/; - this.listNotEmptyRegex = /^\[\d\d:\d\d:\d\d\] \[Server thread\/INFO\]: There are [1-9]\d{0,} of a max of \d{1,} players online:/; + this.listEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are 0 of a max of \d{1,} players online:$/; + this.listNotEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are [1-9]\d{0,} of a max of \d{1,} players online:/; } start() { -- 2.43.5 From 34c0b49f6b5b85d37b4cb3fbfa8b77d8fa8db543 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 5 Jun 2021 12:45:38 +0000 Subject: [PATCH 5/6] Bump ws from 6.2.1 to 6.2.2 Bumps [ws](https://github.com/websockets/ws) from 6.2.1 to 6.2.2. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/commits) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json old mode 100755 new mode 100644 index c6e884a..69fdd18 --- a/package-lock.json +++ b/package-lock.json @@ -50,9 +50,9 @@ "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==" }, "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", + "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", "requires": { "async-limiter": "~1.0.0" } -- 2.43.5 From 5ce01185a3d53e4d98e7dbbc2b92882d41a44f43 Mon Sep 17 00:00:00 2001 From: Lamp Date: Fri, 6 Aug 2021 10:41:19 -0700 Subject: [PATCH 6/6] commit changes i found on my desktop but apparently forgot about (synchronize production changes) --- .gitignore | 0 manager.js | 5 ++++- package-lock.json | 0 package.json | 0 4 files changed, 4 insertions(+), 1 deletion(-) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 manager.js mode change 100755 => 100644 package-lock.json mode change 100755 => 100644 package.json diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/manager.js b/manager.js old mode 100755 new mode 100644 index a8a9adf..2846b29 --- a/manager.js +++ b/manager.js @@ -16,6 +16,7 @@ class MinecraftServer extends EventEmitter { constructor (cwd, jar) { super(); this.cwd = cwd; + this.java = "java"; this.jvm_args = ["-Xmx4G"]; this.jar = jar; this.idleMinutes = 0; @@ -28,7 +29,7 @@ class MinecraftServer extends EventEmitter { start() { this._log("Starting server".green); - this.process = child_process.spawn("nice", ["-n", "1", "java"].concat(this.jvm_args).concat(["-jar", this.jar]), {cwd: this.cwd}); + this.process = child_process.spawn("nice", ["-n", "1", this.java].concat(this.jvm_args).concat(["-jar", this.jar]), {cwd: this.cwd}); this.process.on("error", error => { this.process.emit("exit"); this._log(error.stack.red, true); @@ -119,9 +120,11 @@ servers.modded._testIfConsoleLineIndicatesNoPlayersOnline = function(line) { return line.endsWith("] [Server thread/INFO] [minecraft/DedicatedServer]: There are 0/20 players online:"); } servers.modded.listCommand = "list"; +servers.modded.java = "/usr/bin/java"; // java 8 servers.modded2._testIfConsoleLineIndicatesPlayersOnline = servers.modded._testIfConsoleLineIndicatesPlayersOnline; servers.modded2._testIfConsoleLineIndicatesNoPlayersOnline = servers.modded._testIfConsoleLineIndicatesNoPlayersOnline; servers.modded2.listCommand = servers.modded.listCommand; +servers.modded2.java = "/usr/bin/java"; servers.multiverse.listEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are 0\/\d{1,} players online:$/; servers.multiverse.listNotEmptyRegex = /^\[\d\d:\d\d:\d\d INFO\]: There are [1-9]\d{0,}\/\d{1,} players online:$/; diff --git a/package-lock.json b/package-lock.json old mode 100755 new mode 100644 diff --git a/package.json b/package.json old mode 100755 new mode 100644 -- 2.43.5