How to have 2 word commands?

Discussion in 'Plugin Development' started by ShadowWizardMC, Jan 7, 2014.

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

    ShadowWizardMC

    I would like to have 2 word commands and some help with my plugin.yml as it seems to bee malfunctioning in the server. I dont wanna have a long list of code here so ill put in pastebin but i would also like to know how to have multiple SignListeners for each kit and a fix for the plugin.yml thanks

    Main: http://pastebin.com/WxNHECvg

    Listener :
    Code:java
    1. package me.ShadowWizard.kitpvp;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.block.Sign;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.block.Action;
    8. import org.bukkit.event.block.SignChangeEvent;
    9. import org.bukkit.event.player.PlayerInteractEvent;
    10.  
    11. public class SignListener implements Listener {
    12.  
    13. @EventHandler
    14. public void onSignChange(SignChangeEvent e) {
    15. if (e.getLine(0).equalsIgnoreCase("kit tank")) {
    16. e.setLine(0, "§c [KitPvp]");
    17. e.setLine(1, " [Kit]");
    18. e.setLine(2, "§3 Tank");
    19. }
    20. }
    21.  
    22. @EventHandler
    23. public void onPlayerInteract(PlayerInteractEvent e) {
    24. if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    25. if (e.getClickedBlock().getState() instanceof Sign) {
    26. Sign s = (Sign) e.getClickedBlock().getState();
    27. if (s.getLine(0).equalsIgnoreCase("tank")) {
    28. }
    29. }
    30. }
    31. }
    32.  


    Plugin.yml:

    Code:java
    1. name: KitPvp
    2. main: me.ShadowWizard.kitpvp.core
    3. version: 1.0
    4. depend: [Vault]
    5. commands:
    6. kitpvp:
    7. description: Shows details about the current version of KitPvP
    8. kit:
    9. description: Opens the Kit selection GUI!
    10. kit tank:
    11. description: Chooses the Tank kit!
    12. kit archer:
    13. description: Chooses the Archer kit!
    14. kit ninja:
    15. description: Chooses the Ninja kit!
    16. kit demo:
    17. description: Chooses the Demo kit!
    18. kit solider:
    19. description: Chooses the Solider kit!
    20.  
    21.  
    22. permissions:
    23. kitpvp.tank:
    24. description: Used to access Tank kit.
    25. default: true
    26. kitpvp.archer:
    27. description: Used to access Archer kit.
    28. default: true
    29. kitpvp.ninja:
    30. description: Used to access Ninja kit.
    31. default: true
    32. kitpvp.demo:
    33. description: Used to access Demo kit.
    34. default: true
    35. kitpvp.solider:
    36. description: Used to access Solider kit.
    37. default: true
     
  2. There are some libraries out there who would allow you that but the easiest thing is to just evaluate the first argument.
     
  3. Offline

    MOMOTHEREAL

    In this case, you may use arguments.
    So you would need to have a single /kit command, and then you can do something like this in the command:

    if (args[0].equalsIgnoreCase("tank"){
    //Do stuff
    }
     
Thread Status:
Not open for further replies.

Share This Page