Skip to content

Commit

Permalink
feat: Remove ngrok region var, add 1.21 support
Browse files Browse the repository at this point in the history
Signed-off-by: Etcher <96310503+etcherfx@users.noreply.github.com>
  • Loading branch information
etcherfx committed Jun 29, 2024
1 parent db17abf commit d84d914
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
39 changes: 16 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@

<img src="projectInfo/replitNix.png" width="250">

- Follow the instructions below to set the Java version you want for your server:
- If you want your server version to be Minecraft 1.16.x or below, do not change anything.
- If you want your server version to be Minecraft 1.17.x or above, make sure to change `pkgs.openjdk8-bootstrap` to `pkgs.openjdk17-bootstrap`
- Choose the Java version you want to use from below and replace the default Java version with the one you want to use:

> _The default Java version is `pkgs.openjdk8-bootstrap`_
| Minecraft Version | Java Version |
| ----------------- | -------------------------- |
| `1.21+` | `pkgs.jdk21_headless` |
| `1.17 - 1.20` | `pkgs.openjdk17-bootstrap` |
| `1.16-` | `pkgs.openjdk8-bootstrap` |

## Creating Enviornment Variables

Expand All @@ -68,30 +74,17 @@

<img src="projectInfo/replitSecrets.png" width="550">

- Create a new secret called `ngrok_region` and input one of the regional codes from the list below as the value:

> _Choose the closest region for better network connectivity._
| Region | Code |
| ------------------------- | ---- |
| United States (Ohio) | `us` |
| Europe (Frankfurt) | `eu` |
| Asia/Pacific (Singapore) | `ap` |
| Australia (Sydney) | `au` |
| South America (Sao Paulo) | `sa` |
| Japan (Tokyo) | `jp` |
| India (Mumbai) | `in` |
- Create a new secret with the key named `ngrok_token` and the value as your [authtoken](https://dashboard.ngrok.com/get-started/your-authtoken)

<img src="projectInfo/ngrokRegion.png" width="450">
> _Note: You need to create an ngrok account to get an authtoken_
- Do the same for the variables in the list below:

| Key | Value |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `ngrok_token` | Your [authtoken](https://dashboard.ngrok.com/get-started/your-authtoken) for ngrok. _You need to create an ngrok account for this_ |
| `SERVER` | The server software in all lowercase. e.g `purpur` |
| `VERSION` | Version of Minecraft your server is running on. e.g `1.19.4` |
| `BUILD` | The build number of your server software. _Only use this if you have `paper` as the server software_ |
| Key | Value |
| --------- | ---------------------------------------------------------------------------------------------------- |
| `SERVER` | The server software in all lowercase. e.g `purpur` |
| `VERSION` | Version of Minecraft your server is running on. e.g `1.19.4` |
| `BUILD` | The build number of your server software. _Only use this if you have `paper` as the server software_ |

- List of server software supported:

Expand Down
Binary file removed projectInfo/ngrokRegion.png
Binary file not shown.
20 changes: 12 additions & 8 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,27 @@ while true; do
requireFile "server.jar"
requireExec "ngrok"
requireEnv "ngrok_token"
requireEnv "ngrok_region"
mkdir -p ./logs
touch ./logs/temp
rm ./logs/*
echo -e "${GREEN}Starting ngrok tunnel in region: $ngrok_region"
./ngrok authtoken $ngrok_token >/dev/null 2>&1
./ngrok tcp -region $ngrok_region --log=stdout 25565 >$root/status.log &
if ! pgrep -x "ngrok" >/dev/null; then
echo -e "${GREEN}Starting ngrok tunnel...${NC}"
./ngrok authtoken $ngrok_token >/dev/null 2>&1
./ngrok tcp --log=stdout 25565 >$root/status.log &
fi
echo ""
echo -e "${CYAN}Minecraft server starting, please wait...${NC}"
echo ""
echo -e "${GREEN}=====================================================================${NC}"
echo ""
COMMON_JVM_FLAGS="-Xms128M -Xmx512M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -XX:+UseStringDeduplication -XX:+UseAES -XX:+UseAESIntrinsics -XX:UseSSE=4 -XX:AllocatePrefetchStyle=1 -XX:+UseLoopPredicate -XX:+RangeCheckElimination -XX:+EliminateLocks -XX:+DoEscapeAnalysis -XX:+UseCodeCacheFlushing -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseThreadPriorities -XX:+TrustFinalNonStaticFields -XX:+UseInlineCaches -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:+UseNUMA -XX:-DontCompileHugeMethods -XX:+UseFPUForSpilling -XX:+UseNewLongLShift -XX:+UseXMMForArrayCopy -XX:+UseXmmI2D -XX:+UseXmmI2F -XX:+UseXmmLoadAndClearUpper -XX:+UseXmmRegToRegMoveAll -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/urandom"
JAVA_CMD="java $COMMON_JVM_FLAGS -jar server.jar nogui"

if [[ "$VERSION" =~ ^1\.(17|18|19|20)\. ]]; then
java $COMMON_JVM_FLAGS --add-modules jdk.incubator.vector -XX:UseAVX=2 -Xlog:async -jar server.jar nogui
elif [[ "$VERSION" =~ ^1\.(8|9|10|11|12|13|14|15|16)\. ]]; then
java $COMMON_JVM_FLAGS -XX:-UseBiasedLocking -XX:UseAVX=3 -jar server.jar nogui
if [[ "$VERSION" =~ ^1\.(17|18|19|20|21)(\.|$) ]]; then
JAVA_CMD="java $COMMON_JVM_FLAGS --add-modules jdk.incubator.vector -XX:UseAVX=2 -Xlog:async -jar server.jar nogui"
elif [[ "$VERSION" =~ ^1\.(8|9|10|11|12|13|14|15|16)(\.|$) ]]; then
JAVA_CMD="java $COMMON_JVM_FLAGS -XX:-UseBiasedLocking -XX:UseAVX=3 -jar server.jar nogui"
fi

$JAVA_CMD
done

0 comments on commit d84d914

Please # to comment.