Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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`
Expand All @@ -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
```
26 changes: 8 additions & 18 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}... "
Expand Down
25 changes: 25 additions & 0 deletions etc/files.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
7 changes: 6 additions & 1 deletion opt/index.rhtml
Original file line number Diff line number Diff line change
@@ -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] %>
<b>Server available at:</b>
<% if line.match(/tcp:\/\/(.+:[0-9]+) P/) %>
<%= line.match(/tcp:\/\/(.+:[0-9]+) P/)[1] %>
<% else %>
<%= line.match(/tcp:\/\/(.+:[0-9]+)/)[1] %>
<% end %>
<br />
<% end %>
<% end %>
8 changes: 6 additions & 2 deletions opt/sync
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions server.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gamemode=1
force-gamemode=true
enforce-whitelist=false
white-list=false
1 change: 1 addition & 0 deletions system.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.runtime.version=17