Skip to content

Commit 6eb64ce

Browse files
mdcfeDarkEyeDragon
authored andcommitted
Dispatch commands on main thread when run from XMPP (EssentialsX#3803)
This PR fixes an issue reported on Discord, where commands executed through XMPP are dispatched async from the XMPP listener thread.
1 parent 07f8c87 commit 6eb64ce

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

EssentialsXMPP/src/main/java/com/earth2me/essentials/xmpp/XMPPManager.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,13 @@ private void sendPrivateMessage(final Chat chat, final String message) {
320320

321321
private void sendCommand(final Chat chat, final String message) {
322322
if (config.getStringList("op-users").contains(StringUtils.parseBareAddress(chat.getParticipant()))) {
323-
try {
324-
parent.getServer().dispatchCommand(Console.getInstance().getCommandSender(), message.substring(1));
325-
} catch (final Exception ex) {
326-
logger.log(Level.SEVERE, ex.getMessage(), ex);
327-
}
323+
parent.getServer().getScheduler().runTask(parent, () -> {
324+
try {
325+
parent.getServer().dispatchCommand(Console.getInstance().getCommandSender(), message.substring(1));
326+
} catch (final Exception ex) {
327+
logger.log(Level.SEVERE, ex.getMessage(), ex);
328+
}
329+
});
328330
}
329331
}
330332

0 commit comments

Comments
 (0)