Skip to content

Commit d96a6e0

Browse files
authored
Merge pull request #237 from IamMusavaRibica/patch-1
docs(plugin): improve browsing server.jar guide
2 parents 7c53554 + f794a98 commit d96a6e0

1 file changed

Lines changed: 61 additions & 18 deletions

File tree

content/docs/en/guides/plugin/browsing-serverjar.mdx

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
---
22
title: Browsing the server.jar code
33
description: Learn how to patch the server.jar and browse the source code.
4+
authors:
5+
- name: "musava_ribica"
6+
url: "https://github.com/IamMusavaRibica"
47
---
58

6-
The ~~patcher~~ allows you to more easily prepare an environment for exploring the Hytale Server without publishing the decompiled code.
9+
Our [patcher](https://github.com/HytaleModding/patcher) tool allows you to easily prepare an environment for exploring the Hytale Server.
710

11+
## Why?
812

9-
## Setup
13+
When you add a compiled jar as a library, IntelliJ only decompiles class by class and doesn't let you search it. For example, you cannot right click some class and then Find Usages. This script will give you a ready to use Hytale server code as a project where you can explore anything you want.
1014

11-
* Clone the patcher `git clone https://github.com/HytaleModding/patcher.git`, and enter the directory. `cd patcher`
15+
16+
17+
If anything goes wrong, please ping the author in [this post](https://discord.com/channels/1440173445039132724/1460707397189238785) in the Hytale Modding discord server
18+
19+
20+
## Instructions
21+
22+
* Clone the repository `git clone https://github.com/HytaleModding/patcher.git`, and enter the directory using `cd patcher`
1223

1324
* Create a Python virtual environment in the `.venv` folder. The command for this varies by platform but it is probably
1425
one of these:
@@ -19,45 +30,77 @@ one of these:
1930
In the last one, specifying the version is recommended if you have multiple Pythons installed.
2031

2132
* Activate the virtual environment:
22-
- Windows: `".venv\Scripts\activate"` (including the quotes)
33+
- Windows: If you're using normal command prompt, do `".venv\Scripts\activate"` and if you're using PowerShell, do `.\.venv\Scripts\activate`
2334
- Linux/Mac: `source .venv/bin/activate`
2435
- From now on, you are running python commands from inside the venv, hence you must use `python` instead of `py` or `python3` to invoke python.
36+
37+
* You should now have `(.venv)` prefixed to the current working dir in the terminal.
2538

26-
* Inside the venv, you have to install the dependencies
39+
* Inside the venv, install the dependencies
2740
- `pip install -r requirements.txt`
2841

2942
* Install these dependencies and ensure they are on PATH:
30-
- `git`
43+
- `git` - download from [here](https://git-scm.com/install/) and make sure the `C:\Program Files\Git\cmd\` folder is on your PATH.
3144
- `java` you need JDK 25 or newer
3245
- `jar` (comes with JDK inside the bin folder)
33-
- `mvn`
34-
46+
- `mvn` - download from [here](https://maven.apache.org/download.cgi), extract and add the `bin` folder on your PATH
3547

36-
## Usage
48+
After modifying your PATH, don't forget to close existing terminals and start a new one. Verify that those tools are installed by running these commands: `git --version`, `mvn --version`, `java --version`, `jar --version`.
3749

38-
Put your HytaleServer.jar in the same root directory of this repo or specify an environment variable `HYTALESERVER_JAR_PATH` with the path to your HytaleServer.jar
50+
* Put your HytaleServer.jar in the same root directory of this repo or specify an environment variable `HYTALESERVER_JAR_PATH` with the path to your HytaleServer.jar
3951

4052
Then run this:
4153
```shell
4254
python run.py setup
4355
```
44-
It will
56+
57+
What will it do:
4558
- copy the HytaleServer.jar into `work/download`
4659
* (on Windows) fix `META-INF/license` name collision
47-
- decompile it using Fernflower and save the output to `work/decompile`
60+
- decompile only the `com.hypixel` package using Vineflower and save the output to `work/decompile`
4861
- set up a Maven project in `hytale-server` with the decompiled code
62+
* all other libraries the server uses are added into pom.xml and you don't have to worry about them.
63+
4964

5065
You can then open the `hytale-server` folder in your favorite IDE and begin exploring the code. For *IntelliJ IDEA*,
5166
you must first set up the SDK. After opening the project (you can open the `pom.xml` file, IDEA will prompt you to open
52-
the entire project) press Ctrl+Alt+Shift+S and under _Project_ configure SDK and Language level to *25*.
67+
the entire project) press Ctrl+Alt+Shift+S and under _Project_ configure *SDK* and *Language level* to **25**.
68+
69+
This decompiled code is likely broken. But it is somewhat usable for exploration. Try Ctrl+Shift+F and search PacketAdapters. Want to figure out where is PlayerSetupConnectEvent constructed? Just find it somewhere then right click and Find Usages, and at the bottom see New instance creation.
70+
71+
72+
73+
74+
## Adding HytaleServer as a dependency
5375

54-
If IDEA does not offer an option to run the main file, right-click the `src` folder -> Mark Directory As -> Sources Root
55-
then reload the maven project:
76+
Go into `hytale-server/src/main/java` folder in your terminal (cmd or powershell). Run this command
77+
```shell
78+
jar -f hytale-server-stripped.jar -c com
79+
```
80+
81+
Then run this **from the same folder**:
82+
```shell
83+
mvn install:install-file -Dfile=hytale-server-stripped.jar -DgroupId="com.hypixel.hytale" -DartifactId=HytaleServer-stripped -Dversion="1.0-SNAPSHOT" -Dpackaging=jar
84+
```
85+
86+
Then, in your plugin project add this dependency and also copy other dependencies from the `hytale-server/pom.xml`.
87+
```xml
88+
<dependency>
89+
<groupId>com.hypixel.hytale</groupId>
90+
<artifactId>HytaleServer-stripped</artifactId>
91+
<version>1.0-SNAPSHOT</version>
92+
<scope>provided</scope>
93+
</dependency>
94+
```
95+
96+
Congratulations!
97+
98+
99+
100+
## Reloading Maven projects
101+
You may have to reload the maven project sometimes. Here's how to do that:
56102
![_readme_images/img.png](/assets/reload-maven.png)
57103
It is located in the "m" icon on the right side:
58104
![_readme_images/m.png](/assets/maven.png)
59105
If you don't see it, enable it under View -> Tool Windows -> Maven.
60106
![_readme_images/tool_windows.png](/assets/view-windowtools-maven.png)
61-
62-
63-
This decompiled code is likely broken. But it is somewhat usable for exploration. Try Ctrl+Shift+F and search PacketAdapters

0 commit comments

Comments
 (0)