diff --git a/src/main/java/de/fanta/challenges/challenges/ChallengeEvents/DeathrunChallengeEvent.java b/src/main/java/de/fanta/challenges/challenges/ChallengeEvents/DeathrunChallengeEvent.java index 39d76c6..a5a1ed1 100644 --- a/src/main/java/de/fanta/challenges/challenges/ChallengeEvents/DeathrunChallengeEvent.java +++ b/src/main/java/de/fanta/challenges/challenges/ChallengeEvents/DeathrunChallengeEvent.java @@ -7,6 +7,7 @@ import de.fanta.challenges.scoreboard.ScoreManager; import de.fanta.challenges.utils.ChatSkullAPI.ChatSkull; import de.fanta.challenges.utils.ChatUtil; +import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.GameRule; @@ -38,7 +39,7 @@ private final Challenges plugin = Challenges.getPlugin(); - private static final List deadPlayer = new ArrayList<>(); + private static final List deadPlayer = new ArrayList<>(); private final Map bossBarMap = new HashMap<>(); public static Location spawnLocation; @@ -52,7 +53,7 @@ Player p = e.getPlayer(); World world = p.getWorld(); if (Objects.equals(plugin.getConfig().getString("event.type"), "deathrun") && plugin.getTimer().isRunning() && !plugin.getVanish().isVanish(p) && p.getGameMode() != GameMode.SPECTATOR) { - if (!deadPlayer.contains(p.getUniqueId().toString())) { + if (!deadPlayer.contains(p.getUniqueId())) { Location playerLoc = p.getLocation(); double posRelatedToCenter = playerLoc.getZ() - spawnLocation.getZ(); double distanceToCenter = Math.abs(posRelatedToCenter); @@ -104,7 +105,7 @@ public void onDeath(PlayerDeathEvent e) { Player p = e.getEntity(); if (Objects.equals(plugin.getConfig().getString("event.type"), "deathrun") && plugin.getTimer().isRunning()) { - deadPlayer.add(p.getUniqueId().toString()); + deadPlayer.add(p.getUniqueId()); plugin.getSBManager().removeScoreboard(p); if (plugin.getSBManager().countScoreboardPlayers() == 0) { plugin.getTimer().stopTimer(); @@ -212,7 +213,7 @@ } } - public static List getDeadPlayer() { + public static List getDeadPlayer() { return deadPlayer; } @@ -225,22 +226,25 @@ } private void updateScoreAndBossBar() { - if (Objects.equals(plugin.getConfig().getString("event.type"), "deathrun")) { + if (Objects.equals(plugin.getConfig().getString("event.type"), "deathrun") && plugin.getTimer().isRunning()) { + ScoreManager scoreManager = plugin.getScoreManager(); for (Player p : plugin.getVanish().getPlayerListWithoutVanishPlayers()) { - if (!deadPlayer.contains(p.getUniqueId().toString())) { - int distance = (int) p.getLocation().toVector().subtract(p.getWorld().getSpawnLocation().toVector()).length(); - ScoreManager scoreManager = plugin.getScoreManager(); - scoreManager.setScore(new ChallengePlayer(p), distance); - + if (!plugin.getVanish().isVanish(p) && p.getGameMode() != GameMode.SPECTATOR) { + if (!deadPlayer.contains(p.getUniqueId())) { + int distance = (int) p.getLocation().toVector().subtract(p.getWorld().getSpawnLocation().toVector()).length(); + scoreManager.setScore(new ChallengePlayer(p), distance); + } BossBar bossBar = bossBarMap.computeIfAbsent(p, player -> { - BossBar newBossBar = Bukkit.createBossBar(ChatUtil.GREEN + "Position: " + ChatUtil.BLUE + (scoreManager.getPosition(new ChallengePlayer(p))) + ChatUtil.RED + " | " + ChatUtil.GREEN + "Distanz zum Spawn: " + ChatUtil.BLUE + distance + " Blöcke", BarColor.GREEN, BarStyle.SOLID); + BossBar newBossBar = Bukkit.createBossBar(ChatUtil.GREEN + "Position: " + ChatUtil.BLUE + scoreManager.getPosition(new ChallengePlayer(p)) + ChatUtil.RED + " | " + ChatUtil.GREEN + "Distanz zum Spawn: " + ChatUtil.BLUE + scoreManager.getScore(new ChallengePlayer(p)) + " Blöcke", BarColor.GREEN, BarStyle.SOLID); newBossBar.setVisible(true); newBossBar.addPlayer(p); return newBossBar; }); - - bossBar.setTitle(ChatUtil.GREEN + "Position: " + ChatUtil.BLUE + (scoreManager.getPosition(new ChallengePlayer(p))) + ChatUtil.RED + " | " + ChatUtil.GREEN + "Distanz zum Spawn: " + ChatUtil.BLUE + distance + " Blöcke"); - + if (!deadPlayer.contains(p.getUniqueId())) { + bossBar.setTitle(ChatUtil.GREEN + "Position: " + ChatUtil.BLUE + scoreManager.getPosition(new ChallengePlayer(p)) + ChatUtil.RED + " | " + ChatUtil.GREEN + "Distanz zum Spawn: " + ChatUtil.BLUE + scoreManager.getScore(new ChallengePlayer(p)) + " Blöcke"); + } else { + bossBar.setTitle(ChatUtil.GREEN + "Position: " + ChatUtil.BLUE + scoreManager.getPosition(new ChallengePlayer(p)) + ChatUtil.RED + " | " + ChatUtil.GREEN + ChatColor.BOLD + "†" + ChatUtil.RED + "Distanz zum Spawn: " + ChatUtil.BLUE + scoreManager.getScore(new ChallengePlayer(p)) + " Blöcke"); + } } } } diff --git a/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java b/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java index d06f153..7617522 100644 --- a/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java +++ b/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java @@ -43,7 +43,7 @@ ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat die Lobby betreten! " + ChatUtil.YELLOW + "[" + (Bukkit.getServer().getOnlinePlayers().size() - plugin.getVanish().countVanishPlayers()) + "/" + Bukkit.getServer().getMaxPlayers() + "]"); e.setJoinMessage(null); if (plugin.getServerType() != ServerType.ADVENTURE) { - if (!DeathrunChallengeEvent.getDeadPlayer().contains(p.getUniqueId().toString())) { + if (!DeathrunChallengeEvent.getDeadPlayer().contains(p.getUniqueId())) { plugin.getScoreManager().join(new ChallengePlayer(p)); plugin.getSBManager().setScoreboardtoPlayer(p); plugin.getSBManager().updateEventScoreboard();