Finish MySQL implementation

This commit is contained in:
William committed 2022-05-24 02:13:03 +01:00
1 parent bd52c99d4d
commit 28a54b0b4a
8 files changed
+457 -156

No files matched your search

@@ -7,10 +7,31 @@ import java.util.UUID;
/**
* Represents persistently stored {@link User} data about a {@link Player}; uuid and username
* A {@link Player} may be retrieved from a user by the platform implementing classes
*
* @param uuid
* @param username {@see {@link Player}} - an online player representation
*/
public record User(@NotNull UUID uuid, @NotNull String username) {
public class User {
public final UUID uuid;
public final String username;
/**
* Get a user from a {@link UUID} and username
*
* @param uuid Minecraft account {@link UUID} of the player
* @param username Username of the player
*/
public User(@NotNull UUID uuid, @NotNull String username) {
this.uuid = uuid;
this.username = username;
}
/**
* Get a user from an online {@link Player}
*
* @param player the online {@link Player}
*/
public User(Player player) {
this.uuid = player.getUuid();
this.username = player.getName();
}
}
@@ -0,0 +1,44 @@
package net.william278.huskhomes.player;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Extension of a {@link User} that contains persistently-stored additional user data
* (home slots, teleport ignoring status & rtp cooldown)
*/
public class UserData extends User {
/**
* The number of slots this user has consumed (bought) in total, used for economy checks
*/
public int homeSlots;
/**
* Whether this user is ignoring incoming /tpa and /tpahere requests
*/
public boolean isIgnoringTeleports;
/**
* A timestamp indicating when the user can use the /rtp command next
*/
public long rtpCooldown;
public UserData(@NotNull UUID uuid, @NotNull String username,
int homeSlots, boolean isIgnoringTeleports, long rtpCooldown) {
super(uuid, username);
this.homeSlots = homeSlots;
this.isIgnoringTeleports = isIgnoringTeleports;
this.rtpCooldown = rtpCooldown;
}
public UserData(@NotNull User user,
int homeSlots, boolean isIgnoringTeleports, long rtpCooldown) {
super(user.uuid, user.username);
this.homeSlots = homeSlots;
this.isIgnoringTeleports = isIgnoringTeleports;
this.rtpCooldown = rtpCooldown;
}
}