mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-01-05 06:57:37 +01:00
Refactor before dev build
This commit is contained in:
parent
786d1881bf
commit
1a5f5986aa
@ -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);
|
||||
|
@ -117,13 +117,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
private final Map<String, Integer> 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<String> unlockedItems= new HashSet<>();
|
||||
private final Set<String> 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<String> unlockedItems) {
|
||||
unlockedItems.clear();
|
||||
unlockedItems.addAll(unlockedItems);
|
||||
this.unlockedItems.clear();
|
||||
this.unlockedItems.addAll(unlockedItems);
|
||||
}
|
||||
|
||||
|
||||
public void resetTimesClaimed() {
|
||||
tableItemClaims.clear();
|
||||
}
|
||||
|
@ -105,11 +105,9 @@ public class SavedClassInformation {
|
||||
if (json.has("bound-skills") && json.get("bound-skills").isJsonObject())
|
||||
for (Entry<String, JsonElement> 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<String> 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));
|
||||
|
||||
|
@ -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<String> targetSkills = new ArrayList<>();
|
||||
final List<SkillHandler<?>> 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());
|
||||
}
|
||||
}
|
@ -24,11 +24,11 @@ public class ClassSkill implements CooldownObject {
|
||||
private final Set<Condition> 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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());
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user