Package me.hsgamer.bettergui.argument
Class ArgumentHandler
- java.lang.Object
-
- me.hsgamer.bettergui.argument.ArgumentHandler
-
- All Implemented Interfaces:
ArgumentProcessor,MenuElement
public class ArgumentHandler extends Object implements ArgumentProcessor
The handler for arguments
-
-
Constructor Summary
Constructors Constructor Description ArgumentHandler(Menu menu)Create a new handler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProcessor(ArgumentProcessor processor)Add a processorvoidclearProcessors()Clear all processorsMenugetMenu()Get the menu containing the elementList<ArgumentProcessor>getProcessors()Get the processorsList<String>handleTabComplete(UUID uuid, String[] args)Get the tab complete for the argumentsvoidonClear(UUID uuid)Called when the display of the menu is removedvoidonClearAll()Called when the menu is clearedOptional<String[]>process(UUID uuid, String[] args)Process the argumentsvoidremoveProcessor(ArgumentProcessor processor)Remove a processorPair<Optional<List<String>>,String[]>tabComplete(UUID uuid, String[] args)Get the tab complete for the arguments
-
-
-
Constructor Detail
-
ArgumentHandler
public ArgumentHandler(Menu menu)
Create a new handler- Parameters:
menu- the menu
-
-
Method Detail
-
addProcessor
public void addProcessor(ArgumentProcessor processor)
Add a processor- Parameters:
processor- the processor
-
removeProcessor
public void removeProcessor(ArgumentProcessor processor)
Remove a processor- Parameters:
processor- the processor
-
clearProcessors
public void clearProcessors()
Clear all processors
-
getProcessors
public List<ArgumentProcessor> getProcessors()
Get the processors- Returns:
- the processors
-
process
public Optional<String[]> process(UUID uuid, String[] args)
Description copied from interface:ArgumentProcessorProcess the arguments- Specified by:
processin interfaceArgumentProcessor- Parameters:
uuid- the UUID of the playerargs- the arguments- Returns:
- the remaining arguments, or empty if the arguments are invalid
-
tabComplete
public Pair<Optional<List<String>>,String[]> tabComplete(UUID uuid, String[] args)
Description copied from interface:ArgumentProcessorGet the tab complete for the arguments- Specified by:
tabCompletein interfaceArgumentProcessor- Parameters:
uuid- the UUID of the playerargs- the arguments- Returns:
- A pair of the optional suggestions and the remaining arguments. The optional suggestions can be null if the processor should be skipped, then the remaining arguments will be used for the next processor
-
handleTabComplete
public List<String> handleTabComplete(UUID uuid, String[] args)
Get the tab complete for the arguments- Parameters:
uuid- the UUID of the playerargs- the arguments- Returns:
- the suggestions
-
onClear
public void onClear(UUID uuid)
Description copied from interface:ArgumentProcessorCalled when the display of the menu is removed- Specified by:
onClearin interfaceArgumentProcessor- Parameters:
uuid- the UUID of the player
-
onClearAll
public void onClearAll()
Description copied from interface:ArgumentProcessorCalled when the menu is cleared- Specified by:
onClearAllin interfaceArgumentProcessor
-
getMenu
public Menu getMenu()
Description copied from interface:MenuElementGet the menu containing the element- Specified by:
getMenuin interfaceMenuElement- Returns:
- the menu
-
-