Class TachyonProfileImpl

java.lang.Object
tech.skworks.tachyon.plugin.core.playerdata.TachyonProfileImpl
All Implemented Interfaces:
TachyonProfile

public class TachyonProfileImpl extends Object implements TachyonProfile
  • Constructor Details

  • Method Details

    • initComponent

      public <T extends Record> void initComponent(@NotNull T component)
    • setComponent

      public <T extends Record> void setComponent(@NotNull T component)
      Description copied from interface: TachyonProfile
      Overwrites the current instance of the component in the profile memory and marks it as dirty for the next profile save.
      Specified by:
      setComponent in interface TachyonProfile
      Type Parameters:
      T - The specific type of the Protobuf message.
      Parameters:
      component - The new Protobuf component instance to store.
    • updateComponent

      public <T extends Record> void updateComponent(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull UnaryOperator<T> modifier)
      Description copied from interface: TachyonProfile
      Convenience method to safely update an existing Record component using its Builder.

      This retrieves the current immutable Record component, applies the modification function replaces the stored component, and automatically mark it as dirty for the next save cycle, and increment its version counter.

      Specified by:
      updateComponent in interface TachyonProfile
      Type Parameters:
      T - The specific record comportnent type
      Parameters:
      clazz - The class of the Record component to update
      modifier - A function taking the current Record instance and returning a new updated Record instance.
    • getComponent

      public <T extends Record> T getComponent(@NotNull @NotNull Class<T> clazz, @NotNull T defaultValue)
      Description copied from interface: TachyonProfile
      Retrieves a component by its class type, returning a fallback value if it is not found.
      Specified by:
      getComponent in interface TachyonProfile
      Type Parameters:
      T - The specific type of the Protobuf message.
      Parameters:
      clazz - The class of the component to retrieve.
      defaultValue - The value to return if the player does not have this component loaded.
      Returns:
      The current component instance, or the provided default value.
    • getComponent

      @Nullable public <T extends Record> T getComponent(@NotNull @NotNull Class<T> clazz)
      Description copied from interface: TachyonProfile
      Retrieves a component by its class type.
      Specified by:
      getComponent in interface TachyonProfile
      Type Parameters:
      T - The specific type of the Protobuf message.
      Parameters:
      clazz - The class of the component to retrieve.
      Returns:
      The current component instance, or null if not found.
    • removeComponent

      public <T extends Record> void removeComponent(@NotNull @NotNull Class<T> clazz)
      Specified by:
      removeComponent in interface TachyonProfile
    • hasPendingChanges

      public boolean hasPendingChanges()
      Specified by:
      hasPendingChanges in interface TachyonProfile
    • extractDirtyComponents

      @NotNull public @NotNull Map<ComponentNamespace, org.bson.BsonDocument> extractDirtyComponents()
      Specified by:
      extractDirtyComponents in interface TachyonProfile
    • extractDeletedComponents

      @NotNull public @NotNull List<ComponentNamespace> extractDeletedComponents()
      Specified by:
      extractDeletedComponents in interface TachyonProfile
    • markAsClean

      public void markAsClean(@NotNull @NotNull Collection<Class<? extends Record>> savedClasses, @NotNull @NotNull Collection<ComponentNamespace> deletedNames)
      Specified by:
      markAsClean in interface TachyonProfile
    • getUuid

      public UUID getUuid()
      Description copied from interface: TachyonProfile
      Gets the unique identifier of the player who owns this profile.
      Specified by:
      getUuid in interface TachyonProfile
      Returns:
      The player's UUID.