Class CommandSender


  • public class CommandSender
    extends Object
    This class present an executor to execute command. We can use it to distinguish different permissions.
    • 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​(CommandPermission permission)
        Indicate 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 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
      • getPermission

        public @NonNull CommandPermission getPermission()
        Get permission
        Returns:
        permission of this sender
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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
      • 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