Beispiel #1
0
  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  private void onEntityShootBow(EntityShootBowEvent event) {
    Entity entity = event.getEntity();

    if (entity instanceof Player) {
      DurabilityUtils.handleInfiniteDurability(((Player) entity).getItemInHand());
    }
  }
Beispiel #2
0
  /**
   * Apply combat modifiers
   *
   * @param event The event to run the combat checks on.
   */
  void combatChecks(EntityDamageByEntityEvent event) {
    Entity damager = event.getDamager();
    EntityType damagerType = damager.getType();

    switch (damagerType) {
      case PLAYER:
        Player attacker = (Player) event.getDamager();
        ItemStack itemInHand = attacker.getItemInHand();

        DurabilityUtils.handleInfiniteDurability(itemInHand);
      default:
        return;
    }
  }
Beispiel #3
0
  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  private void onEntityDamage(EntityDamageEvent event) {
    if (event.getDamage() == 0 || event.getEntity().isDead()) {
      return;
    }

    Entity entity = event.getEntity();

    if (entity instanceof Player) {
      Player player = (Player) entity;

      for (ItemStack itemStack : player.getInventory().getArmorContents()) {
        DurabilityUtils.handleInfiniteDurability(itemStack);
      }
    }
  }