Package dev.jorel.commandapi.wrappers
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.SpigotNested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience
net.kyori.adventure.audience.ForwardingAudience.Single -
Constructor Summary
ConstructorsConstructorDescriptionNativeProxyCommandSender(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 TypeMethodDescriptionorg.bukkit.permissions.PermissionAttachmentaddAttachment(org.bukkit.plugin.Plugin plugin) Adds a new empty PermissionAttachment to this objectorg.bukkit.permissions.PermissionAttachmentaddAttachment(org.bukkit.plugin.Plugin plugin, int ticks) Temporarily adds a new empty PermissionAttachment to this objectorg.bukkit.permissions.PermissionAttachmentaddAttachment(org.bukkit.plugin.Plugin plugin, String name, boolean value) Adds a new PermissionAttachment with a single permission by name and valueorg.bukkit.permissions.PermissionAttachmentaddAttachment(org.bukkit.plugin.Plugin plugin, String name, boolean value, int ticks) Temporarily adds a new PermissionAttachment with a single permission by name and valueorg.bukkit.command.CommandSenderReturns the CommandSender which is being used to call the commandorg.bukkit.command.CommandSenderReturns the CommandSender which triggered this proxied commandSet<org.bukkit.permissions.PermissionAttachmentInfo> Gets a set containing all of the permissions currently in effect by this objectorg.bukkit.LocationReturns the location that this native command sender representsgetName()Gets the name of this command senderorg.bukkit.ServerReturns the server instance that this command is running onorg.bukkit.WorldgetWorld()Returns the world that this native command sender representsbooleanhasPermission(String name) Gets the value of the specified permission, if set.booleanhasPermission(org.bukkit.permissions.Permission perm) Gets the value of the specified permission, if set.booleanisOp()Checks if this object is a server operatorbooleanisPermissionSet(String name) Checks if this object contains an override for the specified permission, by fully qualified namebooleanisPermissionSet(org.bukkit.permissions.Permission perm) Checks if this object contains an override for the specified Permission@NotNull net.kyori.adventure.text.Componentname()voidRecalculates the permissions for this object, if the attachments have changed values.voidremoveAttachment(org.bukkit.permissions.PermissionAttachment attachment) Removes the given PermissionAttachment from this objectvoidsendMessage(String message) Sends this sender a messagevoidsendMessage(String... messages) Sends this sender multiple messagesvoidsendMessage(UUID sender, String message) Sends this sender a messagevoidsendMessage(UUID sender, String... messages) Sends this sender multiple messagesvoidsetOp(boolean value) Sets the operator status of this objectorg.bukkit.command.CommandSender.Spigotspigot()Returns a Spigot instance of this objectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, stopSoundMethods inherited from interface org.bukkit.command.CommandSender
sendMessage, sendMessage, sendPlainMessage, sendRichMessageMethods 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, stopSoundMethods inherited from interface org.bukkit.permissions.Permissible
permissionValue, permissionValueMethods 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 commandcallee- the command sender that will be executing the commandlocation- the proxied location that the command will be run atworld- 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:
addAttachmentin interfaceorg.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:
addAttachmentin interfaceorg.bukkit.permissions.Permissible- Parameters:
plugin- Plugin responsible for this attachment, may not be null or disabledticks- 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:
addAttachmentin interfaceorg.bukkit.permissions.Permissible- Parameters:
plugin- Plugin responsible for this attachment, may not be null or disabledname- Name of the permission to attachvalue- 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:
addAttachmentin interfaceorg.bukkit.permissions.Permissible- Parameters:
plugin- Plugin responsible for this attachment, may not be null or disabledname- Name of the permission to attachvalue- Value of the permissionticks- 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:
getCalleein interfaceorg.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:
getCallerin interfaceorg.bukkit.command.ProxiedCommandSender- Returns:
- the caller which triggered the command
-
getEffectivePermissions
Gets a set containing all of the permissions currently in effect by this object- Specified by:
getEffectivePermissionsin interfaceorg.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
Gets the name of this command sender- Specified by:
getNamein interfaceorg.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:
getServerin interfaceorg.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:
hasPermissionin interfaceorg.bukkit.permissions.Permissible- Parameters:
perm- Permission to get- Returns:
- Value of the permission
-
hasPermission
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:
hasPermissionin interfaceorg.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:
isOpin interfaceorg.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:
isPermissionSetin interfaceorg.bukkit.permissions.Permissible- Parameters:
perm- Permission to check- Returns:
- true if the permission is set, otherwise false
-
isPermissionSet
Checks if this object contains an override for the specified permission, by fully qualified name- Specified by:
isPermissionSetin interfaceorg.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:
recalculatePermissionsin interfaceorg.bukkit.permissions.Permissible
-
removeAttachment
public void removeAttachment(org.bukkit.permissions.PermissionAttachment attachment) Removes the given PermissionAttachment from this object- Specified by:
removeAttachmentin interfaceorg.bukkit.permissions.Permissible- Parameters:
attachment- Attachment to remove- Throws:
IllegalArgumentException- Thrown when the specified attachment isn't part of this object
-
sendMessage
Sends this sender a message- Specified by:
sendMessagein interfaceorg.bukkit.command.CommandSender- Parameters:
message- Message to be displayed
-
sendMessage
Sends this sender multiple messages- Specified by:
sendMessagein interfaceorg.bukkit.command.CommandSender- Parameters:
messages- An array of messages to be displayed
-
sendMessage
-
sendMessage
-
setOp
public void setOp(boolean value) Sets the operator status of this object- Specified by:
setOpin interfaceorg.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:
spigotin interfaceorg.bukkit.command.CommandSender- Returns:
- a Spigot instance of this object
-
name
@NotNull public @NotNull net.kyori.adventure.text.Component name()- Specified by:
namein interfaceorg.bukkit.command.CommandSender
-