Establishing key values

At the moment, this should be your game instance class:

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);
    }
    
}

If we check the javadocs, we can see that the GameInstance class has some methods marked with the @MustOverride annotation, these methods are used by the code to obtain key information about the game flow. These methods are:

  • int getMaxPlayers() -> It is used to set the maximum number of players allowed in a game instance.

  • int getTimeBeforeStart() -> As we have already seen in the Game Flow, after the instance is started, the game is prepared to start, this method is used to obtain the time in seconds before the game starts.

  • int getTimeOfGame() -> As we already saw in the Game Flow, after the timer before starting the game ends, the game starts, this method marks in seconds how long the playable time should be.

  • int getTimeBeforeEnd() -> As we have already seen in the Game Flow, after the game timer ends, it prepares to end the game, this method marks in seconds how long the post-game time should last.

Setting any time value to -1 will prevent the timers from starting.

At the moment, this should be your game instance class:

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);
    }
    
    @Override
    public int getMaxPlayers() {
        return <YOUR_VALUE>; 
    }

    @Override
    public int getTimeBeforeStart() {
        return <YOUR_VALUE>;
    }

    @Override
    public int getTimeOfGame() {
        return <YOUR_VALUE>;
    }

    @Override
    public int getTimeBeforeEnd() {
        return <YOUR_VALUE>;
    }
    
}

Last updated