Exemplo 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());
      }
    }
  }
Exemplo n.º 2
0
 @SuppressWarnings("deprecation")
 public static ItemStack getWeapon(HumanEntity human) {
   if (human == null) return null;
   ItemStack ret = human.getItemInHand();
   ret = clean(ret);
   return ret;
 }
Exemplo n.º 3
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;
  }
 /**
  * Sets the invulerability state of an Entity
  *
  * @param entity to set it for
  * @param state to set to
  */
 public static void setInvulnerable(Entity entity, boolean state) {
   if (entity instanceof HumanEntity) {
     getAbilities((HumanEntity) entity).setInvulnerable(state);
   }
 }
Exemplo n.º 5
0
 public static void setShield(HumanEntity human, ItemStack shield) {
   if (human == null) return;
   setShield(human.getInventory(), shield);
 }
Exemplo n.º 6
0
 public static ItemStack getShield(HumanEntity human) {
   if (human == null) return null;
   return getShield(human.getInventory());
 }
Exemplo n.º 7
0
 @SuppressWarnings("deprecation")
 public static void setWeapon(HumanEntity human, ItemStack weapon) {
   if (human == null) return;
   human.setItemInHand(weapon);
 }
Exemplo n.º 8
0
 public static void setBoots(HumanEntity human, ItemStack boots) {
   if (human == null) return;
   setBoots(human.getInventory(), boots);
 }
Exemplo n.º 9
0
 public static void setLeggings(HumanEntity human, ItemStack leggings) {
   if (human == null) return;
   setLeggings(human.getInventory(), leggings);
 }
Exemplo n.º 10
0
 public static ItemStack getLeggings(HumanEntity human) {
   if (human == null) return null;
   return getLeggings(human.getInventory());
 }
Exemplo n.º 11
0
 public static void setChestplate(HumanEntity human, ItemStack chestplate) {
   if (human == null) return;
   setChestplate(human.getInventory(), chestplate);
 }
Exemplo n.º 12
0
 public static ItemStack getChestplate(HumanEntity human) {
   if (human == null) return null;
   return getChestplate(human.getInventory());
 }
Exemplo n.º 13
0
 public static void setHelmet(HumanEntity human, ItemStack helmet) {
   if (human == null) return;
   setHelmet(human.getInventory(), helmet);
 }
Exemplo n.º 14
0
 public void manageDeath(PlayerKilledEvent event) {
   Gamer killed = event.getKilled();
   final Player p = killed.getPlayer();
   p.setHealth(20);
   if (event.isCancelled()) return;
   for (HumanEntity human : p.getInventory().getViewers()) human.closeInventory();
   p.leaveVehicle();
   p.eject();
   p.setLevel(0);
   p.setExp(0F);
   if (event.getDeathMessage().equals(ChatColor.stripColor(event.getDeathMessage())))
     event.setDeathMessage(ChatColor.DARK_RED + event.getDeathMessage());
   event.setDeathMessage(
       this.formatDeathMessage(
           event.getDeathMessage().replace("%Remaining%", "" + (getAliveGamers().size() - 1)), p));
   if (event.getKillerPlayer() != null) {
     event.getKillerPlayer().addKill();
     event.setDeathMessage(
         this.formatDeathMessage(event.getDeathMessage(), event.getKillerPlayer().getPlayer()));
   }
   Bukkit.broadcastMessage(event.getDeathMessage());
   int reward = hg.getPrize(getAliveGamers().size());
   if (reward > 0) killed.addBalance(reward);
   hg.cannon();
   killed.clearInventory();
   World world = p.getWorld();
   for (ItemStack item : event.getDrops()) {
     if (item == null
         || item.getType() == Material.AIR
         || item.containsEnchantment(EnchantmentManager.UNLOOTABLE)) continue;
     else if (item.hasItemMeta())
       world
           .dropItemNaturally(event.getDropsLocation(), item.clone())
           .getItemStack()
           .setItemMeta(item.getItemMeta());
     else world.dropItemNaturally(event.getDropsLocation(), item);
   }
   setSpectator(killed);
   ScoreboardManager.makeScore(
       "Main", DisplaySlot.SIDEBAR, cm.getScoreboardPlayersLength(), getAliveGamers().size());
   hg.checkWinner();
   p.setVelocity(new Vector());
   for (PotionEffect effect : p.getActivePotionEffects()) p.removePotionEffect(effect.getType());
   p.teleport(p.getWorld().getHighestBlockAt(p.getLocation()).getLocation().clone().add(0, 10, 0));
   p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 9), true);
   p.sendBlockChange(p.getLocation(), Material.PORTAL.getId(), (byte) 0);
   p.sendBlockChange(p.getLocation(), Material.AIR.getId(), (byte) 0);
   for (Entity entity : p.getWorld().getEntities()) {
     if (entity instanceof Tameable
         && ((Tameable) entity).isTamed()
         && ((Tameable) entity).getOwner().getName().equals(p.getName())) {
       if (entity instanceof Wolf) ((Wolf) entity).setSitting(true);
       else if (entity instanceof Ocelot) ((Ocelot) entity).setSitting(true);
       else entity.remove();
     }
     if (entity instanceof Creature && ((Creature) entity).getTarget() == p)
       ((Creature) entity).setTarget(null);
   }
   if (HungergamesApi.getConfigManager().getMainConfig().isKickOnDeath()
       && !p.hasPermission("hungergames.spectate"))
     p.kickPlayer(String.format(cm.getKickDeathMessage(), event.getDeathMessage()));
   HungergamesApi.getAbilityManager().unregisterPlayer(p);
   HungergamesApi.getInventoryManager().updateSpectatorHeads();
 }