Mark logged in event as final, add logout event

This commit is contained in:
Aria 2023-02-27 23:05:46 -07:00
parent 579b6ca344
commit a46ec5ec73
3 changed files with 17 additions and 3 deletions

View file

@ -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);
}
}

View file

@ -19,7 +19,7 @@ modId="libzontreck" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build
version="1.0.5.0227232249" #mandatory
version="1.0.5.0227232305" #mandatory
# A display name for the mod
displayName="LibZontreck" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/