Sueta

GuicyBukkit

1.1.3

Easily use Guice with your plugin to make it testable and more maintainable!

·Plugin

guicy logo.png
GuicyBukkit

Dependency injection is great. Using it with Spigot is even better, right?

Guice is a pretty good framework to use it with, but it was pretty boilerplate-y to use it with Spigot . Not to mention the hassle of putting listeners and commands.

And that's where GuicyBukkit comes in!

Features

  • Register listeners
  • Register commands
  • Remove your pesky static singletons

Documentation

Showcase

public   class  MyNicePluginModule  extends  PluginModule  {  
       // We need a MyNicePlugin instance to create this module, and inject it.  
       public  MyNicePluginModule  (  MyNicePlugin plugin  )   {  
           super   (  plugin  )   ;  
       }  

     @Override 
       protected   void  configureBindings  (   )   {  
         bind  (  SomeService.  class   )  .  to   (  SomeServiceImpl.  class   )   ;  
       }  

     @Override 
       protected   void  configureListeners  (  Multibinder  <  Listener  >  binder  )   {  
         binder.  addBinding   (   )  .  to   (  UsefulListener.  class   )   ;  
       }  

     @Override 
       protected   void  configureCommands  (  Multibinder  <  CommandConfigurator  >  binder  )   {  
         binder.  addBinding   (   )  .  to   (  HelloCommand.  class   )   ;  
       }  
 }
public   class  MyNicePlugin  extends  JavaPlugin  {  
   @Override 
     public   void  onLoad  (   )   {  
       Injector injector  =  Guice.  createInjector   (   new  MyNicePluginModule  (   this   )   )   ;  
       PluginDependencies.  fromInjector   (  injector  )  .  registerAll   (   this   )   ;  
     }  
 }

You just need few lines of code to get Guice running with spigot. Neat.

Aditionnal resources

  • MockBukkit is a pretty good library to mock a Bukkit server to test your plugin. In fact it's the only one I've found.

Similar projects

Plugin →