private void broadcast(WorldBorderMessage message) { world.getPlayers().forEach(player -> ((GlowPlayer) player).getSession().send(message)); } }
/** * Gets every player that has ever played on this server. * * @return An OfflinePlayer[] future. */ public CompletableFuture<OfflinePlayer[]> getOfflinePlayersAsync() { Set<OfflinePlayer> result = new HashSet<>(); Set<UUID> uuids = new HashSet<>(); // add the currently online players for (World world : getWorlds()) { for (Player player : world.getPlayers()) { result.add(player); uuids.add(player.getUniqueId()); } } return getPlayerDataService().getOfflinePlayers() .thenAcceptAsync(offlinePlayers -> offlinePlayers.stream() .filter(offline -> !uuids.contains(offline.getUniqueId())) .forEach(offline -> { result.add(offline); uuids.add(offline.getUniqueId()); })).thenApply((v) -> result.toArray(new OfflinePlayer[result.size()])); }
@Override public List<MCPlayer> getPlayers() { List<MCPlayer> list = new ArrayList<>(); for(Player p : w.getPlayers()) { list.add(new BukkitMCPlayer(p)); } return list; }
public static List<Player> getOnline() { List<Player> list = new ArrayList<>(); for (World world : Bukkit.getWorlds()) { list.addAll(world.getPlayers()); } return Collections.unmodifiableList(list); }
/** * Plays the effect at the given location to the given players. * * @param location location */ @Override public void apply(Location location) { this.applyTo(location, location.getWorld().getPlayers().toArray(new Player[location.getWorld().getPlayers().size()])); }
@SuppressWarnings("deprecation") private void send(Material mat, byte data) { if (player != null) { player.sendBlockChange(temp, mat, data); } else { for (Player player : world.getPlayers()) { player.sendBlockChange(temp, mat, data); } } } }
/** * Plays the effect at the given location to the given players. * * @param location location */ @Override public void apply(Location location) { this.apply(location, location.getWorld().getPlayers()); }
@SuppressWarnings("deprecation") private void send(Material mat, byte data) { if (player != null) { player.sendBlockChange(temp, mat, data); } else { for (Player player : world.getPlayers()) { player.sendBlockChange(temp, mat, data); } } } }
static void refreshPlayer(Player player) { Preconditions.checkState(Main.getInst().isEnabled(), "Not Enabled!"); Preconditions.checkNotNull(player, "player"); player.getWorld().getPlayers().forEach(playerFor -> refreshPlayer(player, playerFor)); }
public static LinkedHashMap<String, Integer> getPingAndSort() { HashMap<String, Integer> pingRecord = new HashMap<>(); for (World world : Bukkit.getWorlds()) { for (Player p : world.getPlayers()) { pingRecord.put(p.getName(), getPing(p)); } } return NeverLagUtils.sortMapByValues(pingRecord); }
/** * Makes all players leave the world. Attempts to let them leave properly if they are correct DInstancePlayers; teleports them to the spawn if they are not. */ public void kickAllPlayers() { getPlayers().forEach(p -> p.leave()); // Players who shouldn't be in the dungeon but still are for some reason world.getPlayers().forEach(p -> PlayerUtil.secureTeleport(p, Bukkit.getWorlds().get(0).getSpawnLocation())); }
/** * Queue a task to update shops for players in the given world * * @param world World in whose players to show updates */ public void updateShops(World world) { queue(() -> { for (Player player : world.getPlayers()) { plugin.getShopUtils().updateShops(player); } }); }
@Override public void onTrigger() { if (location != null) { for (Player player : getGameWorld().getWorld().getPlayers()) { player.teleport(location); } } }
@Override public void onTrigger() { if (initialized) { for (Player player : getGameWorld().getWorld().getPlayers()) { MessageUtil.sendMessage(player, msg); } remove(); } }
public static void sendSkillMessage(Player player, NotificationType notificationType, String key) { Location location = player.getLocation(); for (Player otherPlayer : player.getWorld().getPlayers()) { if (otherPlayer != player && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { NotificationManager.sendNearbyPlayersInformation(player, notificationType, key, player.getName()); } } }
@Override public GameMode validateChange(String property, GameMode newValue, GameMode oldValue, MVWorld object) throws ChangeDeniedException { for (Player p : plugin.getServer().getWorld(getName()).getPlayers()) { plugin.log(Level.FINER, String.format("Setting %s's GameMode to %s", p.getName(), newValue.toString())); plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this); } return super.validateChange(property, newValue, oldValue, object); } }
@Override public void onTrigger() { if (initialized) { for (Player player : getGameWorld().getWorld().getPlayers()) { player.playSound(getSign().getLocation(), sound, category, volume, pitch); } remove(); } }
@Override public void run() { for (World world : Bukkit.getWorlds()) { WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID()); if (climateEngine != null && climateEngine.isEffectEnabled(ClimateEffectType.PERMANENT_SLOWNESS)) { for (Player player : world.getPlayers()) { updatePlayerSlowness(player, climateEngine.getTemperature()); } } } }
private void movePlayers(GriefBlock gb) { for (Player player : world.getPlayers()) { Vec blockLocation = gb.toVec(); Vec location = new Vec(player.getLocation()); if (blockLocation.equals(location) || blockLocation.equals(location.add(0, 1, 0))) { plugin.getTeleportationManager().teleportAway(player); } } } }
private void movePlayers(TranslocationBlock tb) { for (Player player : world.getPlayers()) { Vec blockLocation = tb.toVec(); Vec location = new Vec(player.getLocation()); if (blockLocation.equals(location) || blockLocation.equals(location.add(0, 1, 0))) { plugin.getTeleportationManager().teleportAway(player); } } } }