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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    componentFullNameRegistered(@NotNull String componentFullName)
    Checks if a component is registered using its full descriptor name.
    boolean
    componentShortNameRegistered(@NotNull String componentName)
    Checks if a component is registered using its short descriptor name.
    @Nullable String
    getComponentShortName(@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.
    @NonNull Set<String>
    Retrieves an immutable set containing the full names of all currently registered components.
    @NonNull Set<String>
    Retrieves an immutable set containing the short names of all currently registered components.
    <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
    void
    registerComponent(T defaultInstance)
    Registers a new Protobuf component without a UI preview handler.
    <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
    void
    registerComponent(T defaultInstance, @Nullable ComponentPreviewHandler<org.bukkit.inventory.ItemStack> previewHandler)
    Registers a new Protobuf component into the ecosystem along with its UI preview handler.
    int
    Gets the total number of components successfully loaded into the registry.
    @Nullable tech.skworks.tachyon.libs.com.google.protobuf.Message
    unpack(tech.skworks.tachyon.libs.com.google.protobuf.Any any)
    Unpacks a Any wrapper into its concrete Java Message instance.
    @Nullable tech.skworks.tachyon.libs.com.google.protobuf.Message
    unpackRawBytes(@NotNull String componentFullName, byte[] rawData)
    Deserializes a raw byte array directly into a concrete Java Message instance, using the provided full component name to determine the correct parser.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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: ComponentRegistry
      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.

      Specified by:
      registerComponent in interface ComponentRegistry<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 via MyComponent.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: ComponentRegistry
      Registers a new Protobuf component without a UI preview handler.
      Specified by:
      registerComponent in interface ComponentRegistry<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: ComponentRegistry
      Unpacks a Any wrapper into its concrete Java Message instance.

      The registry extracts the Type URL from the Any object, matches it against registered components, and uses the correct parser to decode the inner bytes.

      Specified by:
      unpack in interface ComponentRegistry<org.bukkit.inventory.ItemStack>
      Parameters:
      any - The Protobuf Any container received from the back-end.
      Returns:
      The fully parsed concrete message, or null if 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: ComponentRegistry
      Deserializes a raw byte array directly into a concrete Java Message instance, using the provided full component name to determine the correct parser.
      Specified by:
      unpackRawBytes in interface ComponentRegistry<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 null if the name is not registered or the byte sequence is invalid.
    • componentFullNameRegistered

      public boolean componentFullNameRegistered(@NotNull @NotNull String componentFullName)
      Description copied from interface: ComponentRegistry
      Checks if a component is registered using its full descriptor name.
      Specified by:
      componentFullNameRegistered in interface ComponentRegistry<org.bukkit.inventory.ItemStack>
      Parameters:
      componentFullName - The full name to check (e.g., "tech.skworks.cookies.components.CookieComponent").
      Returns:
      true if the component is registered, false otherwise.
    • componentShortNameRegistered

      public boolean componentShortNameRegistered(@NotNull @NotNull String componentName)
      Description copied from interface: ComponentRegistry
      Checks if a component is registered using its short descriptor name.
      Specified by:
      componentShortNameRegistered in interface ComponentRegistry<org.bukkit.inventory.ItemStack>
      Parameters:
      componentName - The short name to check (e.g., "CookieComponent").
      Returns:
      true if the component is registered, false otherwise.
    • getComponentShortName

      @Nullable public @Nullable String getComponentShortName(@NotNull @NotNull String componentFullName)
      Description copied from interface: ComponentRegistry
      Resolves the short name of a component from its full descriptor name.
      Specified by:
      getComponentShortName in interface ComponentRegistry<org.bukkit.inventory.ItemStack>
      Parameters:
      componentFullName - The full name of the component.
      Returns:
      The short name (e.g., "CookieComponent"), or null if the full name is unknown.
    • getRegisteredComponentsFullNames

      public @NonNull Set<String> getRegisteredComponentsFullNames()
      Description copied from interface: ComponentRegistry
      Retrieves an immutable set containing the full names of all currently registered components.
      Specified by:
      getRegisteredComponentsFullNames in interface ComponentRegistry<org.bukkit.inventory.ItemStack>
      Returns:
      A set of registered full descriptor names.
    • getRegisteredComponentsShortsNames

      public @NonNull Set<String> getRegisteredComponentsShortsNames()
      Description copied from interface: ComponentRegistry
      Retrieves an immutable set containing the short names of all currently registered components.
      Specified by:
      getRegisteredComponentsShortsNames in interface ComponentRegistry<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: ComponentRegistry
      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.

      Specified by:
      getPreviewHandler in interface ComponentRegistry<org.bukkit.inventory.ItemStack>
      Parameters:
      componentFullName - The full name of the component.
      Returns:
      The associated ComponentPreviewHandler, or null if none was provided during registration or if the component is unknown.
    • registeredCount

      public int registeredCount()
      Description copied from interface: ComponentRegistry
      Gets the total number of components successfully loaded into the registry.
      Specified by:
      registeredCount in interface ComponentRegistry<org.bukkit.inventory.ItemStack>
      Returns:
      The count of registered components.