Skip to main content
 Warning: Unmaintained Version
Version: 0.4.2

ArtifactEntry

The ArtifactEntry is a specialized interface derived from AssetEntry. Its primary purpose is to handle artifacts, which are assets generated by the plugins/adapters itself. Unlike standard assets, artifacts are usually dynamic and created during runtime. This makes them particularly useful for storing data that changes based on player interactions or game events.

An essential feature of ArtifactEntry is its unique artifactId. This identifier must remain constant once assigned and is used to reference the artifact within the plugin.

Usage

Here's a generic example of creating and using an ArtifactEntry:

Defining an ArtifactEntry

@Entry("example_artifact", "An example artifact entry.", Colors.BLUE, Icons.ARROW)
class ExampleArtifactEntry(
override val id: String = "",
override val name: String = "",
override val artifactId: String = "",
) : ArtifactEntry

Accessing the Artifact's Content

import org.koin.java.KoinJavaComponent.get

val assetManager = get<AssetManager>(AssetManager::class.java)

val id = // ID of the entry
val entry = Query.findById<ExampleArtifactEntry>(id)
val content: String = assetManager.fetchAsset(entry)

In this example, ExampleArtifactEntry is defined as an artifact with a unique identifier. The assetManager.fetchAsset method is then used to retrieve the content of the artifact, based on its artifactId.