Example #1
0
 public void update(Player player) {
   Container container = containers.get(player);
   if (container != null) {
     int index = 0;
     Widget[] bars = container.getChildren();
     if (members.size() > 1 || alwaysshow) {
       if (hplugin.getCharacterManager().getHero(player).hasParty()) {
         for (Hero h : hplugin.getCharacterManager().getHero(player).getParty().getMembers()) {
           String name = h.getPlayer().getName();
           GenericLivingEntity bar;
           if (index >= bars.length) {
             container.addChild(bar = new GenericLivingEntity());
           } else {
             bar = (GenericLivingEntity) bars[index];
           }
           bar.setEntity(
               name,
               (hplugin
                           .getCharacterManager()
                           .getHero(this.getServer().getPlayer(name))
                           .getParty()
                           .getLeader()
                       == hplugin.getCharacterManager().getHero(this.getServer().getPlayer(name)))
                   ? ChatColor.GREEN + "@"
                   : "");
           bar.setTargets(showpet ? getPets(this.getServer().getPlayer(name)) : null);
           index++;
         }
       } else {
         String name = player.getName();
         GenericLivingEntity bar;
         if (index >= bars.length) {
           container.addChild(bar = new GenericLivingEntity());
         } else {
           bar = (GenericLivingEntity) bars[index];
         }
         bar.setEntity(name, ChatColor.GREEN + "@");
         bar.setTargets(showpet ? getPets(this.getServer().getPlayer(name)) : null);
         index++;
       }
     }
     while (index < bars.length) {
       container.removeChild(bars[index++]);
     }
     container.updateLayout();
   }
 }