Command Example

Hey there, been lurking for awhile, and I’m liking how sponge is looking. I’m in the process of learning java currently and plan to work on some simple plugins once the API is released. From what it looks like, processing commands is fairly different from how Bukkit works, I’ve seen a couple posts, but I was curious if anyone has any examples of setting up commands that they would be willing to share.


Lapis has a few ideas.

that’s part of their own api (or whatever you wanna call it) as to how they want to try to make it doable. that’s not how sponge itself does it.

you’ll mainly be dealing with the CommandCallable class, which is basically Bukkit’s CommandExecutor class with a method name change (onCommand -> call). its then registered to the server’s command dispatcher so players are able to use it.

that’s the basic process of it. download the javadocs jar and look through it on the CommandCallable and CommandExecutor classes and see what you can get from it; you’ll learn better from doing that than you will from looking at one code snippet.

Sponge JavaDocs as of Build 133, 11/23

It’s pretty messy right now but I’m using CommandCallable in LWC here:

(BaseCommandRegisteredEvent is an internal LWC event)

It’s still a bit messy, and I’m guessing you’re probably more interesting in the @Annotation version of implementing commands which I don’t use and will make commands a lot easier to do than what I linked above.

lapis’ version of commands is nice but the problem is that its not directly integrated with sponge
its my preference (and this probably applies for a lot) that my plugins are as standalone as possible. if i have to use an api i’d probably stick with the ones that were commonly used and therefore installed everywhere (e.g. something like Vault)

I thought that vault was dead already?

wasn’t implying it was alive, but i didnt know it was declared dead either. regardless, i was just using it as an example of a widely-used api/service manager plugin. i haven’t been keeping up to date so i wouldn’t know whats alive and whats dead