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

public class FunctionWrapper extends SimpleFunctionWrapper
A wrapper class for Minecraft 1.12's functions
  • 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 function
      invoker - a method which, when invoked, runs the function
      clwArgB - the instance of the CommandListenerWrapper which executed this command
      mapper - a function that maps a Bukkit Entity to a Minecraft Entity
      internalCommands - 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 convert
      commandListenerWrapper - the instance of the CommandListenerWrapper which will be applied to this function
      mapper - 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