Respect level cap for mcMMO Classic, fixes #2226

This commit is contained in:
PikaMug 2024-07-16 21:01:54 -04:00
parent 89a1b1eb70
commit 97d64e8347

View File

@ -12,6 +12,7 @@ package me.pikamug.quests.quests;
import com.alessiodp.parties.api.interfaces.Party;
import com.alessiodp.parties.api.interfaces.PartyPlayer;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.characters.Hero;
@ -835,7 +836,14 @@ public class BukkitQuest implements Quest {
}
for (final String s : rewards.getMcmmoSkills()) {
final int levels = rewards.getMcmmoAmounts().get(rewards.getMcmmoSkills().indexOf(s));
UserManager.getOfflinePlayer(player).getProfile().addLevels(plugin.getDependencies().getMcMMOSkill(s), levels);
final SkillType type = plugin.getDependencies().getMcMMOSkill(s);
final int current = UserManager.getOfflinePlayer(player).getProfile().getSkillLevel(type);
final int max = Config.getInstance().getLevelCap(type);
if (current + levels > max) {
UserManager.getOfflinePlayer(player).getProfile().modifySkill(type, max);
} else {
UserManager.getOfflinePlayer(player).getProfile().addLevels(type, levels);
}
if (plugin.getConfigSettings().getConsoleLogging() > 2) {
plugin.getLogger().info(player.getUniqueId() + " was rewarded " + s + " x " + levels);
}