diff --git a/README.md b/README.md new file mode 100644 index 0000000..204cf21 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# replit eaglercraft server + +[extra help discord server](https://discord.gg/9HfPSp3D) + +### smashed together by [ayunami2000](https://github.com/ayunami2000) + +## Helpful video tutorial by a generous user +motd changing is a LOT easier now -- see the top of `main.sh` to change it!! + +https://www.wevideo.com/view/2581865286 + +YouTube Mirror: https://www.youtube.com/watch?v=As99AOL_-vM + +## Usage: +Fork it, and press "Run" at the top to run the server! + +## + +### NOTE: to control, you MUST open the website view in a new tab instead of playing in the editor. + +## To change the server icon: +Replace the `server-icon.png` file under `java/bungee_command` with your desired server icon. + +## To run server commands: +In the "Console" tab in the replit, you can send server commands. + +## To save progress: +**Notice: This is now done automatically, every 5 minutes, using a plugin!** In the server console or in-game as an opped player, run `/save-all` to save the world. + +## Too slow? +This is because you are using a free service to host a Minecraft server. Of course it is slow and the only way to fix this is to self-host at home. + +## Getting admin/OP or enabling command blocks +To give yourself OP (admin), go to the server console and run `op username` and press enter (replacing "username" with your username in-game). + +To enable command blocks, go to `java/bukkit_command/server.properties` and add a new line at the end: `enable-command-block=true`. Then, restart the server. + +## [Item ID List](http://mineteamleblog.blogspot.com/p/minecraft-id-list-151.html) + +## Plugins +Eaglercraft is Minecraft 1.5.2, so plugins you will use will have to be supported by Bukkit 1.5.2 (not Spigot). You can add plugin JAR files into the `java/bukkit_command/plugins` folder. + +**Official Plugin Collection** + +https://github.com/LAX1DUDE/eaglercraft-plugins + +**Some plugins I suggest you use:** + +### [LoginSecurity](https://dev.bukkit.org/projects/loginsecurity/files/711129) +Adds /login and /register to your server. **Make sure you turn OFF sessions in the config (run server once after adding plugin, run the server once after adding loginsecurity, go to "plugins/LoginSecurity/config.yml", and change `sessions: use:` from true to false), or else players may be able to "resume session" on any account!** +### [Essentials](https://dev.bukkit.org/projects/essentials/files/711777) & [Essentials Extra](https://dev.bukkit.org/projects/essentials/files/711776) +"Essential" commands and features for any Minecraft server. Widely popular, even today! +### [WorldEdit](https://dev.bukkit.org/projects/worldedit/files/698941) +Super popular world editing plugin! +### [WorldGuard](https://dev.bukkit.org/projects/worldguard/files/706558) +Region protecting. Requires WorldEdit for selecting the regions. +### [PlotMe](https://dev.bukkit.org/projects/plotme/files/707659) +A once-popular plot plugin for creative OR survival plots to build on! +### [SeekAndFind](https://dev.bukkit.org/projects/seekandfind/files/699522) +A cool-looking hide-and-seek plugin, BUT I have not tested it so it might not work! +### [NoSpawnChunks](https://dev.bukkit.org/projects/nospawnchunks/files/586974) +Prevents loading spawn chunks on your server. Helps to optimize it greatly! + +## Not working? +1. Make sure you haven't broken any essential files. +2. **(try this multiple times, at least 5-10)** Try clicking on the "Shell" tab (next to the "Console" tab) and running `busybox reboot`. Then you can try pressing the Run button again and see if it works. +3. Join the [official Eaglercraft discord server](https://discord.gg/6yTNkypXWh) and look for any answers there. +4. If all else fails, contact me directly **through Discord** at `ayunami2000#5250` +5. If you do not have access to Discord, THEN you can leave a comment on the Replit. \ No newline at end of file diff --git a/main.sh b/main.sh index 84bd732..a53665a 100644 --- a/main.sh +++ b/main.sh @@ -1,67 +1,93 @@ #!/bin/bash -#change the following to "false" to disable auto web updates -updcheck="true" -#change the following to "false" to disable all replacements (e.g. changing the default server, ensuring bungeecord is on the right port, etc.) -rplcheck="true" +#change the following to "false" to disable changing the default server name and motd +setserver="true" +#change the following to "false" to disable updating of server jars and website +syncweb="true" +syncjars="true" +#server name and motd -- DO NOT USE BACKTICKS (`) within it!! -- stuff WONT work if you DO!! ALSO do not use "${anything}" UNLESS YOU KNOW WHAT YOU ARE DOING!! +srvname="Your Minecraft Server" +srvmotd="Minecraft Server" + + +#DANGER!! setting the following to "true" will redownload the bukkit server! only change if you know what you are doing! +emergbukkit="false" + + + +#~# this code was smashed together by ayunami2000 #~# + +eagurl="https://raw.githubusercontent.com/LAX1DUDE/eaglercraft/main/stable-download/stable-download_repl.zip" echo ensuring old server process is truly closed... nginx -s stop -c ~/$REPL_SLUG/nginx.conf -g 'daemon off; pid /tmp/nginx/nginx.pid;' -p /tmp/nginx -e /tmp/nginx/error.log pkill java pkill nginx rm -rf /tmp/* -echo deleting old backup files... -rm -rf old/ -echo verifying files... -if [ -d "java" -a -d "web" ]; then - echo files exist! proceeding... +if [ ! -f "updated.yet" ]; then + syncweb="true" + syncjars="true" +fi + +echo checking if file still works... + +status_code=$(curl -L --write-out %{http_code} --silent --output /dev/null "$eagurl") + +if [[ "$status_code" -ne 200 ]] ; then + syncweb="false" + syncjars="false" + echo " + + +site is down! not updating... + + +" else - echo files do not exist! forcing download, if needed... - updcheck="true" - rplcheck="true" + echo site is still up! downloading... + curl -L -o stable-download.zip "$eagurl" + echo extracting zip... + mkdir /tmp/new + unzip stable-download.zip -d /tmp/new + echo deleting original zip file... + rm -rf stable-download.zip + if [ "$syncweb" = "true" ]; then + echo updating web folder... + rm -rf web/* + cp -r /tmp/new/web/. ./web/ + echo backing up original index.html file... + cp web/index.html web/index.html.ORIG + fi + if [ "$syncjars" = "true" ]; then + echo updating bungeecord server... + if [ -f "updated.yet" ]; then + rm -f java/bungee_command/bungee-dist.jar + cp /tmp/new/java/bungee_command/bungee-dist.jar ./java/bungee_command/ + else + rm -rf java/bungee_command/* + cp -r /tmp/new/java/bungee_command/. ./java/bungee_command/ + echo ensuring that bungeecord is hosting on the correct port... + sed -i 's/host: 0\.0\.0\.0:[0-9]\+/host: 0.0.0.0:1/' java/bungee_command/config.yml + fi + echo updating bukkit server... + if [ "$emergbukkit" = "true" ]; then + rm -rf java/bukkit_command/* + cp -r /tmp/new/java/bukkit_command/. ./java/bukkit_command/ + else + rm -f java/bukkit_command/craftbukkit-1.5.2-R1.0.jar + cp /tmp/new/java/bukkit_command/craftbukkit-1.5.2-R1.0.jar ./java/bukkit_command/ + fi + fi + echo removing update data... + rm -rf /tmp/new + echo deleting old directory if it exists for some reason... + rm -rf old fi -if [ "$updcheck" = "true" ]; then - echo backing up old files... - mkdir old - mv java web old - echo checking if file still works... - - status_code=$(curl -L --write-out %{http_code} --silent --output /dev/null https://raw.githubusercontent.com/LAX1DUDE/eaglercraft/main/stable-download/stable-download.zip) - - if [[ "$status_code" -ne 200 ]] ; then - echo site is down! using backup files... - cp old/java old/web ./ - else - echo site is still up! downloading... - curl -L -o stable-download.zip https://raw.githubusercontent.com/LAX1DUDE/eaglercraft/main/stable-download/stable-download.zip - echo extracting zip... - unzip stable-download.zip - echo deleting original zip file... - rm -rf stable-download.zip - fi - - echo verifying files... - if [ -d "java" -a -d "web" ]; then - echo files exist! proceeding... - else - echo files do not exist! using backup files... - cp old/java old/web ./ - fi - - #todo: detect modified files - if [ -d "old/java/bukkit_command" -a -d "old/java/bungee_command" ]; then - echo restoring servers from backup so you dont lose data... - rm -rf java/* - cp -r old/java/* ./java/ - fi -fi - -if [ "$rplcheck" = "true" ]; then - echo ensuring that bungeecord is hosting on the correct port... - sed -i 's/host: 0\.0\.0\.0:[0-9]\+/host: 0.0.0.0:1/' java/bungee_command/config.yml +if [ ! -f "updated.yet" ]; then + touch updated.yet fi echo starting bungeecord... @@ -69,12 +95,15 @@ cd java/bungee_command java -Xmx32M -Xms32M -jar bungee-dist.jar > /dev/null 2>&1 & cd - -if [ "$rplcheck" = "true" ]; then +if [ "$setserver" = "true" -a "$syncweb" = "true" ]; then + echo restoring original index.html... + rm web/index.html + cp web/index.html.ORIG web/index.html echo configuring local website... sed -i 's/https:\/\/g\.eags\.us\/eaglercraft/https:\/\/gnome\.vercel\.app/' web/index.html sed -i 's/alert/console.log/' web/index.html echo setting default server... - sed -i 's/"CgAACQAHc2VydmVycwoAAAABCAACaXAAIHdzKHMpOi8vIChhZGRyZXNzIGhlcmUpOihwb3J0KSAvCAAEbmFtZQAIdGVtcGxhdGUBAAtoaWRlQWRkcmVzcwEIAApmb3JjZWRNT1REABl0aGlzIGlzIG5vdCBhIHJlYWwgc2VydmVyAAA="/btoa(atob("CgAACQAHc2VydmVycwoAAAABCAAKZm9yY2VkTU9URABtb3RkaGVyZQEAC2hpZGVBZGRyZXNzAQgAAmlwAGlwaGVyZQgABG5hbWUAbmFtZWhlcmUAAA==").replace("motdhere",String.fromCharCode("Your Minecraft Server".length)+"Your Minecraft Server").replace("namehere",String.fromCharCode("Minecraft Server".length)+"Minecraft Server").replace("iphere",String.fromCharCode(("ws"+location.protocol.slice(4)+"\/\/"+location.host+"\/server").length)+("ws"+location.protocol.slice(4)+"\/\/"+location.host+"\/server")))/' web/index.html + sed -i "s/\"CgAACQAHc2VydmVycwoAAAABCAACaXAAIHdzKHMpOi8vIChhZGRyZXNzIGhlcmUpOihwb3J0KSAvCAAEbmFtZQAIdGVtcGxhdGUBAAtoaWRlQWRkcmVzcwEIAApmb3JjZWRNT1REABl0aGlzIGlzIG5vdCBhIHJlYWwgc2VydmVyAAA=\"/btoa(atob(\"CgAACQAHc2VydmVycwoAAAABCAAKZm9yY2VkTU9URABtb3RkaGVyZQEAC2hpZGVBZGRyZXNzAQgAAmlwAGlwaGVyZQgABG5hbWUAbmFtZWhlcmUAAA==\").replace(\"motdhere\",String.fromCharCode(\`$srvname\`.length)+\`$srvname\`).replace(\"namehere\",String.fromCharCode(\`$srvmotd\`.length)+\`$srvmotd\`).replace(\"iphere\",String.fromCharCode((\"ws\"+location.protocol.slice(4)+\"\/\/\"+location.host+\"\/server\").length)+(\"ws\"+location.protocol.slice(4)+\"\/\/\"+location.host+\"\/server\")))/" web/index.html fi echo starting nginx... diff --git a/replit.nix b/replit.nix index 5e64605..c9313e0 100644 --- a/replit.nix +++ b/replit.nix @@ -4,5 +4,6 @@ pkgs.graalvm8-ce pkgs.unzip pkgs.nginx + pkgs.busybox ]; } \ No newline at end of file diff --git a/updated.yet b/updated.yet new file mode 100644 index 0000000..e69de29