Dispatch commands on main thread when run from XMPP (#3803)

This PR fixes an issue reported on Discord, where commands executed through XMPP are dispatched async from the XMPP listener thread.
This commit is contained in:
MD 2020-12-11 16:36:29 +00:00 committed by GitHub
parent 43eff69a2f
commit 5bb3cc88e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -320,11 +320,13 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
private void sendCommand(final Chat chat, final String message) {
if (config.getStringList("op-users").contains(StringUtils.parseBareAddress(chat.getParticipant()))) {
try {
parent.getServer().dispatchCommand(Console.getInstance().getCommandSender(), message.substring(1));
} catch (final Exception ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
parent.getServer().getScheduler().runTask(parent, () -> {
try {
parent.getServer().dispatchCommand(Console.getInstance().getCommandSender(), message.substring(1));
} catch (final Exception ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
});
}
}