mcMMO/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java

73 lines
2.5 KiB
Java
Raw Normal View History

package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.SkillType;
2013-01-10 15:26:01 +01:00
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
2012-06-13 18:31:20 +02:00
import com.gmail.nossr50.util.Permissions;
2013-01-10 15:26:01 +01:00
public class AcrobaticsManager extends SkillManager {
public AcrobaticsManager (Player player) {
2013-01-10 15:26:01 +01:00
super(player, SkillType.ACROBATICS);
}
/**
* Check for fall damage reduction.
*
* @param event The event to check
*/
public void rollCheck(EntityDamageEvent event) {
if (Misc.isNPC(player) || !Permissions.roll(player)) {
return;
}
if (Config.getInstance().getAcrobaticsAFKDisabled() && player.isInsideVehicle()) {
return;
}
RollEventHandler eventHandler = new RollEventHandler(this, event);
double chance;
if (eventHandler.isGraceful) {
chance = (Acrobatics.gracefulRollMaxChance / Acrobatics.gracefulRollMaxBonusLevel) * eventHandler.skillModifier;
}
else {
chance = (Acrobatics.rollMaxChance / Acrobatics.rollMaxBonusLevel) * eventHandler.skillModifier;
}
2013-01-22 02:01:33 +01:00
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.rollXpModifier);
}
else if (!eventHandler.isFatal(event.getDamage())) {
eventHandler.processXPGain(eventHandler.damage * Acrobatics.fallXpModifier);
}
}
/**
* Check for dodge damage reduction.
*
* @param event The event to check
*/
public void dodgeCheck(EntityDamageEvent event) {
if (Misc.isNPC(player) || !Permissions.dodge(player)) {
return;
}
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier;
2013-01-22 02:01:33 +01:00
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.dodgeXpModifier);
}
}
}