How do I get worldguard regions in 1.13?

Discussion in 'Spigot Plugin Development' started by Xsm0deus, Oct 10, 2018.

  1. I had this written up for older versions of worldguard and it no longer works. How do I fix it?

    Code (Text):
    public ArrayList < String > getRegions(Location loc) {
            ArrayList < String > ret = new ArrayList < String > ();
            WorldGuardPlugin wg = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard");
            if (wg != null) {
                RegionContainer rc = wg.getRegionContainer();
                ApplicableRegionSet ars = rc.get(loc.getWorld()).getApplicableRegions(loc);
                for (ProtectedRegion pr: ars.getRegions()) ret.add(pr.getId().toLowerCase());
            }
            return ret;
        }
     
  2. No longer works isn't helpful at all. Define "doesn't work". Are you having any errors? Is it doing nothing at all? Etc..
     
  3. They changed the API and there is no instructions anywhere on how to use it (When I last looked). It literally doesn't work, there are errors because you can't run that code anymore, it worked before, they changed the API, it doesn't work anymore. It isn't helpful to say "That's not helpful". Try it yourself with the old version and the new version and see for yourself.
     
  4. Why even bother posting if you're not helping?
    OP just said theres no documentation for the 1.13 API so google is pretty useless.

    The way you do it in 1.13 is as follows:
    Code (Text):
    //get the region manager
    RegionManager rm = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world));

    //get the regions at a given location
    ApplicableRegionSet set = rm.getApplicableRegions( BukkitAdapter.asVector(loc) );

           for ( ProtectedRegion region : set ) //do stuff with the regions at the location.
     
     
  5. https://www.spigotmc.org/threads/worldguard-api-for-1-13.333574/

    First link when you search "WorldEdit 1.13 api"
     

Share This Page