Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Jul 3, 2024
1 parent 015eab3 commit dcc86e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ServerStarterJar
ServerStarterJar is a same-process wrapper around the Forge (1.17-1.20.1) and NeoForge server run scripts.
ServerStarterJar is a same-process wrapper around the Forge (1.17+) and NeoForge server run scripts.

This project brings back the `server.jar` file in old versions, that can be used when a server host does not support custom launch scripts (such as the `run.sh` file).

Expand All @@ -12,7 +12,7 @@ Afterwards, you may run the jar as an executable (i.e. `java -jar server.jar`).
> Any JVM arguments (such as `-Xmx`) placed in the `user_jvm_args.txt` file will *not* be picked up by default. You'll need to run `java @user_jvm_args.txt -jar server.jar`.
## Compatible Versions
This starter is compatible with all [MinecraftForge](https://minecraftforge.net) versions since 1.17 and up to 1.20.1, and with all [NeoForge](https://neoforged.net) versions.
This starter is compatible with all [MinecraftForge](https://minecraftforge.net) versions since 1.17, and with all [NeoForge](https://neoforged.net) versions.

## Running the installer
If the starter cannot find the run scripts, it will attempt to run an installer.
Expand All @@ -26,11 +26,15 @@ or a **NeoForge version** to download the installer for (i.e. `21.0.46-beta`).
Below you will find the steps the start goes through to launch a modular NeoForge environment:
1. search the folder the starter was invoked in for the `run.sh` (*nix) / `run.bat` (Windows) file
2. find the `java` invocation in the run script
3. extract and parse the arguments file for the correct version: `@libraries/[...]/neoforge-[...]/unix_args.txt` / `@libraries/[...]/neoforge-[...]/win_args.txt`
4. parse the module path (`-p`) argument, and load the jars on a new module layer, which will replace the boot layer
5. parse the `--add-exports`/`--add-opens` arguments and replicate them using Java instrumentation module redefinition
6. ignore the `--add-modules` arguments as they're irrelevant since the module path is fully loaded as the boot layer
7. set the system properties (`-D<name>=<value>`) specified by the args file
8. consider the first remaining argument the main class, load it, and retrieve its `main(String[])` method
9. append any arguments specified to the starter executable to the remaining arguments
10. launch Minecraft with the remaining arguments
3. extract and parse any argument file references (`@[...]`)
4. if a `-jar` argument is found:
- put it on the system classpath alongside all entries specified in the `Class-Path` manifest entry
- update the `java.class.path` system property with the new entries
5. otherwise
- parse the module path (`-p`) argument, and load the jars on a new module layer, which will replace the boot layer
- parse the `--add-exports`/`--add-opens` arguments and replicate them using Java instrumentation module redefinition
- ignore the `--add-modules` arguments as they're irrelevant since the module path is fully loaded as the boot layer
6. set the system properties (`-D<name>=<value>`) specified by the args file
7. consider the `Main-Class` attribute of the jar / the first remaining argument the main class, load it, and retrieve its `main(String[])` method
8. append any arguments specified to the starter executable to the remaining arguments 9
9. launch Minecraft with the remaining arguments
3 changes: 1 addition & 2 deletions src/main/java/net/neoforged/serverstarterjar/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public static void mainLaunch(String[] starterArgs) throws Throwable {
System.exit(1);
}

// If we're able to find a jar in the invocation, load that jar on the boot CP as an automatic module, and invoke it
// Note: the correct way of loading it would have been as an unnamed module, but I have no idea how to do that
// If we're able to find a jar in the invocation, load that jar on the boot CP, and invoke it
var jar = findValue(args, "-jar");
if (jar != null) {
var jarFile = new File(jar);
Expand Down

0 comments on commit dcc86e5

Please sign in to comment.