How to integrate WorldGuard completely in my Plugin?

Discussion in 'Plugin Development' started by Hannobal, Jul 15, 2012.

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

    Hannobal

    Hey :D

    I have a new question again ^^

    I want to integrate WorldGuard in my Plugin that I can change or "manipulate" the owner or members of the regions. Also I want to read out the size (width, length, height) of the regions.

    I read the following api instructions, but this doesn't helps me ...
    http://wiki.sk89q.com/wiki/WorldGuard/Regions/API

    Is this in any way possible? I am happy about every solution! :)

    Greetings,
    Hanno
     
  2. try importing the worlguard plugin to your project, and see hwat methodes there are on the main class

    found an example how to get the main worldguard plugin:
    Code:java
    1. public static WorldGuardPlugin getWorldGuard(JavaPlugin plugin)
    2. {
    3. Plugin wPlugin = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
    4.  
    5. if ((wPlugin == null) || (!(wPlugin instanceof WorldGuardPlugin)))
    6. {
    7. return null;
    8. }
    9.  
    10. return (WorldGuardPlugin) wPlugin;
    11. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  3. Offline

    Hannobal

    I tried it already ;) But (I think) there is no method i can use for this

    I copied your code example into my main class and tried to call "getWorldGuard(this)."

    A list of all commands i got you see on the image I uploaded

    View attachment 10436

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  4. getGlobalRegionManager() ?
    getRegionManager(World world) ?

    Look through those for methods :)
     
  5. Offline

    Hannobal

    Nothing, sorry
    There are almost the same methods, only some methods lessier :(
     
  6. I saw those methodes standing on the list you posted?
     
  7. Offline

    Hannobal

    Yes you are right, but i tried the following

    Code:
    getWorldGuard(this).getGlobalRegionManager().
     
    getWorldGuard(this).getRegionManager(World world).
    And then i got the same but lessier methods
     
  8. I don't really get what you're saying... what are the methods that those 2 methods provide ?

    Also, don't call getWorldGuard() all the time, store its pointer.

    EDIT: here's an example from the very link you posted:

    Code:
    WorldGuardPlugin worldGuard = getWorldGuard();
    Vector pt = toVector(block); // This also takes a location
    LocalPlayer localPlayer = worldGuard.wrapPlayer(player);
     
    RegionManager regionManager = worldGuard.getRegionManager(world);
    ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
    return set.canBuild(localPlayer);
    So, I'm unsure if you really understand Java or not, but there are alot of methods there that you can use.
     
    Hannobal likes this.
  9. Offline

    Hannobal

    I hope it is allowed posting links of picture upload sites, the pictures take very much space of the thread ^^

    What do you mean with "pointer"? Maybe something like this?
    Code:
    WorldGuardPlugin wgp = getWorldGuard(this);
    This I got if I used "getWorldGuard(this).getRegionManager(World world);" (I got lessier methods but some of them are the same)
    [​IMG]

    And this I got if I used "getWorldGuard(this).getGlobalRegionManager()." (more lessier methods than in the picture before, but they are the same)
    [​IMG]

    I don't found a method, which I can use for my plan


    Okay this code seems to be very interesting for my plan, but how I can remove a player from owner or / and member of a region ?

    Okay, I took a good look at this code, but i found no way to CHANGE owners and members. I think with this code I can only get informations about the regions or the player, but I want to change owners and members of regions....

    Is there no way or am I too stupid for that?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  10. just guaessing, it might be
    WorldGuardPlugin worldGuard = getWorldGuard();
    Vector pt = toVector(block); // This also takes a location
    LocalPlayer localPlayer = worldGuard.wrapPlayer(player);

    RegionManager regionManager = worldGuard.getRegionManager(world);
    ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
    set.addOwner(localPlayer);
    // or it might be
    set.addOwner(localPlaye.getNamer);
     
  11. Offline

    Hannobal

    I can't access to the method "addOwner()" -.-'
     
  12. How about look at the available methods there ?
    And also look at the available methods for worldGuard.getRegionManager(world).
     
Thread Status:
Not open for further replies.

Share This Page