diff --git a/README.md b/README.md
index 7d6e84fa..79c98d86 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ $ git add eula.txt
$ git commit -m "first commit"
```
-Then, install the [Heroku toolbelt](https://toolbelt.heroku.com/).
+Then, install the [Heroku CLI](https://cli.heroku.com/).
Create a Heroku app, set your ngrok token, and push:
```sh-session
@@ -67,7 +67,7 @@ The buildpack will sync your world to the bucket every 60 seconds, but this is c
The Minecraft server runs inside a `screen` session. You can use [Heroku Exec](https://devcenter.heroku.com/articles/heroku-exec) to connect to your server console.
-Once you have Heroku Exec installed, you can connect to the console using
+Once you have Heroku Exec installed, you can connect to the console using
```
$ heroku ps:exec
@@ -76,7 +76,7 @@ Connecting to web.1 on ⬢ lovely-minecraft-2351...
$ screen -r minecraft
```
-**WARNING** You are now connected to the Minecraft server. Use `Ctrl-A Ctrl-D` to exit the screen session.
+**WARNING** You are now connected to the Minecraft server. Use `Ctrl-A Ctrl-D` to exit the screen session.
(If you hit `Ctrl-C` while in the session, you'll terminate the Minecraft server.)
## Customizing
@@ -94,7 +94,7 @@ $ heroku config:set NGROK_OPTS="--remote-addr 1.tcp.ngrok.io:25565"
You can choose the Minecraft version by setting the MINECRAFT_VERSION like so:
```
-$ heroku config:set MINECRAFT_VERSION="1.8.3"
+$ heroku config:set MINECRAFT_VERSION="1.18.1"
```
You can also configure the server properties by creating a `server.properties`
@@ -104,3 +104,16 @@ described on the [Minecraft Wiki](http://minecraft.gamepedia.com/Server.properti
You can add files such as `banned-players.json`, `banned-ips.json`, `ops.json`,
`whitelist.json` to your Git repository and the Minecraft server will pick them up.
+
+### Adding New Minecraft Versions
+
+Please submit Pull Requests to [`etc/files.json`](https://github.com/jkutner/heroku-buildpack-minecraft/blob/master/etc/files.json)
+
+### Using the Buildpack from source
+
+If you want the bleeding edge version of this buildpack run:
+
+```
+$ heroku buildpacks:remove jkutner/minecraft
+$ heroku buildpacks:add https://github.com/jkutner/heroku-buildpack-minecraft
+```
diff --git a/bin/compile b/bin/compile
index c08fed09..fbe4ea8a 100755
--- a/bin/compile
+++ b/bin/compile
@@ -19,10 +19,11 @@ export_env_dir() {
fi
}
-BP_DIR="$(cd "$(dirname "$0")" && pwd)"
+BP_BIN_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR=$1
CACHE_DIR=$2
-OPT_DIR=$BP_DIR/../opt/
+OPT_DIR=$BP_BIN_DIR/../opt/
+ETC_DIR=$BP_BIN_DIR/../etc/
export_env_dir $3
@@ -60,22 +61,11 @@ curl --silent -o ngrok.zip -L "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable
unzip ngrok.zip -d $BUILD_DIR/bin > /dev/null 2>&1
echo "done"
-minecraft_version=${MINECRAFT_VERSION:-"1.16.2"}
-
-if echo "$minecraft_version" | grep -q '^1\.16.*$'; then
- minecraft_uuid="${MINECRAFT_UUID:="a412fd69db1f81db3f511c1463fd304675244077"}"
- minecraft_url="https://launcher.mojang.com/v1/objects/${minecraft_uuid}/server.jar"
-elif echo "$minecraft_version" | grep -q '^1\.15.*$'; then
- minecraft_uuid="${MINECRAFT_UUID:="bb2b6b1aefcd70dfd1892149ac3a215f6c636b07"}"
- minecraft_url="https://launcher.mojang.com/v1/objects/${minecraft_uuid}/server.jar"
-elif echo "$minecraft_version" | grep -q '^1\.13.*$'; then
- minecraft_uuid="${MINECRAFT_UUID:="d0caafb8438ebd206f99930cfaecfa6c9a13dca0"}"
- minecraft_url="https://launcher.mojang.com/mc/game/${minecraft_version}/server/${minecraft_uuid}/server.jar"
-elif echo "$minecraft_version" | grep -q '^1\.14.*$'; then
- minecraft_uuid="${MINECRAFT_UUID:="d0d0fe2b1dc6ab4c65554cb734270872b72dadd6"}"
- minecraft_url="https://launcher.mojang.com/v1/objects/${minecraft_uuid}/server.jar"
-else
- minecraft_url="https://s3.amazonaws.com/Minecraft.Download/versions/${minecraft_version}/minecraft_server.${minecraft_version}.jar"
+minecraft_version=${MINECRAFT_VERSION:-"1.18.1"}
+minecraft_url="$(cat $ETC_DIR/files.json | python -c "import json,sys;obj=json.load(sys.stdin);print(obj[\"server\"][\"${minecraft_version}\"][\"url\"])")"
+if [ -z "$minecraft_url" ]; then
+ echo "Could not find URL for Minecraft version $minecraft_version. Please check files.json."
+ exit 1
fi
echo -n "-----> Installing Minecraft ${minecraft_version}... "
diff --git a/etc/files.json b/etc/files.json
new file mode 100644
index 00000000..336ce3a1
--- /dev/null
+++ b/etc/files.json
@@ -0,0 +1,25 @@
+{
+ "server": {
+ "1.18.1" : {
+ "url" : "https://launcher.mojang.com/v1/objects/3cf24a8694aca6267883b17d934efacc5e44440d/server.jar"
+ },
+ "1.17.1" : {
+ "url" : "https://launcher.mojang.com/v1/objects/fc87ef4c3cf1c815809249cc00ccade233b22cf5/server.jar"
+ },
+ "1.16.4" : {
+ "url": "https://launcher.mojang.com/v1/objects/35139deedbd5182953cf1caa23835da59ca3d7cd/server.jar"
+ },
+ "1.16.3" : {
+ "url": "https://launcher.mojang.com/v1/objects/f02f4473dbf152c23d7d484952121db0b36698cb/server.jar"
+ },
+ "1.15.1" : {
+ "url": "https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar"
+ },
+ "20w51a": {
+ "url": "https://launcher.mojang.com/v1/objects/fc87ef4c3cf1c815809249cc00ccade233b22cf5/server.jar"
+ },
+ "1.12.2": {
+ "url": "https://launcher.mojang.com/v1/objects/886945bfb2b978778c3a0288fd7fab09d315b25f/server.jar"
+ }
+ }
+}
diff --git a/opt/index.rhtml b/opt/index.rhtml
index 3ab7631c..19078a58 100644
--- a/opt/index.rhtml
+++ b/opt/index.rhtml
@@ -1,6 +1,11 @@
<% open('ngrok.log') do |f| %>
<% f.lines.select { |line| line.include?("URL:") }.each do |line| %>
- Server available at: <%= line.match(/tcp:\/\/(.+:[0-9]+) /)[1] %>
+ Server available at:
+ <% if line.match(/tcp:\/\/(.+:[0-9]+) P/) %>
+ <%= line.match(/tcp:\/\/(.+:[0-9]+) P/)[1] %>
+ <% else %>
+ <%= line.match(/tcp:\/\/(.+:[0-9]+)/)[1] %>
+ <% end %>
<% end %>
<% end %>
diff --git a/opt/sync b/opt/sync
index 82f197f8..6c4f8392 100755
--- a/opt/sync
+++ b/opt/sync
@@ -1,17 +1,21 @@
#!/usr/bin/env bash
+world_name="${WORLD_NAME:-default}"
+
if [ -n "$AWS_BUCKET" ]; then
cat << EOF > .s3cfg
[default]
access_key = ${AWS_ACCESS_KEY}
secret_key = ${AWS_SECRET_KEY}
EOF
+ # note: this won't work if level-name is set in server.properties
+ # todo: dynamically determine world/ dir
if [ -d world ]; then
- s3cmd sync world/ s3://${AWS_BUCKET}/world/
+ s3cmd sync world/ s3://${AWS_BUCKET}/${WORLD_NAME}/world/
else
mkdir -p world
cd world
- s3cmd get --recursive s3://${AWS_BUCKET}/world/
+ s3cmd get --recursive s3://${AWS_BUCKET}/${WORLD_NAME}/world/
cd ..
fi
rm .s3cfg
diff --git a/server.properties b/server.properties
new file mode 100644
index 00000000..c7726474
--- /dev/null
+++ b/server.properties
@@ -0,0 +1,4 @@
+gamemode=1
+force-gamemode=true
+enforce-whitelist=false
+white-list=false
diff --git a/system.properties b/system.properties
new file mode 100644
index 00000000..eafd676c
--- /dev/null
+++ b/system.properties
@@ -0,0 +1 @@
+java.runtime.version=17