diff --git a/src/main/java/de/fanta/challenges/listeners/DamageListener.java b/src/main/java/de/fanta/challenges/listeners/DamageListener.java index 0a3d424..109b3ae 100644 --- a/src/main/java/de/fanta/challenges/listeners/DamageListener.java +++ b/src/main/java/de/fanta/challenges/listeners/DamageListener.java @@ -23,12 +23,10 @@ if (plugin.getConfig().getBoolean("dmginchat")) { if ((e.getFinalDamage() > 0) && (e.getFinalDamage() < 10000)) { if (!e.getCause().name().startsWith("ENTITY_")) { - if (e.getCause() == DamageCause.FALL) { - ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause()); - } else if (e.getCause() == DamageCause.CUSTOM) { + if (e.getCause() == DamageCause.CUSTOM) { ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + plugin.getConfig().getDouble("sneakdmg") + ChatUtil.GREEN + " HP Schaden genommen durch" + ChatUtil.ORANGE + " Server"); } else { - ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause()); + ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause().toString().replace("_", " ").toLowerCase()); } } } @@ -48,7 +46,14 @@ if ((e.getEntity() instanceof Player p) && (e.getFinalDamage() > 0) && !plugin.getVanish().isVanish(p)) { String dmg = new DecimalFormat("#.##").format(e.getFinalDamage()); if ((e.getCause() == DamageCause.ENTITY_ATTACK || e.getCause() == DamageCause.ENTITY_EXPLOSION) && plugin.getConfig().getBoolean("dmginchat")) { + if (e.getDamager() instanceof Player damager) { + if (!plugin.getVanish().isVanish(damager)) { + ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getDamager().getName()); + } + } else { ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getDamager().getName()); + } + } } } diff --git a/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java b/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java index a17fca2..37c6d13 100644 --- a/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java +++ b/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java @@ -12,6 +12,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; @@ -21,7 +22,7 @@ private final Challenges plugin = Challenges.getPlugin(); - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); @@ -38,34 +39,32 @@ p.teleport(netherspawn); } - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { - if (!plugin.getVanish().isVanish(p)) { - ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat die Lobby betreten! " + ChatColor.of("#E4E737") + "[" + (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())) { - plugin.getSBManager().setScoreboard(p); - plugin.getSBManager().updateEventScoreboard(); - } + if (!plugin.getVanish().isVanish(p)) { + ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat die Lobby betreten! " + ChatColor.of("#E4E737") + "[" + (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())) { + plugin.getSBManager().setScoreboard(p); + plugin.getSBManager().updateEventScoreboard(); } - if (plugin.getCurrentEditor() == null) { - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { - if (p.hasPermission("Challenges.editor")) { - plugin.setCurrentEditor(p); - plugin.setFirstEditor(p); - - } else { - ChatUtil.sendWarningMessage(p, "Es ist aktuell kein Editor in dieser Lobby"); - ChatUtil.sendWarningMessage(p, "Um selbst Editor zu werden musst du VIP sein!"); - } - }, 1L); - } else { - ChatUtil.sendNormalMessage(p, ChatUtil.BLUE + plugin.getCurrentEditor().getName() + ChatUtil.GREEN + " ist der Editor dieser Lobby!"); - } - } else { - ChatUtil.sendNormalMessage(p, "Du bist im Vanish, niemand weiß, dass du in der Lobby bist."); } - }, 10L); + if (plugin.getCurrentEditor() == null) { + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { + if (p.hasPermission("Challenges.editor")) { + plugin.setCurrentEditor(p); + plugin.setFirstEditor(p); + + } else { + ChatUtil.sendWarningMessage(p, "Es ist aktuell kein Editor in dieser Lobby"); + ChatUtil.sendWarningMessage(p, "Um selbst Editor zu werden musst du VIP sein!"); + } + }, 1L); + } else { + ChatUtil.sendNormalMessage(p, ChatUtil.BLUE + plugin.getCurrentEditor().getName() + ChatUtil.GREEN + " ist der Editor dieser Lobby!"); + } + } else { + ChatUtil.sendNormalMessage(p, "Du bist im Vanish, niemand weiß, dass du in der Lobby bist."); + } Bukkit.getPluginManager().callEvent(new PlayerCountChangedEvent(Bukkit.getOnlinePlayers().size() - plugin.getVanish().countVanishPlayers())); @@ -131,9 +130,7 @@ Bukkit.getPluginManager().callEvent(new PlayerCountChangedEvent(Bukkit.getOnlinePlayers().size() - plugin.getVanish().countVanishPlayers() - 1)); if (plugin.isWaitingForShutdown() && Bukkit.getOnlinePlayers().size() == 1) { - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { - Bukkit.getPluginManager().callEvent(new ServerStatusChangedEvent(false)); - }, 1L); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getPluginManager().callEvent(new ServerStatusChangedEvent(false)), 1L); } } }