Exemplo n.º 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();
   }
 }
Exemplo n.º 2
0
 public void onTick() {
   if (this.target != null) {
     int health = getHealth(this.target);
     if ((!this.target.isDead())
         && (health > 0)
         && (this.player.getWorld() == this.target.getWorld())
         && (this.player.getLocation().distance(this.target.getLocation())
             <= config_max_range)) {
       if (((this.target instanceof Player)) && (data.containsKey((Player) this.target)))
         setTargets(new LivingEntity[] {((perPlayer) data.get((Player) this.target)).target});
       else if (((this.target instanceof Creature))
           && (((Creature) this.target).getTarget() != null)
           && (!((Creature) this.target).getTarget().isDead()))
         setTargets(new LivingEntity[] {((Creature) this.target).getTarget()});
       else setTargets(new LivingEntity[0]);
     } else {
       setTargets(new LivingEntity[0]);
       setTarget(null);
     }
   }
   super.onTick();
 }