diff --git a/pom.xml b/pom.xml index 3e58e07..d00057f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ com.songoda UltimateStacker 4.0.0 - 1.11.1 + 1.11.2 clean install UltimateStacker-${project.version} diff --git a/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java b/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java index a3505b1..8c574da 100644 --- a/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java +++ b/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java @@ -110,6 +110,8 @@ public class EntityStack { } private void handleWholeStackDeath(LivingEntity killed, List drops, boolean custom, int droppedExp, EntityDeathEvent event) { + UltimateStacker.getInstance().getEntityStackManager().removeStack(event.getEntity()); + Location killedLocation = killed.getLocation(); List preStackedDrops = new ArrayList<>(); for (int i = 1; i < amount; i++) { @@ -172,8 +174,7 @@ public class EntityStack { public void onDeath(LivingEntity killed, List drops, boolean custom, int droppedExp, EntityDeathEvent event) { killed.setCustomName(null); - killed.setCustomNameVisible(true); - killed.setCustomName(Methods.formatText("&7")); + killed.setCustomNameVisible(false); boolean killWholeStack = Settings.KILL_WHOLE_STACK_ON_DEATH.getBoolean() || plugin.getMobFile().getBoolean("Mobs." + killed.getType().name() + ".Kill Whole Stack"); diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java index b0be237..62e155d 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java @@ -7,6 +7,7 @@ import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.entity.EntityStack; import com.songoda.ultimatestacker.settings.Settings; import com.songoda.ultimatestacker.utils.DropUtils; +import org.bukkit.GameRule; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.ChestedHorse; @@ -52,6 +53,9 @@ public class DeathListeners implements Listener { } } + if (!event.getEntity().getWorld().getGameRuleValue(GameRule.DO_MOB_LOOT)) + drops.clear(); + if (instance.getEntityStackManager().isStacked(event.getEntity())) instance.getEntityStackManager().getStack(event.getEntity()) .onDeath(event.getEntity(), drops, custom, event.getDroppedExp(), event); diff --git a/src/main/java/com/songoda/ultimatestacker/settings/Settings.java b/src/main/java/com/songoda/ultimatestacker/settings/Settings.java index c55e69a..4d8fc8a 100644 --- a/src/main/java/com/songoda/ultimatestacker/settings/Settings.java +++ b/src/main/java/com/songoda/ultimatestacker/settings/Settings.java @@ -145,6 +145,11 @@ public class Settings { "With this enabled any metadata assigned from supported plugins such", "as EpicSpawners and mcMMO will be preserved when the entity is killed."); + public static final ConfigSetting WEAPONS_ARENT_EQUIPMENT = new ConfigSetting(config, "Entities.Weapons Arent Equipment", false, + "This allows entities holding weapons to stack. Enchanted weapons are excluded.", + "If you would like to disable the stacked entity check you can do that by removing", + "\"HAS_EQUIPMENT\", from the list above."); + public static final ConfigSetting ONLY_STACK_ON_SURFACE = new ConfigSetting(config, "Entities.Only Stack On Surface", true, "Should entities only be stacked if they are touching the ground", "or swimming? This does not effect flying entities."); diff --git a/src/main/java/com/songoda/ultimatestacker/utils/EntityUtils.java b/src/main/java/com/songoda/ultimatestacker/utils/EntityUtils.java index 5751d04..b967dda 100644 --- a/src/main/java/com/songoda/ultimatestacker/utils/EntityUtils.java +++ b/src/main/java/com/songoda/ultimatestacker/utils/EntityUtils.java @@ -10,6 +10,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; +import org.bukkit.inventory.EntityEquipment; import java.util.*; import java.util.stream.Collectors; @@ -19,10 +20,11 @@ public class EntityUtils { UltimateStacker plugin = UltimateStacker.getInstance(); private final List checks = Settings.STACK_CHECKS.getStringList(); - private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean(); - private final boolean keepFire = Settings.KEEP_FIRE.getBoolean(); - private final boolean keepPotion = Settings.KEEP_POTION.getBoolean(); - private final boolean stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean(); + private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean(), + keepFire = Settings.KEEP_FIRE.getBoolean(), + keepPotion = Settings.KEEP_POTION.getBoolean(), + stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean(), + weaponsArentEquipment = Settings.WEAPONS_ARENT_EQUIPMENT.getBoolean(); private final int searchRadius = Settings.SEARCH_RADIUS.getInt(); private final Map cachedChunks = new HashMap<>(); @@ -503,16 +505,15 @@ public class EntityUtils { } public boolean isEquipped(LivingEntity initialEntity) { - return initialEntity.getEquipment() != null - && (initialEntity.getEquipment().getItemInHand().getType() != Material.AIR - || (initialEntity.getEquipment().getHelmet() != null - && initialEntity.getEquipment().getHelmet().getType() != Material.AIR) - || (initialEntity.getEquipment().getChestplate() != null - && initialEntity.getEquipment().getChestplate().getType() != Material.AIR) - || (initialEntity.getEquipment().getLeggings() != null - && initialEntity.getEquipment().getLeggings().getType() != Material.AIR) - || (initialEntity.getEquipment().getBoots() != null - && initialEntity.getEquipment().getBoots().getType() != Material.AIR)); + if (initialEntity.getEquipment() == null) return false; + EntityEquipment equipment = initialEntity.getEquipment(); + + return (equipment.getItemInHand().getType() != Material.AIR + && !weaponsArentEquipment && !equipment.getItemInHand().getEnchantments().isEmpty() + || (equipment.getHelmet() != null && equipment.getHelmet().getType() != Material.AIR) + || (equipment.getChestplate() != null && equipment.getChestplate().getType() != Material.AIR) + || (equipment.getLeggings() != null && equipment.getLeggings().getType() != Material.AIR) + || (equipment.getBoots() != null && equipment.getBoots().getType() != Material.AIR)); } public void splitFromStack(LivingEntity entity) {