I’ve been following the documentation at https://docs.spongepowered.org/nb/server/index.html in order to get a test server up and running. However, once I insert the Sponge jar (located in ./run/libs) into the mods folder of my server, I get the following error:
I’m also following the instruction in the README for the Sponge github project. That’s how I’m starting up my server. Keep in mind the forge server comes up, but when I add the sponge mod, the problem occurs.
You can’t just mix and match the production jar with the development instructions. If you want to run production then follow the instructions in the docs, if you want to run dev then follow the instructions in the README. You cannot just import the production jar into a dev workspace and have it work because the two environments are fundamentally incompatible.
If you’re doing development I strongly recommend you just use the SDK instead because it just automates everything for you.
But you haven’t followed it exactly if you’re putting the Sponge jar in your mods folder…
then you’re not following the instructions in the README because at no point does it tell you to do that. In the development workspace you only need to import the gradle projects and set up your run configuration as described. If you put the production jar into the development mods folder, then you will get the crash you are experiencing, because the two environments are not compatible.
The reason I added the Sponge jar to the mods folder was because of the output generated by running the jar directly.
Following the README only, in the build section, it tells me how to build the jar, by running the gradle command. Then, it tells me where the jar is. Attempting to run the jar gives me the following output/instructions:
Link to the issue you posted when it wouldn’t work and I’ll look into it for you, it was probably overlooked.
That information is provided to help people who want to run the production jar.
The build command runs a production build and generates a production jar that you can use in a Forge server. You do not need to run build in order to develop Sponge, that’s why the Build section is at the end of the README after the information about setting up the workspace.
Which says, place this jar in the mods folder of your server. My server was nicely set up my the sponge project, located in ./run/server[/quote]
No, you have a dev workspace, which is not the same. You cannot put the production jar into the dev workspace.
In production, everything is obfuscated, all the class names, field names, method names, everything is obfuscated because that’s how it is in minecraft. In production the FML tweaker partially de-obfuscates on-the-fly but only to what are called “Searge names” which are common names across all versions of minecraft but aren’t particularly human readable. Of course, developing with these nonsense names would be (first) impossible, because you couldn’t import anything, and (second) incredibly difficult because everything would be utterly unreadable.
During dev, an extra level of de-obfuscation is applied and is actually baked into the classes used in the dev-time environment (eg. the classes are actually de-obfuscated en situ, not on-the-fly) and these classes are used to develop against. Once dev is done, running a build both compiles all the new classes and re-obfuscates them so that they will work with the obfuscated names in production.
This means that dev-time and production-time classes are always incompatible, and is the entire purpose of the API existing in the first place (because with the API, all this obfuscation shenanigans are not needed).
Further, the runtime patching we use in Sponge, called Mixin uses some quite complicated runtime trickery in order to function through the thick pile of obfuscation, and has a very delicate relationship with the classloader. At dev-time, the Mixin subsytem is boostrapped directly via the Sponge “core mod”, which leverages the Mixin framework into the classloader and allows it to mix in sponge’s functionality into Forge. However at production time, the core mod gets called too late in the cycle for Mixin to be properly loaded, and thus a tweaker is used instead. These two approaches are also incompatible and another reason that you cannot use production jars in dev (even if the classes would work - which they won’t).
Hope that explains adequately why you cannot mix 'n match the jars.
It does! Thank you. However, I still feel a little lost. (I understand everything you said about obfuscation. That all makes sense.)
I want to develop a test plugin for Sponge. Now, you might be quick to tell me to use a production setup and not a dev setup, but I ALSO want to be able to develop for Sponge, in case that my plugins would need something in the API that isn’t implemented, or in case I would like to add something new to the API as a pull request (Like a new service).
So, the real question is:
With my development server for Sponge, how can I add a Sponge plugin?
Once you get the Sponge dev workspace set up (by following all the steps in the README except build), make a new project in your Eclipse workspace and simply make it depend on the SpongeAPI project. Then edit your run configuration to include your plugin project in the runtime classpath.