Search in sources :

Example 1 with DynamicPagination

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

the class MapCommands method mapList.

// 
// /maplist command
// 
@CommandInfo(name = { "maplist", "maps", "ml" }, description = "Show all loaded maps", usage = "[# page]", permission = "arcade.command.maplist")
public void mapList(Sender sender, CommandContext context) {
    int paramPage = context.getParamInt(0, 1);
    MapContainer container = this.plugin.getMaps().getContainer();
    DynamicPagination pagination = new DynamicPagination.Builder().description(ChatColor.GOLD + "Next page: /" + context.getLabel() + " " + (paramPage + 1)).items(new ArrayList<>(container.getMaps())).title("Map List").build();
    if (paramPage < 1 || paramPage > pagination.getPages()) {
        throw new CommandException("Page #" + paramPage + " not found.");
    }
    pagination.display(sender, paramPage);
}
Also used : DynamicPagination(pl.themolka.arcade.util.pagination.DynamicPagination) MapContainer(pl.themolka.arcade.map.MapContainer)

Example 2 with DynamicPagination

use of pl.themolka.arcade.util.pagination.DynamicPagination 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

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