Something like variables in commands?

Discussion in 'Plugin Development' started by AaronLLF, Jan 15, 2011.

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


    OK, so I need something that is used as a variable in a command. For example, /item 1 would give you stone, because it then uses, after the if statement, drops the item that's id is equal to the variable. I was wondering how I could do that.

    Or a better example:
    Like if they type /time 1000, I'd use plugin.getServer().time(userTimeInput) (Or whatever) where userTimeInput = 1000, rather than doing it over and over again with each time of the day.

    Please help.
  2. Offline


    Usually you do this by using string.split
    String[] split = event.getMessage().split(" ");
    int myVar = Integer.parseInt(split[1]);

    This makes an array of everything that is between a space.
    You should first check if the length is higher than 0 of course.
Thread Status:
Not open for further replies.

Share This Page