Remove config caching from CombatTools.java

This commit is contained in:
GJ 2013-02-22 13:47:54 -05:00
parent f9ad8ffe93
commit 0d473d232e

View File

@ -46,8 +46,6 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
public final class CombatTools { public final class CombatTools {
private static Config configInstance = Config.getInstance();
private CombatTools() {} private CombatTools() {}
/** /**
@ -342,7 +340,7 @@ public final class CombatTools {
* @param cause DamageCause to pass to damage event * @param cause DamageCause to pass to damage event
*/ */
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) { private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (configInstance.getEventCallbackEnabled()) { if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg); EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede); mcMMO.p.getServer().getPluginManager().callEvent(ede);
@ -365,7 +363,7 @@ public final class CombatTools {
* @param attacker Player to pass to event as damager * @param attacker Player to pass to event as damager
*/ */
private static void dealDamage(LivingEntity target, int dmg, Player attacker) { private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (configInstance.getEventCallbackEnabled()) { if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede); mcMMO.p.getServer().getPluginManager().callEvent(ede);
@ -445,14 +443,14 @@ public final class CombatTools {
double baseXP = 0; double baseXP = 0;
if (target instanceof Player) { if (target instanceof Player) {
if (!configInstance.getExperienceGainsPlayerVersusPlayerEnabled()) { if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) {
return; return;
} }
Player defender = (Player) target; Player defender = (Player) target;
if (System.currentTimeMillis() >= Users.getPlayer(defender).getProfile().getRespawnATS() + 5) { if (System.currentTimeMillis() >= Users.getPlayer(defender).getProfile().getRespawnATS() + 5) {
baseXP = 20 * configInstance.getPlayerVersusPlayerXP(); baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
} }
} }
else if (!target.hasMetadata(mcMMO.entityMetadataKey)) { else if (!target.hasMetadata(mcMMO.entityMetadataKey)) {
@ -461,7 +459,7 @@ public final class CombatTools {
baseXP = ModChecks.getCustomEntity(target).getXpMultiplier(); baseXP = ModChecks.getCustomEntity(target).getXpMultiplier();
} }
else { else {
baseXP = configInstance.getAnimalsXP(); baseXP = Config.getInstance().getAnimalsXP();
} }
} }
else { else {
@ -469,7 +467,7 @@ public final class CombatTools {
switch (type) { switch (type) {
case BAT: case BAT:
baseXP = configInstance.getAnimalsXP(); baseXP = Config.getInstance().getAnimalsXP();
break; break;
case BLAZE: case BLAZE:
@ -498,7 +496,7 @@ public final class CombatTools {
case SKELETON: case SKELETON:
switch(((Skeleton) target).getSkeletonType()) { switch(((Skeleton) target).getSkeletonType()) {
case WITHER: case WITHER:
baseXP = configInstance.getWitherSkeletonXP(); baseXP = Config.getInstance().getWitherSkeletonXP();
break; break;
default: default:
baseXP = Config.getInstance().getCombatXP(type); baseXP = Config.getInstance().getCombatXP(type);