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; 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) { if (playerData.getSkillPoints() < 1) {
ConfigMessage.fromKey("not-enough-skill-points").send(player); ConfigMessage.fromKey("not-enough-skill-points").send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2); 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 class ConfigManager {
public final CommandVerbose commandVerbose = new CommandVerbose(); 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; pvpModeEnabled, pvpModeInvulnerabilityCanDamage, forceClassSelection, enableGlobalSkillTreeGUI, enableSpecificSkillTreeGUI;
public String partyChatPrefix, noSkillBoundPlaceholder; public String partyChatPrefix, noSkillBoundPlaceholder;
public ChatColor staminaFull, staminaHalf, staminaEmpty; public ChatColor staminaFull, staminaHalf, staminaEmpty;
@ -156,7 +156,7 @@ public class ConfigManager {
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GRAY); staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GRAY);
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE); 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"); canCreativeCast = MMOCore.plugin.getConfig().getBoolean("can-creative-cast");
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp"); cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info"); saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -113,6 +113,7 @@ skills:
MINOR_HEALINGS: MINOR_HEALINGS:
level: 10 level: 10
max-level: 30 max-level: 30
upgradable: false # Player cannot upgrade this skill via the skill UI
FIRE_BERSERKER: FIRE_BERSERKER:
level: 15 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.' 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.' 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.' 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 # Skill Trees
no-skill-tree-points-spent: '&cYou have not spent any skill tree points.' no-skill-tree-points-spent: '&cYou have not spent any skill tree points.'