How to integrate WorldGuard completely in my Plugin?

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

  1. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    This post has been edited 1 time. It was last edited by Hannobal Jul 15, 2012.
  2. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    try importing the worlguard plugin to your project, and see hwat methodes there are on the main class
  3. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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. }
  4. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I tried it already ;) But (I think) there is no method i can use for this
  5. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    methods.jpg

    This post has been edited 3 times. It was last edited by Hannobal Jul 15, 2012.
  6. Offline

    Digi

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    getGlobalRegionManager() ?
    getRegionManager(World world) ?

    Look through those for methods :)
  7. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Nothing, sorry
    There are almost the same methods, only some methods lessier :(
  8. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I saw those methodes standing on the list you posted?
  9. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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
  10. Offline

    Digi

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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.

    This post has been edited 3 times. It was last edited by Digi Jul 15, 2012.
    Hannobal likes this.
  11. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    This post has been edited 1 time. It was last edited by Hannobal Jul 15, 2012.
  12. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME

    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 ?
  13. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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?
  14. Offline

    ferrybig

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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);
  15. Offline

    Hannobal

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I can't access to the method "addOwner()" -.-'
  16. Offline

    Digi

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    How about look at the available methods there ?
    And also look at the available methods for worldGuard.getRegionManager(world).
  17. Offline

    James | Buchanan

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME

Share This Page