Package com.plotsquared.core.uuid
Class UUIDPipeline
java.lang.Object
com.plotsquared.core.uuid.UUIDPipeline
An UUID pipeline is essentially an ordered list of
uuid services
that each get the
opportunity of providing usernames or UUIDs.
Each request is then passed through a secondary list of consumers, that can then be used to cache them, etc
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
consume
(@NonNull UUIDMapping mapping) Consume a single mappingvoid
consume
(@NonNull List<@NonNull UUIDMapping> mappings) Let all consumers act on the given mapping.final @NonNull Collection<@NonNull UUIDMapping>
Get as many UUID mappings as possible under the condition that the operation cannot be blocking (for an extended amount of time)final @Nullable UUIDMapping
getImmediately
(@NonNull Object object) Get a single UUID mapping immediately, if possiblegetNames
(@NonNull Collection<@NonNull UUID> requests) Asynchronously attempt to fetch the mapping from a list of UUIDsgetNames
(@NonNull Collection<@NonNull UUID> requests, long timeout) Asynchronously attempt to fetch the mapping from a list of UUIDs.Get a copy of the service listGet a single UUID from a username.void
Get a single UUID from a username.Get a single username from a UUID.void
Get a single username from a UUID.getUUIDs
(@NonNull Collection<@NonNull String> requests) Asynchronously attempt to fetch the mapping from a list of namesgetUUIDs
(@NonNull Collection<String> requests, long timeout) Asynchronously attempt to fetch the mapping from a list of names.void
registerConsumer
(@NonNull Consumer<@NonNull List<@NonNull UUIDMapping>> mappingConsumer) Register a mapping consumervoid
registerService
(@NonNull UUIDService uuidService) Register a UUID servicevoid
storeImmediately
(@NonNull String username, @NonNull UUID uuid) This will store the given username-UUID pair directly, and overwrite any existing caches.
-
Constructor Details
-
UUIDPipeline
Construct a new UUID pipeline- Parameters:
executor
- Executor that is used to run asynchronous tasks inside of the pipeline
-
-
Method Details
-
registerService
Register a UUID service- Parameters:
uuidService
- UUID service to register
-
registerConsumer
public void registerConsumer(@NonNull Consumer<@NonNull List<@NonNull UUIDMapping>> mappingConsumer) Register a mapping consumer- Parameters:
mappingConsumer
- Consumer to register
-
getServiceListInstance
Get a copy of the service list- Returns:
- Copy of service list
-
consume
Let all consumers act on the given mapping.- Parameters:
mappings
- Mappings
-
consume
Consume a single mapping- Parameters:
mapping
- Mapping to consume
-
storeImmediately
This will store the given username-UUID pair directly, and overwrite any existing caches. This can be used to update usernames automatically whenever a player joins the server, to make sure an up-to-date UUID mapping is stored- Parameters:
username
- Player usernameuuid
- Player uuid
-
getSingle
Get a single UUID from a username. This is blocking.- Parameters:
username
- Usernametimeout
- Timeout in milliseconds- Returns:
- The mapped uuid. Will return null if the request timed out.
-
getSingle
Get a single username from a UUID. This is blocking.- Parameters:
uuid
- UUIDtimeout
- Timeout in milliseconds- Returns:
- The mapped username. Will return null if the request timeout.
-
getSingle
public void getSingle(@NonNull String username, @NonNull BiConsumer<@Nullable UUID, @Nullable Throwable> uuid) Get a single UUID from a username. This is non-blocking.- Parameters:
username
- Usernameuuid
- UUID consumer
-
getSingle
public void getSingle(@NonNull UUID uuid, @NonNull BiConsumer<@Nullable String, @Nullable Throwable> username) Get a single username from a UUID. This is non-blocking.- Parameters:
uuid
- UUIDusername
- Username consumer
-
getNames
public @NonNull CompletableFuture<@NonNull List<@NonNull UUIDMapping>> getNames(@NonNull Collection<@NonNull UUID> requests, long timeout) Asynchronously attempt to fetch the mapping from a list of UUIDs.This will timeout after the specified time and throws a
TimeoutException
if this happens- Parameters:
requests
- UUIDstimeout
- Timeout in milliseconds- Returns:
- Mappings
-
getUUIDs
public @NonNull CompletableFuture<List<UUIDMapping>> getUUIDs(@NonNull Collection<String> requests, long timeout) Asynchronously attempt to fetch the mapping from a list of names.This will timeout after the specified time and throws a
TimeoutException
if this happens- Parameters:
requests
- Namestimeout
- Timeout in milliseconds- Returns:
- Mappings
-
getNames
public @NonNull CompletableFuture<@NonNull List<@NonNull UUIDMapping>> getNames(@NonNull Collection<@NonNull UUID> requests) Asynchronously attempt to fetch the mapping from a list of UUIDs- Parameters:
requests
- UUIDs- Returns:
- Mappings
-
getUUIDs
public @NonNull CompletableFuture<@NonNull List<@NonNull UUIDMapping>> getUUIDs(@NonNull Collection<@NonNull String> requests) Asynchronously attempt to fetch the mapping from a list of names- Parameters:
requests
- Names- Returns:
- Mappings
-
getAllImmediately
Get as many UUID mappings as possible under the condition that the operation cannot be blocking (for an extended amount of time)- Returns:
- All mappings that could be provided immediately
-
getImmediately
Get a single UUID mapping immediately, if possible
-