Skip to content

Commit a03d117

Browse files
committed
add bypass permission for sending msg to vanished players
1 parent f295a92 commit a03d117

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/main/java/pro/cloudnode/smp/cloudnodemsg/Permission.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ public final class Permission {
1212
* Allows reloading the plugin
1313
*/
1414
public final static @NotNull String RELOAD = "cloudnodemsg.reload";
15+
16+
/**
17+
* Allows sending messages to vanished players
18+
*/
19+
public final static @NotNull String SEND_VANISHED = "cloudnodemsg.send.vanished";
1520
}

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() || CloudnodeMSG.isVanished(recipient.get())) return new PlayerNotFoundError(args[0]).send(sender);
31+
if (recipient.isEmpty() || (CloudnodeMSG.isVanished(recipient.get()) && !sender.hasPermission(Permission.SEND_VANISHED))) 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public boolean onCommand(final @NotNull CommandSender sender, final @NotNull org
3030
!recipient.get().getUniqueId().equals(Message.console.getUniqueId())
3131
&& (
3232
!recipient.get().isOnline()
33-
|| CloudnodeMSG.isVanished(Objects.requireNonNull(recipient.get().getPlayer()))
33+
|| (CloudnodeMSG.isVanished(Objects.requireNonNull(recipient.get().getPlayer())) && !sender.hasPermission(Permission.SEND_VANISHED))
3434
)
3535
)
3636
return new ReplyOfflineError(Optional.ofNullable(recipient.get().getName()).orElse("Unknown Player")).send(sender);

0 commit comments

Comments
 (0)