Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class PlayerUtils {
- private PlayerUtils() {
- }
- /**
- * Get all online players except the provided players.
- */
- public static Collection<Player> getPlayersExcept(Player... excluded) {
- Set<UUID> excludedIds = Arrays.stream(excluded)
- .filter(Objects::nonNull)
- .map(Player::getUniqueId)
- .collect(Collectors.toSet());
- return Bukkit.getOnlinePlayers().stream()
- .filter(p -> !excludedIds.contains(p.getUniqueId()))
- .collect(Collectors.toList());
- }
- /**
- * Get all online players except the players with the provided UUIDs.
- */
- public static Collection<Player> getPlayersExcept(UUID... excluded) {
- Set<UUID> excludedIds = Arrays.stream(excluded)
- .filter(Objects::nonNull)
- .collect(Collectors.toSet());
- return Bukkit.getOnlinePlayers().stream()
- .filter(p -> !excludedIds.contains(p.getUniqueId()))
- .collect(Collectors.toList());
- }
- }
Advertisement