SpoGro - Groovy integration for Sponge


This plugin adds Groovy integration to Sponge, but why Groovy? Groovy is a Java compatible scripting language, but you don't need an JDK or create a clumpsy project just for a basic command.


I don't care much about what you do with this Code, so I chose [WTFPL](http://www.wtfpl.net/about/).


Currently you can't do much more than creating a VERY basic command.

Planned features

  • discontinued, DSL language in development

Groovy Development

The only thing you need for development is a basic text editor. You don't need any JDK or Groovy installation, the plugin comes with the Groovy parser.


The folder structure is very simple, in the plugin configuration a commands folder gets generated. Just place your Groovy file in that directory, the file name (before .groovy) equals the command label.

Basic command

The command system is pretty much the same as in Sponge, it even uses Sponge classes directly (you can use everything in Java in Groovy). The second release now automatically imports the GroovyCommand class and all Sponge packages, you can add more packages in the configuration.

class HelloWorld extends GroovyCommand{
    CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
        src.sendMessage(Text.of("Hello World!"))
        return CommandResult.success()

If you want to change more stuff, you can use (in Constructor):

  • description(Text)

  • extendedDescription(Text)

  • inputTokenizer(InputTokenizer)

  • permission(String)

  • arguments(CommandElement…)

Clone on GitHub

This project uses Gradle, I changed a few things to optimize it for Sponge and I also added 3 (4) tasks:

  • setupSponge - Sets up a full Sponge server in the folder “server”

  • runSpongeCMD/runSpongeBash - Builds the jar, checks the Sponge installation with setupSponge and runs the server, has some bugs

Downloads and more information

I uploaded everything to a GitHub Repository: **[https://github.com/dav20011/SpoGro](https://github.com/dav20011/SpoGro)**


For a Sponge first-timer, I congratulate you on such an interesting, useful, and well-written plugin.

1 Like

Thank you. I wrote Spigot plugins before, learning Sponge is not so difficult.

Many times, that’s the problem - a user writes Spigot plugins until everything Bukkit is completely ingrained. Then, when transitioning to Sponge, they do all the things they did in Spigot, completely circumventing large portions of the API and producing buggy code in the process. Not so with you.

There’s a very good german book for Java 8 (by Christian Ullenboom) that also explains the new Java 8 features. When I changed to Sponge, I just thought: “Oh cool, Java 8 stuff (Optionals, etc)”. Most Spigot/Bukkit dev are also just people who never really learned Java, that’s the big problem.

Just one question, do you think writing little commands in Groovy is really useful, because it’s still mostly Java and I can’t really shorten it anymore.

Groovy commands are a good idea, but the average user wouldn’t have much use for it because they still need to be able to write Groovy. You could make a DSL for commands, that’d be awesome.


I’ll try it, but writing the interpreter will take a while.

Man, that’s a license :laughing:

1 Like

If you want some inspiration, here is a super WIP builder I ported from bukkit recently. Not much there yet, and probably a few bugs in it, but the “essential” parts are there to make it work, and show of how it works.


Hmm, really need to learn Scala.

@pie_flavor @Katrix
Some basics are done: http://goo.gl/Fcd6nL
If you have some ideas for a better name or some implementations, please tell me.
For example I want to make Text String compatible and add literals. But I don’t have a specific idea of how these should like.

Here is a Java version if it helps you understand. It’s a bit more verbose though.


Ok, thank you.

As I said, any ideas how Text literals look best?
For example:

Text foo = "HelloWorld".aqua() + "!".red()


Text foo = AQUA("HelloWorld") + RED("!")


Text foo = AQUA + "HelloWorld" + RED + "!"

I like the first one the best.

Does Groovy support custom string interpolation? I recently(like 10 minutes ago) created a custom string interpolator which allows me to write something like

t"Some $RED text $BLUE here"

If it does, why not something similar. If not the I personally like the second one best.

Unfortunately, no, Groovy wasn’t intended for expandable syntax like Scala. But in this case, you could do something similar in most languages by just replacing the the characters with the color codes.
I think the problem with second and third methods is that the color would actually be either a function or a variable of the current class. The first example uses a function of the class Text.

What we can’t do is represent it as a left-to-right sequence. The Text object is a tree, not a formatted string.

I added some stuff to the language specs document, please tell me whether you like it.

Speaking as a scrub with heavily limited experience of languages, the second is the most intuitive and understandable for the end result.

The project may take some time, I’m currently very busy.