Allods Developers Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[JAVA] - How to view and change java in server jars (gameMechanics, itemServer and etc)

В данном гайде представлено обобщение и структурирование информации о работе с jar файлами.
This guide provides a summary and structure of information about working with jar files.
1745267106864.png

В папке server_bin/jars содержится скомпилированный код игры в запакованном виде.
Вы можете просмотреть данные файлы например с помощью 7zip
You do not have permission to view link Log in or register now.
или WinRar
The server_bin/jars folder contains the compiled game code in a compressed form.
You can view these files, for example, using 7zip
You do not have permission to view link Log in or register now.
or WinRar

1745267881968.png

Файлы c префиксом .class это скомпилированные .java файлы при сборке серверной части.
Files with the .class prefix are compiled .java files when building the server part.
1745267434251.png

Данные файлы легко можно декомпилировать в .java класс например с помощью Idea Community
You do not have permission to view link Log in or register now.

или других более простых инструментов например JD (java decompiler)
You do not have permission to view link Log in or register now.

Окей, мы не имеем исходного кода, но нам ничто не мешает изменить имеющийся код, так как .class легко можно декомпилировать в .java.
Для кого-то это "черный ящик", но я попытаюсь вам показать, что эти файлы могут помочь вам в работе с .xdb конфигурациями и пониманием работы механик сервера.

These files can be easily decompiled into a .java class, for example, using Idea Community
You do not have permission to view link Log in or register now.

or other simpler tools, such as JD (java decompiler)
You do not have permission to view link Log in or register now.

Okay, we don't have the source code, but nothing prevents us from changing the existing code, since .class can easily be decompiled into .java.
For some, this is a "black box", but I will try to show you that these files can help you in working with .xdb configurations and understanding the work of the server mechanics.


1745269029139.png
Посмотрите на ваш xdb файл - это же десериализованный в xml java объект!
gameMechanics.world.mob.MobWorld - это путь который реально существует в исходных файлах.
Обычно первое слово перед точкой в первом же теге xdb это и есть тот самый исходный jar (но бывают исключения например itemService назван itemServer можно перепутать)

Look at your xdb file - it's a deserialized xml java object!
gameMechanics.world.mob.MobWorld is a path that actually exists in the source files.
Usually the first word before the dot in the first xdb tag is the same original jar (but there are exceptions, for example itemService is called itemServer, which can be confused)
1745269564869.png

Подготовьте вашу папку для работы. 1. Скопируйте jdk для удобной работы сразу в одну папку 2. Распакуйте файлы из jar
Prepare your folder for work. 1. Copy jdk for convenient work in one folder 2. Unpack files from jar
1745270108224.png
Откройте данную папку в Idea Comunity для удобной работы с файлами. Найдем для примера gameMechanics.world.mob.MobWorld
Как видите здесь имеются даже некоторые комментарии от разработчиков и некоторые аннотации которые могут вам давать дополнительную информацию для разработки, советую пользоваться этим.


Open this folder in Idea Community for easy work with files. Let's find gameMechanics.world.mob.MobWorld for example
As you can see, there are even some comments from the developers and some annotations that can give you additional information.

1745270235880.png
И ещё захардкодил здесь для примера
And also hardcode this for example
1745272787368.png
Давайте попробуем изменить базовую скорость перемещения мобов ради эксперимента.
Создадим папку "source" и в ней создадим MobWorld.java (аналогичное название для .class) и переместим декомпилированный код в этот файл.
Не обращайте внимание на ошибки, это взятый из контекста файл, у него естественно нет зависимостей.
Let's try changing the base speed of mobs for the sake of experiment. (walkSpeed)
Create a "source" folder and in it create MobWorld.java (similar name to .class) and move the decompiled code to this file.
Ignore the errors, this is a file taken out of context, it naturally has no dependencies.

1745270504998.png

1745270613977.png

Изменяем значение walkSpeed с 1.0F на 6.0F. Готово теперь нам надо декомпилировать .java -> .class.
Change the value of walkSpeed from 1.0F to 6.0F. Done, now we need to decompile .java -> .class.

1745270851407.png
Используем следующую команду:
"./jdk/bin/javac" -encoding UTF-8 -cp "C:/Server_7.0/server_bin/jars/*" ./source/MobWorld.java
  • -cp (или -classpath) — указывает путь к зависимостям (библиотекам .jar), которые нужны для компиляции.
    • "C:/Server_7.0/server_bin/jars/*" — компилятор включает все .jar-файлы из этой папки.
    • Без этого флага компилятор не найдёт внешние классы, используемые в MobWorld.java.
  • ./source/MobWorld.java - компиляция указанного файла который мы изменили

  • -cp (or -classpath) — specifies the path to dependencies (.jar libraries) that are needed for compilation.
    • "C:/Server_7.0/server_bin/jars/*"— the compiler includes all .jar files from this folder.
    • Without this flag, the compiler will not find external classes used in MobWorld.java.
  • ./source/MobWorld.java - compilation of the specified file that we changed
1745272129497.png
Напоминаю перед заменой .class в jar файле, не забывайте делать бэкап исходного jar файла, чтобы его откатить в случае ошибок!
Заменяем все файлы, которые мы получили в папке "source" кроме исходного .java. Запускаем сервер.

I remind you that before replacing .class in a jar file, do not forget to make a backup of the original jar file to roll it back in case of errors!
We replace all the files that we received in the "source" folder except for the original .java. We start the server.

1745272282177.png

View attachment presentation (2).mp4
 

Attachments

  • 1745267420714.png
    1745267420714.png
    34.9 KB · Views: 1
  • 1745272198837.png
    1745272198837.png
    182.7 KB · Views: 1
  • 1745271111394.png
    1745271111394.png
    42.6 KB · Views: 1
  • 1745269218520.png
    1745269218520.png
    80.7 KB · Views: 1
Back
Top