diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index 09bacb19d..e1e4ef45b 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -179,7 +179,14 @@ public class PlayerOnlineListener implements Listener { processing.submitNonCritical(processors.info().playerPageUpdateProcessor(playerUUID)); processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN)); + } + @EventHandler(priority = EventPriority.NORMAL) + public void beforePlayerQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); + UUID playerUUID = player.getUniqueId(); + String playerName = player.getName(); + processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE)); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/Plan/bungeecord/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java b/Plan/bungeecord/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java index eaee33f5f..6b7863b98 100644 --- a/Plan/bungeecord/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java +++ b/Plan/bungeecord/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.db.Database; import com.djrapitops.plan.db.access.transactions.events.GeoInfoStoreTransaction; import com.djrapitops.plan.db.access.transactions.events.PlayerRegisterTransaction; +import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionServiceImplementation; import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.cache.SessionCache; @@ -39,6 +40,7 @@ import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; +import net.md_5.bungee.event.EventPriority; import javax.inject.Inject; import java.net.InetAddress; @@ -84,7 +86,7 @@ public class PlayerOnlineListener implements Listener { this.errorHandler = errorHandler; } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onPostLogin(PostLoginEvent event) { try { ProxiedPlayer player = event.getPlayer(); @@ -105,14 +107,22 @@ public class PlayerOnlineListener implements Listener { database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName)); processing.submit(processors.info().playerPageUpdateProcessor(playerUUID)); - processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, com.djrapitops.plan.extension.CallEvents.PLAYER_JOIN)); + processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN)); ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID())); } catch (Exception e) { errorHandler.log(L.WARN, this.getClass(), e); } } - @EventHandler + @EventHandler(priority = EventPriority.NORMAL) + public void beforeLogout(PlayerDisconnectEvent event) { + ProxiedPlayer player = event.getPlayer(); + UUID playerUUID = player.getUniqueId(); + String playerName = player.getName(); + processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE)); + } + + @EventHandler(priority = EventPriority.HIGHEST) public void onLogout(PlayerDisconnectEvent event) { try { ProxiedPlayer player = event.getPlayer(); @@ -126,7 +136,7 @@ public class PlayerOnlineListener implements Listener { } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onServerSwitch(ServerSwitchEvent event) { try { ProxiedPlayer player = event.getPlayer(); diff --git a/Plan/sponge/src/main/java/com/djrapitops/plan/system/listeners/sponge/PlayerOnlineListener.java b/Plan/sponge/src/main/java/com/djrapitops/plan/system/listeners/sponge/PlayerOnlineListener.java index 2a3392742..84eeff9a5 100644 --- a/Plan/sponge/src/main/java/com/djrapitops/plan/system/listeners/sponge/PlayerOnlineListener.java +++ b/Plan/sponge/src/main/java/com/djrapitops/plan/system/listeners/sponge/PlayerOnlineListener.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.store.objects.Nickname; import com.djrapitops.plan.db.Database; import com.djrapitops.plan.db.access.transactions.events.*; +import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionServiceImplementation; import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.cache.NicknameCache; @@ -181,7 +182,15 @@ public class PlayerOnlineListener { )); processing.submitNonCritical(processors.info().playerPageUpdateProcessor(playerUUID)); - processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, com.djrapitops.plan.extension.CallEvents.PLAYER_JOIN)); + processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN)); + } + + @Listener(order = Order.DEFAULT) + public void beforeQuit(ClientConnectionEvent.Disconnect event) { + Player player = event.getTargetEntity(); + UUID playerUUID = player.getUniqueId(); + String playerName = player.getName(); + processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE)); } @Listener(order = Order.POST) diff --git a/Plan/velocity/src/main/java/com/djrapitops/plan/system/listeners/velocity/PlayerOnlineListener.java b/Plan/velocity/src/main/java/com/djrapitops/plan/system/listeners/velocity/PlayerOnlineListener.java index 9fd350e2b..7a499f2fe 100644 --- a/Plan/velocity/src/main/java/com/djrapitops/plan/system/listeners/velocity/PlayerOnlineListener.java +++ b/Plan/velocity/src/main/java/com/djrapitops/plan/system/listeners/velocity/PlayerOnlineListener.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.db.Database; import com.djrapitops.plan.db.access.transactions.events.GeoInfoStoreTransaction; import com.djrapitops.plan.db.access.transactions.events.PlayerRegisterTransaction; +import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionServiceImplementation; import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.cache.SessionCache; @@ -33,6 +34,7 @@ import com.djrapitops.plan.system.webserver.cache.PageId; import com.djrapitops.plan.system.webserver.cache.ResponseCache; import com.djrapitops.plugin.logging.L; import com.djrapitops.plugin.logging.error.ErrorHandler; +import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.connection.PostLoginEvent; @@ -87,7 +89,7 @@ public class PlayerOnlineListener { this.errorHandler = errorHandler; } - @Subscribe + @Subscribe(order = PostOrder.LAST) public void onPostLogin(PostLoginEvent event) { try { Player player = event.getPlayer(); @@ -109,14 +111,22 @@ public class PlayerOnlineListener { database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName)); processing.submit(processors.info().playerPageUpdateProcessor(playerUUID)); - processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, com.djrapitops.plan.extension.CallEvents.PLAYER_JOIN)); + processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN)); ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID())); } catch (Exception e) { errorHandler.log(L.WARN, this.getClass(), e); } } - @Subscribe + @Subscribe(order = PostOrder.NORMAL) + public void beforeLogout(DisconnectEvent event) { + Player player = event.getPlayer(); + UUID playerUUID = player.getUniqueId(); + String playerName = player.getUsername(); + processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE)); + } + + @Subscribe(order = PostOrder.LAST) public void onLogout(DisconnectEvent event) { try { Player player = event.getPlayer(); @@ -130,7 +140,7 @@ public class PlayerOnlineListener { } } - @Subscribe + @Subscribe(order = PostOrder.LAST) public void onServerSwitch(ServerConnectedEvent event) { try { Player player = event.getPlayer();