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, "material-symbols:home-storage-rounded")
class ExampleArtifactEntry(
override val id: String = "",
override val name: String = "",
override val artifactId: String = "",
) : ArtifactEntry
Accessing the Artifact's Content
suspend fun accessArtifactData(ref: Ref<out ArtifactEntry>) {
val assetManager = KoinJavaComponent.get<AssetManager>(AssetManager::class.java)
val entry = ref.get() ?: return
val content: String? = assetManager.fetchAsset(entry)
// Do something with the content
}
In this example, we get the content of the given artifact reference by using the AssetManager
.
The assetManager.fetchAsset
method is then used to retrieve the content of the artifact, based the entry
.