Added one option to prevent players from upgrading skills using the skill UI

This commit is contained in:
Jules 2024-04-06 23:31:27 -07:00
parent d4bea3dba7
commit 558a5f5a01
9 changed files with 42 additions and 20 deletions

View File

@ -515,6 +515,12 @@ public class SkillList extends EditableInventory {
return;
}
if (!selected.isUpgradable()) {
ConfigMessage.fromKey("cannot-upgrade-skill").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
return;
}
if (playerData.getSkillPoints() < 1) {
ConfigMessage.fromKey("not-enough-skill-points").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);

View File

@ -27,7 +27,7 @@ import java.util.logging.Level;
public class ConfigManager {
public final CommandVerbose commandVerbose = new CommandVerbose();
public boolean overrideVanillaExp, canCreativeCast, passiveSkillNeedBound, cobbleGeneratorXP, saveDefaultClassInfo, splitMainExp, splitProfessionExp, disableQuestBossBar,
public boolean overrideVanillaExp, canCreativeCast, passiveSkillsNeedBinding, cobbleGeneratorXP, saveDefaultClassInfo, splitMainExp, splitProfessionExp, disableQuestBossBar,
pvpModeEnabled, pvpModeInvulnerabilityCanDamage, forceClassSelection, enableGlobalSkillTreeGUI, enableSpecificSkillTreeGUI;
public String partyChatPrefix, noSkillBoundPlaceholder;
public ChatColor staminaFull, staminaHalf, staminaEmpty;
@ -156,7 +156,7 @@ public class ConfigManager {
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GRAY);
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE);
passiveSkillNeedBound = MMOCore.plugin.getConfig().getBoolean("passive-skill-need-bound");
passiveSkillsNeedBinding = MMOCore.plugin.getConfig().getBoolean("passive-skill-need-bound");
canCreativeCast = MMOCore.plugin.getConfig().getBoolean("can-creative-cast");
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");

View File

@ -1,6 +1,5 @@
package net.Indyuce.mmocore.skill;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.player.cooldown.CooldownObject;
import io.lumine.mythic.lib.player.modifier.ModifierSource;
@ -20,9 +19,21 @@ import java.util.*;
public class ClassSkill implements CooldownObject, Unlockable {
private final RegisteredSkill skill;
private final int unlockLevel, maxSkillLevel;
private final boolean unlockedByDefault, needsBound;
private final boolean unlockedByDefault, needsBinding, upgradable;
private final Map<String, LinearValue> parameters = new HashMap<>();
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel) {
this(skill, unlockLevel, maxSkillLevel, true);
}
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault) {
this(skill, unlockLevel, maxSkillLevel, unlockedByDefault, MMOCore.plugin.configManager.passiveSkillsNeedBinding);
}
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault, boolean needsBinding) {
this(skill, unlockLevel, maxSkillLevel, unlockedByDefault, needsBinding, true);
}
/**
* Class used to save information about skills IN A CLASS CONTEXT
* i.e at which level the skill can be unlocked, etc.
@ -32,20 +43,13 @@ public class ClassSkill implements CooldownObject, Unlockable {
* <p>
* It is also used by the MMOCore API to force players to cast abilities.
*/
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel) {
this(skill, unlockLevel, maxSkillLevel, true);
}
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault) {
this(skill, unlockLevel, maxSkillLevel, unlockedByDefault, MMOCore.plugin.configManager.passiveSkillNeedBound);
}
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault, boolean needsBound) {
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault, boolean needsBinding, boolean upgradable) {
this.skill = skill;
this.unlockLevel = unlockLevel;
this.maxSkillLevel = maxSkillLevel;
this.unlockedByDefault = unlockedByDefault;
this.needsBound = needsBound;
this.needsBinding = needsBinding;
this.upgradable = upgradable;
for (String param : skill.getHandler().getParameters())
this.parameters.put(param, skill.getParameterInfo(param));
}
@ -55,7 +59,8 @@ public class ClassSkill implements CooldownObject, Unlockable {
unlockLevel = config.getInt("level");
maxSkillLevel = config.getInt("max-level");
unlockedByDefault = config.getBoolean("unlocked-by-default", true);
needsBound = config.getBoolean("needs-bound", MMOCore.plugin.configManager.passiveSkillNeedBound);
needsBinding = config.getBoolean("needs-bound", MMOCore.plugin.configManager.passiveSkillsNeedBinding);
upgradable = config.getBoolean("upgradable", true);
for (String param : skill.getHandler().getParameters()) {
LinearValue defaultValue = skill.getParameterInfo(param);
this.parameters.put(param, config.isConfigurationSection(param) ? readLinearValue(defaultValue, config.getConfigurationSection(param)) : defaultValue);
@ -79,13 +84,17 @@ public class ClassSkill implements CooldownObject, Unlockable {
return maxSkillLevel;
}
public boolean isUpgradable() {
return upgradable;
}
@Override
public boolean isUnlockedByDefault() {
return unlockedByDefault;
}
public boolean needsBound() {
return needsBound;
return needsBinding;
}
@Override
@ -99,14 +108,15 @@ public class ClassSkill implements CooldownObject, Unlockable {
if (skill.equalsIgnoreCase(getUnlockNamespacedKey().split(":")[1]))
playerData.unbindSkill(slot);
});
//Update the stats to remove the passive skill if it is locked
if (!needsBound && getSkill().getTrigger().isPassive())
// Update the stats to remove the passive skill if it is locked
if (!needsBinding && getSkill().getTrigger().isPassive())
playerData.getStats().updateStats();
}
@Override
public void whenUnlocked(PlayerData playerData) {
if (!needsBound && getSkill().getTrigger().isPassive())
if (!needsBinding && getSkill().getTrigger().isPassive())
playerData.getStats().updateStats();
}
@ -183,7 +193,7 @@ public class ClassSkill implements CooldownObject, Unlockable {
public PassiveSkill toPassive(PlayerData caster) {
Validate.isTrue(skill.getTrigger().isPassive(), "Skill is active");
//MMOCorePassiveSkillNotBound to identify passive skills that don't need to be bound
return new PassiveSkill("MMOCorePassiveSkill" + (!needsBound ? "NotBound" : ""), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER);
return new PassiveSkill("MMOCorePassiveSkill" + (!needsBinding ? "NotBound" : ""), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER);
}
@Override

View File

@ -118,6 +118,7 @@ skills:
WARP:
level: 13
max-level: 30
upgradable: false # Player cannot upgrade this skill via the skill UI
GREATER_HEALINGS:
level: 15
max-level: 30

View File

@ -156,6 +156,7 @@ skills:
max-level: 30
ICE_SPIKES:
level: 8
upgradable: false # Player cannot upgrade this skill via the skill UI
AMBERS:
level: 9
max-level: 30

View File

@ -92,6 +92,7 @@ skills:
MINOR_HEALINGS:
level: 10
max-level: 30
upgradable: false # Player cannot upgrade this skill via the skill UI
attributes:
knockback-resistance:

View File

@ -87,6 +87,7 @@ skills:
MINOR_HEALINGS:
level: 10
max-level: 30
upgradable: false # Player cannot upgrade this skill via the skill UI
SNEAKY_PICKY:
level: 2
max-level: 20

View File

@ -113,6 +113,7 @@ skills:
MINOR_HEALINGS:
level: 10
max-level: 30
upgradable: false # Player cannot upgrade this skill via the skill UI
FIRE_BERSERKER:
level: 15

View File

@ -224,6 +224,7 @@ not-skill-reallocation-point: '&cYou do not have 1 skill reallocation point.'
no-skill-points-spent: '&cYou have not spent any skill points.'
skill-points-reallocated: '&eYou successfully reset your skill points. You now have &6{points} &eskill points.'
max-points-reached: '&cYou reached the maximum points you can spend. You need to reallocate your points to rollback.'
cannot-upgrade-skill: '&cYou cannot upgrade this skill.'
# Skill Trees
no-skill-tree-points-spent: '&cYou have not spent any skill tree points.'