Taking Command Input as well as Variable

Discussion in 'Plugin Development' started by sparkhead95, Mar 6, 2014.

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

    sparkhead95

    Hi, i'm new on this site so if there is a lack of information provided (or i'm in the wrong category) please let me know and i will try and update you all/change it ASAP.

    I'm trying to find out how to take an input as well as my custom command from the user.
    For example, my code at this stage is:


    Code:java
    1. public boolean onCommand(CommandSender sender, Command command,
    2. String commandlabel, String[] args) {
    3. if(sender instanceof Player){
    4. Player player = (Player) sender;
    5. if(commandlabel.equalsIgnoreCase("setjheight")){
    6. getConfig().set(".Jump Height = ", jheight);
    7. saveConfig();
    8. }
    9. }
    10. return false;
    11. }


    I want to know how to take an integer from the cmd, which will eventually be signed to the global variable "setjheight", after /setjheight has been entered.
    This is so that the user can configure jheight during gameplay, and not have to edit it in the YML and have to reload the server.

    Thanks in advance,
    Sparkhead95

     
  2. Offline

    Wolfey

  3. If jheight is a string then use the parseInt() method in the Integer class to convert it into an Integer.
     
Thread Status:
Not open for further replies.

Share This Page