mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-01-06 07:07:38 +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);
|
return new UnlockSkillTrigger(config);
|
||||||
|
|
||||||
if (config.getKey().equals("skill_buff"))
|
if (config.getKey().equals("skill_buff"))
|
||||||
return new SkillBuffTrigger(config);
|
return new SkillModifierTrigger(config);
|
||||||
|
|
||||||
if (config.getKey().equals("message"))
|
if (config.getKey().equals("message"))
|
||||||
return new MessageTrigger(config);
|
return new MessageTrigger(config);
|
||||||
|
@ -117,13 +117,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
private final Map<String, Integer> skillTreePoints = new HashMap<>();
|
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:
|
* This is used for:
|
||||||
* -Waypoints
|
* - waypoints
|
||||||
* -Skills
|
* - skills
|
||||||
* -Skill Books
|
|
||||||
*/
|
*/
|
||||||
private final Set<String> unlockedItems= new HashSet<>();
|
private final Set<String> unlockedItems = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the amount of times the player has claimed some
|
* 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) {
|
public void setUnlockedItems(Set<String> unlockedItems) {
|
||||||
unlockedItems.clear();
|
this.unlockedItems.clear();
|
||||||
unlockedItems.addAll(unlockedItems);
|
this.unlockedItems.addAll(unlockedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void resetTimesClaimed() {
|
public void resetTimesClaimed() {
|
||||||
tableItemClaims.clear();
|
tableItemClaims.clear();
|
||||||
}
|
}
|
||||||
|
@ -105,11 +105,9 @@ public class SavedClassInformation {
|
|||||||
if (json.has("bound-skills") && json.get("bound-skills").isJsonObject())
|
if (json.has("bound-skills") && json.get("bound-skills").isJsonObject())
|
||||||
for (Entry<String, JsonElement> entry : json.getAsJsonObject("bound-skills").entrySet())
|
for (Entry<String, JsonElement> entry : json.getAsJsonObject("bound-skills").entrySet())
|
||||||
boundSkills.put(Integer.parseInt(entry.getKey()), entry.getValue().getAsString());
|
boundSkills.put(Integer.parseInt(entry.getKey()), entry.getValue().getAsString());
|
||||||
if(json.has("unlocked-items")){
|
if (json.has("unlocked-items"))
|
||||||
for(JsonElement unlockedItem: json.get("unlocked-items").getAsJsonArray()){
|
for (JsonElement unlockedItem : json.get("unlocked-items").getAsJsonArray())
|
||||||
unlockedItems.add(unlockedItem.getAsString());
|
unlockedItems.add(unlockedItem.getAsString());
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SavedClassInformation(ClassDataContainer data) {
|
public SavedClassInformation(ClassDataContainer data) {
|
||||||
@ -234,6 +232,10 @@ public class SavedClassInformation {
|
|||||||
attributeLevels.put(attribute, level);
|
attributeLevels.put(attribute, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getUnlockedItems() {
|
||||||
|
return unlockedItems;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param profess Target player class
|
* @param profess Target player class
|
||||||
* @param player Player changing class
|
* @param player Player changing class
|
||||||
@ -267,7 +269,6 @@ public class SavedClassInformation {
|
|||||||
player.unbindSkill(0);
|
player.unbindSkill(0);
|
||||||
player.clearNodeTimesClaimed();
|
player.clearNodeTimesClaimed();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads this class info, applies it to the player. set class after
|
* Reads this class info, applies it to the player. set class after
|
||||||
* changing level so the player stats can be calculated based on new
|
* changing level so the player stats can be calculated based on new
|
||||||
@ -284,7 +285,6 @@ public class SavedClassInformation {
|
|||||||
for (int slot : boundSkills.keySet())
|
for (int slot : boundSkills.keySet())
|
||||||
player.bindSkill(slot, profess.getSkill(boundSkills.get(slot)));
|
player.bindSkill(slot, profess.getSkill(boundSkills.get(slot)));
|
||||||
|
|
||||||
|
|
||||||
skillLevels.forEach(player::setSkillLevel);
|
skillLevels.forEach(player::setSkillLevel);
|
||||||
attributeLevels.forEach((id, pts) -> player.getAttributes().setBaseAttribute(id, pts));
|
attributeLevels.forEach((id, pts) -> player.getAttributes().setBaseAttribute(id, pts));
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package net.Indyuce.mmocore.api.quest.trigger;
|
package net.Indyuce.mmocore.api.quest.trigger;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
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.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.quest.trigger.api.Removable;
|
import net.Indyuce.mmocore.api.quest.trigger.api.Removable;
|
||||||
@ -10,41 +12,37 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SkillBuffTrigger extends Trigger implements Removable {
|
public class SkillModifierTrigger extends Trigger implements Removable {
|
||||||
private final SkillBuff skillBuff;
|
private final SkillModifier mod;
|
||||||
private final String buffKey = TRIGGER_PREFIX + "." + UUID.randomUUID();
|
private final String modifierKey = TRIGGER_PREFIX + "." + UUID.randomUUID();
|
||||||
private final double amount;
|
private final double amount;
|
||||||
|
|
||||||
|
public SkillModifierTrigger(MMOLineConfig config) {
|
||||||
public SkillBuffTrigger(MMOLineConfig config) {
|
|
||||||
super(config);
|
super(config);
|
||||||
|
|
||||||
config.validateKeys("modifier");
|
config.validateKeys("modifier");
|
||||||
config.validateKeys("amount");
|
config.validateKeys("amount");
|
||||||
config.validateKeys("formula");
|
config.validateKeys("formula");
|
||||||
config.validateKeys("type");
|
config.validateKeys("type");
|
||||||
|
|
||||||
amount = config.getDouble("amount");
|
amount = config.getDouble("amount");
|
||||||
String skillModifier = config.getString("modifier");
|
String skillModifier = config.getString("modifier");
|
||||||
String formula = config.getString("formula");
|
String formula = config.getString("formula");
|
||||||
List<String> targetSkills = new ArrayList<>();
|
final List<SkillHandler<?>> targetSkills = new ArrayList<>();
|
||||||
for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll())
|
for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll())
|
||||||
if (skill.matchesFormula(formula))
|
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
|
@Override
|
||||||
public void apply(PlayerData player) {
|
public void apply(PlayerData player) {
|
||||||
if (player.getMMOPlayerData().getSkillBuffMap().hasSkillBuff(buffKey)) {
|
mod.register(player.getMMOPlayerData());
|
||||||
player.getMMOPlayerData().getSkillBuffMap().getSkillBuff(buffKey).add(amount).register(player.getMMOPlayerData());
|
|
||||||
} else {
|
|
||||||
skillBuff.register(player.getMMOPlayerData());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(PlayerData playerData) {
|
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<>();
|
private final Set<Condition> unlockConditions = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to save information about skills IN A CLASS CONTEXT i.e at
|
* Class used to save information about skills IN A CLASS CONTEXT
|
||||||
* which level the skill can be unlocked, etc.
|
* i.e at which level the skill can be unlocked, etc.
|
||||||
* <p>
|
* <p>
|
||||||
* This constructor can be used by other plugins to register class skills
|
* This constructor can be used by other plugins to register class
|
||||||
* directly without the use of class config files.
|
* skills directly without the use of class config files.
|
||||||
* <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.
|
||||||
*/
|
*/
|
||||||
@ -56,7 +56,6 @@ public class ClassSkill implements CooldownObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RegisteredSkill getSkill() {
|
public RegisteredSkill getSkill() {
|
||||||
return skill;
|
return skill;
|
||||||
}
|
}
|
||||||
@ -107,9 +106,7 @@ public class ClassSkill implements CooldownObject {
|
|||||||
|
|
||||||
// Calculate placeholders
|
// Calculate placeholders
|
||||||
Placeholders placeholders = new Placeholders();
|
Placeholders placeholders = new Placeholders();
|
||||||
modifiers.keySet().forEach(modifier ->
|
modifiers.keySet().forEach(modifier -> placeholders.register(modifier, data.getMMOPlayerData().getSkillModifierMap().getInstance(skill.getHandler(), modifier).getTotal(modifiers.get(modifier).calculate(x))));
|
||||||
placeholders.register(modifier, data.getMMOPlayerData().getSkillBuffMap()
|
|
||||||
.getSkillInstance(skill.getHandler().getId()).getSkillModifier(modifier).getTotal(modifiers.get(modifier).calculate(x))));
|
|
||||||
placeholders.register("mana_name", data.getProfess().getManaDisplay().getName());
|
placeholders.register("mana_name", data.getProfess().getManaDisplay().getName());
|
||||||
placeholders.register("mana_color", data.getProfess().getManaDisplay().getFull().toString());
|
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");
|
name = Objects.requireNonNull(config.getString("name"), "Could not find skill name");
|
||||||
icon = MMOCoreUtils.readIcon(Objects.requireNonNull(config.getString("material"), "Could not find skill icon"));
|
icon = MMOCoreUtils.readIcon(Objects.requireNonNull(config.getString("material"), "Could not find skill icon"));
|
||||||
lore = Objects.requireNonNull(config.getStringList("lore"), "Could not find skill lore");
|
lore = Objects.requireNonNull(config.getStringList("lore"), "Could not find skill lore");
|
||||||
categories = config.getStringList("categories");
|
|
||||||
// Trigger type
|
// Trigger type
|
||||||
triggerType = getHandler().isTriggerable() ? (config.contains("passive-type") ? TriggerType.valueOf(UtilityMethods.enumName(config.getString("passive-type"))) : TriggerType.CAST) : TriggerType.API;
|
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());
|
categories.add(getHandler().getId());
|
||||||
if (triggerType.isPassive())
|
if (triggerType.isPassive())
|
||||||
categories.add("passive");
|
categories.add("passive");
|
||||||
@ -123,7 +126,7 @@ public class RegisteredSkill implements Unlockable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Modifier formula.
|
* @return Modifier formula.
|
||||||
* Not null as long as the modifier is well defined
|
* Not null as long as the modifier is well defined
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public LinearValue getModifierInfo(String modifier) {
|
public LinearValue getModifierInfo(String modifier) {
|
||||||
@ -142,8 +145,8 @@ public class RegisteredSkill implements Unlockable {
|
|||||||
try {
|
try {
|
||||||
boolean res = (boolean) MythicLib.plugin.getInterpreter().eval(parsedExpression);
|
boolean res = (boolean) MythicLib.plugin.getInterpreter().eval(parsedExpression);
|
||||||
return res;
|
return res;
|
||||||
} catch (EvalError e) {
|
} catch (EvalError error) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user