Update for a new 5.1 method in sudo.
@@ -67,7 +67,12 @@ public class SudoCommand extends AbstractCommand<CommandSource> {
}
Text rawMessage = Text.of(cmd.split(":", 2)[1]);
- MessageChannelEvent.Chat event = new NucleusMessageChannelEvent(
+
+ MessageChannelEvent.Chat event;
+ try {
+ event = pl.simulateChat(rawMessage, Cause.of(NamedCause.simulated(pl), NamedCause.owner(src)));
+ } catch (Throwable e) { // just in case people don't update.
+ event = new NucleusMessageChannelEvent(
Cause.source(pl).named(NamedCause.notifier(src)).build(),
pl.getMessageChannel(),
rawMessage,
@@ -79,13 +84,17 @@ public class SudoCommand extends AbstractCommand<CommandSource> {
if (!Sponge.getEventManager().post(event)) {
pl.getMessageChannel().send(pl, Util.applyChatTemplate(event.getFormatter()));
- return CommandResult.success();
+ }
}
+ if (event.isCancelled()) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.sudo.chatcancelled"));
return CommandResult.empty();
}
+ return CommandResult.success();
+ }
+
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.sudo.force", pl.getName(), cmd));
Sponge.getCommandManager().process(pl, cmd);
return CommandResult.success();
