Esempio n. 1
0
  @EventHandler
  public void handleClose(InventoryCloseEvent event) {
    HumanEntity p = event.getPlayer();
    Inventory inv = event.getInventory();

    if (inv.getName().equals(name)) {
      eat();

      if (SpawnerGUI.openGUIs.contains(p.getName())) {
        SpawnerGUI.openGUIs.remove(p.getName());
      }
    }
  }
Esempio n. 2
0
  public static LivingEntity[] getPets(HumanEntity player) {
    ArrayList<LivingEntity> pets = new ArrayList<LivingEntity>();
    String name;
    if ((player != null) && ((!(player instanceof Player)) || (((Player) player).isOnline()))) {
      name = player.getName();
      for (World world : Bukkit.getServer().getWorlds()) {
        for (LivingEntity entity : world.getLivingEntities()) {
          if (((entity instanceof Tameable))
              && (((Tameable) entity).isTamed())
              && ((((Tameable) entity).getOwner() instanceof Player))
              && (name.equals(((Player) ((Tameable) entity).getOwner()).getName()))) {
            pets.add(entity);
          }
        }
      }
    }

    LivingEntity[] list = new LivingEntity[pets.size()];
    pets.toArray(list);
    return list;
  }