Class Extension

java.lang.Object
net.minestom.server.extensions.Extension

public abstract class Extension extends Object
  • Field Details

    • dependents

      protected final Set<String> dependents
      List of extensions that depend on this extension.
  • Constructor Details

    • Extension

      protected Extension()
  • Method Details

    • preInitialize

      public void preInitialize()
    • initialize

      public abstract void initialize()
    • postInitialize

      public void postInitialize()
    • preTerminate

      public void preTerminate()
    • terminate

      public abstract void terminate()
    • postTerminate

      public void postTerminate()
    • getOrigin

      @NotNull public @NotNull DiscoveredExtension getOrigin()
    • getLogger

      @NotNull public @NotNull net.kyori.adventure.text.logger.slf4j.ComponentLogger getLogger()
      Gets the logger for the extension
      Returns:
      The logger for the extension
    • getEventNode

      @NotNull public @NotNull EventNode<Event> getEventNode()
    • getDataDirectory

      @NotNull public @NotNull Path getDataDirectory()
    • getResource

      @Nullable public @Nullable InputStream getResource(@NotNull @NotNull String fileName)
      Gets a resource from the extension directory, or from inside the jar if it does not exist in the extension directory.

      If it does not exist in the extension directory, it will be copied from inside the jar.

      The caller is responsible for closing the returned InputStream.

      Parameters:
      fileName - The file to read
      Returns:
      The file contents, or null if there was an issue reading the file.
    • getResource

      @Nullable public @Nullable InputStream getResource(@NotNull @NotNull Path target)
      Gets a resource from the extension directory, or from inside the jar if it does not exist in the extension directory.

      If it does not exist in the extension directory, it will be copied from inside the jar.

      The caller is responsible for closing the returned InputStream.

      Parameters:
      target - The file to read
      Returns:
      The file contents, or null if there was an issue reading the file.
    • getPackagedResource

      @Nullable public @Nullable InputStream getPackagedResource(@NotNull @NotNull String fileName)
      Gets a resource from inside the extension jar.

      The caller is responsible for closing the returned InputStream.

      Parameters:
      fileName - The file to read
      Returns:
      The file contents, or null if there was an issue reading the file.
    • getPackagedResource

      @Nullable public @Nullable InputStream getPackagedResource(@NotNull @NotNull Path target)
      Gets a resource from inside the extension jar.

      The caller is responsible for closing the returned InputStream.

      Parameters:
      target - The file to read
      Returns:
      The file contents, or null if there was an issue reading the file.
    • savePackagedResource

      public boolean savePackagedResource(@NotNull @NotNull String fileName)
      Copies a resource file to the extension directory, replacing any existing copy.
      Parameters:
      fileName - The resource to save
      Returns:
      True if the resource was saved successfully, null otherwise
    • savePackagedResource

      public boolean savePackagedResource(@NotNull @NotNull Path target)
      Copies a resource file to the extension directory, replacing any existing copy.
      Parameters:
      target - The resource to save
      Returns:
      True if the resource was saved successfully, null otherwise
    • getDependents

      public Set<String> getDependents()
      Returns:
      A modifiable list of dependents.