Skip to content

Commit f295a92

Browse files
committed
check if player is in vanish before allowing to send a msg
1 parent b009648 commit f295a92

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/java/pro/cloudnode/smp/cloudnodemsg/command/MessageCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public boolean onCommand(final @NotNull CommandSender sender, final @NotNull org
2828

2929
final @NotNull Optional<@NotNull Player> recipient = Optional.ofNullable(CloudnodeMSG.getInstance().getServer()
3030
.getPlayer(args[0]));
31-
if (recipient.isEmpty()) return new PlayerNotFoundError(args[0]).send(sender);
31+
if (recipient.isEmpty() || CloudnodeMSG.isVanished(recipient.get())) return new PlayerNotFoundError(args[0]).send(sender);
3232
if (sender instanceof final @NotNull Player player && recipient.get().getUniqueId().equals(player.getUniqueId()))
3333
return new MessageYourselfError().send(sender);
3434

src/main/java/pro/cloudnode/smp/cloudnodemsg/command/ReplyCommand.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.util.ArrayList;
1515
import java.util.List;
16+
import java.util.Objects;
1617
import java.util.Optional;
1718

1819
public final class ReplyCommand extends Command {
@@ -25,7 +26,14 @@ public boolean onCommand(final @NotNull CommandSender sender, final @NotNull org
2526

2627
final @NotNull Optional<@NotNull OfflinePlayer> recipient = Message.getReplyTo(Message.offlinePlayer(sender));
2728
if (recipient.isEmpty()) return new NobodyReplyError().send(sender);
28-
if (!recipient.get().getUniqueId().equals(Message.console.getUniqueId()) && !recipient.get().isOnline()) return new ReplyOfflineError(Optional.ofNullable(recipient.get().getName()).orElse("Unknown Player")).send(sender);
29+
if (
30+
!recipient.get().getUniqueId().equals(Message.console.getUniqueId())
31+
&& (
32+
!recipient.get().isOnline()
33+
|| CloudnodeMSG.isVanished(Objects.requireNonNull(recipient.get().getPlayer()))
34+
)
35+
)
36+
return new ReplyOfflineError(Optional.ofNullable(recipient.get().getName()).orElse("Unknown Player")).send(sender);
2937

3038
try {
3139
new Message(Message.offlinePlayer(sender), recipient.get(), String.join(" ", args)).send();

0 commit comments

Comments
 (0)