From 52cbd15dea2981feda232f0fa5f489d583fa8037 Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 24 Apr 2012 01:48:57 +0200 Subject: [PATCH] Added Player to addXP arguments, avoids getPlayer call --- src/main/java/com/gmail/nossr50/api/ExperienceAPI.java | 2 +- .../java/com/gmail/nossr50/datatypes/PlayerProfile.java | 6 ++---- .../java/com/gmail/nossr50/listeners/mcEntityListener.java | 2 +- src/main/java/com/gmail/nossr50/runnables/GainXp.java | 2 +- src/main/java/com/gmail/nossr50/skills/Acrobatics.java | 6 +++--- src/main/java/com/gmail/nossr50/skills/Excavation.java | 2 +- src/main/java/com/gmail/nossr50/skills/Fishing.java | 4 ++-- src/main/java/com/gmail/nossr50/skills/Herbalism.java | 2 +- src/main/java/com/gmail/nossr50/skills/Mining.java | 2 +- src/main/java/com/gmail/nossr50/skills/Repair.java | 2 +- src/main/java/com/gmail/nossr50/skills/WoodCutting.java | 4 ++-- 11 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 77c346b39..474bb6827 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -61,7 +61,7 @@ public class ExperienceAPI { * @param XP The amount of XP to add */ 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); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 01daf227a..5aae3e675 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -1008,13 +1008,11 @@ public class PlayerProfile { /** * 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 newvalue The amount of XP to add - * @param player The player to add XP to */ - public void addXP(SkillType skillType, int newValue) { - Player player = Bukkit.getPlayer(playerName); - + public void addXP(Player player, SkillType skillType, int newValue) { if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) { return; } diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index 1b35fdaab..3ef2d5c08 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -309,7 +309,7 @@ public class mcEntityListener implements Listener { break; } - PP.addXP(SkillType.TAMING, xp); + PP.addXP(player, SkillType.TAMING, xp); Skills.XpCheckSkill(SkillType.TAMING, player); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/GainXp.java b/src/main/java/com/gmail/nossr50/runnables/GainXp.java index 8ba896dfc..0dbf26a0c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/GainXp.java +++ b/src/main/java/com/gmail/nossr50/runnables/GainXp.java @@ -39,7 +39,7 @@ public class GainXp implements Runnable { damage += health; } - PP.addXP(skillType, (int) (damage * baseXp)); + PP.addXP(player, skillType, (int) (damage * baseXp)); Skills.XpCheckSkill(skillType, player); } } diff --git a/src/main/java/com/gmail/nossr50/skills/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/Acrobatics.java index 205c2ebd5..367bb3d40 100644 --- a/src/main/java/com/gmail/nossr50/skills/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/Acrobatics.java @@ -58,7 +58,7 @@ public class Acrobatics { /* Check for death */ 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); event.setDamage(newDamage); @@ -76,7 +76,7 @@ public class Acrobatics { } } 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); } } @@ -111,7 +111,7 @@ public class Acrobatics { defender.sendMessage(mcLocale.getString("Acrobatics.Dodge")); 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); } diff --git a/src/main/java/com/gmail/nossr50/skills/Excavation.java b/src/main/java/com/gmail/nossr50/skills/Excavation.java index 16586b995..2d5d15489 100644 --- a/src/main/java/com/gmail/nossr50/skills/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/Excavation.java @@ -120,7 +120,7 @@ public class Excavation { } //Handle XP related tasks - PP.addXP(SkillType.EXCAVATION, xp); + PP.addXP(player, SkillType.EXCAVATION, xp); Skills.XpCheckSkill(SkillType.EXCAVATION, player); } diff --git a/src/main/java/com/gmail/nossr50/skills/Fishing.java b/src/main/java/com/gmail/nossr50/skills/Fishing.java index a74c5e82f..e0bb9bcc8 100644 --- a/src/main/java/com/gmail/nossr50/skills/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/Fishing.java @@ -102,7 +102,7 @@ public class Fishing { FishingTreasure treasure = rewards.get(random.nextInt(rewards.size())); 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()); } } @@ -117,7 +117,7 @@ public class Fishing { 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); } diff --git a/src/main/java/com/gmail/nossr50/skills/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/Herbalism.java index 9562242a7..552fa5052 100644 --- a/src/main/java/com/gmail/nossr50/skills/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/Herbalism.java @@ -252,7 +252,7 @@ public class Herbalism { } } - PP.addXP(SkillType.HERBALISM, xp); + PP.addXP(player, SkillType.HERBALISM, xp); Skills.XpCheckSkill(SkillType.HERBALISM, player); } diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 04623444d..b144be885 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -145,7 +145,7 @@ public class Mining { break; } - PP.addXP(SkillType.MINING, xp); + PP.addXP(player, SkillType.MINING, xp); Skills.XpCheckSkill(SkillType.MINING, player); } diff --git a/src/main/java/com/gmail/nossr50/skills/Repair.java b/src/main/java/com/gmail/nossr50/skills/Repair.java index 78c08414e..ced7cb2e4 100644 --- a/src/main/java/com/gmail/nossr50/skills/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/Repair.java @@ -138,7 +138,7 @@ public class Repair { dif = (short) (dif / 2); } - PP.addXP(SkillType.REPAIR, dif * 10); + PP.addXP(player, SkillType.REPAIR, dif * 10); Skills.XpCheckSkill(SkillType.REPAIR, player); //CLANG CLANG diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 1197a3873..919af0570 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -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); } @@ -301,7 +301,7 @@ public class WoodCutting { } WoodCutting.woodCuttingProcCheck(player, block); - PP.addXP(SkillType.WOODCUTTING, xp); + PP.addXP(player, SkillType.WOODCUTTING, xp); Skills.XpCheckSkill(SkillType.WOODCUTTING, player); }