vanish bypass perms and ignoreCancelled on chat

This commit is contained in:
Draycia committed 2021-10-18 13:43:50 -07:00
1 parent 2964e7ef09
commit 9c576e8cdb
6 files changed
+20 -5

No files matched your search

@@ -37,7 +37,7 @@ public final class BukkitChatListener implements Listener {
this.registry = registry;
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void onPlayerChat(final @NonNull AsyncChatEvent event) {
final var playerResult = this.carbonChat.server().player(event.getPlayer().getUniqueId()).join();
final @Nullable CarbonPlayer sender = playerResult.player();
@@ -46,6 +46,11 @@ public class ContinueCommand {
return;
}
if (!sender.awareOf(recipient) && !sender.hasPermission("carbon.seevanish.continue")) {
messageService.whisperTargetOffline(sender, CarbonPlayer.renderName(sender));
return;
}
if (sender.equals(recipient)) {
messageService.whisperSelfError(sender, CarbonPlayer.renderName(sender));
return;
@@ -48,6 +48,11 @@ public class ReplyCommand {
return;
}
if (!sender.awareOf(recipient) && !sender.hasPermission("carbon.seevanish.reply")) {
messageService.whisperTargetOffline(sender, CarbonPlayer.renderName(sender));
return;
}
if (sender.equals(recipient)) {
messageService.whisperSelfError(sender, CarbonPlayer.renderName(sender));
return;
@@ -26,7 +26,6 @@ public class UnmuteCommand {
final CarbonPlayerArgument carbonPlayerArgument
) {
final var command = commandManager.commandBuilder("unmute")
// TODO: only suggest muted players :D
.argument(carbonPlayerArgument.newInstance(false, "player",
CarbonPlayerArgument.NO_SENDER.and((sender, player) -> {
return !player.muteEntries().isEmpty();
@@ -49,6 +48,7 @@ public class UnmuteCommand {
} else {
throw new IllegalStateException("No target found to unmute.");
}
messageService.playerAlertUnmuted(target);
messageService.broadcastPlayerUnmuted(sender, target.username());
@@ -34,7 +34,12 @@ public class WhisperCommand {
return;
}
if (!recipient.online() || !sender.awareOf(recipient)) {
if (!recipient.online()) {
messageService.whisperTargetOffline(sender, CarbonPlayer.renderName(sender));
return;
}
if (!sender.awareOf(recipient) && !sender.hasPermission("carbon.seevanish.whisper")) {
messageService.whisperTargetOffline(sender, CarbonPlayer.renderName(sender));
return;
}
@@ -31,8 +31,8 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
protected long temporaryDisplayNameExpiration = -1;
// Whispers
protected @Nullable UUID lastWhisperTarget = null;
protected @Nullable UUID whisperReplyTarget = null;
protected transient @Nullable UUID lastWhisperTarget = null;
protected transient @Nullable UUID whisperReplyTarget = null;
// Administrative
protected boolean spying = false;