Package net.minestom.server.extensions
Class Extension
java.lang.Object
net.minestom.server.extensions.Extension
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of extensions that depend on this extension. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull Path@NotNull net.kyori.adventure.text.logger.slf4j.ComponentLoggerGets the logger for the extension@NotNull DiscoveredExtension@Nullable InputStreamgetPackagedResource(@NotNull String fileName) Gets a resource from inside the extension jar.@Nullable InputStreamgetPackagedResource(@NotNull Path target) Gets a resource from inside the extension jar.@Nullable InputStreamgetResource(@NotNull String fileName) Gets a resource from the extension directory, or from inside the jar if it does not exist in the extension directory.@Nullable InputStreamgetResource(@NotNull Path target) Gets a resource from the extension directory, or from inside the jar if it does not exist in the extension directory.abstract voidvoidvoidvoidvoidbooleansavePackagedResource(@NotNull String fileName) Copies a resource file to the extension directory, replacing any existing copy.booleansavePackagedResource(@NotNull Path target) Copies a resource file to the extension directory, replacing any existing copy.abstract void
-
Field Details
-
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
-
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
-
getDataDirectory
-
getResource
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
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
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
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
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
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
- Returns:
- A modifiable list of dependents.
-