Пример #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());
      }
    }
  }
Пример #2
0
 @SuppressWarnings("deprecation")
 public static ItemStack getWeapon(HumanEntity human) {
   if (human == null) return null;
   ItemStack ret = human.getItemInHand();
   ret = clean(ret);
   return ret;
 }
Пример #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);
   }
 }
Пример #5
0
 public static void setShield(HumanEntity human, ItemStack shield) {
   if (human == null) return;
   setShield(human.getInventory(), shield);
 }
Пример #6
0
 public static ItemStack getShield(HumanEntity human) {
   if (human == null) return null;
   return getShield(human.getInventory());
 }
Пример #7
0
 @SuppressWarnings("deprecation")
 public static void setWeapon(HumanEntity human, ItemStack weapon) {
   if (human == null) return;
   human.setItemInHand(weapon);
 }
Пример #8
0
 public static void setBoots(HumanEntity human, ItemStack boots) {
   if (human == null) return;
   setBoots(human.getInventory(), boots);
 }
Пример #9
0
 public static void setLeggings(HumanEntity human, ItemStack leggings) {
   if (human == null) return;
   setLeggings(human.getInventory(), leggings);
 }
Пример #10
0
 public static ItemStack getLeggings(HumanEntity human) {
   if (human == null) return null;
   return getLeggings(human.getInventory());
 }
Пример #11
0
 public static void setChestplate(HumanEntity human, ItemStack chestplate) {
   if (human == null) return;
   setChestplate(human.getInventory(), chestplate);
 }
Пример #12
0
 public static ItemStack getChestplate(HumanEntity human) {
   if (human == null) return null;
   return getChestplate(human.getInventory());
 }
Пример #13
0
 public static void setHelmet(HumanEntity human, ItemStack helmet) {
   if (human == null) return;
   setHelmet(human.getInventory(), helmet);
 }
Пример #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();
 }