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
|
@ -5,5 +5,5 @@ org.gradle.daemon=false
|
||||||
|
|
||||||
mc_version=1.18.2
|
mc_version=1.18.2
|
||||||
forge_version=40.2.1
|
forge_version=40.2.1
|
||||||
myversion=1.0.5.0227232249
|
myversion=1.0.5.0227232305
|
||||||
parchment_version=2022.11.06
|
parchment_version=2022.11.06
|
|
@ -3,6 +3,7 @@ package dev.zontreck.libzontreck.events;
|
||||||
import dev.zontreck.libzontreck.LibZontreck;
|
import dev.zontreck.libzontreck.LibZontreck;
|
||||||
import dev.zontreck.libzontreck.memory.PlayerContainer;
|
import dev.zontreck.libzontreck.memory.PlayerContainer;
|
||||||
import dev.zontreck.libzontreck.profiles.Profile;
|
import dev.zontreck.libzontreck.profiles.Profile;
|
||||||
|
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||||
|
@ -34,7 +35,7 @@ public class ForgeEventHandlers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent ev)
|
public void onPlayerJoin(final PlayerEvent.PlayerLoggedInEvent ev)
|
||||||
{
|
{
|
||||||
if(ev.getEntity().level.isClientSide)return;
|
if(ev.getEntity().level.isClientSide)return;
|
||||||
|
|
||||||
|
@ -44,4 +45,17 @@ public class ForgeEventHandlers {
|
||||||
MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof));
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
# 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
|
# ${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
|
# 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
|
# A display name for the mod
|
||||||
displayName="LibZontreck" #mandatory
|
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/
|
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||||
|
|
Reference in a new issue