How to write an addon¶
An addon to VGL is just a normal bukkit plugin with some extra stuff.
We will be looking at the 1vs1 game as an example, you can find the full (and updated) code here
Your mainclass is pretty straight forward. You want to extend JavaPlugin as usual, but also implement Module (from VGL).
You also should mark the class @Singleton and add a @ModuleInfo
1 2 3 | @Singleton @ModuleInfo(name = "1vs1", authors = "MiniDigger", version = "1.0.0") public class OneVsOnePlugin extends JavaPlugin implements Module |
1 2 3 4 | @Override public void onLoad() { ModuleHandler.offerModule(this); // always do this first! } |
After the module has been initalized, you can easly access any part of VGL via guice injections.
If you are new to guice, check out this short introduction here
If your addon offers a new gamemode, you also should register that in your main file.
Add a constant called GAMEMODE to hold a reference to your gamemode:
1 | public static final GameMode GAMEMODE = new GameMode("1vs1", OneVsOneGame.class); |
1 2 3 4 | @Override public void enable() { gameHandler.registerGameMode(GAMEMODE); } |
Be sure to checkout the other guides in the developer area to learn how to create phases, features and games!