So i follow the instructions here, multiple times, to the letter and i cannot figure it out. I am using eclipse and i open it in what i think is the repo folder (where is the repo folder), i have git installed and have tried different methods, The setup workspace tutorial from spong is just not detailed enough for me to understand. Where to i create my plugin class, how do i get it so i can edit in eclipse and how do i export it.
thanks in advance to anyone who decided to help me
We canât tell what is going wrong without more information. Its like you told your mechanic that your car is broken and then are expecting them to fix it based off that
@disconsented
well i opened a new folder, and cloned my fork of the git repository with the âgit bashâ, then opened a command prompt in that folder and ran âgradlew setupDecompWorkspaceâ, and then âgradlew eclipseâ, then, in eclipse i set that folder as the workspace and now i am confused were to go from there. How do i get the project to show up in eclipse? In forge there is an âeclipseâ folder, and in my folder for sponge there is not, so im not sure if there is supposed to be one or not. I have EGit installed if there is some way to use that to set up the projectâŚ
@disconsented
My apologies, my grammar was horrible in my earlier post, and I meant to say that an eclipse folder does not appear, even though there are no errors in the build, from gradle or git. Is an eclipse folder supposed to appear?
@disconsented
It does not appear. Does sponge setup similar to forge? The eclipse folder is not there, I feel like I have this problem before, put i cannot remeber how to fix itâŚ
âgradlew setupDecompWorkspace eclipseâ works fine for me on 8.1, you may need to try running it with elevated permissions (you will need to do research on your own) and/or (if youâre on windows) using âgradlew.bat setupDecompWorkSpace eclipseâ. Are you running the command via a script file or via C.L.I.?
I strongly recommend getting the gradle plugin for eclipse. Once you have the plugin you can actually go âimport -> Gradleâ and select the folder where you cloned the sponge repository and then the plugin does absolutely everything else for you.
If youâre having problems getting it to work, then this should probably get you going a lot more easily.
Ok then that tutorial you were looking at is good and all, but I donât think its what youâre looking for. So hereâs what I did for my Eclipse workspace. (I use Maven)
Create a workspace path when you start Eclipse. Mine is âC:\Users<my name>\Home\Java Stuffs\Sponge\Pluginsâ. That âHomeâ folder in there is cause I like Linux file organization better, and to make sort of a âmock-user-folderâ that I can control what goes in it. I hate when programs just drop things in your user folder. >.<
Edit: You can hold multiple plugin projects in one workspace. I have ~8 projects in my workspace.
Create a new Maven project. Check the box that says âSimple projectâ. Fill out a group id and artifact id on the next page (group id is commonly part of a package namespace that is constant across many projects; GitHub pages users can use io.github.. as a namespace for packages, hence, io.github. makes a good group id), and while it is not necessary (oddly enough), you can restate the project name in the âNameâ box, but I find this to be arbitrary. Artifact id is quite simply the name of whatever project you have. Hit finish.
Woo! You have a Maven project! But, its just an empty shell. To use the Sponge API, you must add it as a Maven dependency. Look in your project explorer for pom.xml, and open it. A special screen will pop up with tabs at the bottom. Tab over to âpom.xmlâ. Pasted below is part of my pom.xml for one of my projects.
Another Edit: I should add that all of this needs to be contained within the project and /project brackets (Iâm slightly peeved that I canât openly use <> tags in plain textâŚ)
This defines the remote Maven repository for the API.
This section is not necessary, but something I find handy. This tells Maven to use Java 7. Normally (for my Eclipse installation at least) Maven projects default to J2SE 1.5, and while you can tell it on your own to use Java 7, if you ever do a Maven project refresh, it will reset to J2SE 1.5.
With your pom.xml now set up, the sandbox is built, filled with sand, and a bucket and shovel are at your feet. Get crafting. If you need some pointers on how to get started:
Your main plugin class will need an annotation to declare it as the main plugin class @Plugin(id = âA unique ID, can be the same as nameâ, name = âA User Friendly Nameâ, version = âwhatever version youâre onâ)
Similar to Bukkit, event handlers are declared by annotation. Use @Subscribe on a method to create an event handler.
You will need to register any event handling classes outside of your main plugin class. Note: You still need @Subscribe for event handling methods in the main class, you just donât have to register them, this is done for you when your plugin is started. Someone please tag me if this is not right or has changed
Your main class can use the events found in âorg.spongepowered.api.event.stateâ to make the Sponge equivalent of Bukkitâs onEnable() and onDisable() methods. Iâm sorry to those who like to dig a chasm between Bukkit and Sponge, but lets be real, some things are relatively the same in concept.
If I had a crystal clear idea on how commands worked, I would share, but Iâm still scratching my head at commands. It looks like you implement CommandCallable and just build your command around that?
Tag me again if you have any questions, or if I derped and said some nonsense that doesnât make sense or is false.