Don't pass our events around so much.

This commit is contained in:
GJ
2013-02-25 18:00:15 -05:00
parent 5026bdcbd4
commit d46b134dbb
6 changed files with 60 additions and 22 deletions

View File

@@ -1,11 +1,15 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ParticleEffectUtils;
public class AcrobaticsManager extends SkillManager {
public AcrobaticsManager (McMMOPlayer mcMMOPlayer) {
@@ -17,15 +21,27 @@ public class AcrobaticsManager extends SkillManager {
*
* @param event The event to check
*/
public void dodgeCheck(EntityDamageEvent event) {
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
public int dodgeCheck(int damage) {
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
Player player = getPlayer();
double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier;
if (!Acrobatics.isFatal(player, modifiedDamage) && SkillTools.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
ParticleEffectUtils.playDodgeEffect(player);
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXpGain(eventHandler.damage * Acrobatics.dodgeXpModifier);
PlayerProfile playerProfile = getProfile();
if (playerProfile.useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
// Why do we check respawn cooldown here?
if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
applyXpGain(damage * Acrobatics.dodgeXpModifier);
}
return modifiedDamage;
}
return damage;
}
}