Skip to content

Commit

Permalink
Native Termux support (#4)
Browse files Browse the repository at this point in the history
* Updated and tweaked to be better before implementing (native) wimdow support.

expressing more support for other os, not only android (this script wont work in termux natively i believe but I think I can make it possible too so you dont need to download AnLinux. I'll look into it) + fixes

* Update one-time-install.sh

* Update README.md

* New placeholder server.png

* Native Termux support

goodbye AnLinux! you no longer need external software inorder for this script to work on your android device! Now I can focus on rewriting this for windows

* Moved tutorial to the wiki

less clutter, readme only contains information now

i admit that the termux implementation is sloppy, so it'll need atleast a small rewrite
  • Loading branch information
Theslees authored Oct 10, 2022
1 parent e500488 commit 4adb524
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 85 deletions.
68 changes: 19 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,35 @@
# termux-Optimized-MC-Java-server
This is a simple script that will automatically install and configures an extremely optimized vanilla-experience server for Minecraft Java Edition. Powered by the Quilt Mod Loader! This is the best script to automatically get the most optimized MC Server out there as far as I know. Works in Termux too!
This is a simple script (originally designed for Termux) that will automatically install and configure a vanilla-optimized Quilt server for Minecraft Java (and in the future hopefully, Bedrock.)
This is the most __up-to-date__ script to setup the most optimized MC Server out there, afaik.
You can add any Fabric or Quilt mod you want.

# Thanks to these things/people that made it possible !
> MC 1.19.2 - Synced server package manifest to client, updating the network framework Netty
### I have an example of this running on my own android device; a Modded Survival experience. You can take a peak of its performance by joining; `androidmc.tplinkdns.com` !!

> Quilt Mod Loader - Best solution for hosting MC servers imo. (That isn't enterprise, proprietary and specifically designed for certain things.)
----------------------------------------------------------------------
## Thanks to these things/people that made it possible !
> MC v1.19.2 - Synced server package manifest to client, updating the Netty framework
> Quilt Mod Loader Discord - Very cool people and devs helped me find lib issues, ty.
> Quilt Mod Loader - Best solution for hosting MC servers imo (That isn't enterprise, proprietary, or designed for specific things.)
> The Mods - Lithium, VMP *(Very Many Players)*, FerriteCore, Krypton, ViaFabric, Starlight, qfapi *(fabric library implementation and Quilt library from Quilt)*, Fabrictailor *(to change skins, do /skin)*, Clumps, C2ME.
> Quilt Mod Loader Discord - Very cool people and devs helped me find compalibility issues, ty.
> Sukiru - they're like a java dev as a job or something idk, they were useful nontheless with answering questions.
> The Mods - Lithium, VMP *(Very Many Players)*, FerriteCore, Krypton, ViaFabric, ViaBackwards, ViaRewind, Starlight, qfapi *(fabric library implementation and Quilt library from Quilt)*, Fabrictailor *(to change skins, do /skin)*, Clumps, C2ME.
*Will update this repository accordingly if a new mc version comes out, and I will also update the mods time to time. Feel free to open issues and whatnot too :)*
# Steps to Install
> Sukiru - they're like a java dev or something, they were useful with answering my very urgent and serious questions.
### ⚠️ This guide assumes you are runnning a supported operating system in termux. If not, you can download AnLinux to install a supported distro. ⚠️
As long as you are on a supported operating system, this script should work, even if you're not on Termux.
------------------------------------------------------------------

**Currently supported distros; Fedora, Debian, Ubuntu, Arch Linux, Manjaro, Alpine Linux.**
### ⚠️ This guide assumes you are runnning a supported operating system. ⚠️
The steps are in the Wiki section of this github repo inorder to reduce clutter here. Feedback is appriciated, my discord is Theslees#1162 if you need to reach out.
Please check if your system is compatible with this script before running it;

If you need help with anything, my discord is below.

> ps; Feedback is appriciated!! My discord is Theslees#1162. I want to make this script compatible with anything Linux. so make a PR if you're smarter than me and can contribute^^^. Though you're on you're own if your enviroment isn't exactly as I described.
Anyways, enough talking, lets set this server up!

## Setup
Debian-based

`apt-get install git`

Arch-based

`pacman -S git`

Fedora

`dnf install git`

Alpine

`apk add git`

## Cmds (run in order, do this to update your server whenever I make a new update.)
`git clone https://github.com/Theslees/termux-Optimized-MC-Java-server mc`

`cd mc`

`chmod +x one-time-install.sh`

*With or without root;*

`./one-time-install.sh`

**After finishing the setup and script, you should be able to run "mc" in your terminal to start the server anytime you want. to connect to your server, you can go to your phone's Wifi Settings, and click on your connection to see more details about it. There you find your ip address, which u use to connect to your mc server. (should look something like 192.168.0.XX.) if u need to contact me in any way,, my discord is above, Enjoy~**

###### i am not responsible for batteries frying or anything that may happen. You are doing this on your own will, and you are aware of the Risks that come with putting your phone through this.
### ***Currently supported os; Fedora-based, Debian-based, Arch Linux-based, Alpine-based, Termux.***

# To do
- Add Windows support
- Geyser support
- ~~More Distros~~
- ~~Use functions to make it easier to read ig~~
- ~~Native Termux Support (remove the need for AnLinux.)~~

----------------------------------------------------------------
10 changes: 10 additions & 0 deletions config/quilt/qsl/registry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

[registry_sync]
# Message displayed for players joining with incompatible clients. Support strings and Minecraft's json text format
# default: Unsupported (vanilla?) client!
#This server requires modded client to join!
missing_registry_sync_message = "Unsupported (vanilla?) client!\nThis server requires modded client to join!"
# Allows players with Fabric API to connect, as long as they have all required mods
# default: true
support_fabric_api_protocol = true

2 changes: 1 addition & 1 deletion config/vmp.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Configuration file for VMP
#Thu Aug 18 20:53:23 UTC 2022
experimental0_use_multiple_netty_event_loops=false
experimental0_use_multiple_netty_event_loops=true
target_chunk_send_rate=120
use_async_logging=true
use_optimized_entity_tracking=true
Expand Down
2 changes: 0 additions & 2 deletions eula.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
#Tue Jul 12 03:40:03 UTC 2022
eula=true
Binary file removed mods/Clumps-fabric-1.19.1-9.0.0+9.jar
Binary file not shown.
Binary file added mods/Clumps-fabric-1.19.2-9.0.0+11.jar
Binary file not shown.
Binary file added mods/ViaBackwards-4.4.2.jar
Binary file not shown.
Binary file added mods/ViaRewind-2.0.2.jar
Binary file not shown.
Binary file removed mods/fabrictailor-1.8.4.jar
Binary file not shown.
Binary file added mods/fabrictailor-2.0.1.jar
Binary file not shown.
Binary file added mods/lithium-fabric-mc1.19.2-0.9.0-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
Binary file added mods/viafabric-0.4.9+19-main.jar
Binary file not shown.
Binary file not shown.
139 changes: 114 additions & 25 deletions one-time-install.sh
Original file line number Diff line number Diff line change
@@ -1,61 +1,151 @@
#!/bin/bash
# Works with superuser and normal user. finally
printf "Setting up..."
printf "\ncurrently running script as $USER\n "

# Works with superuser and normal user. finally. https://github.com/Theslees/termux-Optimized-MC-Java-server
clear
printf "Setting up...\n "
printf "currently running script as $USER...\n "

. /etc/os-release
version="1.19.2"
installer_version="0.4.3"
installer_version="0.4.4"
#bashrc variable removed, not used
ram=$(free --mega | grep Mem | awk '{ print $7 }')
whereami=$(pwd)
#distroid removed, not needed
mc="$HOME/.local/bin/mc"
mc_root="/bin/mc"
# Download dependencies and requirements
termux=$(/data/data/com.termux/files/usr)

# - finished! termux does not have openjdk18 but does have openjdk17, which is what will be used if native Termux support is implemented. (poorly implemented but it works)
# - fixed! if openjdk18 is not in your repositories for some reason, it will not error despite not installing properly. fallback to openjdk17, the other supported java version- besides 19, which is most likely not in your repositories as of now.
# - issue! if you're running this on termux, it'll go through the normal installer despite already knowing that they wont work. Not a bug but Termux users will have to wait longer to finish the script.
if [ -x $termux ]; then
echo -n "Detected Termux enviroment, continuing setup..\n " && apt install openjdk-17 grep procps
elif [ $? != 0 ]; then
sudo apt install openjdk-17 grep procps
else
return 0
fi

installer() {
if [ -x "$(command -v apk)" ]; then apk add --no-cache openjdk18-jre-headless
elif [ -x "$(command -v apt-get)" ]; then apt-get install openjdk-18-jre-headless openjdk-18-jdk-headless tar
elif [ -x "$(command -v dnf)" ]; then dnf install java-18-openjdk-headless
elif [ -x "$(command -v pacman)" ]; then pacman -S jre-openjdk-headless --needed
else echo "FAILED TO INSTALL PACKAGE: Package manager not found. You must manually install: Java or check github"
# Download dependencies and requirements
if [ -x "$(command -v apk)" ]; then
pkgfnd=1
apk update && apk add --no-cache openjdk18-jre-headless nano grep procps
elif [ -x "$(command -v apt-get)" ]; then
pkgfnd=2
apt-get update && apt-get install openjdk-18-jre-headless nano grep procps
elif [ -x "$(command -v apt)" ]; then
pkgfnd=3
apt update && apt install openjdk-18-jre-headless nano grep procps
elif [ -x "$(command -v dnf)" ]; then
pkgfnd=4
dnf upgrade && dnf install java-18-openjdk-headless nano grep procps-ng
elif [ -x "$(command -v pacman)" ]; then
pkgfnd=5
pacman -Syy jre-openjdk-headless nano grep procps --needed
else
echo -n "PACKAGE MANAGER NOT FOUND; You must manually install Java 17 or higher. \nMaybe open an issue on Github to suggest support for your distro.\n "
exit
fi

if [ $? = 1 ]; then
pkgfail=true
else
pkgfail=false
fi

# Uses $pkgfnd (package find) to know what package manager you're using inorder to downgrade java version if needed
if [ $pkgfnd = 1 ]; then pkgfnd="apk update && apk add --no-cache openjdk17-jre-headless nano grep procps"
elif [ $pkgfnd = 2 ]; then pkgfnd="apt-get update && apt-get install openjdk-17-jre-headless nano grep procps"
elif [ $pkgfnd = 3 ]; then pkgfnd="apt update && apt install openjdk-17-jre-headless nano grep procps"
elif [ $pkgfnd = 4 ]; then pkgfnd="dnf upgrade && dnf install java-17-openjdk-headless nano grep procps-ng"
elif [ $pkgfnd = 5 ]; then pkgfnd="pacman -Syy jre17-openjdk-headless nano grep procps --needed"
fi

if [ $pkgfail = true ]; then
echo -n "FAILED TO INSTALL PACKAGES; Attempting to download Java 17 instead of 18...\n "
$pkgfnd
else
echo -n "Success!"
return 0
fi
if [ $? = 1 ]; then
echo -n "FAILED TO INSTALL PACKAGES; Java 17 installation failed, or required packages could not be sync and installed. \nPlease check github for more support.\n "
return 1
fi
}

installer_sudo() {
if [ -x "$(command -v apk)" ]; then sudo apk add --no-cache openjdk18-jre-headless
elif [ -x "$(command -v apt-get)" ]; then sudo apt-get install openjdk-18-jre-headless openjdk-18-jdk-headless tar
elif [ -x "$(command -v dnf)" ]; then sudo dnf install java-18-openjdk-headless
elif [ -x "$(command -v pacman)" ]; then sudo pacman -S jre-openjdk-headless --needed
else echo "FAILED TO INSTALL PACKAGE: Package manager not found. You must manually install: Java or check github"
if [ -x "$(command -v apk)" ]; then
pkgfnd=1
sudo apk update && sudo apk add --no-cache openjdk18-jre-headless nano grep procps
elif [ -x "$(command -v apt-get)" ]; then
pkgfnd=2
sudo apt-get update && sudo apt-get install openjdk-18-jre-headless nano grep procps
elif [ -x "$(command -v apt)" ]; then
pkgfnd=3
sudo apt update && sudo apt install openjdk-18-jre-headless nano grep procps
elif [ -x "$(command -v dnf)" ]; then
pkgfnd=4
sudo dnf upgrade && sudo dnf install java-18-openjdk-headless nano grep procps-ng
elif [ -x "$(command -v pacman)" ]; then
pkgfnd=5
sudo pacman -Syy jre-openjdk-headless nano grep procps --needed
else
echo -n "PACKAGE MANAGER NOT FOUND; You must manually install Java 17 or higher. \nMaybe open an issue on Github to suggest support for your distro.\n "
exit
fi

if [ $? = 1 ]; then
pkgfail=true
else
pkgfail=false
fi

if [ $pkgfnd = 1 ]; then pkgfnd="sudo apk update && sudo apk add --no-cache openjdk17-jre-headless nano grep procps"
elif [ $pkgfnd = 2 ]; then pkgfnd="sudo apt-get update && sudo apt-get install openjdk-17-jre-headless nano grep procps"
elif [ $pkgfnd = 3 ]; then pkgfnd="sudo apt update && sudo apt install openjdk-17-jre-headless nano grep procps"
elif [ $pkgfnd = 4 ]; then pkgfnd="sudo dnf upgrade && sudo dnf install java-17-openjdk-headless nano grep procps-ng"
elif [ $pkgfnd = 5 ]; then pkgfnd="sudo pacman -Syy jre17-openjdk-headless nano grep procps --needed"
fi

if [ $pkgfail = true ]; then
echo -n "FAILED TO INSTALL PACKAGES; Attempting to download Java 17 instead of 18..."
$pkgfnd
else
echo -n "Success!"
return 0
fi

if [ $? = 1 ]; then echo -n "FAILED TO INSTALL PACKAGES; Java 17 installation failed, or required packages could not be sync and installed. \nPlease check github for more support.\n "
fi
}

# Detects if you're root
if [ $(id -u) -eq 0 ]; then
installer
else
installer_sudo
fi
# Download Quilt server jar

# The quilt server instance installer
quilt() {
clear
printf "\nDownloading MC Java server $version.. Powered by Quilt! Please Wait.."
java -jar quilt-installer-$installer_version.jar \
install server $version \
--download-server
clear
echo "Done! Finalizing and creating shell script.. (so you should only have to run mc in your terminal.)"
# Cleanup

cd server && cp -r libraries server.jar quilt-server-launch.jar .. && cd .. && rm -R server
cd server && cp -r libraries server.jar quilt-server-launch.jar .. && cd .. && rm -R server LICENSE README.md
}

quilt

mc() {
clear
echo -e "\nYou have *$ram* Mb available!"
echo -e " \nHow much ram do you want to allocate to your server? (Mb) \n(leave atleast 2000Mb or more for Android. u may experience crashes otherwise.)"
echo -e " \nHow much ram do you want to allocate to your server? (Mb) \n(leave atleast 2000Mb or more for your operating system. u may experience crashes otherwise.)"
read -p $"Mb: " option
if [[ ! $option =~ ^[0-9]+$ ]]; then
echo -e "\nPlease enter a number only."
Expand All @@ -69,8 +159,9 @@ fi
}

mc_root() {
clear
echo -e "\nYou have *$ram* Mb available!"
echo -e " \nHow much ram do you want to allocate to your server? (Mb) \n(leave atleast 2000Mb or more for Android. u may experience crashes otherwise.)"
echo -e " \nHow much memory do you want to allocate to your server? (Mb) \n(leave atleast 2000Mb or more for your operating system. u may experience crashes otherwise.)"
read -p $"Mb: " option
if [[ ! $option =~ ^[0-9]+$ ]]; then
echo -e "\nPlease enter a number only."
Expand All @@ -82,13 +173,11 @@ else
cd $whereami && java -Xms$option -Xmx$option -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -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 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar quilt-server-launch.jar nogui" >> $mc_root && chmod +x $mc_root
fi
}

if [ $(id -u) -eq 0 ]; then
mc_root
else
mc
fi
# ^ Creates a shell script at /.local/bin or /bin if root. ^

printf "That should be it! \nrun mc in your terminal to start the mc server anytime. \nPlease make sure to exit your session and log back in for it to take effect! \nIf anything is wrong please open an Issue in github, or DM me on Discord. \n~ https://github.com/Theslees/termux-Optimized-MC-Java-server || Theslees\#1162 ~\n "
printf "That should be it! \nrun \"mc\" in your terminal to start the mc server anytime. \nIf anything is wrong please open an Issue in github, or DM me on Discord. \n~ https://github.com/Theslees/termux-Optimized-MC-Java-server ~ || ~ Theslees\#1162 ~\n "
exit
Binary file not shown.
Binary file added server-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 6 additions & 8 deletions server.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#Minecraft server properties
#Thu Aug 18 20:53:34 UTC 2022
allow-flight=true
allow-flight=false
allow-nether=true
broadcast-console-to-ops=true
broadcast-console-to-ops=false
broadcast-rcon-to-ops=false
difficulty=hard
difficulty=normal
enable-command-block=true
enable-jmx-monitoring=false
enable-query=false
Expand All @@ -23,11 +21,11 @@ hide-online-players=false
level-name=mc
level-seed=
level-type=minecraft\:normal
max-chained-neighbor-updates=1000000
max-chained-neighbor-updates=10000
max-players=50
max-tick-time=6000
max-world-size=29999984
motd=Placeholder. github.com/Theslees/termux-Optimized-MC-Java-server
motd=~Placeholder, edit server.properties~ ~github.com/Theslees/termux-Optimized-MC-Java-server~
network-compression-threshold=512
online-mode=false
op-permission-level=4
Expand All @@ -53,5 +51,5 @@ spawn-protection=0
sync-chunk-writes=true
text-filtering-config=
use-native-transport=true
view-distance=12
view-distance=6
white-list=false

0 comments on commit 4adb524

Please sign in to comment.