Interface ComponentRegistry<V>
- Type Parameters:
V- The visual object type used by theComponentPreviewHandler(e.g.,org.bukkit.inventory.ItemStackfor Spigot).
- All Known Implementing Classes:
ComponentRegistryImpl
The central hub for managing and resolving all Protobuf components within the Tachyon ecosystem.
This registry acts as the dictionary that bridges raw Protobuf data
with concrete Java objects and their associated graphical user interfaces (Preview Handlers).
It handles the dynamic unpacking of byte arrays into typed Message instances.
- Since:
- 1.0.0-SNAPSHOT
- Version:
- 1.0
- Author:
- Jimmy (vSKAH) - 18/04/2026
-
Method Summary
Modifier and TypeMethodDescriptionbooleancomponentFullNameRegistered(@NotNull String componentFullName) Checks if a component is registered using its full descriptor name.booleancomponentShortNameRegistered(@NotNull String componentName) Checks if a component is registered using its short descriptor name.@Nullable StringgetComponentShortName(@NotNull String componentFullName) Resolves the short name of a component from its full descriptor name.@Nullable ComponentPreviewHandler<V> getPreviewHandler(@NotNull String componentFullName) Retrieves the UI preview handler associated with a specific component.Retrieves an immutable set containing the full names of all currently registered components.Retrieves an immutable set containing the short names of all currently registered components.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
voidregisterComponent(T defaultInstance) Registers a new Protobuf component without a UI preview handler.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
voidregisterComponent(T defaultInstance, @Nullable ComponentPreviewHandler<V> previewHandler) Registers a new Protobuf component into the ecosystem along with its UI preview handler.intGets the total number of components successfully loaded into the registry.@Nullable tech.skworks.tachyon.libs.com.google.protobuf.Messageunpack(tech.skworks.tachyon.libs.com.google.protobuf.Any any) Unpacks aAnywrapper into its concrete JavaMessageinstance.@Nullable tech.skworks.tachyon.libs.com.google.protobuf.MessageunpackRawBytes(@NotNull String componentFullName, byte[] rawData) Deserializes a raw byte array directly into a concrete JavaMessageinstance, using the provided full component name to determine the correct parser.
-
Method Details
-
registerComponent
<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> void registerComponent(T defaultInstance, @Nullable @Nullable ComponentPreviewHandler<V> previewHandler) Registers a new Protobuf component into the ecosystem along with its UI preview handler.This method extracts the descriptor from the provided default instance to map both its short name and full name for future deserialization and UI lookups.
- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
defaultInstance- The default, empty instance of the Protobuf message (usually obtained viaMyComponent.getDefaultInstance()).previewHandler- The UI handler responsible for rendering this component in menus.
-
registerComponent
<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> void registerComponent(T defaultInstance) Registers a new Protobuf component without a UI preview handler.- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
defaultInstance- The default, empty instance of the Protobuf message.
-
unpack
@Nullable @Nullable tech.skworks.tachyon.libs.com.google.protobuf.Message unpack(tech.skworks.tachyon.libs.com.google.protobuf.Any any) Unpacks aAnywrapper into its concrete JavaMessageinstance.The registry extracts the Type URL from the
Anyobject, matches it against registered components, and uses the correct parser to decode the inner bytes.- Parameters:
any- The Protobuf Any container received from the back-end.- Returns:
- The fully parsed concrete message, or
nullif the type is not registered.
-
unpackRawBytes
@Nullable @Nullable tech.skworks.tachyon.libs.com.google.protobuf.Message unpackRawBytes(@NotNull @NotNull String componentFullName, byte[] rawData) Deserializes a raw byte array directly into a concrete JavaMessageinstance, using the provided full component name to determine the correct parser.- Parameters:
componentFullName- The exact full name of the Protobuf descriptor (e.g., "tech.skworks.cookies.components.CookieComponent").rawData- The raw byte array (uncompressed) to parse.- Returns:
- The fully parsed concrete message, or
nullif the name is not registered or the byte sequence is invalid.
-
componentFullNameRegistered
Checks if a component is registered using its full descriptor name.- Parameters:
componentFullName- The full name to check (e.g., "tech.skworks.cookies.components.CookieComponent").- Returns:
trueif the component is registered,falseotherwise.
-
componentShortNameRegistered
Checks if a component is registered using its short descriptor name.- Parameters:
componentName- The short name to check (e.g., "CookieComponent").- Returns:
trueif the component is registered,falseotherwise.
-
getComponentShortName
Resolves the short name of a component from its full descriptor name.- Parameters:
componentFullName- The full name of the component.- Returns:
- The short name (e.g., "CookieComponent"), or
nullif the full name is unknown.
-
getRegisteredComponentsFullNames
-
getRegisteredComponentsShortsNames
-
getPreviewHandler
@Nullable @Nullable ComponentPreviewHandler<V> getPreviewHandler(@NotNull @NotNull String componentFullName) Retrieves the UI preview handler associated with a specific component.This is primarily used by the Snapshot GUI system to determine how to visually display the decoded data of a target component.
- Parameters:
componentFullName- The full name of the component.- Returns:
- The associated
ComponentPreviewHandler, ornullif none was provided during registration or if the component is unknown.
-
registeredCount
int registeredCount()Gets the total number of components successfully loaded into the registry.- Returns:
- The count of registered components.
-