From 81c8d2f151a97f312a112c219a1c5950f3724c92 Mon Sep 17 00:00:00 2001 From: William Date: Fri, 29 Mar 2024 14:54:40 +0000 Subject: [PATCH] fix: improve Velocity join/quit messages, close #180 --- .../huskchat/listener/VelocityPlayerListener.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/velocity/src/main/java/net/william278/huskchat/listener/VelocityPlayerListener.java b/velocity/src/main/java/net/william278/huskchat/listener/VelocityPlayerListener.java index ad6da28..f355b91 100644 --- a/velocity/src/main/java/net/william278/huskchat/listener/VelocityPlayerListener.java +++ b/velocity/src/main/java/net/william278/huskchat/listener/VelocityPlayerListener.java @@ -21,7 +21,6 @@ import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.DisconnectEvent; -import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.player.ServerConnectedEvent; import net.william278.huskchat.HuskChat; import net.william278.huskchat.user.VelocityUser; @@ -35,19 +34,19 @@ public VelocityPlayerListener(@NotNull HuskChat plugin) { @Subscribe public void onPlayerChangeServer(ServerConnectedEvent e) { + if (e.getPreviousServer().isEmpty()) { + handlePlayerJoin(VelocityUser.adapt(e.getPlayer(), plugin)); + } final String server = e.getServer().getServerInfo().getName(); final VelocityUser player = VelocityUser.adapt(e.getPlayer(), plugin); handlePlayerSwitchServer(player, server); } - @Subscribe - public void onPlayerJoinNetwork(PostLoginEvent e) { - handlePlayerJoin(VelocityUser.adapt(e.getPlayer(), plugin)); - } - @Subscribe public void onPlayerQuitNetwork(DisconnectEvent e) { - handlePlayerQuit(VelocityUser.adapt(e.getPlayer(), plugin)); + if (e.getLoginStatus() == DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN) { + handlePlayerQuit(VelocityUser.adapt(e.getPlayer(), plugin)); + } } }