Пример #1
0
  /**
   * Monitor EntityDeath events.
   *
   * @param event The event to watch
   */
  @EventHandler(priority = EventPriority.MONITOR)
  public void onEntityDeath(EntityDeathEvent event) {
    LivingEntity entity = event.getEntity();

    if (Misc.isNPCEntity(entity)) {
      return;
    }

    BleedTimerTask.remove(entity);
    Archery.arrowRetrievalCheck(entity);
  }
Пример #2
0
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onProjectileLaunch(ProjectileLaunchEvent event) {
    Projectile projectile = event.getEntity();

    if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) {
      return;
    }

    projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
    projectile.setMetadata(
        mcMMO.arrowDistanceKey,
        new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
  }
Пример #3
0
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onEntityShootBow(EntityShootBowEvent event) {
    Entity projectile = event.getProjectile();

    if (!(projectile instanceof Arrow)) {
      return;
    }

    ItemStack bow = event.getBow();

    if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
      projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
    }

    projectile.setMetadata(
        mcMMO.bowForceKey,
        new FixedMetadataValue(
            plugin,
            Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
    projectile.setMetadata(
        mcMMO.arrowDistanceKey,
        new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
  }