// Handle player defense skills
  private void handle_Defense_Passives(
      double damage, RpgPlayer rpgDefender, LivingEntity entityAttacker) {
    // Variable Declarations
    Random rand = new Random();
    RpgClass rpgClass = rpgDefender.playerConfig.getRpgClass();

    if (rpgClass != null) {
      if (rpgClass.getPassiveID() == BalanceConfig.passive_CounterAttack) {
        // Handle counter-attack chance.
        if (rand.nextInt(FC_Rpg.balanceConfig.getPassivesCounterAttack()) == 0)
          entityAttacker.damage(1, rpgDefender.getPlayer());
      }
    }
  }
  private double handle_Offense_Passives(
      double damage, RpgPlayer rpgAttacker, LivingEntity entityDefender) {
    // Variable Declaration.
    RpgClass rpgClass = rpgAttacker.playerConfig.getRpgClass();

    if (rpgClass != null) {
      if (rpgClass.getPassiveID() == BalanceConfig.passive_BattleLust) {
        // Scale damage by 1/4th
        damage *=
            (1
                + rpgAttacker.getMissingHealthDecimal()
                    * FC_Rpg.balanceConfig.getPassivesBattleLust());
      }
    }

    return damage;
  }
  public void attackPlayerDefender(
      RpgPlayer rpgDefender,
      RpgPlayer rpgAttacker,
      RpgMonster rpgMobAttacker,
      double damage,
      int damageType,
      String typeString) {
    EntityDamageByEntityEvent edbe;
    Player playerDefender = rpgDefender.getPlayer();
    String guildName = "";
    HealthConverter hc = null;
    boolean ignoreArmor = false;
    int guildMemberCount = 0;

    // Get party and member count.
    if (FC_Rpg.guildConfig.getGuildByMember(playerDefender.getName()) != null) {
      guildName = FC_Rpg.guildConfig.getGuildByMember(playerDefender.getName());
      guildMemberCount = FC_Rpg.guildConfig.getOnlineGuildPlayerList(guildName).size();
    } else guildMemberCount = 1;

    // Check to see if the player was recently attacked to make sure he isn't attacked too much.
    if (canAttack(rpgDefender.getLastDamagedLong(), guildMemberCount) == false) return;

    // Refresh player enchants.
    rpgDefender.refreshItemEnchants();

    // Handle immortality effect first.
    if (rpgDefender.playerConfig.getStatusActiveRpgPlayer(SpellEffect.IMMORTAL.getID())) {
      rpgDefender.attemptDamageAvoidNotification(true);
      return;
    }

    // Check if the player has dodge status on them.
    if (rpgDefender.playerConfig.getStatusActiveRpgPlayer(SpellEffect.DODGE.getID())) {
      Random rand = new Random();

      if (rand.nextInt(100)
          < rpgDefender.playerConfig.getStatusMagnitude(SpellEffect.DODGE.getID())) {
        rpgDefender.attemptDamageAvoidNotification(false);
        return;
      }
    }

    if (rpgDefender.playerConfig.getStatusActiveRpgPlayer(SpellEffect.HEAL_CHANCE.getID()))
      rpgDefender.healHealth(
          rpgDefender.playerConfig.maxHealth
              * rpgDefender.playerConfig.getStatusMagnitude(SpellEffect.HEAL_CHANCE.getID()));

    // Set the last damage cause for players.
    if (rpgAttacker != null) {
      // Refresh player enchants.
      rpgAttacker.refreshItemEnchants();

      // Update durability of weapons.
      updateSwordDurabilities(rpgAttacker.getPlayer());

      // Apply false EDBEE
      edbe =
          new EntityDamageByEntityEvent(
              rpgAttacker.getPlayer(), playerDefender, DamageCause.ENTITY_ATTACK, 0);
      playerDefender.setLastDamageCause(edbe);

      // Calculate potions.
      damage *= FC_Rpg.battleCalculations.getPotionOffenseBonus(playerDefender);

      // True gets returned, we ignore armor.
      ignoreArmor =
          rpgAttacker.playerConfig.getStatusActiveRpgPlayer(SpellEffect.IGNORE_ARMOR.getID());
    } else if (rpgMobAttacker != null) {
      // Apply false EDBEE
      edbe =
          new EntityDamageByEntityEvent(
              rpgMobAttacker.getEntity(), rpgDefender.getPlayer(), DamageCause.ENTITY_ATTACK, 0);
      playerDefender.setLastDamageCause(edbe);

      // Handle enchantments for mobs.
      if (damageType == 0)
        damage *=
            FC_Rpg.battleCalculations.getEntityEnchantmentBonus(
                rpgMobAttacker.getEntity(), Enchantment.DAMAGE_ARTHROPODS);

      if (damageType == 1)
        damage *=
            FC_Rpg.battleCalculations.getEntityEnchantmentBonus(
                rpgMobAttacker.getEntity(), Enchantment.ARROW_DAMAGE);

      // Calculate potions.
      damage *= FC_Rpg.battleCalculations.getPotionOffenseBonus(rpgMobAttacker.getEntity());
    }

    // Deal thorns damage before anything is calculated.
    if (rpgDefender.playerConfig.getStatusActiveRpgPlayer(SpellEffect.THORNS.getID())) {
      double thornsDamage =
          damage * rpgDefender.playerConfig.getStatusMagnitude(SpellEffect.THORNS.getID());

      // Attempt a dodge notification
      rpgDefender.attemptThornsNotification(thornsDamage);

      if (rpgAttacker != null) rpgAttacker.dealDamage(thornsDamage);
      else if (rpgMobAttacker != null) rpgMobAttacker.dealDamage(thornsDamage);
    }

    // If the attacker doesn't have the ignore defense status, then...
    if (!ignoreArmor) {
      // Calculate damage based on players armor.
      damage *= FC_Rpg.battleCalculations.getArmorBonus(rpgDefender);

      // Add in enchantment bonuses.
      damage *=
          FC_Rpg.battleCalculations.getArmorEnchantmentBonus(
              playerDefender, Enchantment.PROTECTION_ENVIRONMENTAL);

      if (damageType == 1)
        damage *=
            FC_Rpg.battleCalculations.getArmorEnchantmentBonus(
                playerDefender, Enchantment.PROTECTION_PROJECTILE);
    }

    damage *= FC_Rpg.battleCalculations.getPotionDefenseBonus(playerDefender);

    // Handle block.
    if (playerDefender.isBlocking() == true) {
      // Variable Declaration.
      RpgClass rpgClass = rpgDefender.playerConfig.getRpgClass();

      if (rpgClass != null) {
        if (rpgClass.getPassiveID() == BalanceConfig.passive_StrongerParry)
          damage *=
              FC_Rpg.balanceConfig
                  .getPassivesStrongerParry(); // 25% damage reduction for blocking as defender.
        else damage *= .9; // 10% damage reduction for blocking.
      } else damage *= .9; // 10% damage reduction for blocking.
    }

    // If taunt status is active, then...
    if (rpgDefender.playerConfig.getStatusActiveRpgPlayer(SpellEffect.TAUNT.getID()) == true) {
      // Apply taunt damage reduction.
      damage *= rpgDefender.playerConfig.getStatusMagnitude(SpellEffect.TAUNT.getID());
    }

    // Deal damage greater than 0.
    if (damage < 0.1) damage = 0.1;

    // Deal the damage to the player
    rpgDefender.dealDamage(damage);

    // Perform damage effect.
    playerDefender.playEffect(EntityEffect.HURT);

    if (rpgAttacker != null) {
      handle_Post_Offense_Buffs(rpgAttacker, playerDefender, damage);

      if (playerDefender != null) handle_Post_Offense_Buffs(rpgAttacker, playerDefender, damage);

      rpgAttacker.attemptAttackNotification(
          rpgDefender.getPlayer().getName(),
          rpgDefender.playerConfig.getClassLevel(),
          rpgDefender.playerConfig.curHealth,
          rpgDefender.playerConfig.maxHealth,
          damage);
      applyKnockback(rpgAttacker.getPlayer(), playerDefender, damageType);
    }

    // Set the players health based current health out of maximum health.
    hc =
        new HealthConverter(rpgDefender.playerConfig.maxHealth, rpgDefender.playerConfig.curHealth);

    playerDefender.setHealth(hc.getPlayerHearts());

    // Check armor durabilities for the player defender.
    increaseArmorDurabilities(playerDefender);

    // If the players has 0 health, kill minecraft body and set to dead.
    if (rpgDefender.playerConfig.curHealth < 1) {
      // Damage the player defender.
      playerDefender.damage(10000);

      // Set the player to alive.
      rpgDefender.setIsAlive(false);
    } else {
      if (rpgAttacker != null) {
        rpgDefender.attemptDefenseNotification(
            damage, rpgAttacker.getPlayer().getName(), rpgAttacker.playerConfig.getClassLevel());
        handle_Defense_Passives(damage, rpgDefender, rpgAttacker.getPlayer());
      } else if (rpgMobAttacker != null) {
        rpgDefender.attemptDefenseNotification(
            damage, rpgMobAttacker.getEntity().getType().toString(), rpgMobAttacker.getLevel());
        handle_Defense_Passives(damage, rpgDefender, rpgMobAttacker.getEntity());
      } else {
        rpgDefender.attemptDefenseNotification(damage, typeString, -1);
      }
    }
  }