diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java index b3d9790f..0b179790 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/AnticheatManager.java @@ -11,16 +11,11 @@ import java.util.Set; public class AnticheatManager { private static final Set anticheats = new HashSet<>(); - public static boolean registerIfPresent(AnticheatWrapper anticheat) { - if(Bukkit.getPluginManager().isPluginEnabled(anticheat.getPluginName())) { - if(anticheat instanceof Listener) { - Bukkit.getPluginManager().registerEvents((Listener) anticheat, EcoEnchantsPlugin.getInstance()); - } - - anticheats.add(anticheat); - return true; + public static void register(AnticheatWrapper anticheat) { + if(anticheat instanceof Listener) { + Bukkit.getPluginManager().registerEvents((Listener) anticheat, EcoEnchantsPlugin.getInstance()); } - return false; + anticheats.add(anticheat); } public static void exemptPlayer(Player player) { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java index 0d425353..8cdcefe1 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/AntigriefManager.java @@ -1,6 +1,5 @@ package com.willfp.ecoenchants.integrations.antigrief; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; @@ -12,12 +11,8 @@ import java.util.Set; public class AntigriefManager { private static final Set antigriefs = new HashSet<>(); - public static boolean registerIfPresent(AntigriefWrapper antigrief) { - if(Bukkit.getPluginManager().isPluginEnabled(antigrief.getPluginName())) { - antigriefs.add(antigrief); - return true; - } - return false; + public static void register(AntigriefWrapper antigrief) { + antigriefs.add(antigrief); } /** diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java index d1d80680..6c6ab72e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefKingdoms.java @@ -14,10 +14,11 @@ import org.kingdoms.managers.PvPManager; import org.kingdoms.managers.land.LandManager; public final class AntigriefKingdoms implements AntigriefWrapper { + private final LandManager landManager = new LandManager(); + @Override public boolean canBreakBlock(Player player, Block block) { BlockBreakEvent event = new BlockBreakEvent(block, player); - LandManager landManager = new LandManager(); landManager.onBreak(event); return !event.isCancelled(); } @@ -36,7 +37,6 @@ public final class AntigriefKingdoms implements AntigriefWrapper { public boolean canPlaceBlock(Player player, Block block) { Block placedOn = block.getRelative(0, -1, 0); BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), placedOn, player.getInventory().getItemInMainHand(), player, true, EquipmentSlot.HAND); - LandManager landManager = new LandManager(); landManager.onPlace(event); return !event.isCancelled(); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java index 0afacd69..d16eca2e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/essentials/EssentialsManager.java @@ -1,19 +1,13 @@ package com.willfp.ecoenchants.integrations.essentials; -import org.bukkit.Bukkit; - import java.util.HashSet; import java.util.Set; public class EssentialsManager { private static final Set registered = new HashSet<>(); - public static boolean registerIfPresent(EssentialsWrapper essentials) { - if(Bukkit.getPluginManager().isPluginEnabled(essentials.getPluginName())) { - registered.add(essentials); - return true; - } - return false; + public static void register(EssentialsWrapper essentials) { + registered.add(essentials); } public static void registerEnchantments() { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java b/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java index 82d514cb..867fb2eb 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/loader/Loader.java @@ -320,72 +320,85 @@ public class Loader { Logger.info(""); Logger.info("Loading Integrations..."); - if(AntigriefManager.registerIfPresent(new AntigriefWorldGuard())) { + if(Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) { + AntigriefManager.register(new AntigriefWorldGuard()); Logger.info("WorldGuard: §aENABLED"); } else { Logger.info("WorldGuard: §9DISABLED"); } - if(AntigriefManager.registerIfPresent(new AntigriefFactionsUUID())) { - Logger.info("FactionsUUID: §aENABLED"); - } else { - Logger.info("FactionsUUID: §9DISABLED"); - } - - if(AntigriefManager.registerIfPresent(new AntigriefGriefPrevention())) { + if(Bukkit.getPluginManager().isPluginEnabled("GriefPrevention")) { + AntigriefManager.register(new AntigriefGriefPrevention()); Logger.info("GriefPrevention: §aENABLED"); } else { Logger.info("GriefPrevention: §9DISABLED"); } - if(AntigriefManager.registerIfPresent(new AntigriefKingdoms())) { - Logger.info("Kingdoms: §aENABLED"); + if(Bukkit.getPluginManager().isPluginEnabled("FactionsUUID")) { + AntigriefManager.register(new AntigriefFactionsUUID()); + Logger.info("FactionsUUID: §aENABLED"); } else { - Logger.info("Kingdoms: §9DISABLED"); + Logger.info("FactionsUUID: §9DISABLED"); } - if(AntigriefManager.registerIfPresent(new AntigriefLands())) { - Logger.info("Lands: §aENABLED"); - } else { - Logger.info("Lands: §9DISABLED"); - } - - if(AntigriefManager.registerIfPresent(new AntigriefTowny())) { + if(Bukkit.getPluginManager().isPluginEnabled("Towny")) { + AntigriefManager.register(new AntigriefTowny()); Logger.info("Towny: §aENABLED"); } else { Logger.info("Towny: §9DISABLED"); } - if(EssentialsManager.registerIfPresent(new IntegrationEssentials())) { + if(Bukkit.getPluginManager().isPluginEnabled("Lands")) { + AntigriefManager.register(new AntigriefLands()); + Logger.info("Lands: §aENABLED"); + } else { + Logger.info("Lands: §9DISABLED"); + } + + if(Bukkit.getPluginManager().isPluginEnabled("Kingdoms")) { + AntigriefManager.register(new AntigriefKingdoms()); + Logger.info("Kingdoms: §aENABLED"); + } else { + Logger.info("Kingdoms: §9DISABLED"); + } + + if(Bukkit.getPluginManager().isPluginEnabled("Essentials")) { + EssentialsManager.register(new IntegrationEssentials()); Logger.info("Essentials: §aENABLED"); + EssentialsManager.registerEnchantments(); } else { Logger.info("Essentials: §9DISABLED"); } - if(AnticheatManager.registerIfPresent(new AnticheatAAC())) { + if(Bukkit.getPluginManager().isPluginEnabled("AAC")) { + AnticheatManager.register(new AnticheatAAC()); Logger.info("AAC: §aENABLED"); } else { Logger.info("AAC: §9DISABLED"); } - if(AnticheatManager.registerIfPresent(new AnticheatMatrix())) { + if(Bukkit.getPluginManager().isPluginEnabled("Matrix")) { + AnticheatManager.register(new AnticheatMatrix()); Logger.info("Matrix: §aENABLED"); } else { Logger.info("Matrix: §9DISABLED"); } - if(AnticheatManager.registerIfPresent(new AnticheatNCP())) { + if(Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { + AnticheatManager.register(new AnticheatNCP()); Logger.info("NCP: §aENABLED"); } else { Logger.info("NCP: §9DISABLED"); } - if(AnticheatManager.registerIfPresent(new AnticheatSpartan())) { + if(Bukkit.getPluginManager().isPluginEnabled("Spartan")) { + AnticheatManager.register(new AnticheatSpartan()); Logger.info("Spartan: §aENABLED"); } else { Logger.info("Spartan: §9DISABLED"); } + /* Check for paper */