From faeb09895980df2ca897e6b3e146829b4c448fad Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Wed, 5 Aug 2020 17:42:48 -0400 Subject: [PATCH] @telesphoreo :))) --- .../tfguilds/command/InviteSubcommand.java | 2 +- .../me/totalfreedom/tfguilds/util/GUtil.java | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/totalfreedom/tfguilds/command/InviteSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/InviteSubcommand.java index c39d9cc..be169ab 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/InviteSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/InviteSubcommand.java @@ -32,7 +32,7 @@ public class InviteSubcommand extends Common implements CommandExecutor Player player = (Player)sender; Guild guild = Guild.getGuild(player); Player invitee = Bukkit.getPlayer(args[1]); - if (invitee == null) + if (invitee == null || GUtil.isVanished(invitee)) { sender.sendMessage(PNF); return true; diff --git a/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java b/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java index 1f16a2a..4013851 100644 --- a/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java +++ b/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java @@ -1,17 +1,17 @@ package me.totalfreedom.tfguilds.util; -import java.util.ArrayList; -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; - import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.metadata.MetadataValue; public class GUtil { @@ -54,9 +54,23 @@ public class GUtil List players = new ArrayList<>(); for (Player player : Bukkit.getOnlinePlayers()) { - players.add(player.getName()); + if (!isVanished(player)) + { + players.add(player.getName()); + } } return players; } + public static boolean isVanished(Player player) + { + for (MetadataValue meta : player.getMetadata("vanished")) + { + if (meta.asBoolean()) + { + return true; + } + } + return false; + } } \ No newline at end of file