Solved Question about command argument

Discussion in 'Plugin Development' started by Tabbin, Jul 20, 2014.

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

    Tabbin

    So i have some code, but on the piece of code, it's been lined out and i dont know why. this is it :

    Code:java
    1. @Override
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    3. if(cmd.getName().equalsIgnoreCase("g")) {
    4. if(args.length == 1){
    5. Player target = Bukkit.getServer().getPlayer(arg0);
    6.  
    7.  
    8. target.setGameMode(arg1);

    getPlayer.(arg0); is been lined out.
    I'm pretty sure im doing something wrong, what im trying to do is make it so i could do /g 1 for like /gamemode 1.
    Please help. Thanks!
     
  2. Offline

    dsouzamatt

    Tabbin What do you mean by "lined out"? Which line of code are you referring to?
     
  3. Offline

    Necrodoom

    This is not the correct way to access a variable in an array.
    You are looking for array, not arrayi.
     
  4. Offline

    Phantom_64

    Tabbin
    "args" is an array, so you have to use args[0] and args[1] instead of arg0 and arg1.
     
  5. Offline

    Tabbin

    [​IMG] Phantom_64
     
  6. Offline

    fireblast709

    Tabbin that depreciation is just to make people aware of the UUID change. There are no issues when using it
     
  7. Offline

    Tabbin

    Ah okay. Thanks!
     
  8. Offline

    Necrodoom

    Tabbin Read the message it tells you. Most likely it tells you its deprecated, because UUID change means you shouldnt use player names for the purpose of storage, but the way you use getPlayer is fine, so ignore message.
     
Thread Status:
Not open for further replies.

Share This Page