Determine if a player disconnect event corresponds to a kick
Closed this issue · 1 comments
There should be a way, using this library (until Bukkit comes out with a similiar feature) to determine if a player disconnect event is caused by a kick. I am proposing we use the Utilities
class to do this.
Utilities.isKick(PlayerQuitEvent event)
should determine if the specified quit event corresponds to a kick. To do this, we need to subscribe to uncancelled kick events. Perhaps Utilities
can be an internally initialized and event registered singleton. If this is the case, the singleton will store a list of kicked players' UUID
s, and remove them a tick (please check this amount) later. These UUID
s would be obtained by internally subscribing to the PlayerKickEvent
. Meanwhile, if isKick
is called, it can determine the nature of the disconnect by using the list of UUID
s to determine if the event was a kick.
Utilities
would still be a "static class" so to speak, but a private singleton would be initialized and registered as an event handler by the GBukkitLib plugin class.
Confirmed via testing that the disconnect event and the kick event should occur in the same tick, the kick event a few milliseconds before the quit event. Therefore, we could use a task scheduler to remove a kicked player from the list after one tick. I am considering using an asynchronous task and a thread-safe collection for this. Thoughts?