Fixed addxp() taking xprate/skill modifiers into account.

This commit is contained in:
nossr50 2012-02-14 12:42:20 -08:00
parent 9c9247b9c1
commit 28d73a33ab
3 changed files with 29 additions and 1 deletions

View File

@ -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)

View File

@ -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]));

View File

@ -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