Fixed issue #796.

This commit is contained in:
Ka0rX 2023-04-20 20:54:15 +01:00
parent 4d8df79dc2
commit f4be0ab409

View File

@ -170,17 +170,17 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
//We remove all the stats and buffs associated to triggers. //We remove all the stats and buffs associated to triggers.
mmoData.getStatMap().getInstances().forEach(statInstance -> statInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX))); mmoData.getStatMap().getInstances().forEach(statInstance -> statInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX)));
mmoData.getSkillModifierMap().getInstances().forEach(skillModifierInstance -> skillModifierInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX))); mmoData.getSkillModifierMap().getInstances().forEach(skillModifierInstance -> skillModifierInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX)));
final Iterator<Map.Entry<Integer, BoundSkillInfo>> ite = boundSkills.entrySet().iterator(); Map<Integer, BoundSkillInfo> boundSkillsToRemove = new HashMap<>(boundSkills);
while (ite.hasNext()) for (int slot : boundSkillsToRemove.keySet())
try { try {
final Map.Entry<Integer, BoundSkillInfo> entry = ite.next(); final BoundSkillInfo info = boundSkills.get(slot);
final @Nullable SkillSlot skillSlot = getProfess().getSkillSlot(entry.getKey()); final @Nullable SkillSlot skillSlot = getProfess().getSkillSlot(slot);
final String skillId = entry.getValue().getClassSkill().getSkill().getHandler().getId(); final String skillId = info.getClassSkill().getSkill().getHandler().getId();
final @Nullable ClassSkill classSkill = getProfess().getSkill(skillId); final @Nullable ClassSkill classSkill = getProfess().getSkill(skillId);
Validate.notNull(skillSlot, "Could not find skill slot n" + entry.getKey()); Validate.notNull(skillSlot, "Could not find skill slot n" + slot);
Validate.notNull(classSkill, "Could not find skill with ID '" + skillId + "'"); Validate.notNull(classSkill, "Could not find skill with ID '" + skillId + "'");
unbindSkill(entry.getKey()); unbindSkill(slot);
bindSkill(entry.getKey(), classSkill); bindSkill(slot, classSkill);
} catch (Exception exception) { } catch (Exception exception) {
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not reload data of '" + getPlayer().getName() + "': " + exception.getMessage()); MMOCore.plugin.getLogger().log(Level.WARNING, "Could not reload data of '" + getPlayer().getName() + "': " + exception.getMessage());
} }
@ -810,7 +810,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
* If it's null, no hologram will be displayed * If it's null, no hologram will be displayed
* @param splitExp Should the exp be split among party members * @param splitExp Should the exp be split among party members
*/ */
public void giveExperience(double value, @NotNull EXPSource source, @Nullable Location hologramLocation, boolean splitExp) { public void giveExperience(double value, @NotNull EXPSource source, @Nullable Location hologramLocation,
boolean splitExp) {
if (value <= 0) { if (value <= 0) {
experience = Math.max(0, experience + value); experience = Math.max(0, experience + value);
return; return;
@ -863,7 +864,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
level = getLevel() + 1; level = getLevel() + 1;
// Apply class experience table // Apply class experience table
if (getProfess().hasExperienceTable()) getProfess().getExperienceTable().claim(this, level, getProfess()); if (getProfess().hasExperienceTable())
getProfess().getExperienceTable().claim(this, level, getProfess());
} }
if (level > oldLevel) { if (level > oldLevel) {