Solved Question about command argument

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

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


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

    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);
    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


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


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


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


    [​IMG] Phantom_64
  6. Offline


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


    Ah okay. Thanks!
  8. Offline


    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