Tweaked how we check XP gain permissions.

This commit is contained in:
GJ 2012-06-12 08:10:18 -04:00
parent 534a165c45
commit 975e13d45f
4 changed files with 12 additions and 14 deletions

View File

@ -38,7 +38,7 @@ public class AcrobaticsManager {
eventHandler.sendAbilityMessage();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
}
else if (!eventHandler.isFatal(event.getDamage()) && permHandler.canGainXP()){
else if (!eventHandler.isFatal(event.getDamage())) {
eventHandler.processXPGain(eventHandler.damage * Acrobatics.FALL_XP_MODIFIER);
}
}
@ -58,10 +58,7 @@ public class AcrobaticsManager {
if (Acrobatics.getRandom().nextInt(4000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
if (System.currentTimeMillis() >= profile.getRespawnATS() + 5 && permHandler.canGainXP()) {
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
}
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
}
}

View File

@ -10,13 +10,11 @@ public class AcrobaticsPermissionsHandler {
private boolean canDodge;
private boolean canGracefulRoll;
private boolean canRoll;
private boolean canGainXP;
protected AcrobaticsPermissionsHandler (Player player) {
this.canDodge = permInstance.dodge(player);
this.canGracefulRoll = permInstance.gracefulRoll(player);
this.canRoll = permInstance.roll(player);
this.canGainXP = permInstance.acrobatics(player);
}
protected boolean canDodge() {
@ -31,10 +29,6 @@ public class AcrobaticsPermissionsHandler {
return canRoll;
}
protected boolean canGainXP() {
return canGainXP;
}
protected boolean hasRollPermissions() {
return (canRoll || canGracefulRoll);
}

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
@ -38,6 +39,10 @@ public class DodgeEventHandler extends AcrobaticsEventHandler{
}
protected void processXPGain(int xp) {
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xp);
PlayerProfile profile = manager.getProfile();
if (System.currentTimeMillis() >= profile.getRespawnATS() + 5) {
Skills.xpProcessing(player, profile, SkillType.ACROBATICS, xp);
}
}
}

View File

@ -460,7 +460,9 @@ public class Skills {
* @param xp the amount of XP to gain
*/
public static void xpProcessing(Player player, PlayerProfile profile, SkillType type, int xp) {
profile.addXP(type, xp);
xpCheckSkill(type, player, profile);
if (type.getPermissions(player)) {
profile.addXP(type, xp);
xpCheckSkill(type, player, profile);
}
}
}