Package dev.jorel.commandapi.wrappers
Class FunctionWrapper
java.lang.Object
dev.jorel.commandapi.wrappers.SimpleFunctionWrapper
dev.jorel.commandapi.wrappers.FunctionWrapper
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed,org.bukkit.Keyed
A wrapper class for Minecraft 1.12's functions
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionWrapper(org.bukkit.NamespacedKey minecraftKey, ToIntFunction invoker, Object clwArgB, Function<org.bukkit.entity.Entity, Object> mapper, String[] internalCommands) Creates a FunctionWrapper -
Method Summary
Modifier and TypeMethodDescriptionstatic FunctionWrapperfromSimpleFunctionWrapper(SimpleFunctionWrapper wrapper, Object commandListenerWrapper, Function<org.bukkit.entity.Entity, Object> mapper) Converts a SimpleFunctionWrapper into a FunctionWrapperintrun()Executes this function as the executor of the command.intrunAs(org.bukkit.entity.Entity e) Executes this function as an entity.Methods inherited from class dev.jorel.commandapi.wrappers.SimpleFunctionWrapper
getCommands, getFunction, getFunctions, getKey, getTag, getTags, runMethods 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
-
FunctionWrapper
public FunctionWrapper(org.bukkit.NamespacedKey minecraftKey, ToIntFunction invoker, Object clwArgB, Function<org.bukkit.entity.Entity, Object> mapper, String[] internalCommands) Creates a FunctionWrapper- Parameters:
minecraftKey- the MinecraftKey which is used to reference this functioninvoker- a method which, when invoked, runs the functionclwArgB- the instance of the CommandListenerWrapper which executed this commandmapper- a function that maps a Bukkit Entity to a Minecraft EntityinternalCommands- a String[] of internal commands that this customFunction represents. Typically customFunction.b().map(Object::toString)
-
-
Method Details
-
fromSimpleFunctionWrapper
public static FunctionWrapper fromSimpleFunctionWrapper(SimpleFunctionWrapper wrapper, Object commandListenerWrapper, Function<org.bukkit.entity.Entity, Object> mapper) Converts a SimpleFunctionWrapper into a FunctionWrapper- Parameters:
wrapper- the SimpleFunctionWrapper to convertcommandListenerWrapper- the instance of the CommandListenerWrapper which will be applied to this functionmapper- a function that maps a Bukkit Entity to a Minecraft Entity- Returns:
- A FunctionWrapper which is a child of the provided SimpleFunctionWrapper
-
run
public int run()Executes this function as the executor of the command.- Returns:
- the result of running this command
-
runAs
public int runAs(org.bukkit.entity.Entity e) Executes this function as an entity.- Parameters:
e- entity to execute this function- Returns:
- the result of running this command
-