From fae810fd65b5e52379b0c24f2781646d02f8df4e Mon Sep 17 00:00:00 2001 From: vincss Date: Tue, 13 Feb 2024 10:53:57 +0100 Subject: [PATCH] - 1.9.1 - 1.20.2 : - add useLegacyLogin parameter, to use old login internally --- README.md | 193 ++++++++++-------- docs/egg-paper-mcsleepingserverstarter.json | 164 ++++++++------- ...lla-minecraft-mcsleepingserverstarter.json | 110 +++++----- package-lock.json | 28 +-- package.json | 4 +- src/sleepingContainer.ts | 13 +- src/sleepingHelper.ts | 73 ++++--- src/sleepingMcJava.ts | 51 +++-- src/sleepingServerStarter.ts | 4 +- src/sleepingSettings.ts | 48 +++-- src/sleepingTypes.ts | 78 +++---- src/sleepingWeb.ts | 20 +- 12 files changed, 427 insertions(+), 359 deletions(-) diff --git a/README.md b/README.md index 20e8256..ad71984 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,21 @@ ## ✅ Compatible versions -- Minecraft Java: up to 1.20.1 [node-minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol) -- Bedrock: Waiting for third party compatibility ( you can use the web-gui as a workarround ) [JSPrismarine](https://github.com/JSPrismarine/JSPrismarine) +- Minecraft Java: up to + 1.20.2 [node-minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol) +- Bedrock: Waiting for third party compatibility ( you can use the web-gui as a + workarround ) [JSPrismarine](https://github.com/JSPrismarine/JSPrismarine) ## 🧰 Features - Listen on the same port as your minecraft server. - - Option to connect from BedRock _(Portable version of Minecraft)_ - - Web-gui, to turn on or off your server from anywhere + - Option to connect from BedRock _(Portable version of Minecraft)_ + - Web-gui, to turn on or off your server from anywhere - When someone connects, immediately launch your minecraft server. - - You can also type 'quit' in your console to start minecraft's server. + - You can also type 'quit' in your console to start minecraft's server. -**Works better with [EmptyServerStopper](https://github.com/vincss/mcEmptyServerStopper), a plugin that automatically +**Works better with [EmptyServerStopper](https://github.com/vincss/mcEmptyServerStopper), a plugin +that automatically stops your server after a definied amount of time** ## 📀 Install @@ -37,7 +40,7 @@ There are multiple ways to run SleepingServerStarter: 2. Place the executable in the same folder as your server file (`spigot.jar`, `paper.jar`, etc...) 3. Make sure your server is stopped 4. Run the executable - - On Linux, try `chmod +x mcsleepingserverstarter-linux-x64` if you can't run the executable + - On Linux, try `chmod +x mcsleepingserverstarter-linux-x64` if you can't run the executable ### 📜 Manually install and compile @@ -49,22 +52,27 @@ There are multiple ways to run SleepingServerStarter: ### 🐋 Docker -SleepingServerStarter is available as a Docker image: [ghcr.io/vincss/mcsleepingserverstarter](https://github.com/vincss/mcsleepingserverstarter/pkgs/container/mcsleepingserverstarter) +SleepingServerStarter is available as a Docker +image: [ghcr.io/vincss/mcsleepingserverstarter](https://github.com/vincss/mcsleepingserverstarter/pkgs/container/mcsleepingserverstarter) It supports both x64 and arm64 host system architectures. -For detailed examples and instructions for setup via Docker, [see the wiki page here](https://github.com/vincss/mcsleepingserverstarter/wiki/Docker-Configuration). +For detailed examples and instructions for setup via +Docker, [see the wiki page here](https://github.com/vincss/mcsleepingserverstarter/wiki/Docker-Configuration). ### 🐡 PufferPanel -If you're using PufferPanel, you can import [this template](./docs/pufferpanel.json) as JSON to use Paper Spigot with +If you're using PufferPanel, you can import [this template](./docs/pufferpanel.json) as JSON to use +Paper Spigot with Sleeping Server Starter via PufferPanel ### 🐦 Pterodactyl -If you're using Pterodactyl, you can import [this egg](./docs/egg-paper-mcsleepingserverstarter.json) as JSON to use +If you're using Pterodactyl, you can +import [this egg](./docs/egg-paper-mcsleepingserverstarter.json) as JSON to use Paper Spigot with Sleeping Server Starter OR you can also -import [this egg](./docs/egg-vanilla-minecraft-mcsleepingserverstarter.json) as JSON to use Vanilla Minecraft with +import [this egg](./docs/egg-vanilla-minecraft-mcsleepingserverstarter.json) as JSON to use Vanilla +Minecraft with Sleeping Server Starter on Pterodactyl Pterodactyl can be installed @@ -72,7 +80,8 @@ via [Unofficial pterodactyl-installer](https://github.com/vilhelmprytz/pterodact ## ⚙️ Settings -> Note: If running from binaries, the settings file will be created after the first execution in the same folder as the +> Note: If running from binaries, the settings file will be created after the first execution in the +> same folder as the > executable | Setting | Description | Default value | @@ -106,8 +115,10 @@ via [Unofficial pterodactyl-installer](https://github.com/vilhelmprytz/pterodact | `useBlacklistFiles` | Use Minecraft `banned-ips.json` and `banned-players.json` to prevent players from waking up the server. Can be used together with `blackListedAddress` property | false | | `hideIpInLogs` | Hide the ip from the remote player in the logs | false | | `hideOnConnectionLogs` | Hide 'A Prince has taken a quick peek' the logs | false | +| `useLegacyLogin` | use legacy "login" method from [minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol/issues/1279#issuecomment-1878866611) | false | -> Note: if you need to shutdown the program, simply input a `ctrl + c`, the program will shut down normally afterwards +> Note: if you need to shutdown the program, simply input a `ctrl + c`, the program will shut down +> normally afterwards --- @@ -122,23 +133,28 @@ via [Unofficial pterodactyl-installer](https://github.com/vilhelmprytz/pterodact ## 🕸 Bungeecord -While SleepingServerStarter is made to run on a single server, it can be integrated to a Bungeecord network. **But -please note that you'll need to install and configure SleepingServerStarter on every servers you want to be affected by +While SleepingServerStarter is made to run on a single server, it can be integrated to a Bungeecord +network. **But +please note that you'll need to install and configure SleepingServerStarter on every servers you +want to be affected by the program.** Installing SleepingServerStarter only on your proxy server **will NOT work** For each server you're installing SleepingServerStarter on : -- the `serverPort` should be the port of the server you're installing the program on, not the proxy's port -- make sure `serverOnlineMode` is set to `false` to avoid any problems with Bungee when switching between servers +- the `serverPort` should be the port of the server you're installing the program on, not the + proxy's port +- make sure `serverOnlineMode` is set to `false` to avoid any problems with Bungee when switching + between servers We know this can be a little bit time consuming, but this solution is working great #### In action : When trying to join a sleeping server, you get this kind of message by Bungee
-Basically, it keeps kicking the player with `loginMessage` as reason, telling the player the server is being started +Basically, it keeps kicking the player with `loginMessage` as reason, telling the player the server +is being started ![](./docs/bungeeStartingExample.png) @@ -148,7 +164,8 @@ Basically, it keeps kicking the player with `loginMessage` as reason, telling th ## 🤝 Contributing -Contributions, issues and feature requests are welcome!
Feel free to check [issues page](./issues) +Contributions, issues and feature requests are welcome!
Feel free to +check [issues page](./issues) ## 🙌 Show your support @@ -157,110 +174,118 @@ Give a ⭐️ if you like the project! [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/vincss) ## 📜 ChangeLog + +- 1.9.1 - 1.20.2 : + - add useLegacyLogin parameter, to use old login internally - 1.9.0 - 1.20.1 : - - add useWhitelistFile parameter to switch to whitelist.json instead of whiteListedNames (thanks to spanasiuk) - - add useBlacklistFiles parameter to use banned-ips.json and banned-players.json (thanks to spanasiuk) - - add useNativeFiles parameter to use server.properties for getting serverPort, maxPlayers, serverOnlineMode, useWhitelistFile, and useBlacklistFiles properties (thanks to spanasiuk) - - change stdio streams on Windows when web-gui is used. + - add useWhitelistFile parameter to switch to whitelist.json instead of whiteListedNames (thanks + to spanasiuk) + - add useBlacklistFiles parameter to use banned-ips.json and banned-players.json (thanks to + spanasiuk) + - add useNativeFiles parameter to use server.properties for getting serverPort, maxPlayers, + serverOnlineMode, useWhitelistFile, and useBlacklistFiles properties (thanks to spanasiuk) + - change stdio streams on Windows when web-gui is used. - 1.8.0 - 1.20.1 : - - add webAllowRestart parameter - - add minecraftAutostart parameter - - add restartDelay parameter + - add webAllowRestart parameter + - add minecraftAutostart parameter + - add restartDelay parameter - 1.7.1 - 1.20.1 : - - Run mcsleeperstarter as a non-root user within the docker container + - Run mcsleeperstarter as a non-root user within the docker container - 1.7.0 - 1.20.1 : - - [Feature] Added serverMOTD setting ( thanks to gavinhsmith ) - - [UX] Made the Sleep button disappear while server is online when "preventStop" is true ( thanks to gavinhsmith ) + - [Feature] Added serverMOTD setting ( thanks to gavinhsmith ) + - [UX] Made the Sleep button disappear while server is online when "preventStop" is true ( + thanks to gavinhsmith ) - 1.6.0 - 1.20.1 : - - add hideOnConnectionLogs parameter - - update minecraft-protocol: 1.43.2 ( minecraft 1.20.1 ) + - add hideOnConnectionLogs parameter + - update minecraft-protocol: 1.43.2 ( minecraft 1.20.1 ) - 1.5.13 - 1.20.1 : - - add environement variable DISABLE_FILE_LOGS to disable file logs + - add environement variable DISABLE_FILE_LOGS to disable file logs - 1.5.12 - 1.20.1 : - - update minecraft-protocol: 1.43.0 ( minecraft 1.20.1 ) + - update minecraft-protocol: 1.43.0 ( minecraft 1.20.1 ) - 1.5.11 - 1.19.4 : - - update minecraft-protocol: 1.42.0 ( minecraft 1.19.4 ) + - update minecraft-protocol: 1.42.0 ( minecraft 1.19.4 ) - 1.5.10 - 1.19.3 : - - webServeDynmap setting can be set to an url + - webServeDynmap setting can be set to an url - 1.5.9 - 1.19.3 : - - backup config file before setting to default + - backup config file before setting to default - 1.5.8 - 1.19.3 : - - reload settings on restart + - reload settings on restart - 1.5.7 - 1.19.3 : - - restart on 'uncaughtException' + - restart on 'uncaughtException' - 1.5.6 - 1.19.3 : - - do not exit on 'uncaughtException' + - do not exit on 'uncaughtException' - 1.5.5 - 1.19.3 : - - add hideIpInLogs parameter + - add hideIpInLogs parameter - 1.5.4 - 1.19.3 : - - add version number in start/stop minecraft + - add version number in start/stop minecraft - 1.5.3 - 1.19.3 : - - docker: copy only needed binary + - docker: copy only needed binary - 1.5.2 - 1.19.3 : - - docker: base image eclipse-temurin:17-jre-jammy + - docker: base image eclipse-temurin:17-jre-jammy - 1.5.1 - 1.19.3 : - - add docker generation (@markmetcalfe) - - fix minecraftDirectory not being used as base path when serving dynmap via web GUI (@markmetcalfe) + - add docker generation (@markmetcalfe) + - fix minecraftDirectory not being used as base path when serving dynmap via web GUI ( + @markmetcalfe) - 1.5.0 - 1.19.3 : - - add setting webSubPath - - add more architectures builds - - add setting favIconPath to use a png as icon. - - handle motd in serverName - - Thanks to markmetcalfe for thoses improvements - - update minecraft-protocol: 1.41.2 + - add setting webSubPath + - add more architectures builds + - add setting favIconPath to use a png as icon. + - handle motd in serverName + - Thanks to markmetcalfe for thoses improvements + - update minecraft-protocol: 1.41.2 - 1.4.1 - 1.19.3 : - - update minecraft-protocol: 1.41.1 - - disable bedrock by default - - add whiteListedNames + - update minecraft-protocol: 1.41.1 + - disable bedrock by default + - add whiteListedNames - 1.4.0 - 1.19.3 : - - set option 'version' to false by default (it should handle any compatible version). + - set option 'version' to false by default (it should handle any compatible version). - 1.3.1 - 1.19.3 : - - update minecraft-protocol: 1.41.0 + - update minecraft-protocol: 1.41.0 - 1.3.0 - 1.19.3 : - - add blackListedAddress parameters - - add dynmap - - add preventStop - - update minecraft-protocol: 1.40.3 + - add blackListedAddress parameters + - add dynmap + - add preventStop + - update minecraft-protocol: 1.40.3 - 1.2.6 - 1.19.3 : - - update third-parties + - update third-parties - 1.2.5 - 1.19.3 : - - update minecraft-protocol for MC 1.19.3 + - update minecraft-protocol for MC 1.19.3 - 1.2.4 - 1.19.2 : - - update minecraft-protocol for MC 1.19.2 (no 1.19.3 yet) + - update minecraft-protocol for MC 1.19.2 (no 1.19.3 yet) - 1.2.3 - 1.19 : - - update to Node18 + - update to Node18 - 1.2.2 - 1.19 : - - add arm64 builds (Raspberry Pi) + - add arm64 builds (Raspberry Pi) - 1.2.1 - 1.19 : - - update node-minecraft-protocol for MC 1.19 (no 1.19.1 & 1.19.2 yet) + - update node-minecraft-protocol for MC 1.19 (no 1.19.1 & 1.19.2 yet) - 1.2.0 - 1.18.2 : - - Add settings webStopOnStart - - Change settings startMinecraft to boolean + - Add settings webStopOnStart + - Change settings startMinecraft to boolean - 1.1.5 - 1.18.2 : - - Add more logs when it fails to retreive settings - - update node-minecraft-protocol ^1.34.0 + - Add more logs when it fails to retreive settings + - update node-minecraft-protocol ^1.34.0 - 1.1.4 - 1.18.2 : - - update node-minecraft-protocol ^1.32.0 + - update node-minecraft-protocol ^1.32.0 - 1.1.3 - 1.18.1 : - - Fixed concurent wake up : ./issues/68 - - update node-minecraft-protocol ^1.30.0 + - Fixed concurent wake up : ./issues/68 + - update node-minecraft-protocol ^1.30.0 - 1.1.2 - 1.18.1 : - - Compress binaries ( GZip ) + - Compress binaries ( GZip ) - 1.1.1 - 1.18.1 : - - update node-minecraft-protocol ^1.29.0 -> 1.18.1 + - update node-minecraft-protocol ^1.29.0 -> 1.18.1 - 1.1.0 - 1.17.1 : - - **Feature** Add Discord Notification - - Update dependencies (node16, npm8, typescript,...) + - **Feature** Add Discord Notification + - Update dependencies (node16, npm8, typescript,...) - 1.0.4 - 1.17.1 : - - update node-minecraft-protocol ^1.26.1 + - update node-minecraft-protocol ^1.26.1 - 1.0.3 - 1.16.5 : - - update security + - update security - 1.0.2 - 1.16.5 : - - add maxPlayers in settings + - add maxPlayers in settings - 1.0.1 - 1.16.5 : - - Include version in log. + - Include version in log. - 1.0.0 - 1.16.5 : - - **Feature** Add web-gui + - **Feature** Add web-gui - 1.16.4 : - - Add bedrock support. + - Add bedrock support. - ... diff --git a/docs/egg-paper-mcsleepingserverstarter.json b/docs/egg-paper-mcsleepingserverstarter.json index b6bd812..0e37d16 100644 --- a/docs/egg-paper-mcsleepingserverstarter.json +++ b/docs/egg-paper-mcsleepingserverstarter.json @@ -1,89 +1,85 @@ { - "_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO", - "meta": { - "version": "PTDL_v2", - "update_url": null + "_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO", + "meta": { + "version": "PTDL_v2", + "update_url": null + }, + "exported_at": "2023-06-27T20:12:19+02:00", + "name": "Paper (mcsleepingserverstarter)", + "author": "kevin@boredkevin.com", + "description": "High performance Spigot fork that aims to fix gameplay and mechanics inconsistencies.\r\nPut your minecraft server to rest, while SleepingServerStarter is watching !", + "features": ["eula", "java_version", "pid_limit"], + "docker_images": { + "Java 17": "ghcr.io/pterodactyl/yolks:java_17", + "Java 16": "ghcr.io/pterodactyl/yolks:java_16", + "Java 11": "ghcr.io/pterodactyl/yolks:java_11", + "Java 8": "ghcr.io/pterodactyl/yolks:java_8" + }, + "file_denylist": [], + "startup": "./mcsleepingserverstarter-linux", + "config": { + "files": "{\r\n \"server.properties\": {\r\n \"parser\": \"properties\",\r\n \"find\": {\r\n \"server-ip\": \"0.0.0.0\",\r\n \"server-port\": \"{{server.build.default.port}}\",\r\n \"query.port\": \"{{server.build.default.port}}\"\r\n }\r\n },\r\n \"sleepingSettings.yml\": {\r\n \"parser\": \"yaml\",\r\n \"find\": {\r\n \"serverPort\": \"{{server.build.default.port}}\",\r\n \"minecraftCommand\": \"java -Xms128M -XX:MaxRAMPercentage=95.0 -Dterminal.jline=false -Dterminal.ansi=true -jar {{env.SERVER_JARFILE}}\"\r\n }\r\n }\r\n}", + "startup": "{\r\n \"done\": \")! For help, type \"\r\n}", + "logs": "{}", + "stop": "stop" + }, + "scripts": { + "installation": { + "script": "#!/bin/ash\r\n# Paper Installation Script\r\n#\r\n# Server Files: /mnt/server\r\necho -e \"-- Install Begin --\"\r\n\r\nPROJECT=paper\r\nSYSTEM_ARCHITECTURE=$([[ \"$(uname -m)\" == \"x86_64\" ]] && echo \"x64\" || echo \"arm64\")\r\n\r\nif [ -n \"${DL_PATH}\" ]; then\r\n\techo -e \"Using supplied download url: ${DL_PATH}\"\r\n\tDOWNLOAD_URL=`eval echo $(echo ${DL_PATH} | sed -e 's/{{/${/g' -e 's/}}/}/g')`\r\nelse\r\n\tVER_EXISTS=`curl -s https://api.papermc.io/v2/projects/${PROJECT} | jq -r --arg VERSION $MINECRAFT_VERSION '.versions[] | contains($VERSION)' | grep -m1 true`\r\n\tLATEST_VERSION=`curl -s https://api.papermc.io/v2/projects/${PROJECT} | jq -r '.versions' | jq -r '.[-1]'`\r\n\r\n\tif [ \"${VER_EXISTS}\" == \"true\" ]; then\r\n\t\techo -e \"Version is valid. Using version ${MINECRAFT_VERSION}\"\r\n\telse\r\n\t\techo -e \"Specified version not found. Defaulting to the latest ${PROJECT} version\"\r\n\t\tMINECRAFT_VERSION=${LATEST_VERSION}\r\n\tfi\r\n\r\n\tBUILD_EXISTS=`curl -s https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION} | jq -r --arg BUILD ${BUILD_NUMBER} '.builds[] | tostring | contains($BUILD)' | grep -m1 true`\r\n\tLATEST_BUILD=`curl -s https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION} | jq -r '.builds' | jq -r '.[-1]'`\r\n\r\n\tif [ \"${BUILD_EXISTS}\" == \"true\" ]; then\r\n\t\techo -e \"Build is valid for version ${MINECRAFT_VERSION}. Using build ${BUILD_NUMBER}\"\r\n\telse\r\n\t\techo -e \"Using the latest ${PROJECT} build for version ${MINECRAFT_VERSION}\"\r\n\t\tBUILD_NUMBER=${LATEST_BUILD}\r\n\tfi\r\n\r\n\tJAR_NAME=${PROJECT}-${MINECRAFT_VERSION}-${BUILD_NUMBER}.jar\r\n\r\n\techo \"Version being downloaded\"\r\n\techo -e \"MC Version: ${MINECRAFT_VERSION}\"\r\n\techo -e \"Build: ${BUILD_NUMBER}\"\r\n\techo -e \"JAR Name of Build: ${JAR_NAME}\"\r\n\tDOWNLOAD_URL=https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds/${BUILD_NUMBER}/downloads/${JAR_NAME}\r\nfi\r\necho -e \"----\"\r\nif [ -n \"${PLUGIN_DL_PATH}\" ]; then\r\n\techo -e \"Using supplied plugin download url: ${PLUGIN_DL_PATH}\"\r\n\tPLUGIN_DOWNLOAD_URL=`eval echo $(echo ${PLUGIN_DL_PATH} | sed -e 's/{{/${/g' -e 's/}}/}/g')`\r\nelse\r\n\tPLUGIN_JARFILE=`curl -s https://api.github.com/repos/vincss/mcEmptyServerStopper/releases/latest | jq -r '.assets[].name' | grep 'mcEmptyServerStopper-.*\\.jar'`\r\n\tPLUGIN_VER=`curl -s https://api.github.com/repos/vincss/mcEmptyServerStopper/releases/latest | jq -r '.tag_name'`\r\n\r\n\techo \"Plugin being downloaded\"\r\n\techo -e \"Plugin Version: ${PLUGIN_VER}\"\r\n\techo -e \"JAR Name of Plugin: ${PLUGIN_JARFILE}\"\r\n\tPLUGIN_DOWNLOAD_URL=https://github.com/vincss/mcEmptyServerStopper/releases/latest/download/${PLUGIN_JARFILE}\r\nfi\r\n\r\ncd /mnt/server\r\n\r\necho -e \"Running curl -o ${SERVER_JARFILE} ${DOWNLOAD_URL}\"\r\n\r\nif [ -f ${SERVER_JARFILE} ]; then\r\n\tmv ${SERVER_JARFILE} ${SERVER_JARFILE}.old\r\nfi\r\ncurl -o ${SERVER_JARFILE} ${DOWNLOAD_URL}\r\n\r\nif [ ! -f mcsleepingserverstarter-linux ]; then\r\n echo -e \"Downloading mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\"\r\n curl -Lo mcsleepingserverstarter-linux https://github.com/vincss/mcsleepingserverstarter/releases/latest/download/mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\r\nfi\r\nchmod +x mcsleepingserverstarter-linux\r\n\r\nif [ ! -f server.properties ]; then\r\n echo -e \"Downloading MC server.properties\"\r\n curl -o server.properties https://raw.githubusercontent.com/parkervcp/eggs/master/minecraft/java/server.properties\r\nfi\r\n\r\nif [ ! -f sleepingSettings.yml ]; then\r\n echo -e \"Downloading sleepingSettings.yml\"\r\n curl -o sleepingSettings.yml https://raw.githubusercontent.com/vincss/mcsleepingserverstarter/master/sleepingSettings.yml\r\nfi\r\n\r\nif [ ! -f plugins/${PLUGIN_JARFILE} ]; then\r\n echo -e \"Downloading mcEmptyServerStopper\"\r\n mkdir plugins\r\n cd plugins\r\n curl -Lo ${PLUGIN_JARFILE} ${PLUGIN_DOWNLOAD_URL}\r\nfi\r\n\r\necho -e \"-- Install End --\"", + "container": "ghcr.io/pterodactyl/installers:alpine", + "entrypoint": "ash" + } + }, + "variables": [ + { + "name": "Minecraft Version", + "description": "The version of minecraft to download. \r\n\r\nLeave at latest to always get the latest version. Invalid versions will default to latest.", + "env_variable": "MINECRAFT_VERSION", + "default_value": "latest", + "user_viewable": true, + "user_editable": true, + "rules": "nullable|string|max:20", + "field_type": "text" }, - "exported_at": "2023-06-27T20:12:19+02:00", - "name": "Paper (mcsleepingserverstarter)", - "author": "kevin@boredkevin.com", - "description": "High performance Spigot fork that aims to fix gameplay and mechanics inconsistencies.\r\nPut your minecraft server to rest, while SleepingServerStarter is watching !", - "features": [ - "eula", - "java_version", - "pid_limit" - ], - "docker_images": { - "Java 17": "ghcr.io\/pterodactyl\/yolks:java_17", - "Java 16": "ghcr.io\/pterodactyl\/yolks:java_16", - "Java 11": "ghcr.io\/pterodactyl\/yolks:java_11", - "Java 8": "ghcr.io\/pterodactyl\/yolks:java_8" + { + "name": "Download Path", + "description": "A URL to use to download a server.jar rather than the ones in the install script. This is not user viewable.", + "env_variable": "DL_PATH", + "default_value": "", + "user_viewable": false, + "user_editable": false, + "rules": "nullable|string", + "field_type": "text" }, - "file_denylist": [], - "startup": ".\/mcsleepingserverstarter-linux", - "config": { - "files": "{\r\n \"server.properties\": {\r\n \"parser\": \"properties\",\r\n \"find\": {\r\n \"server-ip\": \"0.0.0.0\",\r\n \"server-port\": \"{{server.build.default.port}}\",\r\n \"query.port\": \"{{server.build.default.port}}\"\r\n }\r\n },\r\n \"sleepingSettings.yml\": {\r\n \"parser\": \"yaml\",\r\n \"find\": {\r\n \"serverPort\": \"{{server.build.default.port}}\",\r\n \"minecraftCommand\": \"java -Xms128M -XX:MaxRAMPercentage=95.0 -Dterminal.jline=false -Dterminal.ansi=true -jar {{env.SERVER_JARFILE}}\"\r\n }\r\n }\r\n}", - "startup": "{\r\n \"done\": \")! For help, type \"\r\n}", - "logs": "{}", - "stop": "stop" + { + "name": "Build Number", + "description": "The build number for the paper release.\r\n\r\nLeave at latest to always get the latest version. Invalid versions will default to latest.", + "env_variable": "BUILD_NUMBER", + "default_value": "latest", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|max:20", + "field_type": "text" }, - "scripts": { - "installation": { - "script": "#!\/bin\/ash\r\n# Paper Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\necho -e \"-- Install Begin --\"\r\n\r\nPROJECT=paper\r\nSYSTEM_ARCHITECTURE=$([[ \"$(uname -m)\" == \"x86_64\" ]] && echo \"x64\" || echo \"arm64\")\r\n\r\nif [ -n \"${DL_PATH}\" ]; then\r\n\techo -e \"Using supplied download url: ${DL_PATH}\"\r\n\tDOWNLOAD_URL=`eval echo $(echo ${DL_PATH} | sed -e 's\/{{\/${\/g' -e 's\/}}\/}\/g')`\r\nelse\r\n\tVER_EXISTS=`curl -s https:\/\/api.papermc.io\/v2\/projects\/${PROJECT} | jq -r --arg VERSION $MINECRAFT_VERSION '.versions[] | contains($VERSION)' | grep -m1 true`\r\n\tLATEST_VERSION=`curl -s https:\/\/api.papermc.io\/v2\/projects\/${PROJECT} | jq -r '.versions' | jq -r '.[-1]'`\r\n\r\n\tif [ \"${VER_EXISTS}\" == \"true\" ]; then\r\n\t\techo -e \"Version is valid. Using version ${MINECRAFT_VERSION}\"\r\n\telse\r\n\t\techo -e \"Specified version not found. Defaulting to the latest ${PROJECT} version\"\r\n\t\tMINECRAFT_VERSION=${LATEST_VERSION}\r\n\tfi\r\n\r\n\tBUILD_EXISTS=`curl -s https:\/\/api.papermc.io\/v2\/projects\/${PROJECT}\/versions\/${MINECRAFT_VERSION} | jq -r --arg BUILD ${BUILD_NUMBER} '.builds[] | tostring | contains($BUILD)' | grep -m1 true`\r\n\tLATEST_BUILD=`curl -s https:\/\/api.papermc.io\/v2\/projects\/${PROJECT}\/versions\/${MINECRAFT_VERSION} | jq -r '.builds' | jq -r '.[-1]'`\r\n\r\n\tif [ \"${BUILD_EXISTS}\" == \"true\" ]; then\r\n\t\techo -e \"Build is valid for version ${MINECRAFT_VERSION}. Using build ${BUILD_NUMBER}\"\r\n\telse\r\n\t\techo -e \"Using the latest ${PROJECT} build for version ${MINECRAFT_VERSION}\"\r\n\t\tBUILD_NUMBER=${LATEST_BUILD}\r\n\tfi\r\n\r\n\tJAR_NAME=${PROJECT}-${MINECRAFT_VERSION}-${BUILD_NUMBER}.jar\r\n\r\n\techo \"Version being downloaded\"\r\n\techo -e \"MC Version: ${MINECRAFT_VERSION}\"\r\n\techo -e \"Build: ${BUILD_NUMBER}\"\r\n\techo -e \"JAR Name of Build: ${JAR_NAME}\"\r\n\tDOWNLOAD_URL=https:\/\/api.papermc.io\/v2\/projects\/${PROJECT}\/versions\/${MINECRAFT_VERSION}\/builds\/${BUILD_NUMBER}\/downloads\/${JAR_NAME}\r\nfi\r\necho -e \"----\"\r\nif [ -n \"${PLUGIN_DL_PATH}\" ]; then\r\n\techo -e \"Using supplied plugin download url: ${PLUGIN_DL_PATH}\"\r\n\tPLUGIN_DOWNLOAD_URL=`eval echo $(echo ${PLUGIN_DL_PATH} | sed -e 's\/{{\/${\/g' -e 's\/}}\/}\/g')`\r\nelse\r\n\tPLUGIN_JARFILE=`curl -s https:\/\/api.github.com\/repos\/vincss\/mcEmptyServerStopper\/releases\/latest | jq -r '.assets[].name' | grep 'mcEmptyServerStopper-.*\\.jar'`\r\n\tPLUGIN_VER=`curl -s https:\/\/api.github.com\/repos\/vincss\/mcEmptyServerStopper\/releases\/latest | jq -r '.tag_name'`\r\n\r\n\techo \"Plugin being downloaded\"\r\n\techo -e \"Plugin Version: ${PLUGIN_VER}\"\r\n\techo -e \"JAR Name of Plugin: ${PLUGIN_JARFILE}\"\r\n\tPLUGIN_DOWNLOAD_URL=https:\/\/github.com\/vincss\/mcEmptyServerStopper\/releases\/latest\/download\/${PLUGIN_JARFILE}\r\nfi\r\n\r\ncd \/mnt\/server\r\n\r\necho -e \"Running curl -o ${SERVER_JARFILE} ${DOWNLOAD_URL}\"\r\n\r\nif [ -f ${SERVER_JARFILE} ]; then\r\n\tmv ${SERVER_JARFILE} ${SERVER_JARFILE}.old\r\nfi\r\ncurl -o ${SERVER_JARFILE} ${DOWNLOAD_URL}\r\n\r\nif [ ! -f mcsleepingserverstarter-linux ]; then\r\n echo -e \"Downloading mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\"\r\n curl -Lo mcsleepingserverstarter-linux https:\/\/github.com\/vincss\/mcsleepingserverstarter\/releases\/latest\/download\/mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\r\nfi\r\nchmod +x mcsleepingserverstarter-linux\r\n\r\nif [ ! -f server.properties ]; then\r\n echo -e \"Downloading MC server.properties\"\r\n curl -o server.properties https:\/\/raw.githubusercontent.com\/parkervcp\/eggs\/master\/minecraft\/java\/server.properties\r\nfi\r\n\r\nif [ ! -f sleepingSettings.yml ]; then\r\n echo -e \"Downloading sleepingSettings.yml\"\r\n curl -o sleepingSettings.yml https:\/\/raw.githubusercontent.com\/vincss\/mcsleepingserverstarter\/master\/sleepingSettings.yml\r\nfi\r\n\r\nif [ ! -f plugins\/${PLUGIN_JARFILE} ]; then\r\n echo -e \"Downloading mcEmptyServerStopper\"\r\n mkdir plugins\r\n cd plugins\r\n curl -Lo ${PLUGIN_JARFILE} ${PLUGIN_DOWNLOAD_URL}\r\nfi\r\n\r\necho -e \"-- Install End --\"", - "container": "ghcr.io\/pterodactyl\/installers:alpine", - "entrypoint": "ash" - } + { + "name": "Server Jar File", + "description": "The name of the server jarfile to run the server with.", + "env_variable": "SERVER_JARFILE", + "default_value": "server.jar", + "user_viewable": true, + "user_editable": true, + "rules": "required|regex:/^([\\w\\d._-]+)(\\.jar)$/", + "field_type": "text" }, - "variables": [ - { - "name": "Minecraft Version", - "description": "The version of minecraft to download. \r\n\r\nLeave at latest to always get the latest version. Invalid versions will default to latest.", - "env_variable": "MINECRAFT_VERSION", - "default_value": "latest", - "user_viewable": true, - "user_editable": true, - "rules": "nullable|string|max:20", - "field_type": "text" - }, - { - "name": "Download Path", - "description": "A URL to use to download a server.jar rather than the ones in the install script. This is not user viewable.", - "env_variable": "DL_PATH", - "default_value": "", - "user_viewable": false, - "user_editable": false, - "rules": "nullable|string", - "field_type": "text" - }, - { - "name": "Build Number", - "description": "The build number for the paper release.\r\n\r\nLeave at latest to always get the latest version. Invalid versions will default to latest.", - "env_variable": "BUILD_NUMBER", - "default_value": "latest", - "user_viewable": true, - "user_editable": true, - "rules": "required|string|max:20", - "field_type": "text" - }, - { - "name": "Server Jar File", - "description": "The name of the server jarfile to run the server with.", - "env_variable": "SERVER_JARFILE", - "default_value": "server.jar", - "user_viewable": true, - "user_editable": true, - "rules": "required|regex:\/^([\\w\\d._-]+)(\\.jar)$\/", - "field_type": "text" - }, - { - "name": "Plugin Download Path", - "description": "A URL to use to download the mcEmptyServerStopper plugin, rather than the ones in the install script. This is not user viewable.", - "env_variable": "PLUGIN_DL_PATH", - "default_value": "", - "user_viewable": false, - "user_editable": false, - "rules": "nullable|string", - "field_type": "text" - } - ] -} \ No newline at end of file + { + "name": "Plugin Download Path", + "description": "A URL to use to download the mcEmptyServerStopper plugin, rather than the ones in the install script. This is not user viewable.", + "env_variable": "PLUGIN_DL_PATH", + "default_value": "", + "user_viewable": false, + "user_editable": false, + "rules": "nullable|string", + "field_type": "text" + } + ] +} diff --git a/docs/egg-vanilla-minecraft-mcsleepingserverstarter.json b/docs/egg-vanilla-minecraft-mcsleepingserverstarter.json index 6efc282..0341790 100644 --- a/docs/egg-vanilla-minecraft-mcsleepingserverstarter.json +++ b/docs/egg-vanilla-minecraft-mcsleepingserverstarter.json @@ -1,59 +1,55 @@ { - "_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO", - "meta": { - "version": "PTDL_v2", - "update_url": null + "_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO", + "meta": { + "version": "PTDL_v2", + "update_url": null + }, + "exported_at": "2023-06-27T20:18:37+02:00", + "name": "Vanilla Minecraft (mcsleepingserverstarter)", + "author": "kevin@boredkevin.com", + "description": "Minecraft is a game about placing blocks and going on adventures. Explore randomly generated worlds and build amazing things from the simplest of homes to the grandest of castles. Play in Creative Mode with unlimited resources or mine deep in Survival Mode, crafting weapons and armor to fend off dangerous mobs. Do all this alone or with friends.\r\nPut your minecraft server to rest, while SleepingServerStarter is watching !", + "features": ["eula", "java_version", "pid_limit"], + "docker_images": { + "Java 17": "ghcr.io/pterodactyl/yolks:java_17", + "Java 16": "ghcr.io/pterodactyl/yolks:java_16", + "Java 11": "ghcr.io/pterodactyl/yolks:java_11", + "Java 8": "ghcr.io/pterodactyl/yolks:java_8" + }, + "file_denylist": [], + "startup": "./mcsleepingserverstarter-linux", + "config": { + "files": "{\r\n \"server.properties\": {\r\n \"parser\": \"properties\",\r\n \"find\": {\r\n \"server-ip\": \"0.0.0.0\",\r\n \"server-port\": \"{{server.build.default.port}}\",\r\n \"query.port\": \"{{server.build.default.port}}\"\r\n }\r\n },\r\n \"sleepingSettings.yml\": {\r\n \"parser\": \"yaml\",\r\n \"find\": {\r\n \"serverPort\": \"{{server.build.default.port}}\",\r\n \"minecraftCommand\": \"java -Xms128M -XX:MaxRAMPercentage=95.0 -jar {{env.SERVER_JARFILE}}\"\r\n }\r\n }\r\n}", + "startup": "{\r\n \"done\": \")! For help, type \"\r\n}", + "logs": "{}", + "stop": "stop" + }, + "scripts": { + "installation": { + "script": "#!/bin/ash\r\n# Vanilla MC Installation Script\r\n#\r\n# Server Files: /mnt/server\r\nmkdir -p /mnt/server\r\ncd /mnt/server\r\n\r\nLATEST_VERSION=`curl https://launchermeta.mojang.com/mc/game/version_manifest.json | jq -r '.latest.release'`\r\nLATEST_SNAPSHOT_VERSION=`curl https://launchermeta.mojang.com/mc/game/version_manifest.json | jq -r '.latest.snapshot'`\r\nSYSTEM_ARCHITECTURE=$([[ \"$(uname -m)\" == \"x86_64\" ]] && echo \"x64\" || echo \"arm64\")\r\n\r\necho -e \"latest version is $LATEST_VERSION\"\r\necho -e \"latest snapshot is $LATEST_SNAPSHOT_VERSION\"\r\n\r\nif [ -z \"$VANILLA_VERSION\" ] || [ \"$VANILLA_VERSION\" == \"latest\" ]; then\r\n MANIFEST_URL=$(curl -sSL https://launchermeta.mojang.com/mc/game/version_manifest.json | jq --arg VERSION $LATEST_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nelif [ \"$VANILLA_VERSION\" == \"snapshot\" ]; then\r\n MANIFEST_URL=$(curl -sSL https://launchermeta.mojang.com/mc/game/version_manifest.json | jq --arg VERSION $LATEST_SNAPSHOT_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nelse\r\n MANIFEST_URL=$(curl -sSL https://launchermeta.mojang.com/mc/game/version_manifest.json | jq --arg VERSION $VANILLA_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nfi\r\n\r\nDOWNLOAD_URL=$(curl ${MANIFEST_URL} | jq .downloads.server | jq -r '. | .url')\r\n\r\necho -e \"running: curl -o ${SERVER_JARFILE} $DOWNLOAD_URL\"\r\ncurl -o ${SERVER_JARFILE} $DOWNLOAD_URL\r\n\r\nif [ ! -f mcsleepingserverstarter-linux ]; then\r\n echo -e \"Running curl -Lo mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE} https://github.com/vincss/mcsleepingserverstarter/releases/latest/download/mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\"\r\n curl -Lo mcsleepingserverstarter-linux https://github.com/vincss/mcsleepingserverstarter/releases/latest/download/mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\r\nfi\r\nchmod +x mcsleepingserverstarter-linux\r\n\r\nif [ ! -f sleepingSettings.yml ]; then\r\n echo -e \"Downloading sleepingSettings.yml\"\r\n curl -o sleepingSettings.yml https://raw.githubusercontent.com/vincss/mcsleepingserverstarter/master/sleepingSettings.yml\r\nfi\r\n\r\necho -e \"Install Complete\"", + "container": "ghcr.io/pterodactyl/installers:alpine", + "entrypoint": "ash" + } + }, + "variables": [ + { + "name": "Server Version", + "description": "The version of Minecraft Vanilla to install. Use \"latest\" to install the latest version, or use \"snapshot\" to install the latest snapshot. Go to Settings > Reinstall Server to apply.", + "env_variable": "VANILLA_VERSION", + "default_value": "latest", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|between:3,15", + "field_type": "text" }, - "exported_at": "2023-06-27T20:18:37+02:00", - "name": "Vanilla Minecraft (mcsleepingserverstarter)", - "author": "kevin@boredkevin.com", - "description": "Minecraft is a game about placing blocks and going on adventures. Explore randomly generated worlds and build amazing things from the simplest of homes to the grandest of castles. Play in Creative Mode with unlimited resources or mine deep in Survival Mode, crafting weapons and armor to fend off dangerous mobs. Do all this alone or with friends.\r\nPut your minecraft server to rest, while SleepingServerStarter is watching !", - "features": [ - "eula", - "java_version", - "pid_limit" - ], - "docker_images": { - "Java 17": "ghcr.io\/pterodactyl\/yolks:java_17", - "Java 16": "ghcr.io\/pterodactyl\/yolks:java_16", - "Java 11": "ghcr.io\/pterodactyl\/yolks:java_11", - "Java 8": "ghcr.io\/pterodactyl\/yolks:java_8" - }, - "file_denylist": [], - "startup": ".\/mcsleepingserverstarter-linux", - "config": { - "files": "{\r\n \"server.properties\": {\r\n \"parser\": \"properties\",\r\n \"find\": {\r\n \"server-ip\": \"0.0.0.0\",\r\n \"server-port\": \"{{server.build.default.port}}\",\r\n \"query.port\": \"{{server.build.default.port}}\"\r\n }\r\n },\r\n \"sleepingSettings.yml\": {\r\n \"parser\": \"yaml\",\r\n \"find\": {\r\n \"serverPort\": \"{{server.build.default.port}}\",\r\n \"minecraftCommand\": \"java -Xms128M -XX:MaxRAMPercentage=95.0 -jar {{env.SERVER_JARFILE}}\"\r\n }\r\n }\r\n}", - "startup": "{\r\n \"done\": \")! For help, type \"\r\n}", - "logs": "{}", - "stop": "stop" - }, - "scripts": { - "installation": { - "script": "#!\/bin\/ash\r\n# Vanilla MC Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\nmkdir -p \/mnt\/server\r\ncd \/mnt\/server\r\n\r\nLATEST_VERSION=`curl https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq -r '.latest.release'`\r\nLATEST_SNAPSHOT_VERSION=`curl https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq -r '.latest.snapshot'`\r\nSYSTEM_ARCHITECTURE=$([[ \"$(uname -m)\" == \"x86_64\" ]] && echo \"x64\" || echo \"arm64\")\r\n\r\necho -e \"latest version is $LATEST_VERSION\"\r\necho -e \"latest snapshot is $LATEST_SNAPSHOT_VERSION\"\r\n\r\nif [ -z \"$VANILLA_VERSION\" ] || [ \"$VANILLA_VERSION\" == \"latest\" ]; then\r\n MANIFEST_URL=$(curl -sSL https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq --arg VERSION $LATEST_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nelif [ \"$VANILLA_VERSION\" == \"snapshot\" ]; then\r\n MANIFEST_URL=$(curl -sSL https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq --arg VERSION $LATEST_SNAPSHOT_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nelse\r\n MANIFEST_URL=$(curl -sSL https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq --arg VERSION $VANILLA_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nfi\r\n\r\nDOWNLOAD_URL=$(curl ${MANIFEST_URL} | jq .downloads.server | jq -r '. | .url')\r\n\r\necho -e \"running: curl -o ${SERVER_JARFILE} $DOWNLOAD_URL\"\r\ncurl -o ${SERVER_JARFILE} $DOWNLOAD_URL\r\n\r\nif [ ! -f mcsleepingserverstarter-linux ]; then\r\n echo -e \"Running curl -Lo mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE} https:\/\/github.com\/vincss\/mcsleepingserverstarter\/releases\/latest\/download\/mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\"\r\n curl -Lo mcsleepingserverstarter-linux https:\/\/github.com\/vincss\/mcsleepingserverstarter\/releases\/latest\/download\/mcsleepingserverstarter-linux-${SYSTEM_ARCHITECTURE}\r\nfi\r\nchmod +x mcsleepingserverstarter-linux\r\n\r\nif [ ! -f sleepingSettings.yml ]; then\r\n echo -e \"Downloading sleepingSettings.yml\"\r\n curl -o sleepingSettings.yml https:\/\/raw.githubusercontent.com\/vincss\/mcsleepingserverstarter\/master\/sleepingSettings.yml\r\nfi\r\n\r\necho -e \"Install Complete\"", - "container": "ghcr.io\/pterodactyl\/installers:alpine", - "entrypoint": "ash" - } - }, - "variables": [ - { - "name": "Server Version", - "description": "The version of Minecraft Vanilla to install. Use \"latest\" to install the latest version, or use \"snapshot\" to install the latest snapshot. Go to Settings > Reinstall Server to apply.", - "env_variable": "VANILLA_VERSION", - "default_value": "latest", - "user_viewable": true, - "user_editable": true, - "rules": "required|string|between:3,15", - "field_type": "text" - }, - { - "name": "Server Jar File", - "description": "The name of the server jarfile to run the server with.", - "env_variable": "SERVER_JARFILE", - "default_value": "server.jar", - "user_viewable": true, - "user_editable": true, - "rules": "required|regex:\/^([\\w\\d._-]+)(\\.jar)$\/", - "field_type": "text" - } - ] -} \ No newline at end of file + { + "name": "Server Jar File", + "description": "The name of the server jarfile to run the server with.", + "env_variable": "SERVER_JARFILE", + "default_value": "server.jar", + "user_viewable": true, + "user_editable": true, + "rules": "required|regex:/^([\\w\\d._-]+)(\\.jar)$/", + "field_type": "text" + } + ] +} diff --git a/package-lock.json b/package-lock.json index 91cae15..0443022 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mcsleepingserverstarter", - "version": "1.9.0", + "version": "1.9.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mcsleepingserverstarter", - "version": "1.9.0", + "version": "1.9.1", "license": "ISC", "dependencies": { "@jsprismarine/prismarine": "0.1.0-rc.49", @@ -15,7 +15,7 @@ "express": "^4.18.2", "express-handlebars": "^7.0.4", "js-yaml": "^4.1.0", - "minecraft-protocol": "^1.44.0", + "minecraft-protocol": "^1.46.0", "prismarine-chat": "^1.8.0", "properties-reader": "^2.3.0", "winston": "^3.8.2" @@ -6848,9 +6848,9 @@ } }, "node_modules/minecraft-data": { - "version": "3.37.0", - "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.37.0.tgz", - "integrity": "sha512-hcKncWDaI4OiGcvZ8ufrLwq548Z1vl1TqMEpxOuPGj0ro4mb7X+rMWtHcP4grWAJz6IKK2TXKSz0YcRX+IBJZw==" + "version": "3.61.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.61.0.tgz", + "integrity": "sha512-e7FMplGNjhAZvdxT66bP56ZqHymr+BrzCZlhNxRr1suFKueGSTQQA+DZ2ZU/vW/02dBFCrHfBEJh1sw5vOZ+Ew==" }, "node_modules/minecraft-folder-path": { "version": "1.2.0", @@ -6858,9 +6858,9 @@ "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==" }, "node_modules/minecraft-protocol": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.44.0.tgz", - "integrity": "sha512-sYu4fFzUKt3spPG5tAdkaB9sNQPT0sV6fyS0sS7/nxdzFfjmLhF6BLNC+32ieK4/MhgNyHtH6xusD0Bi0Roq9w==", + "version": "1.46.0", + "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.46.0.tgz", + "integrity": "sha512-MxFPg+YyucHLxT7t3kDGaIzLoeYtjiXuk3ledy6LZCQmUyPq8YlVeB9WgIGX4NzDx45N3gDNHcx+eh0x1uKsRw==", "dependencies": { "@types/readable-stream": "^4.0.0", "aes-js": "^3.1.2", @@ -6869,12 +6869,12 @@ "endian-toggle": "^0.0.0", "lodash.get": "^4.1.2", "lodash.merge": "^4.3.0", - "minecraft-data": "^3.37.0", + "minecraft-data": "^3.53.0", "minecraft-folder-path": "^1.2.0", "node-fetch": "^2.6.1", "node-rsa": "^0.4.2", "prismarine-auth": "^2.2.0", - "prismarine-nbt": "^2.0.0", + "prismarine-nbt": "^2.5.0", "prismarine-realms": "^1.2.0", "protodef": "^1.8.0", "readable-stream": "^4.1.0", @@ -8057,9 +8057,9 @@ } }, "node_modules/prismarine-nbt": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.2.1.tgz", - "integrity": "sha512-Mb50c58CPnuZ+qvM31DBa08tf9UumlTq1LkvpMoUpKfCuN05GZHTqCUwER3lxTSHLL0GZKghIPbYR/JQkINijQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.5.0.tgz", + "integrity": "sha512-F0/8UAa9SDDnAGrBYqZc4nG8h2zj5cE2eAJU5xlDR/IsQQ3moVxkOjE3h3nMv6SbvZrvAcgX7waA/nd9LLHYdA==", "dependencies": { "protodef": "^1.9.0" } diff --git a/package.json b/package.json index 92c33dc..0014363 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcsleepingserverstarter", - "version": "1.9.0", + "version": "1.9.1", "description": "Sleeps until someone connects", "main": "build/sleepingServerStarter.js", "bin": "build/sleepingServerStarter.js", @@ -23,7 +23,7 @@ "express": "^4.18.2", "express-handlebars": "^7.0.4", "js-yaml": "^4.1.0", - "minecraft-protocol": "^1.44.0", + "minecraft-protocol": "^1.46.0", "prismarine-chat": "^1.8.0", "properties-reader": "^2.3.0", "winston": "^3.8.2" diff --git a/src/sleepingContainer.ts b/src/sleepingContainer.ts index 034d182..4100bc8 100644 --- a/src/sleepingContainer.ts +++ b/src/sleepingContainer.ts @@ -11,7 +11,12 @@ import { import { getLogger, LoggerType, version } from "./sleepingLogger"; import { SleepingMcJava } from "./sleepingMcJava"; import { ISleepingServer } from "./sleepingServerInterface"; -import { getSettings, getAccessSettings, Settings, AccessFileSettings } from "./sleepingSettings"; +import { + getSettings, + getAccessSettings, + Settings, + AccessFileSettings, +} from "./sleepingSettings"; import { Player, PlayerConnectionCallBackType } from "./sleepingTypes"; import { SleepingWeb } from "./sleepingWeb"; @@ -150,7 +155,11 @@ export class SleepingContainer implements ISleepingServer { playerConnectionCallBack: PlayerConnectionCallBackType = async ( player: Player ) => { - const accessStatus = isAccessAllowed(player, this.settings, this.accessSettings); + const accessStatus = isAccessAllowed( + player, + this.settings, + this.accessSettings + ); if (!accessStatus.allowed) { this.logger.info(`[Container] ${player}: ${accessStatus.reason}.`); return; diff --git a/src/sleepingHelper.ts b/src/sleepingHelper.ts index 5d0d09e..d9feb18 100644 --- a/src/sleepingHelper.ts +++ b/src/sleepingHelper.ts @@ -77,85 +77,92 @@ export const getMOTD = ( .toJSON(); }; -export const getMinecraftDirectory = ( - settings: Settings -): string => { +export const getMinecraftDirectory = (settings: Settings): string => { return settings.minecraftWorkingDirectory ?? process.cwd(); -} +}; export const isAccessAllowed = ( - player: Player, - settings: Settings, - accessSettings: AccessFileSettings + player: Player, + settings: Settings, + accessSettings: AccessFileSettings ): AccessStatus => { const username = player.playerName; const uuid = player.uuid; const ip = player.ip; - if (!player.realUser){ + if (!player.realUser) { return new AccessStatus(true, "Not real user"); } if (settings.useBlacklistFiles) { - const isBannedIp = accessSettings.bannedIpEntries?.some(ipEntry => - ip?.includes(ipEntry.ip) + const isBannedIp = accessSettings.bannedIpEntries?.some((ipEntry) => + ip?.includes(ipEntry.ip) ); if (isBannedIp) { return new AccessStatus(false, "IP is banned on the server"); } - const isBannedPlayer = accessSettings.bannedPlayerEntries?.some(playerEntry => - playerEntry.name == username && playerEntry.uuid == uuid + const isBannedPlayer = accessSettings.bannedPlayerEntries?.some( + (playerEntry) => playerEntry.name == username && playerEntry.uuid == uuid ); if (isBannedPlayer) { return new AccessStatus(false, "Player is banned on the server"); } } - if (ip && settings.blackListedAddress?.some((address) => - ip.includes(address) - )) { - return new AccessStatus(false, "IP is in the blackListedAddress") + if ( + ip && + settings.blackListedAddress?.some((address) => ip.includes(address)) + ) { + return new AccessStatus(false, "IP is in the blackListedAddress"); } - if (settings.useWhitelistFile){ + if (settings.useWhitelistFile) { if ( accessSettings.whitelistEntries && - !accessSettings.whitelistEntries?.some(whitelistEntry => + !accessSettings.whitelistEntries?.some( + (whitelistEntry) => whitelistEntry.name == username && whitelistEntry.uuid == uuid - )) { + ) + ) { return new AccessStatus(false, "Player is not in the server whitelist"); } - } else if (settings.whiteListedNames && !settings.whiteListedNames.includes(username)) { - return new AccessStatus(false, "Player name is not in the whiteListedNames"); + } else if ( + settings.whiteListedNames && + !settings.whiteListedNames.includes(username) + ) { + return new AccessStatus( + false, + "Player name is not in the whiteListedNames" + ); } return new AccessStatus(true); -} +}; export const loadFile = ( - filePath: string, - description: string, - settings?: Settings, - onFail?: any + filePath: string, + description: string, + settings?: Settings, + onFail?: any ): any => { let result; try { - const fullPath = settings ? path.join(getMinecraftDirectory(settings), filePath) : filePath; - getLogger().info(`Retrieving ${description} from ${fullPath}`) + const fullPath = settings + ? path.join(getMinecraftDirectory(settings), filePath) + : filePath; + getLogger().info(`Retrieving ${description} from ${fullPath}`); const read = readFileSync(fullPath).toString(); result = load(read); - getLogger().info( - `Retrieved ${description}:${JSON.stringify(result)}` - ); + getLogger().info(`Retrieved ${description}:${JSON.stringify(result)}`); return result; } catch (error: any) { getLogger().error(`Failed to load ${description}.`, error); if (onFail) { - onFail(error) + onFail(error); } } -} +}; export enum ServerStatus { Sleeping = "Sleeping", diff --git a/src/sleepingMcJava.ts b/src/sleepingMcJava.ts index 4212160..23f942a 100644 --- a/src/sleepingMcJava.ts +++ b/src/sleepingMcJava.ts @@ -1,5 +1,10 @@ -import { Client, createServer, Server } from "minecraft-protocol"; -import { getFavIcon, getMOTD, isAccessAllowed, ServerStatus } from "./sleepingHelper"; +import { Client, createServer, Server, ServerClient } from "minecraft-protocol"; +import { + getFavIcon, + getMOTD, + isAccessAllowed, + ServerStatus, +} from "./sleepingHelper"; import { getLogger, LoggerType } from "./sleepingLogger"; import { ISleepingServer } from "./sleepingServerInterface"; import { AccessFileSettings, Settings } from "./sleepingSettings"; @@ -16,9 +21,9 @@ export class SleepingMcJava implements ISleepingServer { isClosing = false; constructor( - playerConnectionCallBack: PlayerConnectionCallBackType, - settings: Settings, - accessSettings: AccessFileSettings + playerConnectionCallBack: PlayerConnectionCallBackType, + settings: Settings, + accessSettings: AccessFileSettings ) { this.settings = settings; this.accessSettings = accessSettings; @@ -54,22 +59,38 @@ export class SleepingMcJava implements ISleepingServer { this.server.on("connection", (client: Client) => { !this.settings.hideOnConnectionLogs && - this.logger.info( - `A Prince has taken a quick peek. [${client.version}${this.getIp( - client - )}]` - ); + this.logger.info( + `A Prince has taken a quick peek. [${client.version}${this.getIp( + client + )}]` + ); }); this.server.on("listening", () => { this.logger.info("[McJava] Ready for battle"); }); - this.server.on("login", (client) => { + if (this.settings.useLegacyLogin) { + this.server.on("login", this.onLogin); + } else { + this.server.on("playerJoin", this.onLogin); + } + + this.server.on("error", (error) => { + this.logger.error(`Something went wrong in wonderland ${error.message}`); + }); + }; + + onLogin = (client: ServerClient) => { + { const userName = client.username; const player = Player.fromClient(client); - const accessStatus = isAccessAllowed(player, this.settings, this.accessSettings); + const accessStatus = isAccessAllowed( + player, + this.settings, + this.accessSettings + ); if (!accessStatus.allowed) { this.logger.info( `${player}.${client.state}:[${client.socket.remoteAddress}], rejected: ${accessStatus.reason}.` @@ -102,11 +123,7 @@ export class SleepingMcJava implements ISleepingServer { }); this.logger.info(`Sending best regards ${this.settings.loginMessage}`); client.end(this.settings.loginMessage); - }); - - this.server.on("error", (error) => { - this.logger.error(`Something went wrong in wonderland ${error.message}`); - }); + } }; close = async () => { diff --git a/src/sleepingServerStarter.ts b/src/sleepingServerStarter.ts index ecc24dc..6f43c3b 100644 --- a/src/sleepingServerStarter.ts +++ b/src/sleepingServerStarter.ts @@ -42,7 +42,9 @@ process.on("uncaughtException", (err: Error) => { } logger.info( - `[Main] ... Restarting the server in (${sleepingContainer.getSettings().restartDelay / 1000} secs)...` + `[Main] ... Restarting the server in (${ + sleepingContainer.getSettings().restartDelay / 1000 + } secs)...` ); setTimeout(async () => { await sleepingContainer.close(true); diff --git a/src/sleepingSettings.ts b/src/sleepingSettings.ts index b0dfef3..aed9903 100644 --- a/src/sleepingSettings.ts +++ b/src/sleepingSettings.ts @@ -4,7 +4,7 @@ import { getLogger } from "./sleepingLogger"; import { getMinecraftDirectory, loadFile } from "./sleepingHelper"; import path from "path"; -import PropertiesReader = require('properties-reader'); +import PropertiesReader = require("properties-reader"); const logger = getLogger(); @@ -44,6 +44,7 @@ export type Settings = { useNativeFiles: boolean; hideIpInLogs?: boolean; hideOnConnectionLogs?: boolean; + useLegacyLogin?: boolean; }; export const DefaultSettings: Settings = { @@ -61,14 +62,14 @@ export const DefaultSettings: Settings = { version: false, useWhitelistFile: false, useBlacklistFiles: false, - useNativeFiles: false + useNativeFiles: false, }; export type AccessFileSettings = { - whitelistEntries?: WhitelistEntry[], - bannedIpEntries?: BannedIpEntry[], - bannedPlayerEntries?: BannedPlayerEntry[] -} + whitelistEntries?: WhitelistEntry[]; + bannedIpEntries?: BannedIpEntry[]; + bannedPlayerEntries?: BannedPlayerEntry[]; +}; export type WhitelistEntry = { name: string; @@ -94,7 +95,7 @@ export type BannedPlayerEntry = { function saveDefault() { try { - logger.info(`Saving default settings to ${SettingFilePath}`) + logger.info(`Saving default settings to ${SettingFilePath}`); const yamlToWrite = dump(DefaultSettings); writeFileSync(SettingFilePath, yamlToWrite); } catch (error: any) { @@ -112,7 +113,10 @@ export function getSettings(): Settings { try { applyNativeProperties(settings); } catch (error: any) { - logger.error(`useNativeFiles is specified, but wasn't able to read ${NativePropertiesFilePath}.`, error) + logger.error( + `useNativeFiles is specified, but wasn't able to read ${NativePropertiesFilePath}.`, + error + ); } } } catch (error: any) { @@ -146,26 +150,34 @@ export function getAccessSettings(settings: Settings): AccessFileSettings { return { whitelistEntries: getWhitelistEntries(settings), bannedIpEntries: getBannerIpEntries(settings), - bannedPlayerEntries: getBannerPlayerEntries(settings) - } + bannedPlayerEntries: getBannerPlayerEntries(settings), + }; } -export function getWhitelistEntries(settings: Settings): WhitelistEntry[] | undefined { - return loadFile(WhitelistFilePath, "whitelist entries", settings) +export function getWhitelistEntries( + settings: Settings +): WhitelistEntry[] | undefined { + return loadFile(WhitelistFilePath, "whitelist entries", settings); } -export function getBannerIpEntries(settings: Settings): BannedIpEntry[] | undefined { - return loadFile(BannedIpsFilePath, "banned ips", settings) +export function getBannerIpEntries( + settings: Settings +): BannedIpEntry[] | undefined { + return loadFile(BannedIpsFilePath, "banned ips", settings); } -export function getBannerPlayerEntries(settings: Settings): BannedPlayerEntry[] | undefined { - return loadFile(BannedPlayersFilePath, "banned players", settings) +export function getBannerPlayerEntries( + settings: Settings +): BannedPlayerEntry[] | undefined { + return loadFile(BannedPlayersFilePath, "banned players", settings); } export function applyNativeProperties(settings: Settings) { - const properties = PropertiesReader(path.join(getMinecraftDirectory(settings), NativePropertiesFilePath)); + const properties = PropertiesReader( + path.join(getMinecraftDirectory(settings), NativePropertiesFilePath) + ); - logger.info(`Loaded server.properties: ${JSON.stringify(properties)}`) + logger.info(`Loaded server.properties: ${JSON.stringify(properties)}`); const portProperty = properties.get("query.port"); const maxPlayersProperty = properties.get("max-players"); diff --git a/src/sleepingTypes.ts b/src/sleepingTypes.ts index 3032197..856df27 100644 --- a/src/sleepingTypes.ts +++ b/src/sleepingTypes.ts @@ -1,52 +1,52 @@ -import {Client} from "minecraft-protocol"; +import { Client } from "minecraft-protocol"; export type PlayerConnectionCallBackType = (player: Player) => void; export class Player { - playerName: string; - uuid: string; - ip?: string; - realUser: boolean; - - private constructor(name: string, client?: Client) { - if (client) { - this.playerName = client.username; - this.uuid = client.uuid; - this.ip = client.socket.remoteAddress - this.realUser = true; - } else { - this.playerName = name; - this.uuid = name; - this.realUser = false; - } + playerName: string; + uuid: string; + ip?: string; + realUser: boolean; + + private constructor(name: string, client?: Client) { + if (client) { + this.playerName = client.username; + this.uuid = client.uuid; + this.ip = client.socket.remoteAddress; + this.realUser = true; + } else { + this.playerName = name; + this.uuid = name; + this.realUser = false; } + } - static cli() { - return new Player("A CliUser"); - } + static cli() { + return new Player("A CliUser"); + } - static bedrock() { - return new Player("A BedRock Player"); - } + static bedrock() { + return new Player("A BedRock Player"); + } - static web() { - return new Player("A WebUser"); - } + static web() { + return new Player("A WebUser"); + } - static fromClient(client: Client) { - return new Player("", client); - } + static fromClient(client: Client) { + return new Player("", client); + } - toString() { - return `${this.playerName}(${this.uuid})`; - } + toString() { + return `${this.playerName}(${this.uuid})`; + } } export class AccessStatus { - allowed: boolean; - reason?: string; - constructor(allowed: boolean, reason?: string) { - this.allowed = allowed; - this.reason = reason; - } -} \ No newline at end of file + allowed: boolean; + reason?: string; + constructor(allowed: boolean, reason?: string) { + this.allowed = allowed; + this.reason = reason; + } +} diff --git a/src/sleepingWeb.ts b/src/sleepingWeb.ts index 465a554..b1c846e 100644 --- a/src/sleepingWeb.ts +++ b/src/sleepingWeb.ts @@ -4,7 +4,12 @@ import { engine } from "express-handlebars"; import * as http from "http"; import path from "path"; import { SleepingContainer } from "./sleepingContainer"; -import { getFavIcon, getMOTD, getMinecraftDirectory, ServerStatus } from "./sleepingHelper"; +import { + getFavIcon, + getMOTD, + getMinecraftDirectory, + ServerStatus, +} from "./sleepingHelper"; import { getLogger, LoggerType } from "./sleepingLogger"; import { ISleepingServer } from "./sleepingServerInterface"; import { Settings } from "./sleepingSettings"; @@ -128,14 +133,10 @@ export class SleepingWeb implements ISleepingServer { this.app.post(`${this.webPath}/restart`, async (req, res) => { res.send("received"); - this.logger.info( - `[WebServer]${this.getIp( - req.socket - )} Restart server` - ); + this.logger.info(`[WebServer]${this.getIp(req.socket)} Restart server`); this.sleepingContainer.killMinecraft(true); - }) + }); this.app.get(`${this.webPath}/status`, async (req, res) => { const status = await this.sleepingContainer.getStatus(); @@ -165,7 +166,10 @@ export class SleepingWeb implements ISleepingServer { return; } } else { - dynmapPath = path.join(getMinecraftDirectory(this.settings), "plugins/dynmap/web"); + dynmapPath = path.join( + getMinecraftDirectory(this.settings), + "plugins/dynmap/web" + ); } this.logger.info(`[WebServer] Serving dynmap: ${dynmapPath}`); if (existsSync(dynmapPath)) {