diff options
author | elveskevtar <kevtar@gmail.com> | 2020-10-20 12:20:16 -0400 |
---|---|---|
committer | elveskevtar <kevtar@gmail.com> | 2020-10-29 01:25:51 -0400 |
commit | 5661e5e5e567232dfbd490665e4a2b67a8d081fd (patch) | |
tree | 402c56822874762aa1d07857655f9acffc56e4be | |
parent | Merge pull request #63 from surepy/master (diff) | |
download | shulker-5661e5e5e567232dfbd490665e4a2b67a8d081fd.tar.gz shulker-5661e5e5e567232dfbd490665e4a2b67a8d081fd.zip |
Add option to output server status into discord
Signed-off-by: elveskevtar <kevtar@gmail.com>
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | config.json | 1 | ||||
-rw-r--r-- | src/Config.ts | 1 | ||||
-rw-r--r-- | src/MinecraftHandler.ts | 10 |
4 files changed, 13 insertions, 0 deletions
diff --git a/README.md b/README.md index 5cd0f71..2ff7d7d 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ You can also easily Deploy to Heroku and the like, just be sure to edit `YOUR_UR "SERVER_NAME": "Shulker", /* The username used when displaying any server information in chat, e.g., Server - Shulker : Server message here*/ "SERVER_IMAGE": "", /* Image for the server when sending such messages (if enabled below). Only for WebHooks. */ + "SHOW_SERVER_STATUS: false, /* Shows when the server turns on and off e.g., Server - Shulker : Server is online */ "SHOW_PLAYER_CONN_STAT": false, /* Shows player connection status in chat, e.g., Server - Shulker : TheMachine joined the game */ "SHOW_PLAYER_ADVANCEMENT": false, /* Shows when players earn advancements in chat, e.g., Server - Shulker : TheMachine has made the advacement [MEME - Machine] */ "SHOW_PLAYER_DEATH": false, /* Shows when players die in chat, e.g., Server - Shulker : TheMachine was blown up by creeper */ diff --git a/config.json b/config.json index be681e0..2f65243 100644 --- a/config.json +++ b/config.json @@ -34,6 +34,7 @@ "SERVER_NAME": "Shulker", "SERVER_IMAGE": "", + "SHOW_SERVER_STATUS": false, "SHOW_PLAYER_CONN_STAT": false, "SHOW_PLAYER_ADVANCEMENT": false, "SHOW_PLAYER_DEATH": false, diff --git a/src/Config.ts b/src/Config.ts index acbab21..5a1417d 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -37,6 +37,7 @@ export interface Config { SERVER_NAME: string SERVER_IMAGE: string + SHOW_SERVER_STATUS: boolean SHOW_PLAYER_CONN_STAT: boolean SHOW_PLAYER_ADVANCEMENT: boolean SHOW_PLAYER_DEATH: boolean diff --git a/src/MinecraftHandler.ts b/src/MinecraftHandler.ts index 7a81718..d9d30d6 100644 --- a/src/MinecraftHandler.ts +++ b/src/MinecraftHandler.ts @@ -88,6 +88,16 @@ class MinecraftHandler { } return { username: serverUsername, message: logLine } + } else if (this.config.SHOW_SERVER_STATUS && (logLine.includes('Starting minecraft server'))) { + if (this.config.DEBUG) { + console.log('[DEBUG]: Server has started') + } + return { username: serverUsername, message: "Server is online" } + } else if (this.config.SHOW_SERVER_STATUS && (logLine.includes('Stopping the server'))) { + if (this.config.DEBUG) { + console.log('[DEBUG]: Server has stopped') + } + return { username: serverUsername, message: "Server is offline" } } else if (this.config.SHOW_PLAYER_ADVANCEMENT && logLine.includes('made the advancement')) { // handle advancements if (this.config.DEBUG){ |