1.15.2 Help with scoreboard team size

Discussion in 'Spigot Plugin Development' started by Donkelyn, Feb 4, 2020.

  1. I'm tryna manage a plugin where it detects the last person on the team and gives them a boost. The plan is basically.

    Code (Text):
       
        @EventHandler
        public void onPlayerDeath (PlayerDeathEvent event)
        {
            ScoreboardManager Manager = Bukkit.getScoreboardManager();
            Scoreboard board = Manager.getMainScoreboard();
            Team asgard = board.getTeam("Asgard");
            asgard.getSize();
           
           // if size is 1
            //find player on asgard
            //give them buffs
          //if size not 1
          //nothing
        }
        }
    I know my use of get size is wrong but idk how to use it properly any help is welcome thanks!
     
  2. I guess you could get a list of all players assigned to that team with Team#getPlayers(). You can get the size of that list with List#size(). I don't know if it would keep track of the Last player in that team though.