From cedc6ae6c8d3c9cb29c91daa2040adea78739457 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 21:15:39 +0100 Subject: [PATCH] Bug Fixing --- .../api/player/profess/skillbinding/SkillSlot.java | 2 +- .../mmocore/api/quest/trigger/SkillBuffTrigger.java | 6 +++++- .../net/Indyuce/mmocore/command/SkillsCommand.java | 1 - .../main/java/net/Indyuce/mmocore/gui/SkillList.java | 10 ++++------ .../net/Indyuce/mmocore/skill/RegisteredSkill.java | 6 +++--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java index e191c921..91e58797 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java @@ -31,7 +31,7 @@ public class SkillSlot { public SkillSlot(ConfigurationSection section) { this.slot = Integer.parseInt(section.getName()); - this.formula = section.contains("expression") ? section.getString("expression") : "true"; + this.formula = section.contains("formula") ? section.getString("formula") : "true"; this.name = section.getString("name"); this.lore = section.getStringList("lore"); if (section.contains("item")) 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/SkillBuffTrigger.java index a9de20cb..40bd9cbe 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/SkillBuffTrigger.java @@ -2,10 +2,12 @@ package net.Indyuce.mmocore.api.quest.trigger; import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.skill.SkillBuff; +import io.lumine.mythic.lib.player.modifier.ModifierType; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.quest.trigger.api.Removable; import net.Indyuce.mmocore.skill.RegisteredSkill; +import org.apache.commons.lang.Validate; import java.util.ArrayList; import java.util.List; @@ -25,12 +27,14 @@ public class SkillBuffTrigger extends Trigger implements Removable { amount = config.getDouble("amount"); String skillModifier = config.getString("modifier"); String formula = config.getString("formula", "true"); + String type = config.getString("type").toUpperCase(); + Validate.isTrue(type.equals("FLAT") || type.equals("RELATIVE")); List targetSkills = new ArrayList<>(); for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll()) { if (skill.matchesFormula(formula)) targetSkills.add(skill.getHandler().getId()); } - skillBuff = new SkillBuff(buffKey, skillModifier, targetSkills, amount); + skillBuff = new SkillBuff(buffKey, skillModifier, targetSkills, amount, ModifierType.valueOf(type)); } @Override diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java index e8d3aede..557f1e7b 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java @@ -29,7 +29,6 @@ public class SkillsCommand extends RegisteredCommand { if (data.getProfess().getSkills() .stream() .filter((classSkill) -> data.hasUnlocked(classSkill.getSkill())) - .sorted((classSkill1,classSkill2)->classSkill1.getUnlockLevel()-classSkill1.getUnlockLevel()) .collect(Collectors.toList()) .size() < 1) { MMOCore.plugin.configManager.getSimpleMessage("no-class-skill").send((Player) sender); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index 573ee9d2..575ad2f4 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -28,6 +28,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.logging.Level; import java.util.stream.Collectors; @@ -201,7 +202,7 @@ public class SkillList extends EditableInventory { @Override public Placeholders getPlaceholders(SkillViewerInventory inv, int n) { - RegisteredSkill selected = inv.selected == null ? null : inv.selected.getSkill(); + RegisteredSkill selected = inv.selected.getSkill(); Placeholders holders = new Placeholders(); @@ -325,12 +326,12 @@ public class SkillList extends EditableInventory { skills = playerData.getProfess().getSkills() .stream() .filter((classSkill) -> playerData.hasUnlocked(classSkill.getSkill())) + .sorted(Comparator.comparingInt(ClassSkill::getUnlockLevel)) .collect(Collectors.toList()); skillSlots = getEditable().getByFunction("skill").getSlots(); Validate.notNull(getEditable().getByFunction("slot"), "Your skill GUI config file is out-of-date, please regenerate it."); slotSlots = getEditable().getByFunction("slot").getSlots(); - if (skills.size() > page * skillSlots.size()) - selected = skills.get(page * skillSlots.size()); + selected = skills.get(page * skillSlots.size()); } @Override @@ -413,9 +414,6 @@ public class SkillList extends EditableInventory { return; } - if (selected == null) - return; - if (!playerData.hasSkillUnlocked(selected)) { MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill").send(player); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2); 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 2fc6b7da..c82a5c68 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 @@ -39,9 +39,9 @@ public class RegisteredSkill implements Unlockable { triggerType = getHandler().isTriggerable() ? (config.contains("passive-type") ? TriggerType.valueOf(UtilityMethods.enumName(config.getString("passive-type"))) : TriggerType.CAST) : TriggerType.API; categories.add(getHandler().getId()); if (triggerType.isPassive()) - categories.add("passive"); + categories.add("PASSIVE"); else - categories.add("active"); + categories.add("ACTIVE"); // Load default modifier formulas for (String mod : handler.getModifiers()) @@ -139,7 +139,7 @@ public class RegisteredSkill implements Unlockable { String parsedExpression = formula; for (String category : categories) parsedExpression = parsedExpression.replace("<" + category + ">", "true"); - parsedExpression = parsedExpression.replaceAll("<.*>", "false"); + parsedExpression = parsedExpression.replaceAll("<.*?>", "false"); try { boolean res = (boolean) MythicLib.plugin.getInterpreter().eval(parsedExpression); return res;