Solved How to check whether an argument in a command is an integer?

Discussion in 'Plugin Development' started by GODofCRAFTERS, Apr 12, 2015.

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

    GODofCRAFTERS

    Here's the code I'm confuzzled with:
    Code:
    if(cmd.getName().equalsIgnoreCase("reqdel") && sender instanceof Player){
            if(sender.hasPermission("requests.manage")){
                    if(args.length == 1 && (args[0] instanceof Integer){
                        blah blah blah
                    }
                }
    The problem is, the instanceof operator doesn't work on String and Integer... How do I check whether the first argument in a command is an integer?
     
  2. Online

    timtower Administrator Administrator Moderator

    @GODofCRAFTERS Integer.parseInt throws an error if the input isn't an integer. Try catch it.
     
    GODofCRAFTERS likes this.
Thread Status:
Not open for further replies.

Share This Page