AdvancedBan
AdvancedBan copied to clipboard
Database Queries on the Main Thread
Applies To Single servers / Bukkit servers
How to Enable the Situation / Reproduce the Bug
- A banned player logs in
- AdvancedBan queries the user's ban and cancels the log-in event (AsyncPlayerPreLoginEvent)
- Another plugin un-cancels the log-in event
- Yet another plugin makes the player chat (via the Player#chat function)
- The chat event is fired on the main thread
- The banned user's possible mute is not cached
- AdvancedBan runs a database query to check whether the mute exists
This scenario has a few requirements:
- If the user is not banned, their data is cached, and therefore when the chat event is called, no database query is made.
- If no plugin makes the player chat, chat events happen asynchronously, so database queries do not slaughter performance.
Some plugins might un-cancel the log-in event, however unwise that is. Many plugins have the feature to make a player chat. Some chat plugins can even make this happen for normal player chat.
Add any additional information below.
Timings may indicate that a user is experiencing this bug.

Here is another scenario which is more common, and lifts one of the requirements of the last scenario:
- A banned player logs in
- AdvancedBan queries the user's ban and cancels the log-in event (AsyncPlayerPreLoginEvent)
- Another plugin un-cancels the log-in event
- The player runs a command. The command event is fired on the main thread
- AdvancedBan runs a database query to check whether the player is muted
So really, there is only 1 requirement for database queries to be made on the main thread:
- There must be a plugin which un-cancels the log-in event after AdvancedBan has determined the user is banned
Thanks to Sheidy for pointing this out