From 07d03b2229ee66064434c19b0673f93a619fee22 Mon Sep 17 00:00:00 2001 From: isokissa3 Date: Mon, 12 Nov 2018 20:48:17 +0200 Subject: [PATCH] Cleaned up WG 6/7 combatiblity --- Common/pom.xml | 88 +++++++++++++++++++ .../WorldGuardExtraFlagsPlugin.java | 9 +- .../essentials/EssentialsHelper.java | 0 .../worldguardextraflags/fawe/FAWEHelper.java | 0 .../fawe/FaweWorldEditFlagMaskManager.java | 4 +- .../worldguardextraflags/flags/Flags.java | 10 +-- .../flags/data/PotionEffectDetails.java | 3 - .../flags/data/SoundData.java | 0 .../flags/helpers/MaterialFlag.java | 0 .../flags/helpers/PotionEffectFlag.java | 0 .../flags/helpers/PotionEffectTypeFlag.java | 0 .../flags/helpers/SoundDataFlag.java | 0 .../listeners/BlockListener.java | 0 .../listeners/EntityListener.java | 0 .../listeners/EntityListenerOnePointNine.java | 0 .../listeners/EssentialsListener.java | 0 .../listeners/PlayerListener.java | 0 .../listeners/WorldEditListener.java | 0 .../listeners/WorldListener.java | 0 .../utils/SupportedFeatures.java | 10 --- .../utils/WorldUtils.java | 0 .../we/AbstractWorldEditFlagHandler.java | 0 .../we/WorldEditFlagHandler.java | 0 .../we/WorldEditUtils.java | 0 .../wg/WorldGuardUtils.java | 32 +++++++ .../handlers/BlockedEffectsFlagHandler.java | 14 +-- .../handlers/CommandOnEntryFlagHandler.java | 2 +- .../wg/handlers/CommandOnExitFlagHandler.java | 2 +- .../ConsoleCommandOnEntryFlagHandler.java | 2 +- .../ConsoleCommandOnExitFlagHandler.java | 2 +- .../wg/handlers/FlyFlagHandler.java | 2 +- .../wg/handlers/GiveEffectsFlagHandler.java | 16 +--- .../wg/handlers/GlideFlagHandler.java | 2 +- .../wg/handlers/GodmodeFlagHandler.java | 2 +- .../wg/handlers/PlaySoundsFlagHandler.java | 2 +- .../handlers/TeleportOnEntryFlagHandler.java | 2 +- .../handlers/TeleportOnExitFlagHandler.java | 2 +- .../wg/handlers/WalkSpeedFlagHandler.java | 2 +- Spigot/pom.xml | 71 +++++++++++++++ {src => Spigot/src}/main/resources/plugin.yml | 2 +- WG/pom.xml | 48 ++++++++++ .../AbstractRegionContainerWrapper.java | 9 ++ .../AbstractRegionManagerWrapper.java | 4 +- .../wrappers/AbstractRegionQueryWrapper.java | 4 +- .../AbstractSessionManagerWrapper.java | 4 +- .../wg}/wrappers/HandlerWrapper.java | 4 +- .../wg/wrappers/WorldGuardCommunicator.java | 23 +++++ WG6/pom.xml | 49 +++++++++++ .../wg/wrappers/v6}/CustomSetFlag.java | 3 +- .../wrappers/v6/RegionContainerWrapper.java | 24 +++++ .../wg/wrappers/v6/RegionManagerWrapper.java | 13 +++ .../wg/wrappers/v6/RegionQueryWrapper.java | 21 +++++ .../wg/wrappers/v6/SessionManagerWrapper.java | 36 ++++++++ .../v6/WorldGuardSixCommunicator.java | 61 +++++++++++++ WG7/pom.xml | 54 ++++++++++++ .../wg/wrappers/v7/CustomSetFlag.java | 44 ++++++++++ .../wrappers/v7/RegionContainerWrapper.java | 26 ++++++ .../wg/wrappers/v7/RegionManagerWrapper.java | 13 +++ .../wg/wrappers/v7/RegionQueryWrapper.java | 8 +- .../wg/wrappers/v7/SessionManagerWrapper.java | 37 ++++++++ .../v7/WorldGuardSevenCommunicator.java | 62 +++++++++++++ pom.xml | 66 +++----------- .../wg/legacy/WorldGuardCommunicator.java | 53 ----------- .../wrappers/RegionContainerWrapper.java | 9 -- .../wg6/RegionContainerWrapperSix.java | 54 ------------ .../wrappers/wg6/RegionManagerWrapperSix.java | 13 --- .../wrappers/wg6/RegionQueryWrapperSix.java | 37 -------- .../wg6/SessionManagerWrapperSix.java | 70 --------------- .../wg6/WorldGuardSixCommunicator.java | 61 ------------- .../wg7/RegionContainerWrapperSeven.java | 29 ------ .../wg7/RegionManagerWrapperSeven.java | 13 --- .../wg7/SessionManagerWrapperSeven.java | 37 -------- .../wg7/WorldGuardSevenCommunicator.java | 57 ------------ 73 files changed, 767 insertions(+), 560 deletions(-) create mode 100644 Common/pom.xml rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/WorldGuardExtraFlagsPlugin.java (94%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/essentials/EssentialsHelper.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/fawe/FAWEHelper.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/fawe/FaweWorldEditFlagMaskManager.java (93%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/flags/Flags.java (79%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/flags/data/PotionEffectDetails.java (90%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/flags/data/SoundData.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/MaterialFlag.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/SoundDataFlag.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/listeners/BlockListener.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListener.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListenerOnePointNine.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/listeners/EssentialsListener.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/listeners/PlayerListener.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldEditListener.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldListener.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/utils/SupportedFeatures.java (71%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/utils/WorldUtils.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/we/AbstractWorldEditFlagHandler.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditFlagHandler.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditUtils.java (100%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java (79%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/BlockedEffectsFlagHandler.java (81%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java (96%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java (96%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java (96%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java (96%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/FlyFlagHandler.java (96%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GiveEffectsFlagHandler.java (85%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GlideFlagHandler.java (96%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GodmodeFlagHandler.java (97%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/PlaySoundsFlagHandler.java (97%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnEntryFlagHandler.java (95%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnExitFlagHandler.java (95%) rename {src => Common/src}/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/WalkSpeedFlagHandler.java (96%) create mode 100644 Spigot/pom.xml rename {src => Spigot/src}/main/resources/plugin.yml (95%) create mode 100644 WG/pom.xml create mode 100644 WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionContainerWrapper.java rename src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionManagerWrapper.java => WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionManagerWrapper.java (91%) rename src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionQueryWrapper.java => WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionQueryWrapper.java (60%) rename src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/SessionManagerWrapper.java => WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractSessionManagerWrapper.java (81%) rename {src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy => WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg}/wrappers/HandlerWrapper.java (96%) create mode 100644 WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/WorldGuardCommunicator.java create mode 100644 WG6/pom.xml rename {src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers => WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6}/CustomSetFlag.java (94%) create mode 100644 WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionContainerWrapper.java create mode 100644 WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionManagerWrapper.java create mode 100644 WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionQueryWrapper.java create mode 100644 WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/SessionManagerWrapper.java create mode 100644 WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/WorldGuardSixCommunicator.java create mode 100644 WG7/pom.xml create mode 100644 WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/CustomSetFlag.java create mode 100644 WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionContainerWrapper.java create mode 100644 WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionManagerWrapper.java rename src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionQueryWrapperSeven.java => WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionQueryWrapper.java (62%) create mode 100644 WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/SessionManagerWrapper.java create mode 100644 WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/WorldGuardSevenCommunicator.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/WorldGuardCommunicator.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionContainerWrapper.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionContainerWrapperSix.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionManagerWrapperSix.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionQueryWrapperSix.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/SessionManagerWrapperSix.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/WorldGuardSixCommunicator.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionContainerWrapperSeven.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionManagerWrapperSeven.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/SessionManagerWrapperSeven.java delete mode 100644 src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/WorldGuardSevenCommunicator.java diff --git a/Common/pom.xml b/Common/pom.xml new file mode 100644 index 0000000..766dada --- /dev/null +++ b/Common/pom.xml @@ -0,0 +1,88 @@ + + 4.0.0 + + net.goldtreeservers + worldguardextraflags + 4.1.0 + + + net.goldtreeservers.worldguardextraflags + common + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sk89q-repo + https://maven.sk89q.com/repo/ + + + ess-repo + http://repo.ess3.net/content/groups/essentials + + + empcraft + http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/ + + + + elMakers + http://maven.elmakers.com/repository/ + + + + + + + net.goldtreeservers.worldguardextraflags + wg + ${project.version} + provided + + + net.goldtreeservers.worldguardextraflags + wg6 + ${project.version} + provided + + + net.goldtreeservers.worldguardextraflags + wg7 + ${project.version} + provided + + + + org.spigotmc + spigot-api + 1.13-R0.1-SNAPSHOT + provided + + + com.sk89q.worldedit + worldedit + 7.0-SNAPSHOT + provided + + + com.sk89q.worldguard + worldguard-legacy + 7.0-SNAPSHOT + provided + + + com.boydti + fawe-api + 18.07.27-3ed2e57-1163-20.5.2 + provided + + + net.ess3 + Essentials + 2.13-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/WorldGuardExtraFlagsPlugin.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/WorldGuardExtraFlagsPlugin.java similarity index 94% rename from src/main/java/net/goldtreeservers/worldguardextraflags/WorldGuardExtraFlagsPlugin.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/WorldGuardExtraFlagsPlugin.java index 3fc2965..9ba1a8d 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/WorldGuardExtraFlagsPlugin.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/WorldGuardExtraFlagsPlugin.java @@ -20,6 +20,7 @@ import net.goldtreeservers.worldguardextraflags.listeners.PlayerListener; import net.goldtreeservers.worldguardextraflags.listeners.WorldEditListener; import net.goldtreeservers.worldguardextraflags.listeners.WorldListener; import net.goldtreeservers.worldguardextraflags.utils.WorldUtils; +import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; import net.goldtreeservers.worldguardextraflags.wg.handlers.BlockedEffectsFlagHandler; import net.goldtreeservers.worldguardextraflags.wg.handlers.CommandOnEntryFlagHandler; import net.goldtreeservers.worldguardextraflags.wg.handlers.CommandOnExitFlagHandler; @@ -33,8 +34,8 @@ import net.goldtreeservers.worldguardextraflags.wg.handlers.PlaySoundsFlagHandle import net.goldtreeservers.worldguardextraflags.wg.handlers.TeleportOnEntryFlagHandler; import net.goldtreeservers.worldguardextraflags.wg.handlers.TeleportOnExitFlagHandler; import net.goldtreeservers.worldguardextraflags.wg.handlers.WalkSpeedFlagHandler; -import net.goldtreeservers.worldguardextraflags.wg.legacy.WorldGuardCommunicator; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator; public class WorldGuardExtraFlagsPlugin extends JavaPlugin { @@ -59,7 +60,7 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin this.worldEditPlugin = (WorldEditPlugin)this.getServer().getPluginManager().getPlugin("WorldEdit"); this.worldGuardPlugin = (WorldGuardPlugin)this.getServer().getPluginManager().getPlugin("WorldGuard"); - this.worldGuardCommunicator = WorldGuardCommunicator.create(); + this.worldGuardCommunicator = WorldGuardUtils.createWorldGuardCommunicator(); if (this.worldGuardCommunicator == null) { throw new RuntimeException("Unsupported WorldGuard version: " + this.worldGuardPlugin.getDescription().getVersion()); @@ -156,7 +157,7 @@ public class WorldGuardExtraFlagsPlugin extends JavaPlugin throw new RuntimeException("Failed to enable WorldGuard communicator", e); } - SessionManagerWrapper sessionManager = this.worldGuardCommunicator.getSessionManager(); + AbstractSessionManagerWrapper sessionManager = this.worldGuardCommunicator.getSessionManager(); sessionManager.registerHandler(TeleportOnEntryFlagHandler.FACTORY); sessionManager.registerHandler(TeleportOnExitFlagHandler.FACTORY); sessionManager.registerHandler(CommandOnEntryFlagHandler.FACTORY); diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/essentials/EssentialsHelper.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/essentials/EssentialsHelper.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/essentials/EssentialsHelper.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/essentials/EssentialsHelper.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FAWEHelper.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FAWEHelper.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FAWEHelper.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FAWEHelper.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FaweWorldEditFlagMaskManager.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FaweWorldEditFlagMaskManager.java similarity index 93% rename from src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FaweWorldEditFlagMaskManager.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FaweWorldEditFlagMaskManager.java index ed87c91..4dfe6f1 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FaweWorldEditFlagMaskManager.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/fawe/FaweWorldEditFlagMaskManager.java @@ -13,7 +13,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper; public class FaweWorldEditFlagMaskManager extends FaweMaskManager { @@ -29,7 +29,7 @@ public class FaweWorldEditFlagMaskManager extends FaweMaskManager public ProtectedRegion getRegion(Player player, Location loc) { final com.sk89q.worldguard.LocalPlayer localplayer = this.plugin.getWorldGuardCommunicator().wrapPlayer(player); - RegionManagerWrapper manager = this.plugin.getWorldGuardCommunicator().getRegionContainer().get(player.getWorld()); + AbstractRegionManagerWrapper manager = this.plugin.getWorldGuardCommunicator().getRegionContainer().get(player.getWorld()); final ProtectedRegion global = manager.getRegion("__global__"); if (global != null && !isDenied(localplayer, global)) { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/Flags.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/Flags.java similarity index 79% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/Flags.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/Flags.java index 0ceb328..4c29d86 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/Flags.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/Flags.java @@ -12,8 +12,8 @@ import com.sk89q.worldguard.protection.flags.SetFlag; import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.StringFlag; +import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.data.SoundData; -import net.goldtreeservers.worldguardextraflags.flags.helpers.CustomSetFlag; import net.goldtreeservers.worldguardextraflags.flags.helpers.MaterialFlag; import net.goldtreeservers.worldguardextraflags.flags.helpers.PotionEffectFlag; import net.goldtreeservers.worldguardextraflags.flags.helpers.PotionEffectTypeFlag; @@ -24,11 +24,11 @@ public final class Flags public final static LocationFlag TELEPORT_ON_ENTRY = new LocationFlag("teleport-on-entry"); public final static LocationFlag TELEPORT_ON_EXIT = new LocationFlag("teleport-on-exit"); - public final static CustomSetFlag COMMAND_ON_ENTRY = new CustomSetFlag("command-on-entry", new CommandStringFlag(null)); - public final static CustomSetFlag COMMAND_ON_EXIT = new CustomSetFlag("command-on-exit", new CommandStringFlag(null)); + public final static SetFlag COMMAND_ON_ENTRY = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("command-on-entry", new CommandStringFlag(null)); + public final static SetFlag COMMAND_ON_EXIT = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("command-on-exit", new CommandStringFlag(null)); - public final static CustomSetFlag CONSOLE_COMMAND_ON_ENTRY = new CustomSetFlag("console-command-on-entry", new CommandStringFlag(null)); - public final static CustomSetFlag CONSOLE_COMMAND_ON_EXIT = new CustomSetFlag("console-command-on-exit", new CommandStringFlag(null)); + public final static SetFlag CONSOLE_COMMAND_ON_ENTRY = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("console-command-on-entry", new CommandStringFlag(null)); + public final static SetFlag CONSOLE_COMMAND_ON_EXIT = WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getCustomSetFlag("console-command-on-exit", new CommandStringFlag(null)); public final static DoubleFlag WALK_SPEED = new DoubleFlag("walk-speed"); diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/PotionEffectDetails.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/PotionEffectDetails.java similarity index 90% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/PotionEffectDetails.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/PotionEffectDetails.java index 7fdcc81..aee3510 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/PotionEffectDetails.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/PotionEffectDetails.java @@ -2,8 +2,6 @@ package net.goldtreeservers.worldguardextraflags.flags.data; import java.util.concurrent.TimeUnit; -import org.bukkit.Color; - import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -14,7 +12,6 @@ public class PotionEffectDetails @Getter private final int amplifier; @Getter private final boolean ambient; @Getter private final boolean particles; - @Getter private final Color color; public long getTimeLeft() { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/SoundData.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/SoundData.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/SoundData.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/data/SoundData.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/MaterialFlag.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/MaterialFlag.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/MaterialFlag.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/MaterialFlag.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/SoundDataFlag.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/SoundDataFlag.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/SoundDataFlag.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/SoundDataFlag.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/BlockListener.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/BlockListener.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/listeners/BlockListener.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/BlockListener.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListener.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListener.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListener.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListener.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListenerOnePointNine.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListenerOnePointNine.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListenerOnePointNine.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EntityListenerOnePointNine.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EssentialsListener.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EssentialsListener.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EssentialsListener.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/EssentialsListener.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/PlayerListener.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/PlayerListener.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/listeners/PlayerListener.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/PlayerListener.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldEditListener.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldEditListener.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldEditListener.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldEditListener.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldListener.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldListener.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldListener.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/WorldListener.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/utils/SupportedFeatures.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/utils/SupportedFeatures.java similarity index 71% rename from src/main/java/net/goldtreeservers/worldguardextraflags/utils/SupportedFeatures.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/utils/SupportedFeatures.java index 3f59a68..5557333 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/utils/SupportedFeatures.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/utils/SupportedFeatures.java @@ -4,7 +4,6 @@ import java.awt.Color; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; import lombok.Getter; @@ -14,7 +13,6 @@ import lombok.Getter; public class SupportedFeatures { @Getter private static boolean frostwalkerSupported; - @Getter private static boolean mobEffectColorsSupported; @Getter private static boolean stopSoundSupported; static @@ -27,14 +25,6 @@ public class SupportedFeatures { } - try - { - SupportedFeatures.mobEffectColorsSupported = PotionEffect.class.getDeclaredMethod("getColor", Color.class) != null; - } - catch (Throwable ignored) - { - } - try { SupportedFeatures.stopSoundSupported = Player.class.getDeclaredMethod("stopSound", Color.class) != null; diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/utils/WorldUtils.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/utils/WorldUtils.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/utils/WorldUtils.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/utils/WorldUtils.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/we/AbstractWorldEditFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/we/AbstractWorldEditFlagHandler.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/we/AbstractWorldEditFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/we/AbstractWorldEditFlagHandler.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditFlagHandler.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditFlagHandler.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditUtils.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditUtils.java similarity index 100% rename from src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditUtils.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/we/WorldEditUtils.java diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java similarity index 79% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java index 808f800..24ebc47 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/WorldGuardUtils.java @@ -17,6 +17,9 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.util.NormativeOrders; import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.v6.WorldGuardSixCommunicator; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.v7.WorldGuardSevenCommunicator; public class WorldGuardUtils { @@ -83,4 +86,33 @@ public class WorldGuardUtils return new FlagValueCalculator(checkForRegions, global); } + + public static WorldGuardCommunicator createWorldGuardCommunicator() + { + try + { + Class.forName("com.sk89q.worldguard.WorldGuard"); //Only exists in WG 7 + + return new WorldGuardSevenCommunicator(); + } + catch (Throwable ignored) + { + + } + + try + { + Class clazz = Class.forName("com.sk89q.worldguard.bukkit.WorldGuardPlugin"); + if (clazz.getMethod("getFlagRegistry") != null) + { + return new WorldGuardSixCommunicator(); + } + } + catch (Throwable ignored) + { + ignored.printStackTrace(); + } + + return null; + } } diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/BlockedEffectsFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/BlockedEffectsFlagHandler.java similarity index 81% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/BlockedEffectsFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/BlockedEffectsFlagHandler.java index ccbfc1d..cf2f81a 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/BlockedEffectsFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/BlockedEffectsFlagHandler.java @@ -19,9 +19,8 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails; -import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class BlockedEffectsFlagHandler extends HandlerWrapper { @@ -83,7 +82,7 @@ public class BlockedEffectsFlagHandler extends HandlerWrapper if (effect != null) { - this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect.getColor() : null)); + this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles())); player.removePotionEffect(effectType); } @@ -103,14 +102,7 @@ public class BlockedEffectsFlagHandler extends HandlerWrapper int timeLeft = removedEffect.getTimeLeftInTicks(); if (timeLeft > 0) { - if (SupportedFeatures.isMobEffectColorsSupported()) - { - player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles(), removedEffect.getColor()), true); - } - else - { - player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true); - } + player.addPotionEffect(new PotionEffect(potionEffect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true); } } diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java index 660a7b4..36b9cd9 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnEntryFlagHandler.java @@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class CommandOnEntryFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java index a96e3b8..f8fc5f7 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/CommandOnExitFlagHandler.java @@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class CommandOnExitFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java index f741ae2..18d283b 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnEntryFlagHandler.java @@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class ConsoleCommandOnEntryFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java index 51de583..c03a0e4 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/ConsoleCommandOnExitFlagHandler.java @@ -16,7 +16,7 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class ConsoleCommandOnExitFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/FlyFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/FlyFlagHandler.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/FlyFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/FlyFlagHandler.java index 9f448f5..c69042b 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/FlyFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/FlyFlagHandler.java @@ -15,7 +15,7 @@ import com.sk89q.worldguard.session.handler.Handler; import lombok.Getter; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class FlyFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GiveEffectsFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GiveEffectsFlagHandler.java similarity index 85% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GiveEffectsFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GiveEffectsFlagHandler.java index fd710fb..488f5ca 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GiveEffectsFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GiveEffectsFlagHandler.java @@ -23,9 +23,8 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.flags.data.PotionEffectDetails; -import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class GiveEffectsFlagHandler extends HandlerWrapper { @@ -89,7 +88,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper if (this.givenEffects.add(effect.getType()) && effect_ != null) { - this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect_.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), effect_.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect_.getColor() : null)); + this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect_.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), effect_.hasParticles())); player.removePotionEffect(effect_.getType()); } @@ -139,14 +138,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper if (timeLeft > 0) { - if (SupportedFeatures.isMobEffectColorsSupported()) - { - player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles(), removedEffect.getColor()), true); - } - else - { - player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true); - } + player.addPotionEffect(new PotionEffect(effect.getKey(), timeLeft, removedEffect.getAmplifier(), removedEffect.isAmbient(), removedEffect.isParticles()), true); } } @@ -166,7 +158,7 @@ public class GiveEffectsFlagHandler extends HandlerWrapper { for(PotionEffect effect : effects) { - this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect.getColor() : null)); + this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles())); } this.check(player, WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation())); diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GlideFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GlideFlagHandler.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GlideFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GlideFlagHandler.java index da6f1ce..b3e97db 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GlideFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GlideFlagHandler.java @@ -14,7 +14,7 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class GlideFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GodmodeFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GodmodeFlagHandler.java similarity index 97% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GodmodeFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GodmodeFlagHandler.java index 3d964de..03847ae 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GodmodeFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/GodmodeFlagHandler.java @@ -18,7 +18,7 @@ import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.essentials.EssentialsHelper; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class GodmodeFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/PlaySoundsFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/PlaySoundsFlagHandler.java similarity index 97% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/PlaySoundsFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/PlaySoundsFlagHandler.java index c921d3a..0c04601 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/PlaySoundsFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/PlaySoundsFlagHandler.java @@ -21,7 +21,7 @@ import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.flags.data.SoundData; import net.goldtreeservers.worldguardextraflags.utils.SupportedFeatures; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class PlaySoundsFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnEntryFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnEntryFlagHandler.java similarity index 95% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnEntryFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnEntryFlagHandler.java index d336aea..a886302 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnEntryFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnEntryFlagHandler.java @@ -16,7 +16,7 @@ import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.we.WorldEditUtils; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class TeleportOnEntryFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnExitFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnExitFlagHandler.java similarity index 95% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnExitFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnExitFlagHandler.java index 3a1204d..a8c97c8 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnExitFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/TeleportOnExitFlagHandler.java @@ -16,7 +16,7 @@ import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.we.WorldEditUtils; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class TeleportOnExitFlagHandler extends HandlerWrapper { diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/WalkSpeedFlagHandler.java b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/WalkSpeedFlagHandler.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/WalkSpeedFlagHandler.java rename to Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/WalkSpeedFlagHandler.java index 363bd49..61a5fb9 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/WalkSpeedFlagHandler.java +++ b/Common/src/main/java/net/goldtreeservers/worldguardextraflags/wg/handlers/WalkSpeedFlagHandler.java @@ -13,7 +13,7 @@ import com.sk89q.worldguard.session.handler.Handler; import net.goldtreeservers.worldguardextraflags.flags.Flags; import net.goldtreeservers.worldguardextraflags.wg.WorldGuardUtils; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.HandlerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.HandlerWrapper; public class WalkSpeedFlagHandler extends HandlerWrapper { diff --git a/Spigot/pom.xml b/Spigot/pom.xml new file mode 100644 index 0000000..1d14522 --- /dev/null +++ b/Spigot/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + + net.goldtreeservers + worldguardextraflags + 4.1.0 + + + net.goldtreeservers.worldguardextraflags + Spigot + + + WorldGuardExtraFlags + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.0 + + + package + + shade + + + + + + + *:* + + **/*.java + **/*.SF + **/*.DSA + + + + + + + + + + + + + net.goldtreeservers.worldguardextraflags + common + ${project.version} + compile + + + net.goldtreeservers.worldguardextraflags + wg + ${project.version} + compile + + + net.goldtreeservers.worldguardextraflags + wg6 + ${project.version} + compile + + + net.goldtreeservers.worldguardextraflags + wg7 + ${project.version} + compile + + + \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/Spigot/src/main/resources/plugin.yml similarity index 95% rename from src/main/resources/plugin.yml rename to Spigot/src/main/resources/plugin.yml index 21cdca1..f261ce8 100644 --- a/src/main/resources/plugin.yml +++ b/Spigot/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: WorldGuardExtraFlags -version: 3.0.4 +version: 4.1.0 description: Adds more flags to WorldGuard to help manage your server easily! author: isokissa3 website: https://goldtreevers.net diff --git a/WG/pom.xml b/WG/pom.xml new file mode 100644 index 0000000..165a1fa --- /dev/null +++ b/WG/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + + net.goldtreeservers + worldguardextraflags + 4.1.0 + + + net.goldtreeservers.worldguardextraflags + wg + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sk89q-repo + https://maven.sk89q.com/repo/ + + + + elMakers + http://maven.elmakers.com/repository/ + + + + + + org.spigotmc + spigot-api + 1.13-R0.1-SNAPSHOT + provided + + + com.sk89q.worldedit + worldedit + 7.0-SNAPSHOT + provided + + + com.sk89q.worldguard + worldguard-legacy + 7.0-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionContainerWrapper.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionContainerWrapper.java new file mode 100644 index 0000000..7ef0b95 --- /dev/null +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionContainerWrapper.java @@ -0,0 +1,9 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers; + +import org.bukkit.World; + +public abstract class AbstractRegionContainerWrapper +{ + public abstract AbstractRegionQueryWrapper createQuery(); + public abstract AbstractRegionManagerWrapper get(World world); +} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionManagerWrapper.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionManagerWrapper.java similarity index 91% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionManagerWrapper.java rename to WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionManagerWrapper.java index 0402e91..609e041 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionManagerWrapper.java +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionManagerWrapper.java @@ -1,4 +1,4 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers; +package net.goldtreeservers.worldguardextraflags.wg.wrappers; import java.util.Map; @@ -14,7 +14,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor -public abstract class RegionManagerWrapper +public abstract class AbstractRegionManagerWrapper { protected final RegionManager regionManager; diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionQueryWrapper.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionQueryWrapper.java similarity index 60% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionQueryWrapper.java rename to WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionQueryWrapper.java index 14264a4..ce08e78 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionQueryWrapper.java +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractRegionQueryWrapper.java @@ -1,10 +1,10 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers; +package net.goldtreeservers.worldguardextraflags.wg.wrappers; import org.bukkit.Location; import com.sk89q.worldguard.protection.ApplicableRegionSet; -public abstract class RegionQueryWrapper +public abstract class AbstractRegionQueryWrapper { public abstract ApplicableRegionSet getApplicableRegions(Location location); } diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/SessionManagerWrapper.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractSessionManagerWrapper.java similarity index 81% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/SessionManagerWrapper.java rename to WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractSessionManagerWrapper.java index 64783e0..3cf0876 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/SessionManagerWrapper.java +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/AbstractSessionManagerWrapper.java @@ -1,4 +1,4 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers; +package net.goldtreeservers.worldguardextraflags.wg.wrappers; import org.bukkit.entity.Player; @@ -9,7 +9,7 @@ import com.sk89q.worldguard.session.handler.Handler; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor -public abstract class SessionManagerWrapper +public abstract class AbstractSessionManagerWrapper { protected final SessionManager sessionManager; diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/HandlerWrapper.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/HandlerWrapper.java similarity index 96% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/HandlerWrapper.java rename to WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/HandlerWrapper.java index 4b5a635..c04e330 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/HandlerWrapper.java +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/HandlerWrapper.java @@ -1,4 +1,4 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers; +package net.goldtreeservers.worldguardextraflags.wg.wrappers; import java.util.Set; @@ -24,7 +24,6 @@ public abstract class HandlerWrapper extends Handler public void initialize(Player player, Location current, ApplicableRegionSet set) { - } public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set entered, Set exited, MoveType moveType) @@ -34,7 +33,6 @@ public abstract class HandlerWrapper extends Handler public void tick(Player player, ApplicableRegionSet set) { - } public State getInvincibility(Player player) diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/WorldGuardCommunicator.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/WorldGuardCommunicator.java new file mode 100644 index 0000000..cc6993b --- /dev/null +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/WorldGuardCommunicator.java @@ -0,0 +1,23 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers; + +import org.bukkit.entity.Player; + +import com.sk89q.worldguard.LocalPlayer; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.flags.SetFlag; +import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; + +public interface WorldGuardCommunicator +{ + public void onLoad() throws Exception; + public void onEnable() throws Exception; + + public FlagRegistry getFlagRegistry(); + + public AbstractSessionManagerWrapper getSessionManager(); + public AbstractRegionContainerWrapper getRegionContainer(); + + public LocalPlayer wrapPlayer(Player player); + + public SetFlag getCustomSetFlag(String name, Flag flag); +} diff --git a/WG6/pom.xml b/WG6/pom.xml new file mode 100644 index 0000000..dc45e2d --- /dev/null +++ b/WG6/pom.xml @@ -0,0 +1,49 @@ + + 4.0.0 + + net.goldtreeservers + worldguardextraflags + 4.1.0 + + + net.goldtreeservers.worldguardextraflags + wg6 + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sk89q-repo + https://maven.sk89q.com/repo/ + + + + + + net.goldtreeservers.worldguardextraflags + wg + ${project.version} + provided + + + org.spigotmc + spigot-api + 1.13-R0.1-SNAPSHOT + provided + + + com.sk89q + guavabackport + 1.2 + provided + + + com.sk89q.worldguard + worldguard-legacy + 6.1.3-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/CustomSetFlag.java b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/CustomSetFlag.java similarity index 94% rename from src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/CustomSetFlag.java rename to WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/CustomSetFlag.java index e55bea6..b19c804 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/CustomSetFlag.java +++ b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/CustomSetFlag.java @@ -1,4 +1,4 @@ -package net.goldtreeservers.worldguardextraflags.flags.helpers; +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6; import java.util.Set; @@ -33,6 +33,7 @@ public class CustomSetFlag extends SetFlag { str = str.substring(1, str.length() - 1); } + FlagContext copy = context.copyWith(null, str, null); items.add(this.getType().parseInput(copy)); } diff --git a/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionContainerWrapper.java b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionContainerWrapper.java new file mode 100644 index 0000000..414cd2e --- /dev/null +++ b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionContainerWrapper.java @@ -0,0 +1,24 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6; + +import org.bukkit.World; + +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper; + +public class RegionContainerWrapper extends AbstractRegionContainerWrapper +{ + @Override + public AbstractRegionQueryWrapper createQuery() + { + return new RegionQueryWrapper(WorldGuardPlugin.inst().getRegionContainer().createQuery()); + } + + @Override + public AbstractRegionManagerWrapper get(World world) + { + return new RegionManagerWrapper(WorldGuardPlugin.inst().getRegionManager(world)); + } +} diff --git a/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionManagerWrapper.java b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionManagerWrapper.java new file mode 100644 index 0000000..e751bbc --- /dev/null +++ b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionManagerWrapper.java @@ -0,0 +1,13 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6; + +import com.sk89q.worldguard.protection.managers.RegionManager; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper; + +public class RegionManagerWrapper extends AbstractRegionManagerWrapper +{ + public RegionManagerWrapper(RegionManager regionManager) + { + super(regionManager); + } +} diff --git a/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionQueryWrapper.java b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionQueryWrapper.java new file mode 100644 index 0000000..7cebc1e --- /dev/null +++ b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/RegionQueryWrapper.java @@ -0,0 +1,21 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6; + +import org.bukkit.Location; + +import com.sk89q.worldguard.bukkit.RegionQuery; +import com.sk89q.worldguard.protection.ApplicableRegionSet; + +import lombok.RequiredArgsConstructor; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper; + +@RequiredArgsConstructor +public class RegionQueryWrapper extends AbstractRegionQueryWrapper +{ + private final RegionQuery regionQuery; + + @Override + public ApplicableRegionSet getApplicableRegions(Location location) + { + return this.regionQuery.getApplicableRegions(location); + } +} diff --git a/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/SessionManagerWrapper.java b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/SessionManagerWrapper.java new file mode 100644 index 0000000..947f4b6 --- /dev/null +++ b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/SessionManagerWrapper.java @@ -0,0 +1,36 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6; + +import org.bukkit.entity.Player; + +import com.sk89q.worldguard.session.Session; +import com.sk89q.worldguard.session.SessionManager; +import com.sk89q.worldguard.session.handler.Handler; +import com.sk89q.worldguard.session.handler.Handler.Factory; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper; + +public class SessionManagerWrapper extends AbstractSessionManagerWrapper +{ + public SessionManagerWrapper(SessionManager sessionManager) + { + super(sessionManager); + } + + @Override + public Session get(Player player) + { + return this.sessionManager.get(player); + } + + @Override + public Session getIfPresent(Player player) + { + return this.sessionManager.getIfPresent(player); + } + + @Override + public void registerHandler(Factory factory) + { + this.sessionManager.registerHandler(factory, null); + } +} diff --git a/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/WorldGuardSixCommunicator.java b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/WorldGuardSixCommunicator.java new file mode 100644 index 0000000..7ca399c --- /dev/null +++ b/WG6/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v6/WorldGuardSixCommunicator.java @@ -0,0 +1,61 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v6; + +import org.bukkit.entity.Player; + +import com.sk89q.worldguard.LocalPlayer; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.flags.SetFlag; +import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator; + +public class WorldGuardSixCommunicator implements WorldGuardCommunicator +{ + private AbstractSessionManagerWrapper sessionManager; + private AbstractRegionContainerWrapper regionContainer; + + @Override + public void onLoad() throws Exception + { + } + + @Override + public void onEnable() throws Exception + { + this.sessionManager = new SessionManagerWrapper(WorldGuardPlugin.inst().getSessionManager()); + this.regionContainer = new RegionContainerWrapper(); + } + + @Override + public FlagRegistry getFlagRegistry() + { + return WorldGuardPlugin.inst().getFlagRegistry(); + } + + @Override + public AbstractSessionManagerWrapper getSessionManager() + { + return this.sessionManager; + } + + @Override + public AbstractRegionContainerWrapper getRegionContainer() + { + return this.regionContainer; + } + + @Override + public LocalPlayer wrapPlayer(Player player) + { + return WorldGuardPlugin.inst().wrapPlayer(player); + } + + @Override + public SetFlag getCustomSetFlag(String name, Flag flag) + { + return new CustomSetFlag(name, flag); + } +} diff --git a/WG7/pom.xml b/WG7/pom.xml new file mode 100644 index 0000000..c53d124 --- /dev/null +++ b/WG7/pom.xml @@ -0,0 +1,54 @@ + + 4.0.0 + + net.goldtreeservers + worldguardextraflags + 4.1.0 + + + net.goldtreeservers.worldguardextraflags + wg7 + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sk89q-repo + https://maven.sk89q.com/repo/ + + + + elMakers + http://maven.elmakers.com/repository/ + + + + + + net.goldtreeservers.worldguardextraflags + wg + ${project.version} + provided + + + org.spigotmc + spigot-api + 1.13-R0.1-SNAPSHOT + provided + + + com.sk89q.worldedit + worldedit + 7.0-SNAPSHOT + provided + + + com.sk89q.worldguard + worldguard-legacy + 7.0-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/CustomSetFlag.java b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/CustomSetFlag.java new file mode 100644 index 0000000..39b7fea --- /dev/null +++ b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/CustomSetFlag.java @@ -0,0 +1,44 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7; + +import java.util.Set; + +import com.google.common.collect.Sets; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.flags.FlagContext; +import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; +import com.sk89q.worldguard.protection.flags.SetFlag; + +public class CustomSetFlag extends SetFlag +{ + public CustomSetFlag(String name, Flag subFlag) + { + super(name, subFlag); + } + + @Override + public Set parseInput(FlagContext context) throws InvalidFlagFormat + { + String input = context.getUserInput(); + if (input.isEmpty()) + { + return Sets.newHashSet(); + } + else + { + Set items = Sets.newHashSet(); + + for (String str : input.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1)) + { + if (str.startsWith("\"") && str.endsWith("\"")) + { + str = str.substring(1, str.length() - 1); + } + + FlagContext copy = context.copyWith(null, str, null); + items.add(this.getType().parseInput(copy)); + } + + return items; + } + } +} diff --git a/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionContainerWrapper.java b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionContainerWrapper.java new file mode 100644 index 0000000..1c9c62d --- /dev/null +++ b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionContainerWrapper.java @@ -0,0 +1,26 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7; + +import org.bukkit.World; + +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldguard.WorldGuard; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper; + +public class RegionContainerWrapper extends AbstractRegionContainerWrapper +{ + + @Override + public AbstractRegionQueryWrapper createQuery() + { + return new RegionQueryWrapper(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()); + } + + @Override + public AbstractRegionManagerWrapper get(World world) + { + return new RegionManagerWrapper(WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world))); + } +} diff --git a/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionManagerWrapper.java b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionManagerWrapper.java new file mode 100644 index 0000000..6f14810 --- /dev/null +++ b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionManagerWrapper.java @@ -0,0 +1,13 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7; + +import com.sk89q.worldguard.protection.managers.RegionManager; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionManagerWrapper; + +public class RegionManagerWrapper extends AbstractRegionManagerWrapper +{ + public RegionManagerWrapper(RegionManager regionManager) + { + super(regionManager); + } +} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionQueryWrapperSeven.java b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionQueryWrapper.java similarity index 62% rename from src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionQueryWrapperSeven.java rename to WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionQueryWrapper.java index 36d4907..63da75a 100644 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionQueryWrapperSeven.java +++ b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/RegionQueryWrapper.java @@ -1,4 +1,4 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7; +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7; import org.bukkit.Location; @@ -7,12 +7,12 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.regions.RegionQuery; import lombok.RequiredArgsConstructor; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionQueryWrapper; @RequiredArgsConstructor -public class RegionQueryWrapperSeven extends RegionQueryWrapper +public class RegionQueryWrapper extends AbstractRegionQueryWrapper { - protected final RegionQuery regionQuery; + private final RegionQuery regionQuery; @Override public ApplicableRegionSet getApplicableRegions(Location location) diff --git a/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/SessionManagerWrapper.java b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/SessionManagerWrapper.java new file mode 100644 index 0000000..e0e2a65 --- /dev/null +++ b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/SessionManagerWrapper.java @@ -0,0 +1,37 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7; + +import org.bukkit.entity.Player; + +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.session.Session; +import com.sk89q.worldguard.session.SessionManager; +import com.sk89q.worldguard.session.handler.Handler; +import com.sk89q.worldguard.session.handler.Handler.Factory; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper; + +public class SessionManagerWrapper extends AbstractSessionManagerWrapper +{ + public SessionManagerWrapper(SessionManager sessionManager) + { + super(sessionManager); + } + + @Override + public Session get(Player player) + { + return this.sessionManager.get(WorldGuardPlugin.inst().wrapPlayer(player)); + } + + @Override + public Session getIfPresent(Player player) + { + return this.sessionManager.getIfPresent(WorldGuardPlugin.inst().wrapPlayer(player)); + } + + @Override + public void registerHandler(Factory factory) + { + this.sessionManager.registerHandler(factory, null); + } +} diff --git a/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/WorldGuardSevenCommunicator.java b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/WorldGuardSevenCommunicator.java new file mode 100644 index 0000000..43f3490 --- /dev/null +++ b/WG7/src/main/java/net/goldtreeservers/worldguardextraflags/wg/wrappers/v7/WorldGuardSevenCommunicator.java @@ -0,0 +1,62 @@ +package net.goldtreeservers.worldguardextraflags.wg.wrappers.v7; + +import org.bukkit.entity.Player; + +import com.sk89q.worldguard.LocalPlayer; +import com.sk89q.worldguard.WorldGuard; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.flags.SetFlag; +import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; + +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractRegionContainerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.AbstractSessionManagerWrapper; +import net.goldtreeservers.worldguardextraflags.wg.wrappers.WorldGuardCommunicator; + +public class WorldGuardSevenCommunicator implements WorldGuardCommunicator +{ + private AbstractSessionManagerWrapper sessionManager; + private AbstractRegionContainerWrapper regionContainer; + + @Override + public void onLoad() throws Exception + { + } + + @Override + public void onEnable() throws Exception + { + this.sessionManager = new SessionManagerWrapper(WorldGuard.getInstance().getPlatform().getSessionManager()); + this.regionContainer = new RegionContainerWrapper(); + } + + @Override + public FlagRegistry getFlagRegistry() + { + return WorldGuard.getInstance().getFlagRegistry(); + } + + @Override + public AbstractSessionManagerWrapper getSessionManager() + { + return this.sessionManager; + } + + @Override + public AbstractRegionContainerWrapper getRegionContainer() + { + return this.regionContainer; + } + + @Override + public LocalPlayer wrapPlayer(Player player) + { + return WorldGuardPlugin.inst().wrapPlayer(player); + } + + @Override + public SetFlag getCustomSetFlag(String name, Flag flag) + { + return new CustomSetFlag(name, flag); + } +} diff --git a/pom.xml b/pom.xml index 2a1d77f..9abbd49 100644 --- a/pom.xml +++ b/pom.xml @@ -4,10 +4,11 @@ net.goldtreeservers worldguardextraflags WorldGuardExtraFlags - 4.0.0 + 4.1.0 - - WorldGuardExtraFlagsPlugin + pom + + org.apache.maven.plugins @@ -21,29 +22,6 @@ - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - sk89q-repo - https://maven.sk89q.com/repo/ - - - ess-repo - http://repo.ess3.net/content/groups/essentials - - - empcraft - http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/ - - - - elMakers - http://maven.elmakers.com/repository/ - - org.projectlombok @@ -51,33 +29,13 @@ 1.16.18 provided - - org.spigotmc - spigot-api - 1.13-R0.1-SNAPSHOT - provided - - - com.sk89q.worldedit - worldedit - 7.0-SNAPSHOT - provided - - - com.sk89q.worldguard - worldguard-legacy - 7.0-SNAPSHOT - provided - - - com.boydti - fawe-api - 18.07.27-3ed2e57-1163-20.5.2 - - - net.ess3 - Essentials - 2.13-SNAPSHOT - + + + WG6 + Common + WG + WG7 + Spigot + \ No newline at end of file diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/WorldGuardCommunicator.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/WorldGuardCommunicator.java deleted file mode 100644 index 8c15878..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/WorldGuardCommunicator.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy; - -import org.bukkit.entity.Player; - -import com.sk89q.worldguard.LocalPlayer; -import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6.WorldGuardSixCommunicator; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7.WorldGuardSevenCommunicator; - -public interface WorldGuardCommunicator -{ - public void onLoad() throws Exception; - public void onEnable() throws Exception; - - public FlagRegistry getFlagRegistry(); - public SessionManagerWrapper getSessionManager(); - - public RegionContainerWrapper getRegionContainer(); - - public LocalPlayer wrapPlayer(Player player); - - public static WorldGuardCommunicator create() - { - try - { - Class.forName("com.sk89q.worldguard.WorldGuard"); //Only exists in WG 7 - - return new WorldGuardSevenCommunicator(); - } - catch (Throwable ignored) - { - - } - - try - { - Class clazz = Class.forName("com.sk89q.worldguard.bukkit.WorldGuardPlugin"); - if (clazz.getMethod("getFlagRegistry") != null) - { - return new WorldGuardSixCommunicator(); - } - } - catch (Throwable ignored) - { - ignored.printStackTrace(); - } - - return null; - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionContainerWrapper.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionContainerWrapper.java deleted file mode 100644 index 0774d30..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/RegionContainerWrapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers; - -import org.bukkit.World; - -public abstract class RegionContainerWrapper -{ - public abstract RegionQueryWrapper createQuery(); - public abstract RegionManagerWrapper get(World world); -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionContainerWrapperSix.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionContainerWrapperSix.java deleted file mode 100644 index 92bb74c..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionContainerWrapperSix.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.bukkit.World; - -import com.sk89q.worldguard.protection.managers.RegionManager; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper; - -public class RegionContainerWrapperSix extends RegionContainerWrapper -{ - protected final Object regionContainer; - - private Method createQueryMethod; - private Method getMethod; - - public RegionContainerWrapperSix(Object regionContainer) throws NoSuchMethodException, SecurityException - { - this.regionContainer = regionContainer; - - this.createQueryMethod = regionContainer.getClass().getMethod("createQuery"); - this.getMethod = regionContainer.getClass().getMethod("get", World.class); - } - - @Override - public RegionQueryWrapper createQuery() - { - try - { - return new RegionQueryWrapperSix(this.createQueryMethod.invoke(this.regionContainer)); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) - { - throw new RuntimeException(e); - } - } - - @Override - public RegionManagerWrapper get(World world) - { - try - { - return new RegionManagerWrapperSix((RegionManager)this.getMethod.invoke(this.regionContainer, world)); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - throw new RuntimeException(e); - } - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionManagerWrapperSix.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionManagerWrapperSix.java deleted file mode 100644 index 1c39340..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionManagerWrapperSix.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6; - -import com.sk89q.worldguard.protection.managers.RegionManager; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper; - -public class RegionManagerWrapperSix extends RegionManagerWrapper -{ - public RegionManagerWrapperSix(RegionManager regionManager) - { - super(regionManager); - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionQueryWrapperSix.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionQueryWrapperSix.java deleted file mode 100644 index 2570a29..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/RegionQueryWrapperSix.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.bukkit.Location; - -import com.sk89q.worldguard.protection.ApplicableRegionSet; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper; - -public class RegionQueryWrapperSix extends RegionQueryWrapper -{ - protected final Object regionQuery; - - private Method getApplicableRegionsMethod; - - public RegionQueryWrapperSix(Object regionQuery) throws NoSuchMethodException, SecurityException - { - this.regionQuery = regionQuery; - - this.getApplicableRegionsMethod = regionQuery.getClass().getMethod("getApplicableRegions", Location.class); - } - - @Override - public ApplicableRegionSet getApplicableRegions(Location location) - { - try - { - return (ApplicableRegionSet)this.getApplicableRegionsMethod.invoke(this.regionQuery, location); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - throw new RuntimeException(e); - } - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/SessionManagerWrapperSix.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/SessionManagerWrapperSix.java deleted file mode 100644 index cc8441e..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/SessionManagerWrapperSix.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.bukkit.entity.Player; - -import com.sk89q.worldguard.session.Session; -import com.sk89q.worldguard.session.SessionManager; -import com.sk89q.worldguard.session.handler.Handler; -import com.sk89q.worldguard.session.handler.Handler.Factory; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper; - -public class SessionManagerWrapperSix extends SessionManagerWrapper -{ - private Method getMethod; - private Method getIfPresentMethod; - - private Method registerHandlerMethod; - - public SessionManagerWrapperSix(SessionManager sessionManager) throws NoSuchMethodException, SecurityException - { - super(sessionManager); - - this.getMethod = sessionManager.getClass().getMethod("get", Player.class); - this.getIfPresentMethod = sessionManager.getClass().getMethod("getIfPresent", Player.class); - - this.registerHandlerMethod = sessionManager.getClass().getMethod("registerHandler", Factory.class, Factory.class); - } - - @Override - public Session get(Player player) - { - try - { - return (Session)this.getMethod.invoke(this.sessionManager, player); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - throw new RuntimeException(e); - } - } - - @Override - public Session getIfPresent(Player player) - { - try - { - return (Session)this.getIfPresentMethod.invoke(this.sessionManager, player); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - throw new RuntimeException(e); - } - } - - @Override - public void registerHandler(Factory factory) - { - try - { - this.registerHandlerMethod.invoke(this.sessionManager, factory, null); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) - { - throw new RuntimeException(e); - } - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/WorldGuardSixCommunicator.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/WorldGuardSixCommunicator.java deleted file mode 100644 index d892b74..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg6/WorldGuardSixCommunicator.java +++ /dev/null @@ -1,61 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg6; - -import java.lang.reflect.Method; - -import org.bukkit.entity.Player; - -import com.sk89q.worldguard.LocalPlayer; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; -import com.sk89q.worldguard.session.SessionManager; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.WorldGuardCommunicator; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper; - -public class WorldGuardSixCommunicator implements WorldGuardCommunicator -{ - private FlagRegistry flagRegistry; - private SessionManagerWrapper sessionManager; - private RegionContainerWrapper regionContainer; - - public void onLoad() throws Exception - { - Method getFlagRegistryMethod = WorldGuardPlugin.class.getMethod("getFlagRegistry"); - - this.flagRegistry = (FlagRegistry)getFlagRegistryMethod.invoke(WorldGuardPlugin.inst()); - } - - public void onEnable() throws Exception - { - Method getSessionManagerMethod = WorldGuardPlugin.class.getMethod("getSessionManager"); - Method getRegionContainerMethod = WorldGuardPlugin.class.getMethod("getRegionContainer"); - - this.sessionManager = new SessionManagerWrapperSix((SessionManager)getSessionManagerMethod.invoke(WorldGuardPlugin.inst())); - this.regionContainer = new RegionContainerWrapperSix(getRegionContainerMethod.invoke(WorldGuardPlugin.inst())); - } - - @Override - public FlagRegistry getFlagRegistry() - { - return this.flagRegistry; - } - - @Override - public SessionManagerWrapper getSessionManager() - { - return this.sessionManager; - } - - @Override - public RegionContainerWrapper getRegionContainer() - { - return this.regionContainer; - } - - @Override - public LocalPlayer wrapPlayer(Player player) - { - return WorldGuardPlugin.inst().wrapPlayer(player); - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionContainerWrapperSeven.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionContainerWrapperSeven.java deleted file mode 100644 index f6b778f..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionContainerWrapperSeven.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7; - -import org.bukkit.World; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldguard.protection.regions.RegionContainer; - -import lombok.RequiredArgsConstructor; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionQueryWrapper; - -@RequiredArgsConstructor -public class RegionContainerWrapperSeven extends RegionContainerWrapper -{ - protected final RegionContainer regionContainer; - - @Override - public RegionQueryWrapper createQuery() - { - return new RegionQueryWrapperSeven(this.regionContainer.createQuery()); - } - - @Override - public RegionManagerWrapper get(World world) - { - return new RegionManagerWrapperSeven(this.regionContainer.get(BukkitAdapter.adapt(world))); - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionManagerWrapperSeven.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionManagerWrapperSeven.java deleted file mode 100644 index 6f38ff3..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/RegionManagerWrapperSeven.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7; - -import com.sk89q.worldguard.protection.managers.RegionManager; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionManagerWrapper; - -public class RegionManagerWrapperSeven extends RegionManagerWrapper -{ - public RegionManagerWrapperSeven(RegionManager regionManager) - { - super(regionManager); - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/SessionManagerWrapperSeven.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/SessionManagerWrapperSeven.java deleted file mode 100644 index c5f2148..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/SessionManagerWrapperSeven.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7; - -import org.bukkit.entity.Player; - -import com.sk89q.worldguard.session.Session; -import com.sk89q.worldguard.session.SessionManager; -import com.sk89q.worldguard.session.handler.Handler; -import com.sk89q.worldguard.session.handler.Handler.Factory; - -import net.goldtreeservers.worldguardextraflags.WorldGuardExtraFlagsPlugin; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper; - -public class SessionManagerWrapperSeven extends SessionManagerWrapper -{ - public SessionManagerWrapperSeven(SessionManager sessionManager) - { - super(sessionManager); - } - - @Override - public Session get(Player player) - { - return this.sessionManager.get(WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().wrapPlayer(player)); - } - - @Override - public Session getIfPresent(Player player) - { - return this.sessionManager.getIfPresent(WorldGuardExtraFlagsPlugin.getPlugin().getWorldGuardCommunicator().wrapPlayer(player)); - } - - @Override - public void registerHandler(Factory factory) - { - this.sessionManager.registerHandler(factory, null); - } -} diff --git a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/WorldGuardSevenCommunicator.java b/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/WorldGuardSevenCommunicator.java deleted file mode 100644 index 45bb007..0000000 --- a/src/main/java/net/goldtreeservers/worldguardextraflags/wg/legacy/wrappers/wg7/WorldGuardSevenCommunicator.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.wg7; - -import org.bukkit.entity.Player; - -import com.sk89q.worldguard.LocalPlayer; -import com.sk89q.worldguard.WorldGuard; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; - -import net.goldtreeservers.worldguardextraflags.wg.legacy.WorldGuardCommunicator; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.RegionContainerWrapper; -import net.goldtreeservers.worldguardextraflags.wg.legacy.wrappers.SessionManagerWrapper; - -public class WorldGuardSevenCommunicator implements WorldGuardCommunicator -{ - private SessionManagerWrapper sessionManager; - private RegionContainerWrapper regionContainer; - - public WorldGuardSevenCommunicator() - { - } - - @Override - public void onLoad() throws Exception - { - } - - @Override - public void onEnable() throws Exception - { - this.sessionManager = new SessionManagerWrapperSeven(WorldGuard.getInstance().getPlatform().getSessionManager()); - this.regionContainer = new RegionContainerWrapperSeven(WorldGuard.getInstance().getPlatform().getRegionContainer()); - } - - @Override - public FlagRegistry getFlagRegistry() - { - return WorldGuard.getInstance().getFlagRegistry(); - } - - @Override - public SessionManagerWrapper getSessionManager() - { - return this.sessionManager; - } - - @Override - public RegionContainerWrapper getRegionContainer() - { - return this.regionContainer; - } - @Override - public LocalPlayer wrapPlayer(Player player) - { - return WorldGuardPlugin.inst().wrapPlayer(player); - } -}