Class ComponentRegistryImpl
java.lang.Object
tech.skworks.tachyon.plugin.internal.player.component.ComponentRegistryImpl
- All Implemented Interfaces:
ComponentRegistry<org.bukkit.inventory.ItemStack>
public class ComponentRegistryImpl
extends Object
implements ComponentRegistry<org.bukkit.inventory.ItemStack>
Project Tachyon
Class ComponentRegistry
- Since:
- 1.0.0-SNAPSHOT
- Version:
- 1.0
- Author:
- Jimmy (vSKAH) - 08/04/2026
-
Constructor Summary
Constructors -
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<org.bukkit.inventory.ItemStack> 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<org.bukkit.inventory.ItemStack> 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.
-
Constructor Details
-
ComponentRegistryImpl
public ComponentRegistryImpl()
-
-
Method Details
-
registerComponent
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> void registerComponent(T defaultInstance, @Nullable @Nullable ComponentPreviewHandler<org.bukkit.inventory.ItemStack> previewHandler) Description copied from interface:ComponentRegistryRegisters 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.
- Specified by:
registerComponentin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- 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
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> void registerComponent(T defaultInstance) Description copied from interface:ComponentRegistryRegisters a new Protobuf component without a UI preview handler.- Specified by:
registerComponentin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
defaultInstance- The default, empty instance of the Protobuf message.
-
unpack
@Nullable public @Nullable tech.skworks.tachyon.libs.com.google.protobuf.Message unpack(tech.skworks.tachyon.libs.com.google.protobuf.Any any) Description copied from interface:ComponentRegistryUnpacks 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.- Specified by:
unpackin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- 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 public @Nullable tech.skworks.tachyon.libs.com.google.protobuf.Message unpackRawBytes(@NotNull @NotNull String componentFullName, byte[] rawData) Description copied from interface:ComponentRegistryDeserializes a raw byte array directly into a concrete JavaMessageinstance, using the provided full component name to determine the correct parser.- Specified by:
unpackRawBytesin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- 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
Description copied from interface:ComponentRegistryChecks if a component is registered using its full descriptor name.- Specified by:
componentFullNameRegisteredin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- Parameters:
componentFullName- The full name to check (e.g., "tech.skworks.cookies.components.CookieComponent").- Returns:
trueif the component is registered,falseotherwise.
-
componentShortNameRegistered
Description copied from interface:ComponentRegistryChecks if a component is registered using its short descriptor name.- Specified by:
componentShortNameRegisteredin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- Parameters:
componentName- The short name to check (e.g., "CookieComponent").- Returns:
trueif the component is registered,falseotherwise.
-
getComponentShortName
Description copied from interface:ComponentRegistryResolves the short name of a component from its full descriptor name.- Specified by:
getComponentShortNamein interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- Parameters:
componentFullName- The full name of the component.- Returns:
- The short name (e.g., "CookieComponent"), or
nullif the full name is unknown.
-
getRegisteredComponentsFullNames
Description copied from interface:ComponentRegistryRetrieves an immutable set containing the full names of all currently registered components.- Specified by:
getRegisteredComponentsFullNamesin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- Returns:
- A set of registered full descriptor names.
-
getRegisteredComponentsShortsNames
Description copied from interface:ComponentRegistryRetrieves an immutable set containing the short names of all currently registered components.- Specified by:
getRegisteredComponentsShortsNamesin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- Returns:
- A set of registered short descriptor names.
-
getPreviewHandler
@Nullable public @Nullable ComponentPreviewHandler<org.bukkit.inventory.ItemStack> getPreviewHandler(@NotNull @NotNull String componentFullName) Description copied from interface:ComponentRegistryRetrieves 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.
- Specified by:
getPreviewHandlerin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- 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
public int registeredCount()Description copied from interface:ComponentRegistryGets the total number of components successfully loaded into the registry.- Specified by:
registeredCountin interfaceComponentRegistry<org.bukkit.inventory.ItemStack>- Returns:
- The count of registered components.
-