public void counterAttackChecks(LivingEntity attacker, int damage) { if (player == null) return; if (!Permissions.counterAttack(player)) { return; } CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage); if (eventHandler.isHoldingSword()) { eventHandler.calculateSkillModifier(); int randomChance = 100; if (Permissions.luckySwords(player)) { randomChance = (int) (randomChance * 0.75); } float chance = (float) (((double) Swords.COUNTER_ATTACK_CHANCE_MAX / (double) Swords.COUNTER_ATTACK_MAX_BONUS_LEVEL) * skillLevel); if (chance > Swords.COUNTER_ATTACK_CHANCE_MAX) chance = Swords.COUNTER_ATTACK_CHANCE_MAX; if (chance > Misc.getRandom().nextInt(randomChance)) { eventHandler.dealDamage(); eventHandler.sendAbilityMessages(); } } }
public void counterAttackChecks(LivingEntity attacker, int damage) { if (!permissionsInstance.counterAttack(player)) { return; } CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage); if (eventHandler.isHoldingSword()) { eventHandler.calculateSkillModifier(); int randomChance = 2000; if (player.hasPermission("mcmmo.perks.lucky.swords")) { randomChance = (int) (randomChance * 0.75); } if (Swords.getRandom().nextInt(randomChance) < eventHandler.skillModifier) { eventHandler.dealDamage(); eventHandler.sendAbilityMessages(); } } }