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

public class SimpleFunctionWrapper extends Object implements org.bukkit.Keyed
A wrapper class for Minecraft 1.12's functions
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleFunctionWrapper(org.bukkit.NamespacedKey minecraftKey, ToIntFunction invoker, String[] internalCommands)
    Creates a SimpleFunctionWrapper
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an array of commands that will be executed by this FunctionWrapper
    getFunction(org.bukkit.NamespacedKey key)
    Returns a SimpleFunctionWrapper representation of the Minecraft function for the provided NamespacedKey
    static Set<org.bukkit.NamespacedKey>
    Returns a set of all functions that the server has registered
    org.bukkit.NamespacedKey
    Returns the NamespacedKey that uniquely represents this object
    getTag(org.bukkit.NamespacedKey key)
    Returns a SimpleFunctionWrapper[], which is an array of all of the functions that this tag contains
    static Set<org.bukkit.NamespacedKey>
    Returns a set of all tags that the server has registered
    int
    run(org.bukkit.command.CommandSender sender)
    Runs this function with a given CommandSender

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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 function
      invoker - a method which, when invoked, runs the function
      internalCommands - a String[] of internal commands that this customFunction represents. Typically customFunction.b().map(Object::toString)
  • Method Details

    • getTag

      public static SimpleFunctionWrapper[] getTag(org.bukkit.NamespacedKey key)
      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

      public static SimpleFunctionWrapper getFunction(org.bukkit.NamespacedKey key)
      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

      public static Set<org.bukkit.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

      public static Set<org.bukkit.NamespacedKey> 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

      public String[] 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:
      getKey in interface org.bukkit.Keyed
      Returns:
      the NamespacedKey that uniquely represents this object