WorldGuard API Problem

Discussion in 'Plugin Development' started by zlToxicNetherlz, Nov 12, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    zlToxicNetherlz

    I do not speak English very well.
    Hello, I can not make my plugin works with multiple versions of WolrdGuard
    i try to use the next code:
    Code:
        public static boolean wgRegionHook(Location location){
            if(Listen.plugin.getServer().getPluginManager().getPlugin("WorldGuard") != null){
                if(Listen.plugin.getServer().getPluginManager().getPlugin("WorldGuard").getDescription().getVersion().contains("6.1") ||
                         Listen.plugin.getServer().getPluginManager().getPlugin("WorldGuard").getDescription().getVersion().contains("6.0")){
                    if(WG_6_0(location)){
                        return true;
                    } else {
                        return false;
                    }
                } else {
                    if(WG_5_0(location)){
                        return true;
                    } else {
                        return false;
                    }
                   
                   
                }
            } else {
                return true;
            }
        }
       
        public static boolean WG_6_0(Location location){
            /**
            * New [WorldGuard] Versions
            * @6.0 >
            */
            WorldGuardPlugin worldGuard = getWorldGuard();
            com.sk89q.worldedit.Vector pt = com.sk89q.worldguard.bukkit.BukkitUtil.toVector(location);
                    
            RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
            ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
                   
            if(set.size() != 0){
                return false;
            } else {
                return true;
            }
        }
       
        public static boolean WG_5_0(Location location){
            /**
             * Old [WorldGuard] Versions
             * @5.0 >
             */
            WorldGuardPlugin WGP = (WorldGuardPlugin)ElementalTrees.plugin.getServer().getPluginManager().getPlugin("WorldGuard");
            if (WGP.getRegionManager(location.getWorld()).getApplicableRegions(location).size() == 0) {
                    return true;
            }
            return false;
         }
    I need to make my plugin works with all versions of WG. But I can not do it.
    It only works with the 5.0 and up. But 6.0 or 6.1 not work with the same method.
    Appreciate your help.
     
  2. Offline

    mcdorli

    I don't think it matters if your plugin is not compatible with older versions of a another one, just use the 6.1
     
Thread Status:
Not open for further replies.

Share This Page