diff --git a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java index e1eb374..4443a27 100644 --- a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java +++ b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java @@ -8,7 +8,6 @@ import org.sayandev.sayanvanish.api.SayanVanishAPI; import org.sayandev.sayanvanish.bukkit.api.BukkitUser; import org.sayandev.sayanvanish.bukkit.api.SayanVanishBukkitAPI; - import org.bukkit.entity.Player; import java.util.UUID; diff --git a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java index b1a4446..e306468 100644 --- a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java +++ b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java @@ -24,8 +24,6 @@ import java.util.List; import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; public class EntityDeath implements Listener { @@ -65,27 +63,27 @@ void onEntityDeath(EntityDeathEvent e) { } else { // Killed by mob Entity ent = pm.getLastEntityDamager(); - String mobName = EntityUtil.getConfigNodeByEntity(ent); - int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Radius"); - int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Amount"); - boolean gangKill = false; if (Gangs.getInstance().getConfig().getBoolean("Gang.Enabled")) { + String mobName = EntityUtil.getConfigNodeByEntity(ent); + int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Radius"); + int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Amount"); + int totalMobEntities = 0; - // Dreeam TODO: need move to EntityUtil - Predicate isNotDragonParts = entity -> !entity.toString().contains("EnderDragonPart"); // Exclude EnderDragonPart - List entities = player.getNearbyEntities(radius, radius, radius).stream() - .filter(isNotDragonParts).collect(Collectors.toList()); + List nearbyEntities = player.getNearbyEntities(radius, radius, radius); - for (Entity entity : entities) { - if (entity.getType().equals(ent.getType())) { - totalMobEntities++; + for (Entity entity : nearbyEntities) { + if (entity.toString().contains("EnderDragonPart")) { // Exclude EnderDragonPart + continue; } - } - if (totalMobEntities >= amount) { - gangKill = true; + if (entity.getType().equals(ent.getType())) { + if (++totalMobEntities >= amount) { + gangKill = true; + break; + } + } } } diff --git a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java index d1d8029..a91d00b 100644 --- a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java +++ b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java @@ -14,7 +14,6 @@ import net.kyori.adventure.text.TextComponent; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -22,8 +21,6 @@ import java.util.List; import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; public class PlayerUntag implements Listener { @@ -36,24 +33,26 @@ public void untagPlayer(PlayerUntagEvent e) { if (!reason.equals(UntagReason.QUIT)) return; - int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Radius"); - int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Amount"); boolean gangKill = false; if (Gangs.getInstance().getConfig().getBoolean("Gang.Enabled")) { + int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Radius"); + int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Amount"); + int totalMobEntities = 0; - Predicate isNotDragonParts = entity -> !entity.toString().contains("EnderDragonPart"); // Exclude EnderDragonPart - List entities = player.getNearbyEntities(radius, radius, radius).stream() - .filter(isNotDragonParts).collect(Collectors.toList()); + List nearbyEntities = player.getNearbyEntities(radius, radius, radius); - for (Entity entity : entities) { - if (entity.getType().equals(EntityType.PLAYER)) { - totalMobEntities++; + for (Entity entity : nearbyEntities) { + if (entity.toString().contains("EnderDragonPart")) { // Exclude EnderDragonPart + continue; } - } - if (totalMobEntities >= amount) { - gangKill = true; + if (entity instanceof Player) { + if (++totalMobEntities >= amount) { + gangKill = true; + break; + } + } } } diff --git a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java index 64bec86..ee606d6 100644 --- a/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java +++ b/DeathMessagesLegacy/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java @@ -1,7 +1,5 @@ package dev.mrshawn.deathmessages.utils; -import dev.mrshawn.deathmessages.DeathMessages; - public class PlatformUtil { //public static final boolean IS_FOLIA = DeathMessages.getInstance().foliaLib.isFolia(); diff --git a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java index e1eb374..4443a27 100644 --- a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java +++ b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/hooks/SayanVanishExtension.java @@ -8,7 +8,6 @@ import org.sayandev.sayanvanish.api.SayanVanishAPI; import org.sayandev.sayanvanish.bukkit.api.BukkitUser; import org.sayandev.sayanvanish.bukkit.api.SayanVanishBukkitAPI; - import org.bukkit.entity.Player; import java.util.UUID; diff --git a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamage.java b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamage.java index 3d6507e..ba4ddf9 100644 --- a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamage.java +++ b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamage.java @@ -6,7 +6,6 @@ import dev.mrshawn.deathmessages.config.EntityDeathMessages; import dev.mrshawn.deathmessages.enums.MobType; import dev.mrshawn.deathmessages.utils.EntityUtil; -import dev.mrshawn.deathmessages.utils.Util; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.LivingEntity; diff --git a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamageByEntity.java b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamageByEntity.java index 7c09407..c425624 100644 --- a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamageByEntity.java +++ b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDamageByEntity.java @@ -6,7 +6,6 @@ import dev.mrshawn.deathmessages.config.EntityDeathMessages; import dev.mrshawn.deathmessages.enums.MobType; import dev.mrshawn.deathmessages.utils.EntityUtil; -import dev.mrshawn.deathmessages.utils.Util; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.AreaEffectCloud; diff --git a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java index b1a4446..e306468 100644 --- a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java +++ b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/EntityDeath.java @@ -24,8 +24,6 @@ import java.util.List; import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; public class EntityDeath implements Listener { @@ -65,27 +63,27 @@ void onEntityDeath(EntityDeathEvent e) { } else { // Killed by mob Entity ent = pm.getLastEntityDamager(); - String mobName = EntityUtil.getConfigNodeByEntity(ent); - int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Radius"); - int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Amount"); - boolean gangKill = false; if (Gangs.getInstance().getConfig().getBoolean("Gang.Enabled")) { + String mobName = EntityUtil.getConfigNodeByEntity(ent); + int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Radius"); + int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs." + mobName + ".Amount"); + int totalMobEntities = 0; - // Dreeam TODO: need move to EntityUtil - Predicate isNotDragonParts = entity -> !entity.toString().contains("EnderDragonPart"); // Exclude EnderDragonPart - List entities = player.getNearbyEntities(radius, radius, radius).stream() - .filter(isNotDragonParts).collect(Collectors.toList()); + List nearbyEntities = player.getNearbyEntities(radius, radius, radius); - for (Entity entity : entities) { - if (entity.getType().equals(ent.getType())) { - totalMobEntities++; + for (Entity entity : nearbyEntities) { + if (entity.toString().contains("EnderDragonPart")) { // Exclude EnderDragonPart + continue; } - } - if (totalMobEntities >= amount) { - gangKill = true; + if (entity.getType().equals(ent.getType())) { + if (++totalMobEntities >= amount) { + gangKill = true; + break; + } + } } } diff --git a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java index b73845e..54a49d7 100644 --- a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java +++ b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/listeners/combatlogx/PlayerUntag.java @@ -14,7 +14,6 @@ import net.kyori.adventure.text.TextComponent; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -22,8 +21,6 @@ import java.util.List; import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; public class PlayerUntag implements Listener { @@ -36,24 +33,26 @@ public void untagPlayer(PlayerUntagEvent e) { if (!reason.equals(UntagReason.QUIT)) return; - int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Radius"); - int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Amount"); boolean gangKill = false; if (Gangs.getInstance().getConfig().getBoolean("Gang.Enabled")) { + int radius = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Radius"); + int amount = Gangs.getInstance().getConfig().getInt("Gang.Mobs.player.Amount"); + int totalMobEntities = 0; - Predicate isNotDragonParts = entity -> !entity.toString().contains("EnderDragonPart"); // Exclude EnderDragonPart - List entities = player.getNearbyEntities(radius, radius, radius).stream() - .filter(isNotDragonParts).collect(Collectors.toList()); + List nearbyEntities = player.getNearbyEntities(radius, radius, radius); - for (Entity entity : entities) { - if (entity.getType().equals(EntityType.PLAYER)) { - totalMobEntities++; + for (Entity entity : nearbyEntities) { + if (entity.toString().contains("EnderDragonPart")) { // Exclude EnderDragonPart + continue; } - } - if (totalMobEntities >= amount) { - gangKill = true; + if (entity instanceof Player) { + if (++totalMobEntities >= amount) { + gangKill = true; + break; + } + } } } diff --git a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java index cb34134..515739b 100644 --- a/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java +++ b/DeathMessagesModern/src/main/java/dev/mrshawn/deathmessages/utils/PlatformUtil.java @@ -1,7 +1,5 @@ package dev.mrshawn.deathmessages.utils; -import dev.mrshawn.deathmessages.DeathMessages; - public class PlatformUtil { //public static final boolean IS_FOLIA = DeathMessages.getInstance().foliaLib.isFolia();