Package dev.jorel.commandapi.wrappers
Class SimpleFunctionWrapper
java.lang.Object
dev.jorel.commandapi.wrappers.SimpleFunctionWrapper
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed,org.bukkit.Keyed
- Direct Known Subclasses:
FunctionWrapper
A wrapper class for Minecraft 1.12's functions
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleFunctionWrapper(org.bukkit.NamespacedKey minecraftKey, ToIntFunction invoker, String[] internalCommands) Creates a SimpleFunctionWrapper -
Method Summary
Modifier and TypeMethodDescriptionString[]Returns an array of commands that will be executed by this FunctionWrapperstatic SimpleFunctionWrappergetFunction(org.bukkit.NamespacedKey key) Returns a SimpleFunctionWrapper representation of the Minecraft function for the provided NamespacedKeystatic Set<org.bukkit.NamespacedKey> Returns a set of all functions that the server has registeredorg.bukkit.NamespacedKeygetKey()Returns the NamespacedKey that uniquely represents this objectstatic SimpleFunctionWrapper[]getTag(org.bukkit.NamespacedKey key) Returns a SimpleFunctionWrapper[], which is an array of all of the functions that this tag containsstatic Set<org.bukkit.NamespacedKey> getTags()Returns a set of all tags that the server has registeredintrun(org.bukkit.command.CommandSender sender) Runs this function with a given CommandSenderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bukkit.Keyed
key
-
Constructor Details
-
SimpleFunctionWrapper
public SimpleFunctionWrapper(org.bukkit.NamespacedKey minecraftKey, ToIntFunction invoker, String[] internalCommands) Creates a SimpleFunctionWrapper- Parameters:
minecraftKey- the MinecraftKey which is used to reference this functioninvoker- a method which, when invoked, runs the functioninternalCommands- a String[] of internal commands that this customFunction represents. Typically customFunction.b().map(Object::toString)
-
-
Method Details
-
getTag
Returns a SimpleFunctionWrapper[], which is an array of all of the functions that this tag contains- Parameters:
key- a 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
-
getFunction
Returns a SimpleFunctionWrapper representation of the Minecraft function for the provided NamespacedKey- Parameters:
key- a NamespacedKey representation of the function- Returns:
- a SimpleFunctionWrapper representation of the Minecraft function for the provided NamespacedKey
-
getFunctions
Returns a set of all functions that the server has registered- Returns:
- a set of all functions that the server has registered
-
getTags
Returns a set of all tags that the server has registered- Returns:
- a set of all tags that the server has registered
-
run
public int run(org.bukkit.command.CommandSender sender) Runs this function with a given CommandSender- Parameters:
sender- the sender to use to run this function- Returns:
- the result of running this command
-
getCommands
Returns an array of commands that will be executed by this FunctionWrapper- Returns:
- the commands that are defined by this custom function
-
getKey
public org.bukkit.NamespacedKey getKey()Returns the NamespacedKey that uniquely represents this object- Specified by:
getKeyin interfaceorg.bukkit.Keyed- Returns:
- the NamespacedKey that uniquely represents this object
-