World Guard API

Discussion in 'Plugin Development' started by EtgarSH, Dec 22, 2013.

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

    EtgarSH

    Hello,
    I want to code a function that when a player type /claim he claims a new region by his name.
    How can I make a new region via WG API?
    THX a lot!
     
  2. Offline

    Davesan

    First you must connect the WorldGuard.jar to your plugin.jar while you code. If u don't know how send me a PM.
    Second step: Write "depend: [WorldGuard]" into your plugin.yml file.
    Third step: You can get the WorldGuard API this way:
    Code:java
    1. private WorldGuardPlugin getWorldGuard() {
    2. Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
    3.  
    4. // WorldGuard may not be loaded
    5. if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
    6. return null; // Maybe you want throw an exception instead
    7. }
    8.  
    9. return (WorldGuardPlugin) plugin;
    10. }

    You can store it in a WorldGuardPlugin varriable and use it later on. Like:
    Code:java
    1. WorldGuardPlugin wg = getWorldGuard();
    2.  
    3. wg.X.Y(); //> use its methods this way.
     
Thread Status:
Not open for further replies.

Share This Page