Search in sources :

Example 1 with Paginationable

use of pl.themolka.arcade.util.pagination.Paginationable in project Arcade2 by ShootGame.

the class GameCommands method modules.

// 
// /modules command
// 
@CommandInfo(name = { "modulelist", "modules" }, description = "Show a list of modules available in this game", usage = "[# page]", permission = "arcade.command.modulelist")
public void modules(Sender sender, CommandContext context) {
    int paramPage = context.getParamInt(0, 1);
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        throw new CommandException("No game running right now.");
    }
    List<Paginationable> modules = new ArrayList<>(game.getModules().getModules());
    if (modules.isEmpty()) {
        throw new CommandException("No modules were installed in this map.");
    }
    DynamicPagination pagination = new DynamicPagination.Builder().description(ChatColor.GOLD + "Next page: /" + context.getLabel() + " " + (paramPage + 1)).items(modules).title("Module List").build();
    if (paramPage < 1 || paramPage > pagination.getPages()) {
        throw new CommandException("Page #" + paramPage + " not found.");
    }
    pagination.display(sender, paramPage);
}
Also used : Paginationable(pl.themolka.arcade.util.pagination.Paginationable) Game(pl.themolka.arcade.game.Game) ArrayList(java.util.ArrayList) DynamicPagination(pl.themolka.arcade.util.pagination.DynamicPagination)

Aggregations

ArrayList (java.util.ArrayList)1 Game (pl.themolka.arcade.game.Game)1 DynamicPagination (pl.themolka.arcade.util.pagination.DynamicPagination)1 Paginationable (pl.themolka.arcade.util.pagination.Paginationable)1