cijaaimee / Slime-World-Manager

A Spigot plugin that implements the Slime Region Format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there any way to use ClassModifiers without modifying the startup script?

roie123400010 opened this issue · comments

Hey!

I am creating a minigame server and my host doesn't support changing the startup script.
Is there any other way I could use the plugin without modifying the startup script?

Sadly, not really. The CLSM modifies the server code when it's loading, in order to make it compatible with SWM. The only thing you could do (I guess?) is to have a modified version of spigot that already contains those changes. That way, you would not need to inject any changes, as the spigot jar already contains them.

Can you tell me exactly what do I need to do?
Do I take all classes of the ClassMofifier, put into spigot and build it?
If so, in what directory to put it in and what classes to add?

This plugin could really help my minigame.

You would need to add both the ClassModifier & the CLSMBridge classes into your spigot, found here: https://github.com/Grinderwolf/Slime-World-Manager/tree/develop/slimeworldmanager-classmodifier/src/main/java/com/grinderwolf/swm/clsm. Just create the according packages.

Then, find the right version for your spigot here: https://github.com/Grinderwolf/Slime-World-Manager/tree/develop/slimeworldmanager-classmodifier/src/main/resources.

You will find some txt files. Each file has java code, that is inserted on top of a method. To find which method the file is intended for, check out this other file: https://github.com/Grinderwolf/Slime-World-Manager/blob/develop/slimeworldmanager-classmodifier/src/main/resources/list.yml

In that last file, you'll see different class names (net/minecraft/server/v1_15_R1/PlayerChunkMap, etc). Each class has one or more entries. Each entry uses the following formatting so the app knows which file is related to which method: <method name>(<different classes of the parameters, in case two methods have the same name>)@<file location>. Note that some class names will have __optional__ as a prefix. Those methods might not exist (usually these are changes that Paper contains). If you cannot find them, just ignore them.

You would need to add both the ClassModifier & the CLSMBridge classes into your spigot, found here: https://github.com/Grinderwolf/Slime-World-Manager/tree/develop/slimeworldmanager-classmodifier/src/main/java/com/grinderwolf/swm/clsm. Just create the according packages.

Do I need to compile these classes first? And just make a package com.grinderwolf.swm.clsm?

You will find some txt files. Each file has java code, that is inserted on top of a method. To find which method the file is intended for, check out this other file: https://github.com/Grinderwolf/Slime-World-Manager/blob/develop/slimeworldmanager-classmodifier/src/main/resources/list.yml

Do I need to overwrite the existing code with the ones at the txt file?

Do I need to compile these classes first? And just make a package com.grinderwolf.swm.clsm?

I just realized that the compiler will compile them automatically, but I still need the answer for if the package I need to create is com.grinderwolf.swm.clsm.

I just realized that the compiler will compile them automatically, but I still need the answer for if the package I need to create is com.grinderwolf.swm.clsm.

Yes, you need to use the same package in order for SWM to recognize it.

Do I need to overwrite the existing code with the ones at the txt file?

No, you have to insert it at the top of the method.

Ok, I got the JAR file decompiled, I will now start doing what you said and I will update you if everything works.

I decompiled a spigot JAR file that I found on my PC, I changed the files needed and added the classes but I don't know how to export since IntelliJ Idea doesn't detect it as a jar file.
After a short google, I decided to build the JAR with BuildTools and I will have the source code AND a way to compile the code afterward but I can't find 2 out of 3 files that I need to change (net/minecraft/server/v1_12_R1/MinecraftServer.java and net/minecraft/server/v1_12_R1/ChunkProviderServer).

Do you know how to compile it with IntelliJ Idea or how to find the files needed in the files that a run of BuildTools gave me?

You can run BuildTools to get a working clone of the spigot server source code. As soon as BuildTools is finished, go into the "Spigot" folder. In IntellIJ, you can import that project by selecting that folder on the "Create project from sources" option. Then, you should be able to find all the classes you need to modify (note that you're interested in the "Spigot-Server" submodule).

Whenever you're done, open a git command prompt (right click on the folder -> Git Bash here) and do "mvn clean install". Bear in mind that you have to run that command inside the "Spigot" folder. Finally, your server jar should be located at "Spigot/Spigot-Server/target".

You can run BuildTools to get a working clone of the spigot server source code. As soon as BuildTools is finished, go into the "Spigot" folder. In IntellIJ, you can import that project by selecting that folder on the "Create project from sources" option. Then, you should be able to find all the classes you need to modify (note that you're interested in the "Spigot-Server" submodule).

Whenever you're done, open a git command prompt (right click on the folder -> Git Bash here) and do "mvn clean install". Bear in mind that you have to run that command inside the "Spigot" folder. Finally, your server jar should be located at "Spigot/Spigot-Server/target".

Alright, I'm going to try it now, thanks!

I will let you know if this works or not.

When I run "mvn clean install" on the git bash it gives me this error:

[ERROR] D:\Java\Decompiler\buildTools\Spigot\Spigot-Server\src\main\java\com\grinderwolf\swm\clsm\ClassModifier.java:[3] The import com.mojang.datafixers.util.Either cannot be resolved [ERROR] D:\Java\Decompiler\buildTools\Spigot\Spigot-Server\src\main\java\com\grinderwolf\swm\clsm\ClassModifier.java:[31] The method supplyAsync(Supplier<U>) in the type CompletableFuture is not applicable for the arguments (() -> {}) [ERROR] D:\Java\Decompiler\buildTools\Spigot\Spigot-Server\src\main\java\com\grinderwolf\swm\clsm\ClassModifier.java:[31] Either cannot be resolved

Try reimporting the class. It might have been relocated.

What class?

"Either".

There are parts who show in red on the pom.xml.
image
image

Yeah that's intellij not being able to recognize some stuff. Ignore it.

Plus reimporting the project doesn't work

I mean, it does work but doesn't fix the problem.

Actually, do I need to manually add the datafixers library to the pom.xml file?

I did some research and found the datafixers library, I added the repository and dependency (latest version) to the pom.xml file, re-imported and exported. The errors got fixed and the plugin started successfully. Was I supposed to do something else?

Hello?

Sorry, forgot to take a look at GitHub. If the plugin started sucessfully, you are good to go!

Alright, thanks!

Just 1 thing before I close this issue, I am using SlimeWorld.clone(String, SlimeLoader) to clone my maps. And it seems like I cant place or break any blocks...

Make sure the spawn protection is disabled and that you have no other plugins that might be causing that.

I'm gonna close the issue now. If there's anything else I can help you with, feel free to join the discord server or create another issue if appropiate.