diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java index bb807241..d29a0ff6 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java @@ -27,7 +27,7 @@ public class DefaultMMOLoader extends MMOLoader { return new UnlockSkillTrigger(config); if (config.getKey().equals("skill_buff")) - return new SkillBuffTrigger(config); + return new SkillModifierTrigger(config); if (config.getKey().equals("message")) return new MessageTrigger(config); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 88789eb7..282dce35 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -117,13 +117,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc private final Map skillTreePoints = new HashMap<>(); /** - * Saves the namespacedkey of the items that have been unlocked in the form item-type:item-key. + * Saves the namespacedkeys of the items that have been unlocked in the form "namespace:key". * This is used for: - * -Waypoints - * -Skills - * -Skill Books + * - waypoints + * - skills */ - private final Set unlockedItems= new HashSet<>(); + private final Set unlockedItems = new HashSet<>(); /** * Saves the amount of times the player has claimed some @@ -429,11 +428,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc } public void setUnlockedItems(Set unlockedItems) { - unlockedItems.clear(); - unlockedItems.addAll(unlockedItems); + this.unlockedItems.clear(); + this.unlockedItems.addAll(unlockedItems); } - public void resetTimesClaimed() { tableItemClaims.clear(); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java index e1dca27e..05881478 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java @@ -105,11 +105,9 @@ public class SavedClassInformation { if (json.has("bound-skills") && json.get("bound-skills").isJsonObject()) for (Entry entry : json.getAsJsonObject("bound-skills").entrySet()) boundSkills.put(Integer.parseInt(entry.getKey()), entry.getValue().getAsString()); - if(json.has("unlocked-items")){ - for(JsonElement unlockedItem: json.get("unlocked-items").getAsJsonArray()){ + if (json.has("unlocked-items")) + for (JsonElement unlockedItem : json.get("unlocked-items").getAsJsonArray()) unlockedItems.add(unlockedItem.getAsString()); - } - } } public SavedClassInformation(ClassDataContainer data) { @@ -234,6 +232,10 @@ public class SavedClassInformation { attributeLevels.put(attribute, level); } + public Set getUnlockedItems() { + return unlockedItems; + } + /** * @param profess Target player class * @param player Player changing class @@ -267,7 +269,6 @@ public class SavedClassInformation { player.unbindSkill(0); player.clearNodeTimesClaimed(); - /* * Reads this class info, applies it to the player. set class after * changing level so the player stats can be calculated based on new @@ -284,7 +285,6 @@ public class SavedClassInformation { for (int slot : boundSkills.keySet()) player.bindSkill(slot, profess.getSkill(boundSkills.get(slot))); - skillLevels.forEach(player::setSkillLevel); attributeLevels.forEach((id, pts) -> player.getAttributes().setBaseAttribute(id, pts)); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillBuffTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillModifierTrigger.java similarity index 56% rename from MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillBuffTrigger.java rename to MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillModifierTrigger.java index 4de2cc03..0ec0ec71 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillBuffTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillModifierTrigger.java @@ -1,6 +1,8 @@ package net.Indyuce.mmocore.api.quest.trigger; import io.lumine.mythic.lib.api.MMOLineConfig; +import io.lumine.mythic.lib.player.skillmod.SkillModifier; +import io.lumine.mythic.lib.skill.handler.SkillHandler; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.quest.trigger.api.Removable; @@ -10,41 +12,37 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -public class SkillBuffTrigger extends Trigger implements Removable { - private final SkillBuff skillBuff; - private final String buffKey = TRIGGER_PREFIX + "." + UUID.randomUUID(); +public class SkillModifierTrigger extends Trigger implements Removable { + private final SkillModifier mod; + private final String modifierKey = TRIGGER_PREFIX + "." + UUID.randomUUID(); private final double amount; - - public SkillBuffTrigger(MMOLineConfig config) { + public SkillModifierTrigger(MMOLineConfig config) { super(config); config.validateKeys("modifier"); config.validateKeys("amount"); config.validateKeys("formula"); config.validateKeys("type"); + amount = config.getDouble("amount"); String skillModifier = config.getString("modifier"); String formula = config.getString("formula"); - List targetSkills = new ArrayList<>(); + final List> targetSkills = new ArrayList<>(); for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll()) if (skill.matchesFormula(formula)) - targetSkills.add(skill.getHandler().getId()); + targetSkills.add(skill.getHandler()); - skillBuff = new SkillBuff(buffKey, skillModifier, targetSkills, amount); + mod = new SkillModifier(modifierKey, skillModifier, targetSkills, amount); } @Override public void apply(PlayerData player) { - if (player.getMMOPlayerData().getSkillBuffMap().hasSkillBuff(buffKey)) { - player.getMMOPlayerData().getSkillBuffMap().getSkillBuff(buffKey).add(amount).register(player.getMMOPlayerData()); - } else { - skillBuff.register(player.getMMOPlayerData()); - } + mod.register(player.getMMOPlayerData()); } @Override public void remove(PlayerData playerData) { - skillBuff.unregister(playerData.getMMOPlayerData()); + mod.unregister(playerData.getMMOPlayerData()); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java index c0867832..d4fc02d5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java @@ -24,11 +24,11 @@ public class ClassSkill implements CooldownObject { private final Set unlockConditions = new HashSet<>(); /** - * Class used to save information about skills IN A CLASS CONTEXT i.e at - * which level the skill can be unlocked, etc. + * Class used to save information about skills IN A CLASS CONTEXT + * i.e at which level the skill can be unlocked, etc. *

- * This constructor can be used by other plugins to register class skills - * directly without the use of class config files. + * This constructor can be used by other plugins to register class + * skills directly without the use of class config files. *

* It is also used by the MMOCore API to force players to cast abilities. */ @@ -56,7 +56,6 @@ public class ClassSkill implements CooldownObject { } } - public RegisteredSkill getSkill() { return skill; } @@ -107,9 +106,7 @@ public class ClassSkill implements CooldownObject { // Calculate placeholders Placeholders placeholders = new Placeholders(); - modifiers.keySet().forEach(modifier -> - placeholders.register(modifier, data.getMMOPlayerData().getSkillBuffMap() - .getSkillInstance(skill.getHandler().getId()).getSkillModifier(modifier).getTotal(modifiers.get(modifier).calculate(x)))); + modifiers.keySet().forEach(modifier -> placeholders.register(modifier, data.getMMOPlayerData().getSkillModifierMap().getInstance(skill.getHandler(), modifier).getTotal(modifiers.get(modifier).calculate(x)))); placeholders.register("mana_name", data.getProfess().getManaDisplay().getName()); placeholders.register("mana_color", data.getProfess().getManaDisplay().getFull().toString()); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java index bf96c391..7f001828 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java @@ -33,9 +33,12 @@ public class RegisteredSkill implements Unlockable { name = Objects.requireNonNull(config.getString("name"), "Could not find skill name"); icon = MMOCoreUtils.readIcon(Objects.requireNonNull(config.getString("material"), "Could not find skill icon")); lore = Objects.requireNonNull(config.getStringList("lore"), "Could not find skill lore"); - categories = config.getStringList("categories"); + // Trigger type triggerType = getHandler().isTriggerable() ? (config.contains("passive-type") ? TriggerType.valueOf(UtilityMethods.enumName(config.getString("passive-type"))) : TriggerType.CAST) : TriggerType.API; + + // Categories + categories = config.getStringList("categories"); categories.add(getHandler().getId()); if (triggerType.isPassive()) categories.add("passive"); @@ -123,7 +126,7 @@ public class RegisteredSkill implements Unlockable { /** * @return Modifier formula. - * Not null as long as the modifier is well defined + * Not null as long as the modifier is well defined */ @NotNull public LinearValue getModifierInfo(String modifier) { @@ -142,8 +145,8 @@ public class RegisteredSkill implements Unlockable { try { boolean res = (boolean) MythicLib.plugin.getInterpreter().eval(parsedExpression); return res; - } catch (EvalError e) { - throw new RuntimeException(e); + } catch (EvalError error) { + throw new RuntimeException(error); } }