mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
implementing tracking and unloading of transient loaded users (loaded for offline players)
This commit is contained in:
11 files changed
+70
-10
No files matched your search
@@ -145,10 +145,14 @@ public final class CarbonChatFabric implements ModInitializer, CarbonChat {
|
||||
}
|
||||
|
||||
private void registerTickListeners() {
|
||||
final long cleanupDelay = 30 * 20; // 30 seconds
|
||||
final long saveDelay = 5 * 60 * 20; // 5 minutes
|
||||
final long saveProfilesDelay = 15 * 60 * 20; // 15 minutes
|
||||
|
||||
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
||||
if (server.getTickCount() != 0 && server.getTickCount() % cleanupDelay == 0) {
|
||||
this.userManager.cleanup();
|
||||
}
|
||||
if (server.getTickCount() != 0 && server.getTickCount() % saveDelay == 0) {
|
||||
PlayerUtils.saveLoggedInPlayers(this.carbonServerFabric, this.userManager, this.logger);
|
||||
}
|
||||
|
||||
@@ -46,4 +46,9 @@ public final class FabricUserManager extends PlatformUserManager<CarbonPlayerFab
|
||||
return new CarbonPlayerFabric(common, this.carbonChatFabric);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateTransientLoadedStatus(final CarbonPlayerFabric wrapped) {
|
||||
wrapped.carbonPlayerCommon().markTransientLoaded(wrapped.player().isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class CarbonPlayerFabric extends WrappedCarbonPlayer implements Forwardin
|
||||
return this.player().orElseThrow();
|
||||
}
|
||||
|
||||
private Optional<ServerPlayer> player() {
|
||||
public Optional<ServerPlayer> player() {
|
||||
return Optional.ofNullable(
|
||||
this.carbonChatFabric.minecraftServer().getPlayerList()
|
||||
.getPlayer(this.carbonPlayerCommon.uuid())
|
||||
|
||||
Reference in new issue
Block a user