From 10219b2dbea5f82691fbbabfa1cf326f710a516e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berke=20Ak=C3=A7en?= Date: Tue, 29 Oct 2024 14:43:37 +0300 Subject: [PATCH] Small change --- .../java/me/despical/tntrun/arena/Arena.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/despical/tntrun/arena/Arena.java b/src/main/java/me/despical/tntrun/arena/Arena.java index e4168a3..5eb9e63 100644 --- a/src/main/java/me/despical/tntrun/arena/Arena.java +++ b/src/main/java/me/despical/tntrun/arena/Arena.java @@ -44,6 +44,7 @@ import java.text.MessageFormat; import java.util.*; +import java.util.function.Predicate; import java.util.logging.Level; import java.util.stream.Collectors; @@ -215,19 +216,19 @@ public ScoreboardManager getScoreboardManager() { return scoreboardManager; } - public List getPlayers() { - return this.players.stream().filter(user -> { + public Set getPlayers() { + return players.stream().filter(user -> { Player player = user.getPlayer(); return player != null && player.isOnline(); - }).collect(Collectors.toList()); + }).collect(Collectors.toSet()); } - public void addUser(final User user) { + public void addUser(User user) { this.players.add(user); } - public void removeUser(final User user) { + public void removeUser(User user) { this.players.remove(user); } @@ -235,11 +236,11 @@ public boolean isForceStart() { return this.forceStart; } - public void setForceStart(final boolean forceStart) { + public void setForceStart(boolean forceStart) { this.forceStart = forceStart; } - public void addDeathPlayer(final User user) { + public void addDeathPlayer(User user) { deaths.add(user); if (this.getPlayersLeft().size() < 4) { @@ -250,7 +251,7 @@ public void addDeathPlayer(final User user) { this.addSpectator(user); } - public boolean isDeathPlayer(final User user) { + public boolean isDeathPlayer(User user) { return this.deaths.contains(user); } @@ -258,7 +259,7 @@ public List getWinners() { return winners; } - public void addSpectator(final User user) { + public void addSpectator(User user) { this.spectators.add(user); final var nightVision = user.getStat(StatsStorage.StatisticType.SPECTATOR_NIGHT_VISION); @@ -274,11 +275,11 @@ public void addSpectator(final User user) { player.addPotionEffect(XPotion.SPEED.buildInvisible(Integer.MAX_VALUE, level)); } - public void removeSpectator(final User user) { + public void removeSpectator(User user) { this.spectators.remove(user); } - public boolean isSpectator(final User user) { + public boolean isSpectator(User user) { return spectators.contains(user); } @@ -306,7 +307,7 @@ private void startBlockRemoving() { @Override public void run() { - for (final var user : getPlayersLeft()) { + for (var user : getPlayersLeft()) { if (stopped) cancel(); if (arenaState != ArenaState.IN_GAME) return; if (getTimer() <= startBlockRemoving) return; @@ -371,7 +372,7 @@ private Block getBlockUnderPlayer(int y, Location location) { } public Set getPlayersLeft() { - return this.getPlayers().stream().filter(user -> !user.isSpectator()).collect(Collectors.toSet()); + return this.getPlayers().stream().filter(Predicate.not(User::isSpectator)).collect(Collectors.toSet()); } public void playSound(XSound sound) {