How to use world edit methods in my plugin? (still open)

Discussion in 'Plugin Development' started by Tails_Prower_24, Jan 8, 2016.

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

    Tails_Prower_24

    I would like to know how to use world edit methods in my plugin.

    This is my code:

    Code:
    package me.tailsprower24;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class ExampleForBukkit
    {
       public boolean onCommand (CommandSender theSender, Command cmd, String commandLabel, String[] args)
       {
         if (commandLabel.equalsIgnoreCase("bbsetarena"))
         {
           Player thePlayer = (Player) theSender;
           thePlayer.sendMessage("Set the arena.");
         }
         return true;
       }
    }
    
    I would like it to be the following:

    select the area with world edit (??) [how to do this?]
    \/
    do the command
    \/
    arena set

    unfortunately, I only have the command part

    I read through a little of this http://docs.sk89q.com/worldedit/apidocs/ but i'm highly confused.
     
  2. Offline

    Zombie_Striker

    @Tails_Prower_24
    Then I will explain how to use docs. Thew docs contains all the methods and classes used in a plugin/program/API. You use the docs when you are unsure how something works/what methods/classes a class or package has.

    What you're looking for is the following:
    http://docs.sk89q.com/worldedit/apidocs/com/sk89q/worldedit/regions/Region.html
    http://docs.sk89q.com/worldedit/apidocs/com/sk89q/worldedit/regions/RegionSelector.html

    Using these two links, find a method that will search and retrieve a region. There should be a description for each method explaining what each method does.
     
  3. Offline

    Tails_Prower_24

    Thank you @Zombie_Striker

    Ah. Found it in those links.

    I used these lines of code:
    Code:
      public boolean getRegion()
       {
         return false;
       }
    
    now here is the full code:
    Code:
    package me.tailsprower24;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class ExampleForBukkit
    {
       public boolean getRegion()
       {
         return false;
       }
       public boolean onCommand (CommandSender theSender, Command cmd, String commandLabel, String[] args)
       {
         if (commandLabel.equalsIgnoreCase("bbsetarena"))
         {
           Player thePlayer = (Player) theSender;
           thePlayer.sendMessage("Set the arena.");
         }
         return true;
       }
    }
    
    Now how can I save this arena with unique numbers (each arena is classified by a number)?
     
    Last edited: Jan 8, 2016
  4. Offline

    mine-care

    Errr i dont really understand the reason of existance of this method... it will always return false :S

    Dont use commandLabel, use Command#getName() instead

    Dont cast blindly!!!
     
    GamerzKing likes this.
  5. Offline

    Tails_Prower_24

  6. Offline

    IMleader

    Code:
      public boolean getRegion()
       {
         return false;
       }
    
    As @mine-care said. When you try to use this method it will only give you false. Thus making it useless

    Dont use commandLabel, use Command#getName() instead
    Don't use
    Code:
    (commandLabel.equalsIgnoreCase("bbsetarena"))
    
    You can do a lot more with
    Code:
    cmd.getName().equalsIgnoreCase("bbsetarena"))
    

    Dont cast blindly!!!
    Don't cast if you don't have to

    Now on to your problem.
    Make sure you have worldedit added to the build path. I would recommend readed here: https://www.sk89q.com/2013/03/worldedit-selections-for-bukkit-plugins/
     
    GamerzKing and mine-care like this.
  7. Offline

    blue1

    To add WorldEdit to the build path, do you just add the plugin as an external .jar as you would the spigot.jar?
     
  8. Offline

    mcdorli

    Yeah, pretty much.
    Also, you need to include the depend: [worldedit] in ypur plugin.yml
     
  9. Offline

    blue1

    Thanks. :) I'll do a softdepend: [WorldEdit] I think.
     
Thread Status:
Not open for further replies.

Share This Page