From 2fa4a044911eb6ef61832d41b0c3dd07a16598b4 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Mon, 28 Mar 2022 14:48:28 +0300 Subject: Events fixes, more events --- .../limboauth/command/UnregisterCommand.java | 2 ++ .../limboauth/event/AuthUnregisterEvent.java | 32 ++++++++++++++++++++++ .../limboauth/handler/AuthSessionHandler.java | 3 ++ 3 files changed, 37 insertions(+) create mode 100644 src/main/java/net/elytrium/limboauth/event/AuthUnregisterEvent.java (limited to 'src/main') diff --git a/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java b/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java index 0811007..3c23bbf 100644 --- a/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java +++ b/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java @@ -26,6 +26,7 @@ import java.sql.SQLException; import java.util.Locale; import net.elytrium.limboauth.LimboAuth; import net.elytrium.limboauth.Settings; +import net.elytrium.limboauth.event.AuthUnregisterEvent; import net.elytrium.limboauth.handler.AuthSessionHandler; import net.elytrium.limboauth.model.RegisteredPlayer; import net.kyori.adventure.text.Component; @@ -77,6 +78,7 @@ public class UnregisterCommand implements SimpleCommand { source.sendMessage(this.crackedCommand); } else if (AuthSessionHandler.checkPassword(args[0], player, this.playerDao)) { try { + this.plugin.getServer().getEventManager().fireAndForget(new AuthUnregisterEvent(username)); this.playerDao.deleteById(username.toLowerCase(Locale.ROOT)); this.plugin.removePlayerFromCache(username); ((Player) source).disconnect(this.successful); diff --git a/src/main/java/net/elytrium/limboauth/event/AuthUnregisterEvent.java b/src/main/java/net/elytrium/limboauth/event/AuthUnregisterEvent.java new file mode 100644 index 0000000..7450479 --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/AuthUnregisterEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package net.elytrium.limboauth.event; + +public class AuthUnregisterEvent { + + private final String nickname; + + public AuthUnregisterEvent(String nickname) { + this.nickname = nickname; + } + + public String getNickname() { + return this.nickname; + } + +} diff --git a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java index 43895f2..13200d0 100644 --- a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java +++ b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java @@ -332,6 +332,9 @@ public class AuthSessionHandler implements LimboSessionHandler { if (event.getResult() == TaskEvent.Result.CANCEL) { this.proxyPlayer.disconnect(event.getReason()); + return; + } else if (event.getResult() == TaskEvent.Result.WAIT) { + return; } this.plugin.cacheAuthUser(this.proxyPlayer); -- cgit