quick question to a variable

Discussion in 'Plugin Development' started by tschagg, Jan 12, 2013.

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

    tschagg

    hey guys,
    how i can save a playername in a variable ? like "playername = args[0]" ?
    i wanna have "args[0]" in a public void.
    i tried with int and string, but both dont work.

    any ideas?
     
  2. Offline

    Rprrr

    Ehm.. you want to get the args[0] from a command?

    String playername = args[0];
     
  3. Could you please try to explain it in a more understandable way? I would really like to help you, but I can't figure out, what you are trying to do.
     
  4. Offline

    tschagg

    Code:
          if (cmd.getName().equalsIgnoreCase("lban")) {
              if (args.length == 1) {
                  myPlugin.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                        @Override
                        public void run() {
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ban " + args[0] + " Griefing");
                        }
                    }, 60L);
                  // Commands
     
          }
    the args[0] in this public void isnt workin, how i get the text from a command in there ?
    sry for the bad english
     
  5. try this:

    Code:
          if (cmd.getName().equalsIgnoreCase("lban")) {
              if (args.length == 1) {
                  final String playername = args[0];
                  myPlugin.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                        @Override
                        public void run() {
                            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ban " + playername + " Griefing");
                        }
                    }, 60L);
                  // Commands
     
          }
     
  6. Offline

    tschagg

    aah, perfect, thank you :) - Solved -
     
Thread Status:
Not open for further replies.

Share This Page