Added Player to addXP arguments, avoids getPlayer call

This commit is contained in:
bm01 2012-04-24 01:48:57 +02:00
parent 116adb1167
commit 52cbd15dea
11 changed files with 16 additions and 18 deletions

View File

@ -61,7 +61,7 @@ public class ExperienceAPI {
* @param XP The amount of XP to add * @param XP The amount of XP to add
*/ */
public void addXP(Player player, SkillType skillType, int XP) { public void addXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXP(skillType, XP); Users.getProfile(player).addXP(player, skillType, XP);
checkXP(player, skillType); checkXP(player, skillType);
} }

View File

@ -1008,13 +1008,11 @@ public class PlayerProfile {
/** /**
* Adds XP to the player, this is affected by skill modifiers and XP Rate * Adds XP to the player, this is affected by skill modifiers and XP Rate
* *
* @param player The player to add XP to
* @param skillType The skill to add XP to * @param skillType The skill to add XP to
* @param newvalue The amount of XP to add * @param newvalue The amount of XP to add
* @param player The player to add XP to
*/ */
public void addXP(SkillType skillType, int newValue) { public void addXP(Player player, SkillType skillType, int newValue) {
Player player = Bukkit.getPlayer(playerName);
if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) { if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) {
return; return;
} }

View File

@ -309,7 +309,7 @@ public class mcEntityListener implements Listener {
break; break;
} }
PP.addXP(SkillType.TAMING, xp); PP.addXP(player, SkillType.TAMING, xp);
Skills.XpCheckSkill(SkillType.TAMING, player); Skills.XpCheckSkill(SkillType.TAMING, player);
} }
} }

View File

@ -39,7 +39,7 @@ public class GainXp implements Runnable {
damage += health; damage += health;
} }
PP.addXP(skillType, (int) (damage * baseXp)); PP.addXP(player, skillType, (int) (damage * baseXp));
Skills.XpCheckSkill(skillType, player); Skills.XpCheckSkill(skillType, player);
} }
} }

View File

@ -58,7 +58,7 @@ public class Acrobatics {
/* Check for death */ /* Check for death */
if (health - damage >= 1) { if (health - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER); PP.addXP(player, SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player); Skills.XpCheckSkill(SkillType.ACROBATICS, player);
event.setDamage(newDamage); event.setDamage(newDamage);
@ -76,7 +76,7 @@ public class Acrobatics {
} }
} }
else if (health - damage >= 1) { else if (health - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER); PP.addXP(player, SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player); Skills.XpCheckSkill(SkillType.ACROBATICS, player);
} }
} }
@ -111,7 +111,7 @@ public class Acrobatics {
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge")); defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) { if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER); PPd.addXP(defender, SkillType.ACROBATICS, damage * DODGE_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender); Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
} }

View File

@ -120,7 +120,7 @@ public class Excavation {
} }
//Handle XP related tasks //Handle XP related tasks
PP.addXP(SkillType.EXCAVATION, xp); PP.addXP(player, SkillType.EXCAVATION, xp);
Skills.XpCheckSkill(SkillType.EXCAVATION, player); Skills.XpCheckSkill(SkillType.EXCAVATION, player);
} }

View File

@ -102,7 +102,7 @@ public class Fishing {
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size())); FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
if (random.nextDouble() * 100 <= treasure.getDropChance()) { if (random.nextDouble() * 100 <= treasure.getDropChance()) {
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp()); Users.getProfile(player).addXP(player, SkillType.FISHING, treasure.getXp());
theCatch.setItemStack(treasure.getDrop()); theCatch.setItemStack(treasure.getDrop());
} }
} }
@ -117,7 +117,7 @@ public class Fishing {
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
} }
PP.addXP(SkillType.FISHING, LoadProperties.mfishing); PP.addXP(player, SkillType.FISHING, LoadProperties.mfishing);
Skills.XpCheckSkill(SkillType.FISHING, player); Skills.XpCheckSkill(SkillType.FISHING, player);
} }

View File

@ -252,7 +252,7 @@ public class Herbalism {
} }
} }
PP.addXP(SkillType.HERBALISM, xp); PP.addXP(player, SkillType.HERBALISM, xp);
Skills.XpCheckSkill(SkillType.HERBALISM, player); Skills.XpCheckSkill(SkillType.HERBALISM, player);
} }

View File

@ -145,7 +145,7 @@ public class Mining {
break; break;
} }
PP.addXP(SkillType.MINING, xp); PP.addXP(player, SkillType.MINING, xp);
Skills.XpCheckSkill(SkillType.MINING, player); Skills.XpCheckSkill(SkillType.MINING, player);
} }

View File

@ -138,7 +138,7 @@ public class Repair {
dif = (short) (dif / 2); dif = (short) (dif / 2);
} }
PP.addXP(SkillType.REPAIR, dif * 10); PP.addXP(player, SkillType.REPAIR, dif * 10);
Skills.XpCheckSkill(SkillType.REPAIR, player); Skills.XpCheckSkill(SkillType.REPAIR, player);
//CLANG CLANG //CLANG CLANG

View File

@ -156,7 +156,7 @@ public class WoodCutting {
} }
} }
PP.addXP(SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP PP.addXP(player, SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP
Skills.XpCheckSkill(SkillType.WOODCUTTING, player); Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
} }
@ -301,7 +301,7 @@ public class WoodCutting {
} }
WoodCutting.woodCuttingProcCheck(player, block); WoodCutting.woodCuttingProcCheck(player, block);
PP.addXP(SkillType.WOODCUTTING, xp); PP.addXP(player, SkillType.WOODCUTTING, xp);
Skills.XpCheckSkill(SkillType.WOODCUTTING, player); Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
} }