Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public void onDisable() {
// Plugin shutdown logic
}

public static boolean isVanished(final @NotNull Player player) {
public static boolean isVanished(final @NotNull Player player, final @NotNull Player observer) {
if (!observer.canSee(player))
return true;
for (final @NotNull MetadataValue meta : player.getMetadata("vanished"))
if (meta.asBoolean()) return true;
return false;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/pro/cloudnode/smp/cloudnodemsg/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public void send(final @NotNull Context context) throws InvalidPlayerError {
final @NotNull Optional<@NotNull Player> senderPlayer = Optional.ofNullable(this.sender.getPlayer());
final @NotNull Optional<@NotNull Player> recipientPlayer = Optional.ofNullable(this.recipient.getPlayer());

if (!recipient.getUniqueId().equals(console.getUniqueId()) && recipientPlayer.isEmpty() || (recipientPlayer.isPresent() && senderPlayer.isPresent() && CloudnodeMSG.isVanished(recipientPlayer.get()) && !senderPlayer.get().hasPermission(
Permissions.SEND_VANISHED))) {
if (!recipient.getUniqueId().equals(console.getUniqueId()) && recipientPlayer.isEmpty() || (recipientPlayer.isPresent() && senderPlayer.isPresent() && CloudnodeMSG.isVanished(recipientPlayer.get(), senderPlayer.get()) && !senderPlayer.get().hasPermission(Permissions.SEND_VANISHED))) {
if (context == Context.CHANNEL) {
final @NotNull Player player = Objects.requireNonNull(sender.getPlayer());
Message.exitChannel(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean run(final @NotNull CommandSender sender, final @NotNull String la
return sendMessage(player, CloudnodeMSG.getInstance().config().channelClosed(player.getName(), Optional.ofNullable(recipientOffline.getName()).orElse("Unknown Player"), label));
}
}
if (recipient.isEmpty() || (CloudnodeMSG.isVanished(recipient.get()) && !player.hasPermission(Permissions.SEND_VANISHED))) return new PlayerNotFoundError(args[0]).send(player);
if (recipient.isEmpty() || (CloudnodeMSG.isVanished(recipient.get(), player) && !player.hasPermission(Permissions.SEND_VANISHED))) return new PlayerNotFoundError(args[0]).send(player);
if (!Message.isIncomingEnabled(recipient.get())) return new PlayerHasIncomingDisabledError(recipient.get().getName()).send(player);
Message.createChannel(player, recipient.get());
return sendMessage(player, CloudnodeMSG.getInstance().config().channelCreated(player.getName(), recipient.get().getName(), label));
Expand Down