Solved Different arguments

Discussion in 'Plugin Development' started by greaperc4, Oct 2, 2013.

Thread Status:
Not open for further replies.
  1. Hello,

    I'm trying out something, but I need some help.
    This is the command: /test put <player|number>
    How do I know if the player has entered a Player or a Number?

    This is the code I use:
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("test")) {
    2. if (args.length == 0) {
    3. player.sendMessage("try: /test set <player|number>");
    4. }
    5. if (args.length == 2 && args[0].equalsIgnoreCase("put")) {
    6. try {
    7. Player target = Bukkit.getServer().getPlayer(args[1]);
    8. //code
    9. } catch (NullPointerException ex) { }
    10. try {
    11. int number = Integer.parseInt(args[1]);
    12. //code
    13. } catch (NumberFormatException ex) { }
    14. }
    15. }

    is this correct?

    EDIT: NVM, Fixed it!
     
  2. Offline

    tommycake50

    I know it's obvious but could you post how you fixed it for the benefit of other people who may have the same problem?
     
    1Achmed1 likes this.
Thread Status:
Not open for further replies.

Share This Page