Пример #1
0
  @EventHandler()
  public void onEntityDeath(EntityDeathEvent event) {
    if (event.getEntity() instanceof Player) {
      Player player = (Player) event.getEntity();
      MonsterHuntWorld world = HuntWorldManager.getWorld(player.getWorld().getName());

      if (world == null || world.getWorld() == null) return;
      if (world.settings.getInt(Setting.DeathPenalty) == 0) return;

      if (world.state > 1 && world.Score.containsKey(player.getName())) {
        double score = world.Score.get(player.getName()) + 0.00;
        score = score - (score * world.settings.getInt(Setting.DeathPenalty) / 100.00);
        world.Score.put(player.getName(), (int) Math.round(score));
        Util.Message(world.settings.getString(Setting.DeathMessage), player);
      }
    }

    if (!HuntZone.isInsideZone(event.getEntity().getLocation())) return;
    if (event.getEntity() == null
        || !(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)) return;
    MonsterHuntWorld world = HuntWorldManager.getWorld(event.getEntity().getWorld().getName());
    if (world == null || world.getWorld() == null || world.state < 2) return;
    Util.Debug("test");
    kill((LivingEntity) event.getEntity(), world);
  }
Пример #2
0
  @EventHandler()
  public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getEntity() instanceof Creature) {
      MonsterHuntWorld world = HuntWorldManager.getWorld(event.getLocation().getWorld().getName());
      if (world == null || world.getWorld() == null) return;
      if (world.state == 0) return;
      if (!world.settings.getBoolean(Setting.OnlyCountMobsSpawnedOutside)) return;
      Block block = event.getLocation().getBlock();
      int number = 0;
      while (block.getY() < 125) {
        number++;
        block = block.getRelative(BlockFace.UP);
        Boolean empty = false;

        if (block.getType() == Material.AIR || block.getType() == Material.LEAVES) empty = true;
        else if (block.getType() == Material.LOG) {
          if (block.getRelative(BlockFace.NORTH).getType() == Material.AIR
              || block.getRelative(BlockFace.NORTH).getType() == Material.LEAVES) empty = true;
          else if (block.getRelative(BlockFace.EAST).getType() == Material.AIR
              || block.getRelative(BlockFace.EAST).getType() == Material.LEAVES) empty = true;
          else if (block.getRelative(BlockFace.WEST).getType() == Material.AIR
              || block.getRelative(BlockFace.WEST).getType() == Material.LEAVES) empty = true;
          else if (block.getRelative(BlockFace.SOUTH).getType() == Material.AIR
              || block.getRelative(BlockFace.SOUTH).getType() == Material.LEAVES) empty = true;
          else if (block.getRelative(BlockFace.UP).getType() == Material.AIR
              || block.getRelative(BlockFace.UP).getType() == Material.LEAVES) empty = true;
          else if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR
              || block.getRelative(BlockFace.DOWN).getType() == Material.LEAVES) empty = true;
        }

        if (!empty) {
          if (world.settings.getBoolean(Setting.OnlyCountMobsSpawnedOutsideBlackList))
            world.properlyspawned.add(event.getEntity().getEntityId());
          return;
        }
        if (world.settings.getInt(Setting.OnlyCountMobsSpawnedOutsideHeightLimit) > 0
            && world.settings.getInt(Setting.OnlyCountMobsSpawnedOutside) < number) break;
      }
      if (!world.settings.getBoolean(Setting.OnlyCountMobsSpawnedOutsideBlackList))
        world.properlyspawned.add(event.getEntity().getEntityId());
    }
  }