Attempt to fix profiles unloading while a player is still logged on

This commit is contained in:
zontreck 2023-12-21 16:11:07 -07:00
parent 9edb1f40fe
commit d237912942
2 changed files with 18 additions and 6 deletions

View file

@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3
# The mod version. See https://semver.org/
mod_version=1.9.122023.1612
mod_version=1.9.122123.1608
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -5,11 +5,13 @@ import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.LibZontreck;
import dev.zontreck.libzontreck.currency.Account;
import dev.zontreck.libzontreck.currency.Bank;
import dev.zontreck.libzontreck.exceptions.InvalidSideException;
import dev.zontreck.libzontreck.memory.PlayerContainer;
import dev.zontreck.libzontreck.networking.ModMessages;
import dev.zontreck.libzontreck.networking.packets.S2CWalletInitialSyncPacket;
import dev.zontreck.libzontreck.profiles.Profile;
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
import dev.zontreck.libzontreck.util.ServerUtilities;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.MinecraftForge;
@ -65,12 +67,22 @@ public class ForgeEventHandlers {
{
if(ev.getEntity().level().isClientSide)return;
// Get player profile, send disconnect alert, then commit profile and remove it from memory
Profile px=null;
try {
px = Profile.get_profile_of(ev.getEntity().getStringUUID());
} catch (UserProfileNotYetExistsException e) {
e.printStackTrace();
if(ServerUtilities.playerIsOffline(ev.getEntity().getUUID()))
{
Profile px=null;
try {
px = Profile.get_profile_of(ev.getEntity().getStringUUID());
} catch (UserProfileNotYetExistsException e) {
e.printStackTrace();
}
Profile.unload(px);
}
} catch (InvalidSideException e) {
throw new RuntimeException(e);
}
Profile.unload(px);
}
}