Package top.focess.qq.api.command
Class CommandSender
- java.lang.Object
-
- top.focess.qq.api.command.CommandSender
-
public class CommandSender extends Object
This 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 net.mamoe.mirai.contact.Friend friend)Present FriendCommandSender(@NonNull net.mamoe.mirai.contact.Member member)Present Member in GroupCommandSender(@NonNull net.mamoe.mirai.contact.Stranger stranger)Present Stranger
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object o)voidexec(String command)Execute command with this CommandSender@Nullable BotgetBot()Get the bot@Nullable net.mamoe.mirai.contact.FriendgetFriend()Get the Mirai Friend instance, or null if this CommandSender does not present a Mirai Friend instance.IOHandlergetIOHandler()Get the receiver by this CommandSender@Nullable net.mamoe.mirai.contact.MembergetMember()Get the Mirai Member instance, or null if this CommandSender does not present a Mirai Member instance.@NonNull CommandPermissiongetPermission()Get permissionSessiongetSession()Get Session of a special CommandSender.inthashCode()booleanhasPermission(net.mamoe.mirai.contact.MemberPermission permission)Deprecated.booleanhasPermission(CommandPermission permission)Indicate whether this CommandSender owns the permissionbooleanisAuthor()Indicate whether this is an Author Mirai Friend Instance or an Author Mirai Member InstancebooleanisConsole()Indicate whether it is CONSOLEbooleanisFriend()Indicate whether this is a Mirai Friend instancebooleanisMember()Indicate whether this is a Mirai Member instancebooleanisStranger()Indicate whether this is a Mirai Stranger instanceStringtoString()
-
-
-
Field Detail
-
CONSOLE
public static final CommandSender CONSOLE
Present CONSOLE or we call it Terminate
-
-
Constructor Detail
-
CommandSender
public CommandSender(@NonNull net.mamoe.mirai.contact.Friend friend)
Present Friend- Parameters:
friend- the Mirai Friend instance
-
CommandSender
public CommandSender(@NonNull net.mamoe.mirai.contact.Member member)
Present Member in Group- Parameters:
member- The Mirai Member Instance
-
CommandSender
public CommandSender(@NonNull net.mamoe.mirai.contact.Stranger stranger)
Present Stranger- Parameters:
stranger- The Mirai Stranger Instance
-
-
Method Detail
-
getFriend
public @Nullable net.mamoe.mirai.contact.Friend getFriend()
Get the Mirai Friend instance, or null if this CommandSender does not present a Mirai Friend instance.- Returns:
- the Mirai Friend instance
-
isFriend
public boolean isFriend()
Indicate whether this is a Mirai Friend instance- Returns:
- true if this CommandSender presents a Mirai Friend instance, false otherwise
-
hasPermission
@Deprecated public boolean hasPermission(net.mamoe.mirai.contact.MemberPermission permission)
Deprecated.Indicate whether this CommandSender owns the permission- Parameters:
permission- the compared permission- Returns:
- true if the permission of this CommandSender is higher or equivalent to the compared permission, false otherwise
-
hasPermission
public boolean hasPermission(CommandPermission permission)
Indicate whether this CommandSender owns the permission- 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 net.mamoe.mirai.contact.Member getMember()
Get the Mirai Member instance, or null if this CommandSender does not present a Mirai Member instance.- Returns:
- the Mirai Member instance
-
isMember
@EnsuresNonNullIf(expression="getMember()", result=true) public boolean isMember()Indicate whether this is a Mirai Member instance- Returns:
- true if this CommandSender presents a Mirai Member instance, false otherwise
-
isAuthor
public boolean isAuthor()
Indicate whether this is an Author Mirai Friend Instance or an Author Mirai Member Instance- Returns:
- true if this CommandSender presents its id is equal to the id of the author, false otherwise
-
getPermission
public @NonNull CommandPermission getPermission()
Get permission- Returns:
- permission of this sender
-
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 void exec(String command)
Execute command with this CommandSender- Parameters:
command- the command CommandSender execute- See Also:
Main.CommandLine.exec(CommandSender, String)
-
getSession
public Session getSession()
Get Session of a special 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
public boolean isStranger()
Indicate whether this is a Mirai Stranger instance- Returns:
- true if this CommandSender presents a Mirai Stranger instance, false otherwise
-
-