Creating your first minigame

Setting up the plugin configuration

To start with you will need a configuration, that is where Bulb will get the necessary data for the game instances, such as maps.

To create this configuration you will need to register it.

public final class MyPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        ConfigManager<MyPlugin> myConfig = ConfigManager.register(this);
    }

}

The act of registering it, when starting the plugin, will also be loaded. When you start the server in your plugins folder, the folder of your plugin will appear, inside it you will a new file:

  • worlds.yml : Used to register the worlds that will be used within their respective game instances.

Creating your first GameInstance

To create your first minigame you must create a class that inherits from GameInstance.

public class MyMinigame extends GameInstance<MyPlugin> {
    
    public <K extends GameInstance<MyPlugin>> MyMinigame(MyPlugin plugin, GameManager<K, MyPlugin> manager, String gameName, WorldOption worldOption, boolean prepareOnCreation) {
        super(plugin, manager, gameName, worldOption, prepareOnCreation);
    }
    
}

Congratulations, you have already created your first minigame! This class will contain all the logic for a game instance.

Creating the GameManager of your minigame

Now that we have our minigame created, we need to create a game manager to manage these instances.

public final class MyPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        ...
        GameManager<MyMinigame, MyPlugin> minigameManager = GameManager.register(
                this, //Plugin
                myConfig, //The config we previously registered
                "myminigame", //Your minigame name, serves as an id
                MyMinigame::new 
        );
    }

}

The GameManager takes care of always creating instances when necessary, as well as containing information about the players inside them.

Last updated