Development Assistance Getonlineplayers doesnt work

Discussion in 'Plugin Help/Development/Requests' started by DaanSander, Feb 1, 2015.

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

    DaanSander

    hey i have created a command so when i do /tpall it teleports all the players to me but getOnlinePlayers() doesnt work

    code:
    Code:
    if(label.equalsIgnoreCase("tpall")) {
                Player p = (Player) sender;
                for(Player players : Bukkit.getServer().getOnlinePlayers()) {
                    players.teleport(p.getLocation());
                    return true;
                }
    error:
    ambiguous method call. both
     
  2. Offline

    Funergy

    @DaanSander Why do you do return true; in your loop.
    And do you have Bukkits API in your build path or CraftBukkit? Use the API
     
  3. Offline

    drpk

  4. Offline

    DaanSander

    what do you mean??
     
  5. Offline

    DaanSander

    no i have spigot in my build path
     
  6. @DaanSander Shouldn't you be posting to the Spigot forums instead?
     
  7. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
  8. Offline

    nverdier

    No, just in the section it was moved to.
     
  9. Offline

    LordDarthBob

    Code:
    if(label.equalsIgnoreCase("tpall")) {
                Player p = (Player) sender;
                for(Player players : Bukkit.getServer().getOnlinePlayers()) {
                    players.teleport(p.getLocation());
                }
          return true;
    }
    Just move the return statement outside and underneath the for loop. The command stops when java reads over it.

    Nitpicky code stuff (open)

    I'd also suggest that instead of using "label.equalsIgnoreCase("tpall")", you use "cmd.getName().equalsIgnoreCase("tpall")". If you use "label.equalsIgnoreCase("tpall")", you can't use command aliases.
     
Thread Status:
Not open for further replies.

Share This Page