diff --git a/src/main/java/cc/reconnected/server/RccServer.java b/src/main/java/cc/reconnected/server/RccServer.java index e7bece2..140f3de 100644 --- a/src/main/java/cc/reconnected/server/RccServer.java +++ b/src/main/java/cc/reconnected/server/RccServer.java @@ -8,10 +8,9 @@ import cc.reconnected.server.commands.tell.*; import cc.reconnected.server.commands.warp.*; import cc.reconnected.server.core.*; import cc.reconnected.server.data.StateManager; -import cc.reconnected.server.database.PlayerData; -import cc.reconnected.server.events.PlayerUsernameChange; -import cc.reconnected.server.events.PlayerWelcome; -import cc.reconnected.server.events.Ready; +import cc.reconnected.server.api.events.PlayerUsernameChange; +import cc.reconnected.server.api.events.PlayerWelcome; +import cc.reconnected.server.api.events.Ready; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; @@ -23,7 +22,6 @@ import net.luckperms.api.LuckPerms; import net.luckperms.api.LuckPermsProvider; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; import net.minecraft.util.WorldSavePath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -118,9 +116,7 @@ public class RccServer implements ModInitializer { ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { var player = handler.getPlayer(); - var playerState = state.getPlayerState(player.getUuid()); - var playerData = PlayerData.getPlayer(player.getUuid()); if (playerState.firstJoinedDate == null) { LOGGER.info("Player {} joined for the first time!", player.getGameProfile().getName()); @@ -132,14 +128,11 @@ public class RccServer implements ModInitializer { if (spawnPosition != null) { spawnPosition.teleport(player, false); } - - playerData.setDate(PlayerData.KEYS.firstJoinedDate, new Date()); } if (playerState.username != null && !playerState.username.equals(player.getGameProfile().getName())) { LOGGER.info("Player {} has changed their username from {}", player.getGameProfile().getName(), playerState.username); PlayerUsernameChange.PLAYER_USERNAME_CHANGE.invoker().changeUsername(player, playerState.username); - playerData.set(PlayerData.KEYS.username, player.getName().getString()); } playerState.username = player.getGameProfile().getName(); state.savePlayerState(player.getUuid(), playerState); diff --git a/src/main/java/cc/reconnected/server/database/PlayerData.java b/src/main/java/cc/reconnected/server/api/PlayerMeta.java similarity index 94% rename from src/main/java/cc/reconnected/server/database/PlayerData.java rename to src/main/java/cc/reconnected/server/api/PlayerMeta.java index 4ea5282..6ba57cb 100644 --- a/src/main/java/cc/reconnected/server/database/PlayerData.java +++ b/src/main/java/cc/reconnected/server/api/PlayerMeta.java @@ -1,4 +1,4 @@ -package cc.reconnected.server.database; +package cc.reconnected.server.api; import cc.reconnected.server.RccServer; import net.luckperms.api.LuckPerms; @@ -16,7 +16,7 @@ import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -public class PlayerData { +public class PlayerMeta { public static final String nodePrefix = "rcc"; private static LuckPerms luckPerms() { @@ -43,7 +43,7 @@ public class PlayerData { private Set rawNodes; private Map nodes; - private PlayerData(UUID uuid, User lpUser) { + private PlayerMeta(UUID uuid, User lpUser) { this.uuid = uuid; this.lpUser = lpUser; @@ -146,7 +146,7 @@ public class PlayerData { return lpUser.getPrimaryGroup(); } - public static PlayerData getPlayer(UUID uuid) { + public static PlayerMeta getPlayer(UUID uuid) { var lp = luckPerms(); var userManager = lp.getUserManager(); @@ -154,14 +154,14 @@ public class PlayerData { // TODO: ouch, not good... var lpUser = userFuture.join(); - var playerData = new PlayerData(uuid, lpUser); + var playerData = new PlayerMeta(uuid, lpUser); playerData.name = lpUser.getUsername(); return playerData; } - public static PlayerData getPlayer(ServerPlayerEntity player) { + public static PlayerMeta getPlayer(ServerPlayerEntity player) { var user = luckPerms().getPlayerAdapter(ServerPlayerEntity.class).getUser(player); - var playerData = new PlayerData(player.getUuid(), user); + var playerData = new PlayerMeta(player.getUuid(), user); playerData.name = player.getEntityName(); return playerData; } diff --git a/src/main/java/cc/reconnected/server/events/PlayerActivityEvents.java b/src/main/java/cc/reconnected/server/api/events/PlayerActivityEvents.java similarity index 96% rename from src/main/java/cc/reconnected/server/events/PlayerActivityEvents.java rename to src/main/java/cc/reconnected/server/api/events/PlayerActivityEvents.java index 7629e2e..e993c28 100644 --- a/src/main/java/cc/reconnected/server/events/PlayerActivityEvents.java +++ b/src/main/java/cc/reconnected/server/api/events/PlayerActivityEvents.java @@ -1,4 +1,4 @@ -package cc.reconnected.server.events; +package cc.reconnected.server.api.events; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; diff --git a/src/main/java/cc/reconnected/server/events/PlayerTeleport.java b/src/main/java/cc/reconnected/server/api/events/PlayerTeleport.java similarity index 93% rename from src/main/java/cc/reconnected/server/events/PlayerTeleport.java rename to src/main/java/cc/reconnected/server/api/events/PlayerTeleport.java index a14967f..bd1fafe 100644 --- a/src/main/java/cc/reconnected/server/events/PlayerTeleport.java +++ b/src/main/java/cc/reconnected/server/api/events/PlayerTeleport.java @@ -1,4 +1,4 @@ -package cc.reconnected.server.events; +package cc.reconnected.server.api.events; import cc.reconnected.server.struct.ServerPosition; import net.fabricmc.fabric.api.event.Event; diff --git a/src/main/java/cc/reconnected/server/events/PlayerUsernameChange.java b/src/main/java/cc/reconnected/server/api/events/PlayerUsernameChange.java similarity index 93% rename from src/main/java/cc/reconnected/server/events/PlayerUsernameChange.java rename to src/main/java/cc/reconnected/server/api/events/PlayerUsernameChange.java index 74472de..4716144 100644 --- a/src/main/java/cc/reconnected/server/events/PlayerUsernameChange.java +++ b/src/main/java/cc/reconnected/server/api/events/PlayerUsernameChange.java @@ -1,4 +1,4 @@ -package cc.reconnected.server.events; +package cc.reconnected.server.api.events; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; diff --git a/src/main/java/cc/reconnected/server/events/PlayerWelcome.java b/src/main/java/cc/reconnected/server/api/events/PlayerWelcome.java similarity index 93% rename from src/main/java/cc/reconnected/server/events/PlayerWelcome.java rename to src/main/java/cc/reconnected/server/api/events/PlayerWelcome.java index 40b29f2..f02fb94 100644 --- a/src/main/java/cc/reconnected/server/events/PlayerWelcome.java +++ b/src/main/java/cc/reconnected/server/api/events/PlayerWelcome.java @@ -1,4 +1,4 @@ -package cc.reconnected.server.events; +package cc.reconnected.server.api.events; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; diff --git a/src/main/java/cc/reconnected/server/events/Ready.java b/src/main/java/cc/reconnected/server/api/events/Ready.java similarity index 92% rename from src/main/java/cc/reconnected/server/events/Ready.java rename to src/main/java/cc/reconnected/server/api/events/Ready.java index 23f63e0..4ba3a79 100644 --- a/src/main/java/cc/reconnected/server/events/Ready.java +++ b/src/main/java/cc/reconnected/server/api/events/Ready.java @@ -1,4 +1,4 @@ -package cc.reconnected.server.events; +package cc.reconnected.server.api.events; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; diff --git a/src/main/java/cc/reconnected/server/core/AfkTracker.java b/src/main/java/cc/reconnected/server/core/AfkTracker.java index 8e6c689..b248952 100644 --- a/src/main/java/cc/reconnected/server/core/AfkTracker.java +++ b/src/main/java/cc/reconnected/server/core/AfkTracker.java @@ -1,7 +1,7 @@ package cc.reconnected.server.core; import cc.reconnected.server.RccServer; -import cc.reconnected.server.events.PlayerActivityEvents; +import cc.reconnected.server.api.events.PlayerActivityEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.player.*; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; diff --git a/src/main/java/cc/reconnected/server/core/BackTracker.java b/src/main/java/cc/reconnected/server/core/BackTracker.java index af2ac0c..37754ba 100644 --- a/src/main/java/cc/reconnected/server/core/BackTracker.java +++ b/src/main/java/cc/reconnected/server/core/BackTracker.java @@ -1,6 +1,6 @@ package cc.reconnected.server.core; -import cc.reconnected.server.events.PlayerTeleport; +import cc.reconnected.server.api.events.PlayerTeleport; import cc.reconnected.server.struct.ServerPosition; import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;