From 28d73a33abd37d7e729347c6f921e5d0874c8bdd Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 14 Feb 2012 12:42:20 -0800 Subject: [PATCH] Fixed addxp() taking xprate/skill modifiers into account. --- Changelog.txt | 1 + .../commands/general/AddxpCommand.java | 2 +- .../nossr50/datatypes/PlayerProfile.java | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index b2ebd3207..2af55bc91 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -22,6 +22,7 @@ Version 1.2.11 - Added a success message when executing xprate from console Version 1.2.10 + - Fixed addxp command taking xprate and skill modifiers into account - Fixed issue that caused negative XP on levelup (Issue #134) - Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103) - Fixed issue with Spout images & sounds not working (Issue #93) diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java index 5bc5e278c..a109b5e5d 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java @@ -47,7 +47,7 @@ public class AddxpCommand implements CommandExecutor { } else if (args.length == 3) { if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) { int newvalue = Integer.valueOf(args[2]); - Users.getProfile(plugin.getServer().getPlayer(args[0])).addXP(Skills.getSkillType(args[1]), newvalue, plugin.getServer().getPlayer(args[0])); + Users.getProfile(plugin.getServer().getPlayer(args[0])).addXPOverrideNoBonus(Skills.getSkillType(args[1]), newvalue); plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!"); System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + "."); Skills.XpCheckAll(plugin.getServer().getPlayer(args[0])); diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 4127b6a3b..2b5114cf7 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -840,6 +840,32 @@ public class PlayerProfile skillsDATS.put(x, 0); } } + + /** + * Adds XP to the player, doesn't calculate for XP Rate + * @param skillType The skill to add XP to + * @param newvalue The amount of XP to add + */ + public void addXPOverrideNoBonus(SkillType skillType, int newvalue) + { + if(skillType == SkillType.ALL) + { + for(SkillType x : SkillType.values()) + { + if(x == SkillType.ALL) + continue; + Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(Bukkit.getPlayer(playerName), x, newvalue)); + skillsXp.put(x, skillsXp.get(x)+newvalue); + } + } else { + int xp = newvalue; + + Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(Bukkit.getPlayer(playerName), skillType, xp)); + skillsXp.put(skillType, skillsXp.get(skillType)+xp); + lastgained = skillType; + } + } + /** * Adds XP to the player, this ignores skill modifiers * @param skillType The skill to add XP to @@ -865,6 +891,7 @@ public class PlayerProfile lastgained = skillType; } } + /** * Adds XP to the player, this is affected by skill modifiers * @param skillType The skill to add XP to