[1.20.4] Restore the option of server run scripts (#9849)

Executable server jar is still a thing, but the run scripts are restored as an option for those that prefer it.
This commit is contained in:
Paint_Ninja 2024-01-19 20:55:00 +00:00 committed by GitHub
parent a4c26c9b2b
commit 870e3ebcab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 106 additions and 1 deletions

View file

@ -724,6 +724,20 @@ tasks.register('installerJson', InstallerJson) {
'--task', 'EXTRACT_FILES',
'--archive', '{INSTALLER}',
'--from', 'data/README.txt',
'--to', '{ROOT}/README.txt',
'--from', 'data/run.sh',
'--to', '{ROOT}/run.sh',
'--exec', '{ROOT}/run.sh',
'--from', 'data/run.bat',
'--to', '{ROOT}/run.bat',
'--from', 'data/user_jvm_args.txt',
'--to', '{ROOT}/user_jvm_args.txt',
'--optional', '{ROOT}/user_jvm_args.txt',
'--from', 'data/unix_args.txt',
'--to', "{ROOT}/libraries/${MAVEN_PATH}/unix_args.txt",
@ -894,6 +908,12 @@ tasks.register('installerJar', InstallerJar) {
rename { 'win_args.txt' }
}
from(rootProject.file('server_files')) {
filter(tokens, ReplaceTokens)
into 'data'
exclude 'args.txt'
}
jarSigner.sign(it)
}

52
server_files/README.txt Normal file
View file

@ -0,0 +1,52 @@
If you need help with your Forge server, join our Discord or forums:
- https://discord.minecraftforge.net
- https://forums.minecraftforge.net
Quick start guide
=================
The steps will vary depending on if you're self-hosting or using a hosting provider:
Self-hosting
------------
On Windows, start the server by double-clicking the run.bat file.
On Linux or macOS, start the server by running the run.sh script.
- To change the amount of RAM allocated to the game, edit the user_jvm_args.txt file.
- To hide the GUI, edit the run.bat or run.sh file and refer to its instructions.
- To change server settings, edit the server.properties file and config files in the config folder.
Hosting providers
-----------------
The steps will vary depending on your hosting provider and what panel they use.
Some providers require you to install Forge through an option in their panel, others require you to upload the files
yourself and select a jar file. It's recommended to install Forge through the panel if possible, as it'll be easier.
If you need to select a jar file, upload your Forge server install (all files in the folder this readme is in) and
select the shim jar file.
If you're unsure, contact your hosting provider's or server panel's support.
Performance tuning
==================
Here are some tips and advice to improve server performance:
- Use the latest version of MC, Forge and mods when possible. Newer versions usually have performance improvements.
- Turn down the view distance and simulation distance in the server.properties file. Simulation distance should be the
same as or marginally lower than view distance.
- Don't allocate excessive amounts of RAM to the game - especially if self-hosting. Too much can cause lag, as it could
cause resource contention with other things running on the same machine, such as the OS, drivers and other apps.
- When using custom JVM args, test the before and after. There isn't a one-size-fits-all solution, and some settings
might make things worse with your specific hardware and combination of mods.
- Use a profiler (such as the Spark mod by lucko) to find the cause of lag. Some mods may be poorly optimised or simply
do a lot of things. When you find the cause, you may want to disable that specific part of the mod in its config file,
check for an update, report the issue to the mod author, find an alternative and/or remove the mod entirely.
- Contrary to popular belief, modern Minecraft isn't single-threaded. After a certain amount of RAM, you may get better
performance from adding more fast CPU cores rather than adding more RAM.
For more help with performance, please ask on the forums or Discord.

16
server_files/run.bat Normal file
View file

@ -0,0 +1,16 @@
@echo off
REM Add custom JVM arguments (such as RAM allocation) to the user_jvm_args.txt
java -jar @SHIM_JAR_FILE@ --onlyCheckJava
if %ERRORLEVEL% NEQ 0 (
echo.
echo Java check failed.
echo If you're struggling to get Java to work, ask for help on the forums or Discord mentioned in the readme.
goto :exit
)
REM Add custom program arguments (such as nogui) to the next line before the %* or pass them to this script directly
java @libraries/@MAVEN_PATH@/win_args.txt %*
:exit
pause

7
server_files/run.sh Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env sh
# Add custom JVM arguments (such as RAM allocation) to the user_jvm_args.txt
java -jar @SHIM_JAR_FILE@ --onlyCheckJava || exit 1
# Add custom program arguments (such as nogui) to the next line before the "$@" or pass them to this script directly
java @user_jvm_args.txt @libraries/@MAVEN_PATH@/unix_args.txt "$@"

View file

@ -0,0 +1,10 @@
# Note: Not all server panels support this file. You may need to set these options in the panel itself.
# Xmx and Xms set the maximum and minimum RAM usage, respectively.
# They can take any number, followed by an M (for megabyte) or a G (for gigabyte).
# For example, to set the maximum to 3GB: -Xmx3G
# To set the minimum to 2.5GB: -Xms2500M
# A good default for a modded server is 4GB. Do not allocate excessive amounts of RAM as too much may cause lag or crashes.
# Uncomment the next line to set it. To uncomment, remove the # at the beginning of the line.
# -Xmx4G

View file

@ -28,7 +28,7 @@ dependencyResolutionManagement {
library('forgespi', 'net.minecraftforge:forgespi:7.1.3') // Needs modlauncher
library('bootstrap', 'net.minecraftforge:bootstrap:2.0.0') // Needs modlauncher
library('bootstrap-api', 'net.minecraftforge:bootstrap-api:2.0.0')
library('bootstrap-shim', 'net.minecraftforge:bootstrap-shim:2.0.1')
library('bootstrap-shim', 'net.minecraftforge:bootstrap-shim:2.0.2')
library('modlauncher', 'net.minecraftforge:modlauncher:10.1.2') // Needs securemodules
library('securemodules', 'net.minecraftforge:securemodules:2.2.10') // Needs unsafe
library('unsafe', 'net.minecraftforge:unsafe:0.9.2')