feat: Added Support for AuthMe Sessions

This commit is contained in:
Adrian 2023-12-07 13:13:45 -05:00
parent 52b0dca96a
commit f857c25180
No known key found for this signature in database
GPG Key ID: FB8EF84DCE1BE452

View File

@ -17,11 +17,7 @@
package io.github._4drian3d.authmevelocity.paper.listeners; package io.github._4drian3d.authmevelocity.paper.listeners;
import fr.xephi.authme.events.LoginEvent; import fr.xephi.authme.events.*;
import fr.xephi.authme.events.LogoutEvent;
import fr.xephi.authme.events.RegisterEvent;
import fr.xephi.authme.events.UnregisterByAdminEvent;
import fr.xephi.authme.events.UnregisterByPlayerEvent;
import io.github._4drian3d.authmevelocity.api.paper.event.PreSendLoginEvent; import io.github._4drian3d.authmevelocity.api.paper.event.PreSendLoginEvent;
import io.github._4drian3d.authmevelocity.common.MessageType; import io.github._4drian3d.authmevelocity.common.MessageType;
import io.github._4drian3d.authmevelocity.paper.AuthMeVelocityPlugin; import io.github._4drian3d.authmevelocity.paper.AuthMeVelocityPlugin;
@ -53,6 +49,21 @@ public final class AuthMeListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSessionRestored(RestoreSessionEvent event) {
final Player player = event.getPlayer();
plugin.logDebug("RestoreSessionEvent | Start");
// I hate this, but... Spigot compatibility ¯\_()_/¯
final var preSendLoginEvent = new PreSendLoginEvent(player);
Bukkit.getPluginManager().callEvent(preSendLoginEvent);
if (!preSendLoginEvent.isCancelled()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.logDebug("RestoreSessionEvent | PreSendLoginEvent allowed");
}
}
@EventHandler @EventHandler
public void onRegister(final RegisterEvent event) { public void onRegister(final RegisterEvent event) {
plugin.logDebug("RegisterEvent | Executed"); plugin.logDebug("RegisterEvent | Executed");