Bug Fixing

This commit is contained in:
Ka0rX 2023-04-02 21:15:39 +01:00
parent c6b9372026
commit cedc6ae6c8
5 changed files with 13 additions and 12 deletions

View File

@ -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"))

View File

@ -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<String> 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

View File

@ -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);

View File

@ -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);

View File

@ -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;