Class PaginatedCommand<T>

  • Type Parameters:
    T - The type of items on the page.
    Direct Known Subclasses:
    PaginatedCoreCommand

    public abstract class PaginatedCommand<T>
    extends com.pneumaticraft.commandhandler.Command
    A generic paginated command.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  PaginatedCommand.FilterObject
      "Key-Object" containing information about the page and the filter that were requested.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int itemsPerPage
      The number of items per page.
      • Fields inherited from class com.pneumaticraft.commandhandler.Command

        plugin
    • Constructor Summary

      Constructors 
      Constructor Description
      PaginatedCommand​(org.bukkit.plugin.java.JavaPlugin plugin)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String cleanFilter​(java.lang.String filter)
      Escape regex special characters from filter
      protected abstract java.util.List<T> getFilteredItems​(java.util.List<T> availableItems, java.lang.String filter)
      Gets filtered items.
      protected abstract java.lang.String getItemText​(T item)
      Converts an item into a string.
      protected PaginatedCommand.FilterObject getPageAndFilter​(java.util.List<java.lang.String> args)
      Constructs a PaginatedCommand.FilterObject from a List of arguments.
      protected void setItemsPerPage​(int items)
      Set the number of items per page.
      protected void showPage​(int page, org.bukkit.command.CommandSender sender, java.util.List<T> cmds)
      Shows a page.
      protected java.lang.String stitchThisString​(java.util.List<java.lang.String> list)
      Constructs a single string from a list of strings.
      • Methods inherited from class com.pneumaticraft.commandhandler.Command

        addAdditonalPermission, addCommandExample, addKey, addKey, checkArgLength, getAllPermissionStrings, getCommandDesc, getCommandExamples, getCommandName, getCommandUsage, getKey, getKeys, getKeyStrings, getMaxArgs, getMinArgs, getNumKeyArgs, getPermission, getPermissionString, getPlugin, isOpRequired, removeKeyArgs, runCommand, setArgRange, setCommandUsage, setName, setPermission, setPermission, showHelp
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • itemsPerPage

        protected int itemsPerPage
        The number of items per page.
    • Constructor Detail

      • PaginatedCommand

        public PaginatedCommand​(org.bukkit.plugin.java.JavaPlugin plugin)
    • Method Detail

      • setItemsPerPage

        protected void setItemsPerPage​(int items)
        Set the number of items per page.
        Parameters:
        items - The new number of items per page.
      • getFilteredItems

        protected abstract java.util.List<T> getFilteredItems​(java.util.List<T> availableItems,
                                                              java.lang.String filter)
        Gets filtered items.
        Parameters:
        availableItems - All available items.
        filter - The filter-String.
        Returns:
        A list of items that match the filter.
      • cleanFilter

        protected java.lang.String cleanFilter​(java.lang.String filter)
        Escape regex special characters from filter
        Parameters:
        filter - The filter-String.
        Returns:
        String with regex characters escaped
      • stitchThisString

        protected java.lang.String stitchThisString​(java.util.List<java.lang.String> list)
        Constructs a single string from a list of strings.
        Parameters:
        list - The List of strings.
        Returns:
        A single String.
      • showPage

        protected void showPage​(int page,
                                org.bukkit.command.CommandSender sender,
                                java.util.List<T> cmds)
        Shows a page.
        Parameters:
        page - The number of the page to show.
        sender - The CommandSender that wants to see the page.
        cmds - The items that should be displayed on the page.
      • getItemText

        protected abstract java.lang.String getItemText​(T item)
        Converts an item into a string.
        Parameters:
        item - The item.
        Returns:
        A String.