Class NativeProxyCommandSender

java.lang.Object
dev.jorel.commandapi.wrappers.NativeProxyCommandSender
All Implemented Interfaces:
net.kyori.adventure.audience.Audience, net.kyori.adventure.audience.ForwardingAudience, net.kyori.adventure.audience.ForwardingAudience.Single, net.kyori.adventure.pointer.Pointered, org.bukkit.command.CommandSender, org.bukkit.command.ProxiedCommandSender, org.bukkit.permissions.Permissible, org.bukkit.permissions.ServerOperator

public class NativeProxyCommandSender extends Object implements org.bukkit.command.ProxiedCommandSender
A simple representation of Minecraft's CommandListenerWrapper, in the form of Bukkit's ProxiedCommandSender
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.bukkit.command.CommandSender

    org.bukkit.command.CommandSender.Spigot

    Nested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience

    net.kyori.adventure.audience.ForwardingAudience.Single
  • Constructor Summary

    Constructors
    Constructor
    Description
    NativeProxyCommandSender(org.bukkit.command.CommandSender caller, org.bukkit.command.CommandSender callee, org.bukkit.Location location, org.bukkit.World world)
    Constructs a NativeProxyCommandSender, which is basically Minecraft's CommandListenerWrapper
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.permissions.PermissionAttachment
    addAttachment(org.bukkit.plugin.Plugin plugin)
    Adds a new empty PermissionAttachment to this object
    org.bukkit.permissions.PermissionAttachment
    addAttachment(org.bukkit.plugin.Plugin plugin, int ticks)
    Temporarily adds a new empty PermissionAttachment to this object
    org.bukkit.permissions.PermissionAttachment
    addAttachment(org.bukkit.plugin.Plugin plugin, String name, boolean value)
    Adds a new PermissionAttachment with a single permission by name and value
    org.bukkit.permissions.PermissionAttachment
    addAttachment(org.bukkit.plugin.Plugin plugin, String name, boolean value, int ticks)
    Temporarily adds a new PermissionAttachment with a single permission by name and value
    org.bukkit.command.CommandSender
    Returns the CommandSender which is being used to call the command
    org.bukkit.command.CommandSender
    Returns the CommandSender which triggered this proxied command
    Set<org.bukkit.permissions.PermissionAttachmentInfo>
    Gets a set containing all of the permissions currently in effect by this object
    org.bukkit.Location
    Returns the location that this native command sender represents
    Gets the name of this command sender
    org.bukkit.Server
    Returns the server instance that this command is running on
    org.bukkit.World
    Returns the world that this native command sender represents
    boolean
    Gets the value of the specified permission, if set.
    boolean
    hasPermission(org.bukkit.permissions.Permission perm)
    Gets the value of the specified permission, if set.
    boolean
    Checks if this object is a server operator
    boolean
    Checks if this object contains an override for the specified permission, by fully qualified name
    boolean
    isPermissionSet(org.bukkit.permissions.Permission perm)
    Checks if this object contains an override for the specified Permission
    @NotNull net.kyori.adventure.text.Component
     
    void
    Recalculates the permissions for this object, if the attachments have changed values.
    void
    removeAttachment(org.bukkit.permissions.PermissionAttachment attachment)
    Removes the given PermissionAttachment from this object
    void
    Sends this sender a message
    void
    sendMessage(String... messages)
    Sends this sender multiple messages
    void
    sendMessage(UUID sender, String message)
    Sends this sender a message
    void
    sendMessage(UUID sender, String... messages)
    Sends this sender multiple messages
    void
    setOp(boolean value)
    Sets the operator status of this object
    org.bukkit.command.CommandSender.Spigot
    Returns a Spigot instance of this object

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.kyori.adventure.audience.Audience

    deleteMessage, openBook, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, showTitle, stopSound

    Methods inherited from interface org.bukkit.command.CommandSender

    sendMessage, sendMessage, sendPlainMessage, sendRichMessage

    Methods inherited from interface net.kyori.adventure.audience.ForwardingAudience.Single

    audiences, clearTitle, deleteMessage, filterAudience, forEachAudience, get, getOrDefault, getOrDefaultFrom, hideBossBar, openBook, playSound, playSound, playSound, pointers, resetTitle, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, stopSound

    Methods inherited from interface org.bukkit.permissions.Permissible

    permissionValue, permissionValue

    Methods inherited from interface org.bukkit.command.ProxiedCommandSender

    audience, sendMessage
  • Constructor Details

    • NativeProxyCommandSender

      public NativeProxyCommandSender(org.bukkit.command.CommandSender caller, org.bukkit.command.CommandSender callee, org.bukkit.Location location, org.bukkit.World world)
      Constructs a NativeProxyCommandSender, which is basically Minecraft's CommandListenerWrapper
      Parameters:
      caller - the command sender that actually sent the command
      callee - the command sender that will be executing the command
      location - the proxied location that the command will be run at
      world - the proxied world that the command will be run in
  • Method Details

    • addAttachment

      public org.bukkit.permissions.PermissionAttachment addAttachment(org.bukkit.plugin.Plugin plugin)
      Adds a new empty PermissionAttachment to this object
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - Plugin responsible for this attachment, may not be null or disabled
      Returns:
      The PermissionAttachment that was just created
    • addAttachment

      public org.bukkit.permissions.PermissionAttachment addAttachment(org.bukkit.plugin.Plugin plugin, int ticks)
      Temporarily adds a new empty PermissionAttachment to this object
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - Plugin responsible for this attachment, may not be null or disabled
      ticks - Amount of ticks to automatically remove this attachment after
      Returns:
      The PermissionAttachment that was just created
    • addAttachment

      public org.bukkit.permissions.PermissionAttachment addAttachment(org.bukkit.plugin.Plugin plugin, String name, boolean value)
      Adds a new PermissionAttachment with a single permission by name and value
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - Plugin responsible for this attachment, may not be null or disabled
      name - Name of the permission to attach
      value - Value of the permission
      Returns:
      The PermissionAttachment that was just created
    • addAttachment

      public org.bukkit.permissions.PermissionAttachment addAttachment(org.bukkit.plugin.Plugin plugin, String name, boolean value, int ticks)
      Temporarily adds a new PermissionAttachment with a single permission by name and value
      Specified by:
      addAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      plugin - Plugin responsible for this attachment, may not be null or disabled
      name - Name of the permission to attach
      value - Value of the permission
      ticks - Amount of ticks to automatically remove this attachment after
      Returns:
      The PermissionAttachment that was just created
    • getCallee

      public org.bukkit.command.CommandSender getCallee()
      Returns the CommandSender which is being used to call the command
      Specified by:
      getCallee in interface org.bukkit.command.ProxiedCommandSender
      Returns:
      the caller which the command is being run as
    • getCaller

      public org.bukkit.command.CommandSender getCaller()
      Returns the CommandSender which triggered this proxied command
      Specified by:
      getCaller in interface org.bukkit.command.ProxiedCommandSender
      Returns:
      the caller which triggered the command
    • getEffectivePermissions

      public Set<org.bukkit.permissions.PermissionAttachmentInfo> getEffectivePermissions()
      Gets a set containing all of the permissions currently in effect by this object
      Specified by:
      getEffectivePermissions in interface org.bukkit.permissions.Permissible
      Returns:
      Set of currently effective permissions
    • getLocation

      public org.bukkit.Location getLocation()
      Returns the location that this native command sender represents
      Returns:
      the location that this native command sender represents
    • getName

      public String getName()
      Gets the name of this command sender
      Specified by:
      getName in interface org.bukkit.command.CommandSender
      Returns:
      Name of the sender
    • getServer

      public org.bukkit.Server getServer()
      Returns the server instance that this command is running on
      Specified by:
      getServer in interface org.bukkit.command.CommandSender
      Returns:
      Server instance
    • getWorld

      public org.bukkit.World getWorld()
      Returns the world that this native command sender represents
      Returns:
      the world that this native command sender represents
    • hasPermission

      public boolean hasPermission(org.bukkit.permissions.Permission perm)
      Gets the value of the specified permission, if set.

      If a permission override is not set on this object, the default value of the permission will be returned

      Specified by:
      hasPermission in interface org.bukkit.permissions.Permissible
      Parameters:
      perm - Permission to get
      Returns:
      Value of the permission
    • hasPermission

      public boolean hasPermission(String name)
      Gets the value of the specified permission, if set.

      If a permission override is not set on this object, the default value of the permission will be returned.

      Specified by:
      hasPermission in interface org.bukkit.permissions.Permissible
      Parameters:
      name - Name of the permission
      Returns:
      Value of the permission
    • isOp

      public boolean isOp()
      Checks if this object is a server operator
      Specified by:
      isOp in interface org.bukkit.permissions.ServerOperator
      Returns:
      true if this is an operator, otherwise false
    • isPermissionSet

      public boolean isPermissionSet(org.bukkit.permissions.Permission perm)
      Checks if this object contains an override for the specified Permission
      Specified by:
      isPermissionSet in interface org.bukkit.permissions.Permissible
      Parameters:
      perm - Permission to check
      Returns:
      true if the permission is set, otherwise false
    • isPermissionSet

      public boolean isPermissionSet(String name)
      Checks if this object contains an override for the specified permission, by fully qualified name
      Specified by:
      isPermissionSet in interface org.bukkit.permissions.Permissible
      Parameters:
      name - Name of the permission
      Returns:
      true if the permission is set, otherwise false
    • recalculatePermissions

      public void recalculatePermissions()
      Recalculates the permissions for this object, if the attachments have changed values.

      This should very rarely need to be called from a plugin.

      Specified by:
      recalculatePermissions in interface org.bukkit.permissions.Permissible
    • removeAttachment

      public void removeAttachment(org.bukkit.permissions.PermissionAttachment attachment)
      Removes the given PermissionAttachment from this object
      Specified by:
      removeAttachment in interface org.bukkit.permissions.Permissible
      Parameters:
      attachment - Attachment to remove
      Throws:
      IllegalArgumentException - Thrown when the specified attachment isn't part of this object
    • sendMessage

      public void sendMessage(String message)
      Sends this sender a message
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Parameters:
      message - Message to be displayed
    • sendMessage

      public void sendMessage(String... messages)
      Sends this sender multiple messages
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Parameters:
      messages - An array of messages to be displayed
    • sendMessage

      public void sendMessage(UUID sender, String message)
      Sends this sender a message
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Parameters:
      message - Message to be displayed
      sender - The sender of this message
    • sendMessage

      public void sendMessage(UUID sender, String... messages)
      Sends this sender multiple messages
      Specified by:
      sendMessage in interface org.bukkit.command.CommandSender
      Parameters:
      messages - An array of messages to be displayed
      sender - The sender of this message
    • setOp

      public void setOp(boolean value)
      Sets the operator status of this object
      Specified by:
      setOp in interface org.bukkit.permissions.ServerOperator
      Parameters:
      value - New operator value
    • spigot

      public org.bukkit.command.CommandSender.Spigot spigot()
      Returns a Spigot instance of this object
      Specified by:
      spigot in interface org.bukkit.command.CommandSender
      Returns:
      a Spigot instance of this object
    • name

      @NotNull public @NotNull net.kyori.adventure.text.Component name()
      Specified by:
      name in interface org.bukkit.command.CommandSender