1.8.8 run a command on all players

Discussion in 'Spigot Plugin Development' started by toshi2131, Apr 16, 2020.

  1. hello, so I'm using a plugin in my server that has a command
    coins set (player) amount.
    so I know I need to use dispatch command.

    by my question is, I wanna make the command to run on all online players.
    so like every 50m, the command coins add (player Aka all players) amount

    I couldn't figure out out to do it by code.
    any help?
  2. You can use Bukkit#getOnlinePlayers() to get all online players

    For the 50 minutes you can check out BukkitTasks
  3. i know ill use a runnable, my main question is how do i run the command ON all online players and not just a specific player
  4. Code (Java):

    for(Player player : Bukkit.getOnlinePlayers()) {

    //command with player.getName()
  5. Run a for loop?
  6. U should make a for like that

    p is all players online

    Code (Java):
         for (Player p : Bukkit.getOnlinePlayers()){

    //execute something