Mark logged in event as final, add logout event
This commit is contained in:
parent
579b6ca344
commit
a46ec5ec73
3 changed files with 17 additions and 3 deletions
|
@ -3,6 +3,7 @@ package dev.zontreck.libzontreck.events;
|
|||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.memory.PlayerContainer;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
@ -34,7 +35,7 @@ public class ForgeEventHandlers {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent ev)
|
||||
public void onPlayerJoin(final PlayerEvent.PlayerLoggedInEvent ev)
|
||||
{
|
||||
if(ev.getEntity().level.isClientSide)return;
|
||||
|
||||
|
@ -44,4 +45,17 @@ public class ForgeEventHandlers {
|
|||
MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLeave(final PlayerEvent.PlayerLoggedOutEvent ev)
|
||||
{
|
||||
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();
|
||||
}
|
||||
Profile.unload(px);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue