diff --git a/Challenges.iml b/Challenges.iml new file mode 100644 index 0000000..a301989 --- /dev/null +++ b/Challenges.iml @@ -0,0 +1,57 @@ + + + + + + + PAPER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/de/fanta/challenges/listeners/DamageListener.java b/src/main/java/de/fanta/challenges/listeners/DamageListener.java index 602b53e..25efefa 100644 --- a/src/main/java/de/fanta/challenges/listeners/DamageListener.java +++ b/src/main/java/de/fanta/challenges/listeners/DamageListener.java @@ -36,24 +36,33 @@ return; } } + if (e.getEntity() instanceof Player p) { String dmg = new DecimalFormat("#.##").format(e.getFinalDamage()); if (e.getFinalDamage() > 0) { if (e.getCause() == DamageCause.FALL) { if (plugin.getConfig().getBoolean("deathonfall")) { if (plugin.getConfig().getBoolean("dmginchat")) { - ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause()); + if (!e.getCause().name().equals("ENTITY_ATTACK")) { + ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause()); + } } Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> p.setHealth(0), 1); } else if (plugin.getConfig().getBoolean("dmginchat")) { - ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause()); + if (!e.getCause().name().equals("ENTITY_ATTACK")) { + 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 (!p.isSneaking() && (plugin.getConfig().getBoolean("dmginchat"))) { 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 if (plugin.getConfig().getBoolean("dmginchat")) { - ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause()); + if (!e.getCause().name().equals("ENTITY_ATTACK")) { + ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getCause()); + } + } if (plugin.getConfig().getBoolean("sharedmg")) { for (Player pp : Bukkit.getOnlinePlayers()) { @@ -92,10 +101,18 @@ return; } } + + if (e.getDamager() instanceof Player p) { + if (plugin.getVanish().isVanish(p)) { + return; + } + } + if ((e.getEntity() instanceof Player p) && (e.getFinalDamage() > 0) && (plugin.getTimer().isRunning())) { String dmg = new DecimalFormat("#.##").format(e.getFinalDamage()); if ((e.getCause() == DamageCause.ENTITY_ATTACK || e.getCause() == DamageCause.ENTITY_EXPLOSION) && plugin.getConfig().getBoolean("dmginchat")) { - ChatUtil.sendBrodcastMessage(ChatUtil.BLUE + p.getName() + ChatUtil.GREEN + " hat " + ChatUtil.ORANGE + dmg + ChatUtil.GREEN + " HP Schaden genommen durch " + ChatUtil.ORANGE + e.getDamager().getName()); + 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 e73d31a..6eb8d12 100644 --- a/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java +++ b/src/main/java/de/fanta/challenges/listeners/QuitJoinListener.java @@ -96,12 +96,14 @@ public void onPlayerQuit(PlayerQuitEvent e) { Player player = e.getPlayer(); - if (Bukkit.getOnlinePlayers().size() - plugin.getVanish().countVanishPlayers() - 1 == 0) { + if (Bukkit.getOnlinePlayers().size() - plugin.getVanish().countVanishPlayers() == 0) { plugin.getTimer().stopTimer(); + Challenges.LOGGER.info("Stop Timer " + (Bukkit.getOnlinePlayers().size() - plugin.getVanish().countVanishPlayers())); } - if (Bukkit.getServer().getOnlinePlayers().size() - 1 == 0) { + if (Bukkit.getServer().getOnlinePlayers().size() == 0) { plugin.startResetTask(); + Challenges.LOGGER.info("Player Reset Task " + (Bukkit.getServer().getOnlinePlayers().size())); } if (!plugin.getVanish().isVanish(player)) {