Class GrpcTachyonProfile
java.lang.Object
tech.skworks.tachyon.plugin.internal.player.GrpcTachyonProfile
- All Implemented Interfaces:
TachyonProfile
Project Tachyon
Class PlayerProfile
Component lifecycle:
- initComponent() : called at load time — sets value, does NOT mark dirty.
- setComponent() : called by plugins — sets value AND marks dirty.
- saveComponent() : marks dirty + immediately enqueues a gRPC save.
- saveProfile() : flushes only dirty components to the backend.
The dirty set acts as a safety net: if a saveComponent() gRPC call hasn't been confirmed yet when the player disconnects, saveProfile() will catch it.- Since:
- 1.0.0-SNAPSHOT
- Version:
- 1.0
- Author:
- Jimmy (vSKAH) - 06/04/2026
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
CompletableFuture<Void> deleteComponent(T component) Removes a component from memory and enqueues a delete via gRPC.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
TgetComponent(@NotNull Class<T> clazz, T defaultValue) Returns the current in-memory value of a component, or default value if not loaded.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
TgetComponent(@NotNull String componentShortName) Returns the current in-memory value of a component, or null if not loaded.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
TgetComponent(@NonNull Class<T> clazz) Returns the current in-memory value of a component, or null if not loaded.getUuid()Gets the unique identifier of the player who owns this profile.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
voidinitComponent(T component) Sets a component received from the backend at load time.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
CompletableFuture<Void> saveComponent(T component) Saves a component immediately via gRPC AND marks it dirty as a safety net.Flushes only dirty components to the backend.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message>
voidsetComponent(@NonNull T component) Updates a component in memory and marks it dirty.<T extends tech.skworks.tachyon.libs.com.google.protobuf.Message, B extends tech.skworks.tachyon.libs.com.google.protobuf.Message.Builder>
voidupdateComponent(@NonNull Class<T> clazz, @NonNull Consumer<B> modifier) Applies a mutation to an existing component and marks it dirty.
-
Constructor Details
-
GrpcTachyonProfile
-
-
Method Details
-
initComponent
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> void initComponent(@NotNull T component) Sets a component received from the backend at load time. Does NOT mark the component as dirty — avoids unnecessary saves at disconnect. Called exclusively by ProfileManager.load(). -
setComponent
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> void setComponent(@NonNull T component) Updates a component in memory and marks it dirty. The component will be saved during the next saveProfile() call (e.g. at disconnect). Does NOT trigger an immediate gRPC save — use saveComponent() for that.- Specified by:
setComponentin interfaceTachyonProfile- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
component- The new Protobuf component instance to store.
-
updateComponent
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message, B extends tech.skworks.tachyon.libs.com.google.protobuf.Message.Builder> void updateComponent(@NonNull Class<T> clazz, @NonNull Consumer<B> modifier) Applies a mutation to an existing component and marks it dirty. No-op if the component is not loaded.- Specified by:
updateComponentin interfaceTachyonProfile- Type Parameters:
T- The specific type of the Protobuf message.B- The specific type of the Protobuf message's Builder.- Parameters:
clazz- The class of the component to update.modifier- A consumer applying the changes to the component's builder.
-
getComponent
@Nullable public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> T getComponent(@NonNull Class<T> clazz) Returns the current in-memory value of a component, or null if not loaded.- Specified by:
getComponentin interfaceTachyonProfile- 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
nullif not found.
-
getComponent
@Nullable public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> T getComponent(@NotNull @NotNull String componentShortName) Returns the current in-memory value of a component, or null if not loaded.- Specified by:
getComponentin interfaceTachyonProfile- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
componentShortName- The exact short name of the Protobuf descriptor.- Returns:
- The current component instance, or
nullif not found.
-
getComponent
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> T getComponent(@NotNull @NotNull Class<T> clazz, @NotNull T defaultValue) Returns the current in-memory value of a component, or default value if not loaded.- Specified by:
getComponentin interfaceTachyonProfile- 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.
-
saveComponent
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> CompletableFuture<Void> saveComponent(@NotNull T component) Saves a component immediately via gRPC AND marks it dirty as a safety net. If the gRPC call hasn't completed by disconnect time, saveProfile() will retry it.- Specified by:
saveComponentin interfaceTachyonProfile- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
component- The component to save immediately.- Returns:
- A CompletableFuture that completes when the backend acknowledges the save.
-
deleteComponent
public <T extends tech.skworks.tachyon.libs.com.google.protobuf.Message> CompletableFuture<Void> deleteComponent(@NotNull T component) Removes a component from memory and enqueues a delete via gRPC.- Specified by:
deleteComponentin interfaceTachyonProfile- Type Parameters:
T- The specific type of the Protobuf message.- Parameters:
component- The component to remove immediately.- Returns:
- A CompletableFuture that completes when the backend acknowledges the deletion.
-
saveProfile
Flushes only dirty components to the backend. Clears the dirty set on success. On failure, components remain dirty so the next attempt (e.g. retry scheduler) will pick them up.- Specified by:
saveProfilein interfaceTachyonProfile- Returns:
- A CompletableFuture that completes when all dirty components are saved.
-
getUuid
Description copied from interface:TachyonProfileGets the unique identifier of the player who owns this profile.- Specified by:
getUuidin interfaceTachyonProfile- Returns:
- The player's UUID.
-