Teleport all online players

Discussion in 'Plugin Development' started by Elior231, Mar 2, 2020.

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

    Elior231

    I'm Trying To Teleport All Online Players On The Server But
    I Don't Know How
    I Tried Alot Of Ways But It Didn't Work
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Elior231 Loop over the players, teleport?
     
  3. for(Player p : Bukkit.getOnlinePlayers()) {
    //Do your stuf here
    }
     
  4. Offline

    Elior231

    what to place there
     
  5. Offline

    timtower Administrator Administrator Moderator

    The function that teleports players to a specific location.
     
  6. Offline

    Kars

    You need to do SOME work yourself my guy.
     
    MadMarvin likes this.
  7. Offline

    Elior231

    i tried that but when I'm Doing This :
    Location loc = Location(world, 0, 60, 0);

    I'm Getting An Error "world cannot be resolved to a variable"
     
  8. Offline

    wand555

    If you know the name of your world you can use Bukkits method to get the World.
     
  9. Offline

    Kars

  10. Offline

    Elior231

    And I'm Getting This Error :
    The method Location(World, int, int, int) is undefined for the type Main
     
  11. Offline

    timtower Administrator Administrator Moderator

    @Elior231 You are missing the "new" keyword.
     
  12. Offline

    wand555

    @Elior231 Use Kars' approach.
    Also I highly suggest you to get the hang of basic java first...
     
    Strahan and timtower like this.
  13. Offline

    Elior231

    Same Result
    "The method Location(World, int, int, int) is undefined for the type Main"
     
  14. Offline

    timtower Administrator Administrator Moderator

    With what code?
     
  15. For a location you first need to create it as a new Location:

    Location loc = new Location(world, x, y, z);
    After that, you can teleport all the players in a for loop.
     
  16. Offline

    Machine Maker

    Perhaps you need to read up on Java in general. There are some great tutorials on java out there, just google some.
     
  17. Offline

    Lightcaster5

    Pretty much what everyone is saying to do is first, learn some Java, then, try something like this (this has all the ideas coined a bit more connected but not the full answer):
    Code:
    for (Player player : Bukkit.getOnlinePlayers()) {
        Location location = new Location(Bukkit.getWorld("YOUR_WORLD"), 0, 0, 0);
        player.teleport(location);
        player.sendMessage(ChatColor.GOLD + "You have been summoned!");
    }
     
  18. Offline

    Elior231

    Never Mind On Spigot Forum Someone Helped Me
    The Problem Was The Import Thank You For Trying To Help Me
     
Thread Status:
Not open for further replies.

Share This Page