Package top.focess.qq.api.command
Class CommandSender
- java.lang.Object
-
- top.focess.command.CommandSender
-
- top.focess.qq.api.command.CommandSender
-
public class CommandSender extends top.focess.command.CommandSenderThis class present an executor to execute command. We can use it to distinguish different permissions.
-
-
Field Summary
Fields Modifier and Type Field Description static CommandSenderCONSOLEPresent CONSOLE or we call it Terminate
-
Constructor Summary
Constructors Constructor Description CommandSender(@NonNull Friend friend)Deprecated.CommandSender(@NonNull Member member)Deprecated.CommandSender(@NonNull Stranger stranger)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidclear(Plugin plugin)booleanequals(Object o)Future<top.focess.command.CommandResult>exec(String command)Execute command with this CommandSender@Nullable BotgetBot()Get the bot@Nullable FriendgetFriend()Get the friend, or null if this CommandSender does not present a friendIOHandlergetIOHandler()Get the receiver by this CommandSender@Nullable MembergetMember()Get the member, or null if this CommandSender does not present a memberSessiongetSession()Get Session of the CommandSender.@Nullable StrangergetStranger()Get the stranger, or null if this CommandSender does not present a strangerinthashCode()booleanhasPermission(top.focess.command.CommandPermission permission)Indicate this CommandSender owns the permissionbooleanisAdministrator()Indicate this is an AdministratorbooleanisConsole()Indicate whether it is CONSOLEbooleanisFriend()Indicate this is a friendbooleanisMember()Indicate this is a memberbooleanisStranger()Indicate whether this is a strangerstatic CommandSenderof(CommandExecutor executor)Get the CommandSender by CommandExecutorStringtoString()
-
-
-
Field Detail
-
CONSOLE
public static final CommandSender CONSOLE
Present CONSOLE or we call it Terminate
-
-
Constructor Detail
-
CommandSender
@Deprecated public CommandSender(@NonNull Friend friend)
Deprecated.Present Friend- Parameters:
friend- the friend
-
CommandSender
@Deprecated public CommandSender(@NonNull Member member)
Deprecated.Present Member in Group- Parameters:
member- the member
-
CommandSender
@Deprecated public CommandSender(@NonNull Stranger stranger)
Deprecated.Present Stranger- Parameters:
stranger- the stranger
-
-
Method Detail
-
clear
public static void clear(Plugin plugin)
-
getFriend
public @Nullable Friend getFriend()
Get the friend, or null if this CommandSender does not present a friend- Returns:
- the friend
-
isFriend
@EnsuresNonNullIf(expression="getFriend()", result=true) public boolean isFriend()Indicate this is a friend- Returns:
- true if this CommandSender presents a friend, false otherwise
-
hasPermission
public boolean hasPermission(top.focess.command.CommandPermission permission)
Indicate this CommandSender owns the permission- Overrides:
hasPermissionin classtop.focess.command.CommandSender- Parameters:
permission- the compared permission- Returns:
- true if the permission of this CommandSender is higher or equivalent to the compared permission, false otherwise
-
getMember
public @Nullable Member getMember()
Get the member, or null if this CommandSender does not present a member- Returns:
- the member
-
isMember
@EnsuresNonNullIf(expression="getMember()", result=true) public boolean isMember()Indicate this is a member- Returns:
- true if this CommandSender presents a member, false otherwise
-
isAdministrator
public boolean isAdministrator()
Indicate this is an Administrator- Returns:
- true if this CommandSender presents its id is equal to the id of the Administrator, false otherwise
-
isConsole
public boolean isConsole()
Indicate whether it is CONSOLE- Returns:
- true if it is
CONSOLE, false otherwise
-
getIOHandler
public IOHandler getIOHandler()
Get the receiver by this CommandSender- Returns:
- the receiver by this CommandSender
-
exec
public Future<top.focess.command.CommandResult> exec(String command)
Execute command with this CommandSender- Parameters:
command- the command CommandSender execute- Returns:
- the result of the command
- See Also:
CommandLine.exec(CommandSender, String)
-
getSession
public Session getSession()
Get Session of the CommandSender. It can be used to store some data for future using. But the data it stored will be lost after Bot exiting.- Returns:
- Session of sender
-
getBot
public @Nullable Bot getBot()
Get the bot- Returns:
- the bot
-
isStranger
@EnsuresNonNullIf(expression="getStranger()", result=true) public boolean isStranger()Indicate whether this is a stranger- Returns:
- true if this CommandSender presents a stranger, false otherwise
-
getStranger
public @Nullable Stranger getStranger()
Get the stranger, or null if this CommandSender does not present a stranger- Returns:
- the stranger
-
of
public static CommandSender of(CommandExecutor executor)
Get the CommandSender by CommandExecutor- Parameters:
executor- the executor- Returns:
- the CommandSender
-
-