Class SkriptAddon

java.lang.Object
ch.njol.skript.SkriptAddon
All Implemented Interfaces:
SkriptAddon, ViewProvider<SkriptAddon>

public final class SkriptAddon extends Object implements SkriptAddon
Utility class for Skript addons. Use Skript.registerAddon(JavaPlugin) to create a SkriptAddon instance for your plugin.
  • Field Details

    • plugin

      public final org.bukkit.plugin.java.JavaPlugin plugin
    • version

      public final Version version
  • Method Details

    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()
    • loadClasses

      public SkriptAddon loadClasses(String basePackage, String... subPackages) throws IOException
      Loads classes of the plugin by package. Useful for registering many syntax elements like Skript does it.
      Parameters:
      basePackage - The base package to add to all sub packages, e.g. "ch.njol.skript".
      subPackages - Which subpackages of the base package should be loaded, e.g. "expressions", "conditions", "effects". Subpackages of these packages will be loaded as well. Use an empty array to load all subpackages of the base package.
      Returns:
      This SkriptAddon
      Throws:
      IOException - If some error occurred attempting to read the plugin's jar file.
    • setLanguageFileDirectory

      public SkriptAddon setLanguageFileDirectory(String directory)
      Makes Skript load language files from the specified directory, e.g. "lang" or "skript lang" if you have a lang folder yourself. Localised files will be read from the plugin's jar and the plugin's data folder, but the default English file is only taken from the jar and must exist!
      Parameters:
      directory - Directory name
      Returns:
      This SkriptAddon
    • getLanguageFileDirectory

      @Nullable public @Nullable String getLanguageFileDirectory()
    • getFile

      @Nullable public @Nullable File getFile()
      The first invocation of this method uses reflection to invoke the protected method JavaPlugin.getFile() to get the plugin's jar file. The file is then cached and returned upon subsequent calls to this method to reduce usage of reflection. Only nullable if there was an exception thrown.
      Returns:
      The jar file of the plugin.
    • source

      @Experimental public Class<?> source()
      Specified by:
      source in interface SkriptAddon
      Returns:
      A class from the application that registered this addon. Typically, this is the main class or the specific class in which registration occurred.
    • name

      @Experimental public String name()
      Specified by:
      name in interface SkriptAddon
      Returns:
      The name of this addon.
    • storeRegistry

      @Experimental public <R extends Registry<?>> void storeRegistry(Class<R> registryClass, R registry)
      Description copied from interface: SkriptAddon
      Stores a registry under registryClass. If a registry is already stored under registryClass, it will be replaced.
      Specified by:
      storeRegistry in interface SkriptAddon
      Type Parameters:
      R - The type of registry.
      Parameters:
      registryClass - The class (key) to store registry under.
      registry - The registry to store.
    • removeRegistry

      @Experimental public void removeRegistry(Class<? extends Registry<?>> registryClass)
      Description copied from interface: SkriptAddon
      Removes the registry stored under registryClass. It is safe to call this method even if a registry is not stored under registryClass.
      Specified by:
      removeRegistry in interface SkriptAddon
      Parameters:
      registryClass - The class (key) that the registry to remove is under.
    • hasRegistry

      @Experimental public boolean hasRegistry(Class<? extends Registry<?>> registryClass)
      Description copied from interface: SkriptAddon
      Determines whether a registry has been stored under registryClass.
      Specified by:
      hasRegistry in interface SkriptAddon
      Parameters:
      registryClass - The class (key) to search for a registry under.
      Returns:
      Whether a registry is stored under registryClass.
    • registry

      @Experimental public <R extends Registry<?>> R registry(Class<R> registryClass)
      Description copied from interface: SkriptAddon
      Obtains the registry stored under registryClass. This method will never return null, meaning it may be necessary to call SkriptAddon.hasRegistry(Class) if you are not sure whether the registry you need exists.
      Specified by:
      registry in interface SkriptAddon
      Type Parameters:
      R - The type of registry.
      Parameters:
      registryClass - The class (key) that the registry is stored under.
      Returns:
      The registry stored under registryClass.
    • registry

      @Experimental public <R extends Registry<?>> R registry(Class<R> registryClass, Supplier<R> putIfAbsent)
      Description copied from interface: SkriptAddon
      Searches for a registry stored under registryClass. If the search fails, putIfAbsent will be used to get, store, and return a registry of the requested type.
      Specified by:
      registry in interface SkriptAddon
      Type Parameters:
      R - The type of registry.
      Parameters:
      registryClass - The class (key) to search for a registry under.
      putIfAbsent - A supplier to use for creating an instance of the desired type of registry if one is not already stored under registryClass.
      Returns:
      The registry stored under registryClass or created from putIfAbsent.
    • syntaxRegistry

      @Experimental public SyntaxRegistry syntaxRegistry()
      Specified by:
      syntaxRegistry in interface SkriptAddon
      Returns:
      A syntax registry for this addon's syntax.
    • localizer

      @Experimental public Localizer localizer()
      Specified by:
      localizer in interface SkriptAddon
      Returns:
      A localizer for this addon's localizations.