public class ArgOfflinePlayer extends Object implements Argument<OfflinePlayer>
Constructor and Description |
---|
ArgOfflinePlayer() |
Modifier and Type | Method and Description |
---|---|
@Nullable List<String> |
getCompletions()
A list of completions for this argument type.
|
@NotNull String |
getName()
This is what your argument shows up as in a command.
|
boolean |
isPlural()
Used by the system to determine if this argument accepts multiple inputs.
|
boolean |
isRequired()
Used by the system when testing the command.
|
boolean |
matches(String string)
This is your matcher, to check if the player's input is valid.
|
@NotNull OfflinePlayer |
serialise(String string)
This should convert the player's input to a valid object.
|
ArgOfflinePlayer |
setLabel(@NotNull String label)
Ideally, this should set a field that will then be returned by
Argument.getName() . |
ArgOfflinePlayer |
setRequired(boolean boo)
Ideally, this should set a field that will then be returned by
Argument.isRequired() . |
@NotNull public @NotNull OfflinePlayer serialise(String string)
Argument
Argument.matches(String)
will be called first.
Generally, throw an exception if something goes wrong.serialise
in interface Argument<OfflinePlayer>
string
- The passed argument.public boolean matches(String string)
Argument
For example: a material-accepting argument checks if the string matches a Material
enum and, if so, if the enum is a block.
In this case, "grass_block" would pass (Material.GRASS_BLOCK
but "blob" and "diamond_sword" wouldn't as they are not materials/blocks respectively.
This should be a catch-all. If there is any chance of it not being valid, this should FAIL.
matches
in interface Argument<OfflinePlayer>
string
- The player's input argument.@NotNull public @NotNull String getName()
Argument
Good examples: "block", "material", "entity", "player"
Bad examples: "string" (one exists already), "<test>" (the brackets are added later), "something" (vague and unhelpful), "blocks like stone" (should be one word), "verylongcommandargument" (too long).
getName
in interface Argument<OfflinePlayer>
@Nullable public @Nullable List<String> getCompletions()
Argument
getCompletions
in interface Argument<OfflinePlayer>
public boolean isPlural()
Argument
The command handler will automatically handle plural suggestions using comma separation.
Typical plurals: "stone,grass_block,dirt", "stone_stairs[facing=north],oak_log,stone_slab[half=top]"
isPlural
in interface Argument<OfflinePlayer>
public boolean isRequired()
Argument
isRequired
in interface Argument<OfflinePlayer>
public ArgOfflinePlayer setRequired(boolean boo)
Argument
Argument.isRequired()
.
This should ALWAYS default to true.
Note: You may want to change the Argument
returned to be of your implementing class type.
setRequired
in interface Argument<OfflinePlayer>
boo
- True/false.public ArgOfflinePlayer setLabel(@NotNull @NotNull String label)
Argument
Argument.getName()
.
Note: You may want to change the Argument
returned to be of your implementing class type.
setLabel
in interface Argument<OfflinePlayer>
label
- The label to be put [here];Copyright © 2020. All rights reserved.