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.
License
I don't care much about what you do with this Code, so I chose [WTFPL](http://www.wtfpl.net/about/).
Features
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.
Structure
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.
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.
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.
@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.
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.