Class PaginatedCommand<T>
- java.lang.Object
-
- com.pneumaticraft.commandhandler.Command
-
- com.onarandombox.MultiverseCore.commands.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.CommandA generic paginated command.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classPaginatedCommand.FilterObject"Key-Object" containing information about the page and the filter that were requested.
-
Field Summary
Fields Modifier and Type Field Description protected intitemsPerPageThe number of items per page.
-
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.StringcleanFilter(java.lang.String filter)Escape regex special characters from filterprotected abstract java.util.List<T>getFilteredItems(java.util.List<T> availableItems, java.lang.String filter)Gets filtered items.protected abstract java.lang.StringgetItemText(T item)Converts an item into a string.protected PaginatedCommand.FilterObjectgetPageAndFilter(java.util.List<java.lang.String> args)Constructs aPaginatedCommand.FilterObjectfrom aListof arguments.protected voidsetItemsPerPage(int items)Set the number of items per page.protected voidshowPage(int page, org.bukkit.command.CommandSender sender, java.util.List<T> cmds)Shows a page.protected java.lang.StringstitchThisString(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
-
-
-
-
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- TheListof 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- TheCommandSenderthat 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.
-
getPageAndFilter
protected PaginatedCommand.FilterObject getPageAndFilter(java.util.List<java.lang.String> args)
Constructs aPaginatedCommand.FilterObjectfrom aListof arguments.- Parameters:
args- TheListof arguments.- Returns:
- The
PaginatedCommand.FilterObject.
-
-