Solved GetOnlinePlayers only targeting the sender

Discussion in 'Spigot Plugin Development' started by Donkelyn, Sep 28, 2019.

  1. I'm trying to find out how to teleport all players (and other stuff) to a position in the world, but this command only sends me who initiates the command and no one else on the server? Any clue why that would be?

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    for (Player allplayers : Bukkit.getOnlinePlayers()) {
    Location lobby = new Location(Bukkit.getWorld("Ragnarokworld"), -10, 6, 4);

    return true;
  2. First thing, use the code brackets.

    Specific the command with
    Code (Java):
    cmd.getName().equalsIgnoreCase(String str)
    (Not required)

    Also your code is not full as the boolean isn't closing.
  3. Its hard to tell without having your code formatted and also not showing your closing brackets, but my guess is your `return true;` appears to within your loop. Therefor after the first iteration of all players, you are returning the command therefor exiting therefor only teleporting the first player in said list.