Resource Getting the world's RegionManager in WorldGuard 7

Discussion in 'Spigot Plugin Development' started by MrPowerGamerBR, Aug 2, 2018.

  1. WorldGuard's API changed in the Minecraft 1.13 update (because the MC 1.13 version is based in WG 7, not WG 6), so I decided to post here how to get the RegionManager instance in WorldGuard 7!

    Code (Java):
    val regionContainer = WorldGuard.getInstance().platform.regionContainer
    val regionManager = regionContainer[BukkitAdapter.adapt(loc.world)]
    Example:
    Code (Java):
    fun isWithinRegion(loc: Location, region: String): Boolean {
        val regionContainer = WorldGuard.getInstance().platform.regionContainer
        val regionManager = regionContainer[BukkitAdapter.adapt(loc.world)] ?: return false
        val set = regionManager.getApplicableRegions(BukkitAdapter.adapt(loc).toVector())
        return set.any { it.id.equals(region, ignoreCase = true) }
    }
     
    • Like Like x 1
  2. Kotlin for the win.
     
    • Agree Agree x 1