Solved How to add Members to a WorldGuard region?

Discussion in 'Plugin Development' started by NiekDGE, Nov 29, 2014.

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

    NiekDGE

    I'm creating a kingdom plugin, where you can use the command "/builder <Player>" to make someone in your kingdom a builder. If you are a builder you can build in the a specific region. Now, my question is: How to add Members to a WorldGuard region? I know you can do it with /region addmember <region> <player>. This is what I have now:

    Code:java
    1. if (cmd.getName().equalsIgnoreCase("builder")){
    2.  
    3. if (!(p.hasPermission("koning.kingdom1") || p.hasPermission("koning.kingdom2") || p.hasPermission("koning.kingdom3") || p.hasPermission("koning.kingdom4") || p.hasPermission("koning.kingdom5") || p.hasPermission("koning.kingdom6"))){
    4. p.sendMessage(ChatColor.RED + "Je hebt geen permissions om dit te doen!");
    5. }
    6.  
    7. if (p.hasPermission("koning.kingdom1") || p.hasPermission("koning.kingdom2") || p.hasPermission("koning.kingdom3") || p.hasPermission("koning.kingdom4") || p.hasPermission("koning.kingdom5") || p.hasPermission("koning.kingdom6")){
    8.  
    9. if(args.length == 1){
    10. Player target = Bukkit.getServer().getPlayerExact(args[0]);
    11.  
    12.  
    13.  
    14. if (target == null){
    15. sender.sendMessage("De speler is niet online");
    16. }
    17.  
    18. else if (p.hasPermission("koning.kingdom1")){
    19.  
    20.  
    21. if (target.hasPermission("kingdom1")){
    22. ru.tehkode.permissions.bukkit.PermissionsEx.getUser(target).setPrefix(ChatColor.GRAY + "[" + ChatColor.YELLOW + "Builder" + ChatColor.GRAY + "]" + ChatColor.GRAY + "[" + ChatColor.DARK_GREEN + "Kingdom 1" + ChatColor.GRAY + "] ", "world");
    23. p.sendMessage(ChatColor.BLUE + "Je hebt " + target.getName() + " de rank Rechterhand gegeven!");
    24. target.sendMessage(ChatColor.BLUE + "Je koning " + p.getName() + " heeft jou net de rank Rechterhand gegeven!" );
    25.  
    26. }else{
    27. p.sendMessage(ChatColor.RED + "Deze speler is geen lid van jouw kingdom!");
    28. }
    29. }
     
  2. you need to run the command as the console: Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "region addmember exampleregion exampleplayer");
     
  3. Offline

    indyetoile

    NiekDGE
    Additionally you could take a look at the WorldGuard API.
     
  4. Offline

    coasterman10

    Include the WorldGuard plugin into your build path, or if you are using Maven include WorldGuard as a dependency from sk89q's repo: http://maven.sk89q.com/repo

    Then look over the WorldGuard javadocs: http://docs.sk89q.com/

    From there you can access all the features of the WorldGuard API through code, without having to dispatch commands. Don't forget to add WorldGuard as a dependency.

    I would also suggest including WorldEdit too as much of WorldGuard depends on it at compile time, and then adding WorldEdit as a dependency.
     
  5. Offline

    Funergy

    NiekDGE Use what FisheyLP said
     
  6. Offline

    NiekDGE

    FisheyLP likes this.
Thread Status:
Not open for further replies.

Share This Page