diff --git a/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java b/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java index 446e434..ff1c319 100644 --- a/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java +++ b/src/main/java/com/songoda/ultimatestacker/UltimateStacker.java @@ -12,6 +12,7 @@ import com.songoda.core.database.MySQLConnector; import com.songoda.core.database.SQLiteConnector; import com.songoda.core.gui.GuiManager; import com.songoda.core.hooks.HologramManager; +import com.songoda.core.hooks.WorldGuardHook; import com.songoda.core.utils.TextUtils; import com.songoda.ultimatestacker.commands.CommandConvert; import com.songoda.ultimatestacker.commands.CommandGiveSpawner; @@ -86,6 +87,9 @@ public class UltimateStacker extends SongodaPlugin { @Override public void onPluginLoad() { INSTANCE = this; + + // Register WorldGuard + WorldGuardHook.addHook("mob-stacking", true); } @Override diff --git a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java index 37556af..998f4a3 100644 --- a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java +++ b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java @@ -1,5 +1,6 @@ package com.songoda.ultimatestacker.tasks; +import com.songoda.core.hooks.WorldGuardHook; import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.entity.EntityStack; import com.songoda.ultimatestacker.entity.EntityStackManager; @@ -147,6 +148,10 @@ public class StackingTask extends BukkitRunnable { // Make sure the entity has not already been processed. if (this.processed.contains(entity.getUniqueId())) continue; + // Check our WorldGuard flag. + if (WorldGuardHook.isEnabled() && !WorldGuardHook.getBooleanFlag(entity.getLocation(), "mob-stacking")) + continue; + // Get this entities friendStack. EntityStack friendStack = stackManager.getStack(entity); @@ -210,6 +215,10 @@ public class StackingTask extends BukkitRunnable { // If our entity is stacked then skip this entity. if (isStack) return; + // Check our WorldGuard flag. + if (WorldGuardHook.isEnabled() && !WorldGuardHook.getBooleanFlag(livingEntity.getLocation(), "mob-stacking")) + return; + // Remove all stacked entities from our stackable friends. stackableFriends.removeIf(stackManager::isStacked); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8f4bd86..110e9c1 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,6 +2,7 @@ name: UltimateStacker description: UltimateStacker version: maven-version-number softdepend: [HolographicDisplays, WorldGuard, EpicSpawners, mcMMO] +loadbefore: [WorldGuard] main: com.songoda.ultimatestacker.UltimateStacker author: songoda api-version: 1.13