diff --git a/plugin/build.gradle b/plugin/build.gradle index 37aac88..edec6c7 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -45,9 +45,7 @@ dependencies { compileOnly('com.arcaniax:HeadDatabase-API:1.3.1') { transitive false } // WorldGuard compatibility - implementation project(':worldguard_compat') - implementation project(':worldguard_compat_v6') - implementation project(':worldguard_compat_v7') + ['base', 'v6', 'v7'].forEach {implementation project(':plugin:compatibility:worldguard:' + it) } // bStats implementation 'org.bstats:bstats-bukkit:2.2.1' diff --git a/worldguard_compat/build.gradle b/plugin/compatibility/worldguard/base/build.gradle similarity index 100% rename from worldguard_compat/build.gradle rename to plugin/compatibility/worldguard/base/build.gradle diff --git a/plugin/compatibility/worldguard/base/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuardCompatibility.kt b/plugin/compatibility/worldguard/base/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuardCompatibility.kt new file mode 100644 index 0000000..90f82c3 --- /dev/null +++ b/plugin/compatibility/worldguard/base/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuardCompatibility.kt @@ -0,0 +1,13 @@ +package me.gabytm.minecraft.arcanevouchers.compatibility.worldguard + +import org.bukkit.Location + +interface WorldGuardCompatibility { + + /** + * Gets the id of all regions from a certain [Location] + * @return set of region ids + */ + fun getRegions(location: Location): Set + +} \ No newline at end of file diff --git a/worldguard_compat_v6/build.gradle b/plugin/compatibility/worldguard/v6/build.gradle similarity index 68% rename from worldguard_compat_v6/build.gradle rename to plugin/compatibility/worldguard/v6/build.gradle index b9fca6e..fa07c73 100644 --- a/worldguard_compat_v6/build.gradle +++ b/plugin/compatibility/worldguard/v6/build.gradle @@ -5,6 +5,6 @@ repositories { } dependencies { - compileOnly project(':worldguard_compat') + compileOnly project(':plugin:compatibility:worldguard:base') compileOnly 'com.sk89q:worldguard:6.1' } \ No newline at end of file diff --git a/worldguard_compat_v6/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuard6Compat.kt b/plugin/compatibility/worldguard/v6/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuard6Compatibility.kt similarity index 56% rename from worldguard_compat_v6/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuard6Compat.kt rename to plugin/compatibility/worldguard/v6/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuard6Compatibility.kt index 0f41126..5f4580d 100644 --- a/worldguard_compat_v6/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuard6Compat.kt +++ b/plugin/compatibility/worldguard/v6/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuard6Compatibility.kt @@ -1,10 +1,14 @@ -package me.gabytm.minecraft.arcanevouchers.compat.worldguard +package me.gabytm.minecraft.arcanevouchers.compatibility.worldguard import com.sk89q.worldguard.bukkit.WorldGuardPlugin import org.bukkit.Location -class WorldGuard6Compat : WorldGuardCompat { +class WorldGuard6Compatibility : WorldGuardCompatibility { + /** + * Gets the id of all regions from a certain [Location] + * @return set of region ids + */ override fun getRegions(location: Location): Set { return WorldGuardPlugin.inst().regionContainer.createQuery().getApplicableRegions(location) .map { it.id } diff --git a/worldguard_compat_v7/build.gradle b/plugin/compatibility/worldguard/v7/build.gradle similarity index 71% rename from worldguard_compat_v7/build.gradle rename to plugin/compatibility/worldguard/v7/build.gradle index 83159cc..7e894f3 100644 --- a/worldguard_compat_v7/build.gradle +++ b/plugin/compatibility/worldguard/v7/build.gradle @@ -5,6 +5,6 @@ repositories { } dependencies { - compileOnly project(':worldguard_compat') + compileOnly project(':plugin:compatibility:worldguard:base') compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.5' } \ No newline at end of file diff --git a/worldguard_compat_v7/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuard7Compat.kt b/plugin/compatibility/worldguard/v7/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuard7Compatibility.kt similarity index 60% rename from worldguard_compat_v7/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuard7Compat.kt rename to plugin/compatibility/worldguard/v7/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuard7Compatibility.kt index 3b7d69c..eaf810b 100644 --- a/worldguard_compat_v7/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuard7Compat.kt +++ b/plugin/compatibility/worldguard/v7/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/worldguard/WorldGuard7Compatibility.kt @@ -1,11 +1,15 @@ -package me.gabytm.minecraft.arcanevouchers.compat.worldguard +package me.gabytm.minecraft.arcanevouchers.compatibility.worldguard import com.sk89q.worldedit.bukkit.BukkitAdapter import com.sk89q.worldguard.WorldGuard import org.bukkit.Location -class WorldGuard7Compat : WorldGuardCompat { +class WorldGuard7Compatibility : WorldGuardCompatibility { + /** + * Gets the id of all regions from a certain [Location] + * @return set of region ids + */ override fun getRegions(location: Location): Set { return WorldGuard.getInstance().platform.regionContainer.createQuery().getApplicableRegions(BukkitAdapter.adapt(location)) .map { it.id } diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/ArcaneVouchers.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/ArcaneVouchers.kt index 0d31e9e..1e2b0ae 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/ArcaneVouchers.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/ArcaneVouchers.kt @@ -2,7 +2,7 @@ package me.gabytm.minecraft.arcanevouchers import me.gabytm.minecraft.arcanevouchers.actions.ArcaneActionManager import me.gabytm.minecraft.arcanevouchers.commands.CommandManager -import me.gabytm.minecraft.arcanevouchers.compat.CompatHandler +import me.gabytm.minecraft.arcanevouchers.compatibility.CompatibilityHandler import me.gabytm.minecraft.arcanevouchers.config.Config import me.gabytm.minecraft.arcanevouchers.functions.color import me.gabytm.minecraft.arcanevouchers.items.ItemCreator @@ -22,7 +22,7 @@ class ArcaneVouchers : JavaPlugin() { lateinit var settings: Settings private set lateinit var audiences: BukkitAudiences private set - lateinit var compatHandler: CompatHandler private set + lateinit var compatibilityHandler: CompatibilityHandler private set lateinit var vouchersConfig: Config private set private lateinit var langFile: Config @@ -58,7 +58,7 @@ class ArcaneVouchers : JavaPlugin() { this.settings = Settings(this.config) this.audiences = BukkitAudiences.create(this) - this.compatHandler = CompatHandler(this) + this.compatibilityHandler = CompatibilityHandler(this) this.vouchersConfig = Config(this, "vouchers.yml", false) this.langFile = Config(this, "lang.yml") diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/CompatHandler.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/CompatibilityHandler.kt similarity index 53% rename from plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/CompatHandler.kt rename to plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/CompatibilityHandler.kt index 28f1ace..a6c1770 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/CompatHandler.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compatibility/CompatibilityHandler.kt @@ -1,26 +1,26 @@ -package me.gabytm.minecraft.arcanevouchers.compat +package me.gabytm.minecraft.arcanevouchers.compatibility import me.gabytm.minecraft.arcanevouchers.ArcaneVouchers -import me.gabytm.minecraft.arcanevouchers.compat.worldguard.WorldGuard6Compat -import me.gabytm.minecraft.arcanevouchers.compat.worldguard.WorldGuard7Compat -import me.gabytm.minecraft.arcanevouchers.compat.worldguard.WorldGuardCompat +import me.gabytm.minecraft.arcanevouchers.compatibility.worldguard.WorldGuard6Compatibility +import me.gabytm.minecraft.arcanevouchers.compatibility.worldguard.WorldGuard7Compatibility +import me.gabytm.minecraft.arcanevouchers.compatibility.worldguard.WorldGuardCompatibility import org.bukkit.Bukkit -class CompatHandler(plugin: ArcaneVouchers) { +class CompatibilityHandler(plugin: ArcaneVouchers) { /** - * **ALWAYS** check if [hasWorldGuardSupport] is true before accessing [worldGuardCompat] + * **ALWAYS** check if [hasWorldGuardSupport] is true before accessing [worldGuardCompatibility] */ var hasWorldGuardSupport: Boolean = false; private set - lateinit var worldGuardCompat: WorldGuardCompat private set + lateinit var worldGuardCompatibility: WorldGuardCompatibility private set init { if (Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) { val version = Bukkit.getPluginManager().getPlugin("WorldGuard")!!.description.version when { - version.startsWith("6.") -> WorldGuard6Compat() - version.startsWith("7.") -> WorldGuard7Compat() + version.startsWith("6.") -> WorldGuard6Compatibility() + version.startsWith("7.") -> WorldGuard7Compatibility() else -> { plugin.logger.warning("Found an unsupported WorldGuard version, $version") null @@ -28,7 +28,7 @@ class CompatHandler(plugin: ArcaneVouchers) { }?.let { plugin.logger.info("Added support for WorldGuard v${version[0]} ($version)") this.hasWorldGuardSupport = true - this.worldGuardCompat = it + this.worldGuardCompatibility = it } } } diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/listeners/VoucherUseListener.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/listeners/VoucherUseListener.kt index 894f35c..e154971 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/listeners/VoucherUseListener.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/listeners/VoucherUseListener.kt @@ -21,7 +21,7 @@ class VoucherUseListener(private val plugin: ArcaneVouchers) : Listener { private val useActions = EnumSet.of(Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK) private val voucherManager = plugin.voucherManager private val limitManager = voucherManager.limitManager - private val compatHandler = plugin.compatHandler + private val compatHandler = plugin.compatibilityHandler private val audiences = plugin.audiences private fun NBTCompound.getArgs(): MutableMap { @@ -136,7 +136,7 @@ class VoucherUseListener(private val plugin: ArcaneVouchers) : Listener { if (compatHandler.hasWorldGuardSupport) { val regions = settings.regions - val worldGuardRegions = compatHandler.worldGuardCompat.getRegions(player.location) + val worldGuardRegions = compatHandler.worldGuardCompatibility.getRegions(player.location) // The player is inside a blacklisted region if (regions.isBlacklisted(worldGuardRegions, placeholders, values)) { diff --git a/settings.gradle b/settings.gradle index 60a7e29..1fa8cbc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ rootProject.name = 'arcane-vouchers' include(':plugin') -include(':worldguard_compat', ':worldguard_compat_v6', ':worldguard_compat_v7') +['base', 'v6', 'v7'].forEach { include(':plugin:compatibility:worldguard:' + it) } include(':comet') \ No newline at end of file diff --git a/worldguard_compat/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuardCompat.kt b/worldguard_compat/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuardCompat.kt deleted file mode 100644 index f96c8c6..0000000 --- a/worldguard_compat/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/compat/worldguard/WorldGuardCompat.kt +++ /dev/null @@ -1,9 +0,0 @@ -package me.gabytm.minecraft.arcanevouchers.compat.worldguard - -import org.bukkit.Location - -interface WorldGuardCompat { - - fun getRegions(location: Location): Set - -} \ No newline at end of file