diff --git a/Plugin/src/main/java/dev/rosewood/rosestacker/config/SettingKey.java b/Plugin/src/main/java/dev/rosewood/rosestacker/config/SettingKey.java index 7554c2e1..ec1af488 100644 --- a/Plugin/src/main/java/dev/rosewood/rosestacker/config/SettingKey.java +++ b/Plugin/src/main/java/dev/rosewood/rosestacker/config/SettingKey.java @@ -241,6 +241,7 @@ public final class SettingKey implements SettingHolder { public static final RoseSetting MISC_INSIGHTS_LOGGING = create("misc-settings.insights-logging-enabled", BOOLEAN, true, "If Insights is installed, should we track stacked block/spawner break/placing?"); public static final RoseSetting MISC_CLEARALL_REMOVE_SINGLE = create("misc-settings.clearall-remove-single", BOOLEAN, false, "Should single mobs be removed with `/rs clearall`?"); public static final RoseSetting MISC_MYTHICMOBS_ALLOW_STACKING = create("misc-settings.mythicmobs-allow-stacking", BOOLEAN, false, "Should mobs owned by MythicMobs be allowed to stack?", "This is recommended to keep set to false unless you specifically only change mob attributes", "Having this disabled will also disable the entity instant-stack setting due to the timing of MythicMob spawns"); + public static final RoseSetting MISC_MYTHICMOBS_ALLOW_DISABLE_AI = create("misc-settings.mythicmobs-allow-disable-ai", BOOLEAN, true, "Should RoseStacker be allowed to disable the AI of MythicMobs entities?", "If false, RoseStacker will never disable the AI of a MythicMobs entity,", "even if the entity type is configured with disable-all-mob-ai or spawner disable-mob-ai"); public static final RoseSetting MISC_INFERNALMOBS_ALLOW_STACKING = create("misc-settings.infernalmobs-allow-stacking", BOOLEAN, false, "Should mobs from InfernalMobs be allowed to stack?", "Recommended to keep set to false to not interfere with InfernalMobs"); public static final RoseSetting MISC_LEVELLEDMOBS_ALLOW_STACKING = create("misc-settings.levelledmobs-allow-stacking", BOOLEAN, false, "Should mobs from LevelledMobs be allowed to stack?", "Recommended to keep set to false to not interfere with LevelledMobs"); public static final RoseSetting MISC_SPAWNER_PERSISTENT_COMPATIBILITY = create("misc-settings.spawner-persistent-compatibility", BOOLEAN, true, "Some plugins like Jobs, mcMMO, and RoseLoot store special data for spawner mobs.", "Disabling this will cause the functionality within those plugins to break.", "The individual plugin hooks can be configured separately below"); diff --git a/Plugin/src/main/java/dev/rosewood/rosestacker/hook/NPCsHook.java b/Plugin/src/main/java/dev/rosewood/rosestacker/hook/NPCsHook.java index 7c1b107f..6d40dbab 100644 --- a/Plugin/src/main/java/dev/rosewood/rosestacker/hook/NPCsHook.java +++ b/Plugin/src/main/java/dev/rosewood/rosestacker/hook/NPCsHook.java @@ -64,6 +64,14 @@ public static boolean mythicMobsEnabled() { return mythicMobsEnabled = Bukkit.getPluginManager().isPluginEnabled("MythicMobs"); } + /** + * @param entity the entity to check + * @return true if this entity is a MythicMobs entity, false otherwise + */ + public static boolean isMythicMob(LivingEntity entity) { + return mythicMobsEnabled() && MythicBukkit.inst().getAPIHelper().isMythicMob(entity); + } + /** * @return true if EpicBosses is enabled, false otherwise */ diff --git a/Plugin/src/main/java/dev/rosewood/rosestacker/utils/PersistentDataUtils.java b/Plugin/src/main/java/dev/rosewood/rosestacker/utils/PersistentDataUtils.java index ab5237b6..f2472d32 100644 --- a/Plugin/src/main/java/dev/rosewood/rosestacker/utils/PersistentDataUtils.java +++ b/Plugin/src/main/java/dev/rosewood/rosestacker/utils/PersistentDataUtils.java @@ -3,6 +3,7 @@ import dev.rosewood.rosegarden.RosePlugin; import dev.rosewood.rosestacker.RoseStacker; import dev.rosewood.rosestacker.config.SettingKey; +import dev.rosewood.rosestacker.hook.NPCsHook; import dev.rosewood.rosestacker.manager.StackSettingManager; import dev.rosewood.rosestacker.nms.NMSAdapter; import dev.rosewood.rosestacker.nms.NMSHandler; @@ -42,6 +43,9 @@ public static boolean isUnstackable(Entity entity) { } public static void removeEntityAi(LivingEntity entity) { + if (!SettingKey.MISC_MYTHICMOBS_ALLOW_DISABLE_AI.get() && NPCsHook.isMythicMob(entity)) + return; + RosePlugin rosePlugin = RoseStacker.getInstance(); PersistentDataContainer dataContainer = entity.getPersistentDataContainer(); NamespacedKey key = new NamespacedKey(rosePlugin, NO_AI_METADATA_NAME); @@ -65,6 +69,9 @@ public static void applyDisabledAi(LivingEntity entity) { } public static void applyDisabledAi(LivingEntity entity, boolean disable) { + if (disable && !SettingKey.MISC_MYTHICMOBS_ALLOW_DISABLE_AI.get() && NPCsHook.isMythicMob(entity)) + return; + if (isAiDisabled(entity) || !disable) { if (SettingKey.SPAWNER_DISABLE_MOB_AI_OPTIONS_REMOVE_GOALS.get() && disable) { NMSHandler nmsHandler = NMSAdapter.getHandler();