Player saving done right

This commit is contained in:
Draycia committed 2021-09-30 18:52:59 -07:00
1 parent 3736377fd7
commit 9305da7d2d
21 files changed
+314 -257

No files matched your search

@@ -63,4 +63,7 @@ public interface CarbonChat {
IMessageRenderer<SourcedAudience, String, Component, Component> messageRenderer();
// TODO: Redis as MariaDB cache
// TODO: Adopt egg82/Messenger for use with databases?
}
@@ -40,7 +40,7 @@ public interface CarbonServer extends Audience {
* @return the result
* @since 2.0.0
*/
CompletableFuture<ComponentPlayerResult> player(final UUID uuid);
CompletableFuture<ComponentPlayerResult<CarbonPlayer>> player(final UUID uuid);
/**
* Obtains a {@link CarbonPlayer} instance for the specified username.
@@ -49,7 +49,7 @@ public interface CarbonServer extends Audience {
* @return the result
* @since 2.0.0
*/
CompletableFuture<ComponentPlayerResult> player(final String username);
CompletableFuture<ComponentPlayerResult<CarbonPlayer>> player(final String username);
/**
* Obtains the desired user's UUID.
@@ -10,6 +10,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param reason the reason of the result, typically empty unless {@link #player} is null
* @since 2.0.0
*/
public record ComponentPlayerResult(@Nullable CarbonPlayer player, Component reason) {
public record ComponentPlayerResult<C extends CarbonPlayer>(@Nullable C player, Component reason) {
}
@@ -11,7 +11,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
* @since 2.0.0
*/
@DefaultQualifier(NonNull.class)
public interface UserManager {
public interface UserManager<C extends CarbonPlayer> {
/**
* Loads and returns a {@link CarbonPlayer} with the given {@link UUID}.
@@ -20,7 +20,7 @@ public interface UserManager {
* @return the result
* @since 2.0.0
*/
CompletableFuture<ComponentPlayerResult> carbonPlayer(final UUID uuid);
CompletableFuture<ComponentPlayerResult<C>> carbonPlayer(final UUID uuid);
/**
* Saves the {@link CarbonPlayer} and returns the result.
@@ -29,6 +29,6 @@ public interface UserManager {
* @return the result
* @since 2.0.0
*/
CompletableFuture<ComponentPlayerResult> savePlayer(final CarbonPlayer player);
CompletableFuture<ComponentPlayerResult<C>> savePlayer(final C player);
}