Skip to content

Commit

Permalink
refactor!: Rewrite internal user system
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 committed May 8, 2023
1 parent 22810f0 commit 34ebb48
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 307 deletions.
26 changes: 17 additions & 9 deletions src/main/java/com/aetherteam/nitrogen/Nitrogen.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.server.ServerAboutToStartEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
Expand Down Expand Up @@ -51,20 +52,27 @@ public void dataSetup(GatherDataEvent event) {
generator.addProvider(event.includeClient(), new NitrogenLanguageData(packOutput));
}

@SubscribeEvent
public static void serverAboutToStart(ServerStartingEvent event) {
UserData.Server.initializeFromCache(event.getServer());
}

@SubscribeEvent
public static void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
if (event.getEntity() instanceof ServerPlayer serverPlayer) {
UUID uuid = serverPlayer.getUUID();
Player player = event.getEntity();
if (player instanceof ServerPlayer serverPlayer) {
UUID uuid = serverPlayer.getGameProfile().getId();
Map<UUID, User> userData = UserData.Server.getStoredUsers();
User user;
if (userData.containsKey(uuid)) {
User user = userData.get(uuid);
user = userData.get(uuid);
} else {
user = UserData.Server.queryUser(serverPlayer.getServer(), uuid);
}
//todo timestamp check
if (user != null) {
PacketDistributor.sendToPlayer(NitrogenPacketHandler.INSTANCE, new UpdateUserInfoPacket(user), serverPlayer);
}
}
}

@SubscribeEvent
public static void serverAboutToStart(ServerAboutToStartEvent event) {
UserData.Server.initializeForTesting();
}
}
8 changes: 0 additions & 8 deletions src/main/java/com/aetherteam/nitrogen/api/users/Booster.java

This file was deleted.

51 changes: 0 additions & 51 deletions src/main/java/com/aetherteam/nitrogen/api/users/Donor.java

This file was deleted.

80 changes: 0 additions & 80 deletions src/main/java/com/aetherteam/nitrogen/api/users/Patron.java

This file was deleted.

69 changes: 0 additions & 69 deletions src/main/java/com/aetherteam/nitrogen/api/users/Ranked.java

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/java/com/aetherteam/nitrogen/api/users/Role.java

This file was deleted.

Loading

0 comments on commit 34ebb48

Please sign in to comment.