diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java index 0dd9069f..59e60973 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java @@ -28,8 +28,6 @@ import com.willfp.ecoenchants.enchantments.util.HoldItemListener; import com.willfp.ecoenchants.enchantments.util.WatcherTriggers; import com.willfp.ecoenchants.integrations.essentials.EssentialsManager; import com.willfp.ecoenchants.integrations.essentials.plugins.IntegrationEssentials; -import com.willfp.ecoenchants.integrations.worldguard.WorldguardManager; -import com.willfp.ecoenchants.integrations.worldguard.plugins.WorldguardIntegrationImpl; import com.willfp.ecoenchants.proxy.proxies.FastGetEnchantsProxy; import com.willfp.ecoenchants.util.ProxyUtils; import lombok.Getter; @@ -143,9 +141,6 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin { @Override public List getIntegrationLoaders() { return Arrays.asList( - new IntegrationLoader("WorldGuard", () -> { - WorldguardManager.register(new WorldguardIntegrationImpl()); - }), new IntegrationLoader("Essentials", () -> EssentialsManager.register(new IntegrationEssentials())) ); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardManager.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardManager.java deleted file mode 100644 index c93c8a7e..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardManager.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.willfp.ecoenchants.integrations.worldguard; - -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import lombok.experimental.UtilityClass; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -import java.util.HashSet; -import java.util.Set; - -@UtilityClass -public class WorldguardManager { - /** - * All registered WorldGuard integrations. - */ - private static final Set REGISTERED = new HashSet<>(); - - /** - * Register a new WorldGuard integration. - * - * @param worldguard The integration to register. - */ - public static void register(@NotNull final WorldguardWrapper worldguard) { - REGISTERED.add(worldguard); - } - - /** - * Register a new StateFlag with worldguard. - * - * @param flagName The name of the flag. - * @param defaultValue The default value for the flag to have. - */ - public static void registerFlag(@NotNull final String flagName, - final boolean defaultValue) { - REGISTERED.forEach(worldguardWrapper -> worldguardWrapper.registerFlag(flagName, defaultValue)); - } - - /** - * Get if an enchant is enabled at a player's location. - * - * @param enchant The enchantment to check. - * @param player The player to query. - * @return If the enchantment is enabled at a player's location. - */ - public static boolean enabledForPlayer(@NotNull final EcoEnchant enchant, - @NotNull final LivingEntity player) { - if (!(player instanceof Player)) { - return true; - } - if (REGISTERED.isEmpty()) { - return true; - } - - for (WorldguardWrapper worldguardWrapper : REGISTERED) { - if (worldguardWrapper.enabledForPlayer(enchant, (Player) player, player.getLocation())) { - return true; - } - } - return false; - } - - /** - * Get if an enchant is enabled at a specific location. - * - * @param enchant The enchantment to check. - * @param player The player to query. - * @param location The location to query. - * @return If the enchantment is enabled at a player's location. - */ - public static boolean enabledForPlayer(@NotNull final EcoEnchant enchant, - @NotNull final LivingEntity player, - @NotNull final Location location) { - if (!(player instanceof Player)) { - return true; - } - if (REGISTERED.isEmpty()) { - return true; - } - - for (WorldguardWrapper worldguardWrapper : REGISTERED) { - if (worldguardWrapper.enabledForPlayer(enchant, (Player) player, location)) { - return true; - } - } - return false; - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardWrapper.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardWrapper.java deleted file mode 100644 index 0c2fba1f..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/WorldguardWrapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.willfp.ecoenchants.integrations.worldguard; - -import com.willfp.eco.util.integrations.Integration; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -public interface WorldguardWrapper extends Integration { - /** - * Register a flag with WorldGuard. - * - * @param name The name of the flag. - * @param def The default value for the flag to have. - */ - void registerFlag(String name, boolean def); - - /** - * Get if an enchantment is available to be used at a specific location by a player. - * - * @param enchant The enchantment to query. - * @param player The player to query. - * @param location The location to query. - * @return If the enchantment is allowed to be used. - */ - boolean enabledForPlayer(EcoEnchant enchant, Player player, Location location); -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/plugins/WorldguardIntegrationImpl.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/plugins/WorldguardIntegrationImpl.java deleted file mode 100644 index 14aeec99..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/integrations/worldguard/plugins/WorldguardIntegrationImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.willfp.ecoenchants.integrations.worldguard.plugins; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldguard.WorldGuard; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.StateFlag; -import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; -import com.willfp.ecoenchants.enchantments.EcoEnchant; -import com.willfp.ecoenchants.integrations.worldguard.WorldguardWrapper; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -public class WorldguardIntegrationImpl implements WorldguardWrapper { - /** - * Flag registry. - */ - private static final FlagRegistry REGISTRY = WorldGuard.getInstance().getFlagRegistry(); - - @Override - public void registerFlag(@NotNull final String name, - final boolean def) { - StateFlag flag = new StateFlag(name, def); - if (REGISTRY.get(name) == null) { - REGISTRY.register(flag); - } - } - - @Override - public boolean enabledForPlayer(@NotNull final EcoEnchant enchant, - @NotNull final Player player, - @NotNull final Location location) { - if (WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(WorldGuardPlugin.inst().wrapPlayer(player), BukkitAdapter.adapt(location.getWorld()))) { - return true; - } - - return WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery() - .queryState(BukkitAdapter.adapt(location), WorldGuardPlugin.inst().wrapPlayer(player), (StateFlag) REGISTRY.get(enchant.getKey().getKey() + "-enabled")) == StateFlag.State.ALLOW; - } - - @Override - public String getPluginName() { - return "WorldGuard"; - } -}