CommandAPI 9.6.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.wrappers.FunctionWrapper Class Reference

A wrapper class for Minecraft 1.12's functions. More...

+ Inheritance diagram for dev.jorel.commandapi.wrappers.FunctionWrapper:

Public Member Functions

 FunctionWrapper (NamespacedKey minecraftKey, @SuppressWarnings("rawtypes") ToIntFunction invoker, Object clwArgB, Function< Entity, Object > mapper, String[] internalCommands)
 Creates a FunctionWrapper. More...
 
int run ()
 Executes this function as the executor of the command. More...
 
int runAs (Entity e)
 Executes this function as an entity. More...
 
int run (CommandSender sender)
 Runs this function with a given CommandSender. More...
 
String[] getCommands ()
 Returns an array of commands that will be executed by this FunctionWrapper. More...
 
NamespacedKey getKey ()
 Returns the NamespacedKey that uniquely represents this object. More...
 

Static Public Member Functions

static FunctionWrapper fromSimpleFunctionWrapper (SimpleFunctionWrapper wrapper, Object commandListenerWrapper, Function< Entity, Object > mapper)
 Converts a SimpleFunctionWrapper into a FunctionWrapper. More...
 
static SimpleFunctionWrapper[] getTag (NamespacedKey key)
 Returns a SimpleFunctionWrapper[], which is an array of all of the functions that this tag contains. More...
 
static SimpleFunctionWrapper getFunction (NamespacedKey key)
 Returns a SimpleFunctionWrapper representation of the Minecraft function for the provided NamespacedKey. More...
 
static Set< NamespacedKey > getFunctions ()
 Returns a set of all functions that the server has registered. More...
 
static Set< NamespacedKey > getTags ()
 Returns a set of all tags that the server has registered. More...
 

Detailed Description

A wrapper class for Minecraft 1.12's functions.

Constructor & Destructor Documentation

◆ FunctionWrapper()

dev.jorel.commandapi.wrappers.FunctionWrapper.FunctionWrapper ( NamespacedKey  minecraftKey,
@SuppressWarnings("rawtypes") ToIntFunction  invoker,
Object  clwArgB,
Function< Entity, Object >  mapper,
String[]  internalCommands 
)

Creates a FunctionWrapper.

Parameters
minecraftKeythe MinecraftKey which is used to reference this function
invokera method which, when invoked, runs the function
clwArgBthe instance of the CommandListenerWrapper which executed this command
mappera function that maps a Bukkit Entity to a Minecraft Entity
internalCommandsa String[] of internal commands that this customFunction represents. Typically customFunction.b().map(Object::toString)

Member Function Documentation

◆ fromSimpleFunctionWrapper()

static FunctionWrapper dev.jorel.commandapi.wrappers.FunctionWrapper.fromSimpleFunctionWrapper ( SimpleFunctionWrapper  wrapper,
Object  commandListenerWrapper,
Function< Entity, Object >  mapper 
)
static

Converts a SimpleFunctionWrapper into a FunctionWrapper.

Parameters
wrapperthe SimpleFunctionWrapper to convert
commandListenerWrapperthe instance of the CommandListenerWrapper which will be applied to this function
mappera function that maps a Bukkit Entity to a Minecraft Entity
Returns
A FunctionWrapper which is a child of the provided SimpleFunctionWrapper

◆ getCommands()

String[] dev.jorel.commandapi.wrappers.SimpleFunctionWrapper.getCommands ( )
inherited

Returns an array of commands that will be executed by this FunctionWrapper.

Returns
the commands that are defined by this custom function

◆ getFunction()

static SimpleFunctionWrapper dev.jorel.commandapi.wrappers.SimpleFunctionWrapper.getFunction ( NamespacedKey  key)
staticinherited

Returns a SimpleFunctionWrapper representation of the Minecraft function for the provided NamespacedKey.

Parameters
keya NamespacedKey representation of the function
Returns
a SimpleFunctionWrapper representation of the Minecraft function for the provided NamespacedKey

◆ getFunctions()

static Set< NamespacedKey > dev.jorel.commandapi.wrappers.SimpleFunctionWrapper.getFunctions ( )
staticinherited

Returns a set of all functions that the server has registered.

Returns
a set of all functions that the server has registered

◆ getKey()

NamespacedKey dev.jorel.commandapi.wrappers.SimpleFunctionWrapper.getKey ( )
inherited

Returns the NamespacedKey that uniquely represents this object.

Returns
the NamespacedKey that uniquely represents this object

◆ getTag()

static SimpleFunctionWrapper[] dev.jorel.commandapi.wrappers.SimpleFunctionWrapper.getTag ( NamespacedKey  key)
staticinherited

Returns a SimpleFunctionWrapper[], which is an array of all of the functions that this tag contains.

Parameters
keya NamespacedKey representation of the tag. This key should not include a # symbol.
Returns
a SimpleFunctionWrapper[], which is an array of all of the functions that this tag contains

◆ getTags()

static Set< NamespacedKey > dev.jorel.commandapi.wrappers.SimpleFunctionWrapper.getTags ( )
staticinherited

Returns a set of all tags that the server has registered.

Returns
a set of all tags that the server has registered

◆ run() [1/2]

int dev.jorel.commandapi.wrappers.FunctionWrapper.run ( )

Executes this function as the executor of the command.

Returns
the result of running this command

◆ run() [2/2]

int dev.jorel.commandapi.wrappers.SimpleFunctionWrapper.run ( CommandSender  sender)
inherited

Runs this function with a given CommandSender.

Parameters
senderthe sender to use to run this function
Returns
the result of running this command

◆ runAs()

int dev.jorel.commandapi.wrappers.FunctionWrapper.runAs ( Entity  e)

Executes this function as an entity.

Parameters
eentity to execute this function
Returns
the result of running this command