Java Code Examples for org.bukkit.Bukkit#getWhitelistedPlayers()

The following examples show how to use org.bukkit.Bukkit#getWhitelistedPlayers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WhitelistCommands.java    From CardinalPGM with MIT License 6 votes vote down vote up
@Command(aliases = {"list", "l"}, desc = "List players on the whitelist.", min = 0, max = 1)
@CommandPermissions("cardinal.whitelist.list")
public static void list(final CommandContext args, final CommandSender sender) throws CommandException {
    sender.sendMessage(new UnlocalizedChatMessage(ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "--------" + ChatColor.LIGHT_PURPLE + " {0} " + ChatColor.RED + ChatColor.STRIKETHROUGH + "--------", ChatConstant.GENERIC_WHITELISTED_PLAYERS.asMessage()).getMessage(ChatUtil.getLocale(sender)));
    if (Bukkit.getWhitelistedPlayers().size() != 0) {
        String online = "", offline = "";
        for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
            if (player.isOnline()) online += Players.getName(player) + ChatColor.RESET + " ";
            else offline += Players.getName(player) + ChatColor.RESET + " ";
        }
        sender.sendMessage(ChatColor.GREEN + new UnlocalizedChatMessage("{0}:", ChatConstant.MISC_ONLINE.asMessage()).getMessage(ChatUtil.getLocale(sender)));
        sender.sendMessage(online);
        sender.sendMessage(ChatColor.RED + new UnlocalizedChatMessage("{0}:", ChatConstant.MISC_OFFLINE.asMessage()).getMessage(ChatUtil.getLocale(sender)));
        sender.sendMessage(offline);
    } else {
        sender.sendMessage(ChatColor.RED + ChatConstant.GENERIC_NO_WHITELISTED_PLAYERS.getMessage(ChatUtil.getLocale(sender)));
    }
}
 
Example 2
Source File: PlayerEvents.java    From AntiVPN with MIT License 5 votes vote down vote up
private boolean isWhitelisted(UUID playerID) {
    for (OfflinePlayer p : Bukkit.getWhitelistedPlayers()) {
        if (playerID.equals(p.getUniqueId())) {
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: WhitelistClearCommand.java    From UHC with MIT License 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    final Collection<OfflinePlayer> players = Bukkit.getWhitelistedPlayers();

    for (final OfflinePlayer player : players) {
        player.setWhitelisted(false);
    }

    sender.sendMessage(messages.evalTemplate("remove", ImmutableMap.of("count", players.size())));
    return true;
}
 
Example 4
Source File: WhitelistCommands.java    From CardinalPGM with MIT License 5 votes vote down vote up
@Command(aliases = {"clear"}, desc = "Clear the whitelist.", min = 0, max = 0)
@CommandPermissions("cardinal.whitelist.clear")
public static void clear(final CommandContext args, final CommandSender sender) throws CommandException {
    int count = 0;
    for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
        player.setWhitelisted(false);
        count++;
    }
    sender.sendMessage(ChatColor.RED + new LocalizedChatMessage(ChatConstant.GENERIC_REMOVED_PLAYERS_WHITELIST, "" + ChatColor.GOLD + count + ChatColor.RED).getMessage(ChatUtil.getLocale(sender)));
}