public class AnnoyingSender extends Arguments implements Annoyable
AnnoyingCommand| Modifier and Type | Field and Description |
|---|---|
@NotNull org.bukkit.command.CommandSender |
cmdSender
The
CommandSender that was used to initialize this AnnoyingSender |
@Nullable org.bukkit.command.Command |
command
The
Command that was used |
boolean |
isPlayer
Whether the
cmdSender is a Player |
@Nullable java.lang.String |
label
The
Command's label that was used |
@NotNull AnnoyingPlugin |
plugin
The
AnnoyingPlugin instance |
| Constructor and Description |
|---|
AnnoyingSender(@NotNull AnnoyingPlugin plugin,
@NotNull org.bukkit.command.CommandSender cmdSender)
Constructs a new
AnnoyingSender without a Command |
AnnoyingSender(@NotNull AnnoyingPlugin plugin,
@NotNull org.bukkit.command.CommandSender cmdSender,
@Nullable org.bukkit.command.Command command,
@Nullable java.lang.String label,
@Nullable java.lang.String[] args)
Constructs a new
AnnoyingSender |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkPermission(@NotNull java.lang.String permission)
Checks if the
CommandSender has the specified permission. |
boolean |
checkPlayer()
Checks if the
CommandSender is a Player. |
boolean |
equalsSender(@NotNull org.bukkit.command.CommandSender sender)
Checks if the provided
CommandSender is the same as the cmdSender |
@NotNull AnnoyingPlugin |
getAnnoyingPlugin()
The
AnnoyingPlugin instance |
<T> T |
getArgument(int index,
@NotNull java.util.function.Function<java.lang.String,T> function)
Gets the argument at the specified index after applying the specified function
If it's null before/after the function, send the invalid argument message
Example usage: |
<T> @NotNull java.util.Optional<T> |
getArgumentOptional(int index,
@NotNull java.util.function.Function<java.lang.String,T> function)
Gets the argument at the specified index as an
Optional after applying the specified function
If it's empty before/after the function, send the invalid argument message
Example usage: |
<T> @NotNull java.util.Optional<T> |
getArgumentOptionalFlat(int index,
@NotNull java.util.function.Function<java.lang.String,java.util.Optional<T>> function)
Gets the argument at the specified index as an
Optional after applying the specified function and flattening it
If it's empty before/after the function, send the invalid argument message
Example usage: |
@NotNull org.bukkit.entity.Player |
getPlayer()
Casts the
CommandSender to a Player |
@NotNull java.util.Optional<org.bukkit.entity.Player> |
getPlayerOptional()
Returns the
Player as an Optional, empty if the CommandSender is not a Player
If you know that the CommandSender is a Player, use getPlayer() instead |
@Nullable org.bukkit.entity.Player |
getPlayerOrNull()
If the
CommandSender is a Player, it returns it as one. |
void |
invalidArgument(@Nullable java.lang.Object argument)
Sends the invalid argument message, replacing
%argument% with the specified argument |
void |
invalidArgumentByIndex(int index)
Sends the invalid argument message, replacing
%argument% with the specified argument
If Arguments.args is null or the specified index is out of bounds, it logs a warning to console |
void |
invalidArguments()
Sends the invalid arguments message
|
argEquals, getArgument, getArgumentOptional, getArgumentsJoined, getArgumentsJoined, getArgumentsJoined@NotNull public final @NotNull AnnoyingPlugin plugin
AnnoyingPlugin instance@NotNull public final @NotNull org.bukkit.command.CommandSender cmdSender
CommandSender that was used to initialize this AnnoyingSender@Nullable public final @Nullable org.bukkit.command.Command command
Command that was used@Nullable public final @Nullable java.lang.String label
Command's label that was usedpublic final boolean isPlayer
cmdSender is a Playerpublic AnnoyingSender(@NotNull
@NotNull AnnoyingPlugin plugin,
@NotNull
@NotNull org.bukkit.command.CommandSender cmdSender,
@Nullable
@Nullable org.bukkit.command.Command command,
@Nullable
@Nullable java.lang.String label,
@Nullable
@Nullable java.lang.String[] args)
AnnoyingSenderplugin - the AnnoyingPlugin instancecmdSender - the CommandSender to be usedcommand - the Command that was usedlabel - the Command's label that was usedargs - the Command's arguments that were usedpublic AnnoyingSender(@NotNull
@NotNull AnnoyingPlugin plugin,
@NotNull
@NotNull org.bukkit.command.CommandSender cmdSender)
AnnoyingSender without a Commandplugin - the AnnoyingPlugin instancecmdSender - the CommandSender to be used@NotNull public @NotNull AnnoyingPlugin getAnnoyingPlugin()
AnnoyableAnnoyingPlugin instancegetAnnoyingPlugin in interface Annoyablepublic boolean equalsSender(@NotNull
@NotNull org.bukkit.command.CommandSender sender)
CommandSender is the same as the cmdSendersender - the CommandSender to checkCommandSender is the same as the cmdSenderpublic boolean checkPlayer()
CommandSender is a Player. If they aren't, it sends the MessagesOptions.MessageKeys#playerOnly messageCommandSender is a Playerpublic boolean checkPermission(@NotNull
@NotNull java.lang.String permission)
CommandSender has the specified permission. If they don't, it sends the MessagesOptions.MessageKeys#noPermission messagepermission - the permission to checkCommandSender has the specified permission@NotNull public @NotNull org.bukkit.entity.Player getPlayer()
CommandSender to a Player
Only use this if you know that the CommandSender is a Player, otherwise use getPlayerOrNull()
Player that was usedjava.lang.IllegalStateException - if the CommandSender is not a PlayergetPlayerOrNull()@Nullable public @Nullable org.bukkit.entity.Player getPlayerOrNull()
CommandSender is a Player, it returns it as one. Otherwise, it returns null
CommandSender is a Player, use getPlayer() insteadPlayer, or null if the CommandSender is not a PlayergetPlayer()@NotNull public @NotNull java.util.Optional<org.bukkit.entity.Player> getPlayerOptional()
Player as an Optional, empty if the CommandSender is not a Player
CommandSender is a Player, use getPlayer() insteadPlayer as an OptionalgetPlayer()@Nullable
public <T> T getArgument(int index,
@NotNull
@NotNull java.util.function.Function<java.lang.String,T> function)
null before/after the function, send the invalid argument message
final Player target = sender.getArgument(2, Bukkit::getPlayer);
if (target == null) return;
T - the type of the argumentindex - the argument indexfunction - the function to apply to the argument@NotNull
public <T> @NotNull java.util.Optional<T> getArgumentOptional(int index,
@NotNull
@NotNull java.util.function.Function<java.lang.String,T> function)
Optional after applying the specified function
empty before/after the function, send the invalid argument message
final Optional<Player> target = sender.getArgument(2, Bukkit::getPlayer);
if (!target.isPresent()) return;
T - the type of the argumentindex - the argument indexfunction - the function to apply to the argumentOptional after applying the specified function@NotNull
public <T> @NotNull java.util.Optional<T> getArgumentOptionalFlat(int index,
@NotNull
@NotNull java.util.function.Function<java.lang.String,java.util.Optional<T>> function)
Optional after applying the specified function and flattening it
empty before/after the function, send the invalid argument message
final Optional<OfflinePlayer> target = sender.getArgumentFlat(2, BukkitUtility::getOfflinePlayer);
if (!target.isPresent()) return;
T - the type of the argumentindex - the argument indexfunction - the function to apply to the argumentOptional after applying the specified function and flattening itpublic void invalidArgument(@Nullable
@Nullable java.lang.Object argument)
%argument% with the specified argumentargument - the argument to replace %argument% withpublic void invalidArgumentByIndex(int index)
%argument% with the specified argument
Arguments.args is null or the specified index is out of bounds, it logs a warning to consoleindex - the argument indexpublic void invalidArguments()