forked from Upstream/mmocore
Resuming cleanup
This commit is contained in:
parent
b6600245ad
commit
1cbf0f0ea1
@ -183,16 +183,15 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupSkillTree() {
|
public void setupSkillTree() {
|
||||||
|
|
||||||
// Node states setup
|
// Node states setup
|
||||||
for (SkillTree skillTree : getProfess().getSkillTrees())
|
for (SkillTree skillTree : getProfess().getSkillTrees())
|
||||||
skillTree.setupNodeStates(this);
|
skillTree.setupNodeStates(this);
|
||||||
|
|
||||||
// Stat triggers setup
|
// Stat triggers setup
|
||||||
|
|
||||||
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
|
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
|
||||||
for (SkillTreeNode node : skillTree.getNodes())
|
for (SkillTreeNode node : skillTree.getNodes())
|
||||||
node.getExperienceTable().claimStatTriggers(this, node);
|
node.getExperienceTable().claimStatTriggers(this, node);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPointSpent(SkillTree skillTree) {
|
public int getPointSpent(SkillTree skillTree) {
|
||||||
@ -1165,7 +1164,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return mmoData.getCooldownMap();
|
return mmoData.getCooldownMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClass(PlayerClass profess) {
|
public void setClass(@Nullable PlayerClass profess) {
|
||||||
this.profess = profess;
|
this.profess = profess;
|
||||||
|
|
||||||
// Clear old skills
|
// Clear old skills
|
||||||
@ -1177,11 +1176,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
if (isOnline())
|
if (isOnline())
|
||||||
getStats().updateStats();
|
getStats().updateStats();
|
||||||
|
|
||||||
// Loads the classUnlockedSkills
|
if (profess != null)
|
||||||
profess.getSkills()
|
// Loads the classUnlockedSkills
|
||||||
.stream()
|
profess.getSkills()
|
||||||
.filter(ClassSkill::isUnlockedByDefault)
|
.stream()
|
||||||
.forEach(skill ->unlock(skill.getSkill()));
|
.filter(ClassSkill::isUnlockedByDefault)
|
||||||
|
.forEach(skill -> unlock(skill.getSkill()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSkillBound(int slot) {
|
public boolean hasSkillBound(int slot) {
|
||||||
|
@ -104,11 +104,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
| SecurityException exception) {
|
| SecurityException exception) {
|
||||||
throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage());
|
throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage());
|
||||||
}
|
}
|
||||||
Validate.isTrue(config.isConfigurationSection("skill-slots"), "You must define the skills-slots for class " + id);
|
|
||||||
for (String key : config.getConfigurationSection("skill-slots").getKeys(false)) {
|
|
||||||
SkillSlot skillSlot = new SkillSlot(config.getConfigurationSection("skill-slots." + key));
|
|
||||||
skillSlots.put(skillSlot.getSlot(), skillSlot);
|
|
||||||
}
|
|
||||||
for (String string : config.getStringList("display.lore"))
|
for (String string : config.getStringList("display.lore"))
|
||||||
description.add(ChatColor.GRAY + MythicLib.plugin.parseColors(string));
|
description.add(ChatColor.GRAY + MythicLib.plugin.parseColors(string));
|
||||||
for (String string : config.getStringList("display.attribute-lore"))
|
for (String string : config.getStringList("display.attribute-lore"))
|
||||||
@ -119,10 +115,13 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
displayOrder = config.getInt("display.order");
|
displayOrder = config.getInt("display.order");
|
||||||
actionBarFormat = config.contains("action-bar", true) ? config.getString("action-bar") : null;
|
actionBarFormat = config.contains("action-bar", true) ? config.getString("action-bar") : null;
|
||||||
|
|
||||||
|
// Exp curve
|
||||||
expCurve = config.contains("exp-curve")
|
expCurve = config.contains("exp-curve")
|
||||||
? MMOCore.plugin.experience.getCurveOrThrow(
|
? MMOCore.plugin.experience.getCurveOrThrow(
|
||||||
config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
||||||
: ExpCurve.DEFAULT;
|
: ExpCurve.DEFAULT;
|
||||||
|
|
||||||
|
// Main exp table
|
||||||
ExperienceTable expTable = null;
|
ExperienceTable expTable = null;
|
||||||
if (config.contains("exp-table"))
|
if (config.contains("exp-table"))
|
||||||
try {
|
try {
|
||||||
@ -131,6 +130,8 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp table from class '" + id + "': " + exception.getMessage());
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp table from class '" + id + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
this.expTable = expTable;
|
this.expTable = expTable;
|
||||||
|
|
||||||
|
// Skill trees
|
||||||
if (config.contains("skill-trees"))
|
if (config.contains("skill-trees"))
|
||||||
for (String str : config.getStringList("skill-trees"))
|
for (String str : config.getStringList("skill-trees"))
|
||||||
try {
|
try {
|
||||||
@ -139,6 +140,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
MMOCore.log(Level.WARNING, "Could not find skill tree with ID: " + str);
|
MMOCore.log(Level.WARNING, "Could not find skill tree with ID: " + str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Class-specific scripts
|
||||||
if (config.contains("scripts"))
|
if (config.contains("scripts"))
|
||||||
for (String key : config.getConfigurationSection("scripts").getKeys(false))
|
for (String key : config.getConfigurationSection("scripts").getKeys(false))
|
||||||
try {
|
try {
|
||||||
@ -161,6 +163,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
}
|
}
|
||||||
this.comboMap = comboMap;
|
this.comboMap = comboMap;
|
||||||
|
|
||||||
|
// Triggers (DEPRECATED)
|
||||||
if (config.contains("triggers"))
|
if (config.contains("triggers"))
|
||||||
for (String key : config.getConfigurationSection("triggers").getKeys(false))
|
for (String key : config.getConfigurationSection("triggers").getKeys(false))
|
||||||
try {
|
try {
|
||||||
@ -170,6 +173,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
MMOCore.log(Level.WARNING, "Could not load trigger '" + key + "' from class '" + id + "':" + exception.getMessage());
|
MMOCore.log(Level.WARNING, "Could not load trigger '" + key + "' from class '" + id + "':" + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Class STATS, not attributes (historic reasons)
|
||||||
if (config.contains("attributes"))
|
if (config.contains("attributes"))
|
||||||
for (String key : config.getConfigurationSection("attributes").getKeys(false))
|
for (String key : config.getConfigurationSection("attributes").getKeys(false))
|
||||||
try {
|
try {
|
||||||
@ -180,16 +184,30 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
+ id + "': " + exception.getMessage());
|
+ id + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skill slots
|
||||||
|
if (config.contains("skill-slots"))
|
||||||
|
for (String key : config.getConfigurationSection("skill-slots").getKeys(false))
|
||||||
|
try {
|
||||||
|
SkillSlot skillSlot = new SkillSlot(config.getConfigurationSection("skill-slots." + key));
|
||||||
|
skillSlots.put(skillSlot.getSlot(), skillSlot);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill slot '" + key + "' from class '"
|
||||||
|
+ id + "': " + exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Class skills
|
||||||
for (RegisteredSkill registered : MMOCore.plugin.skillManager.getAll()) {
|
for (RegisteredSkill registered : MMOCore.plugin.skillManager.getAll()) {
|
||||||
String key = registered.getHandler().getId();
|
final String key = registered.getHandler().getId();
|
||||||
if (config.contains("skills." + key))
|
if (config.contains("skills." + key))
|
||||||
skills.put(key, new ClassSkill(registered, config.getConfigurationSection("skills." + key)));
|
skills.put(key, new ClassSkill(registered, config.getConfigurationSection("skills." + key)));
|
||||||
else
|
else
|
||||||
skills.put(key, new ClassSkill(registered, 1, 1,false));
|
skills.put(key, new ClassSkill(registered, 1, 1,false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Casting particle
|
||||||
castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle")) : null;
|
castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle")) : null;
|
||||||
|
|
||||||
|
// Other class options
|
||||||
if (config.contains("options"))
|
if (config.contains("options"))
|
||||||
for (String key : config.getConfigurationSection("options").getKeys(false))
|
for (String key : config.getConfigurationSection("options").getKeys(false))
|
||||||
try {
|
try {
|
||||||
@ -200,6 +218,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
|
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Experience sources
|
||||||
if (config.contains("main-exp-sources")) {
|
if (config.contains("main-exp-sources")) {
|
||||||
for (String key : config.getStringList("main-exp-sources"))
|
for (String key : config.getStringList("main-exp-sources"))
|
||||||
try {
|
try {
|
||||||
@ -346,8 +365,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
public void giveExperience(PlayerData playerData, double experience, @Nullable Location hologramLocation, EXPSource source) {
|
||||||
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null
|
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null : hologramLocation;
|
||||||
: hologramLocation;
|
|
||||||
playerData.giveExperience(experience, source, hologramLocation, true);
|
playerData.giveExperience(experience, source, hologramLocation, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import net.Indyuce.mmocore.skill.ClassSkill;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SkillSlot {
|
public class SkillSlot {
|
||||||
@ -11,7 +12,7 @@ public class SkillSlot {
|
|||||||
private final String formula;
|
private final String formula;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final List<String> lore;
|
private final List<String> lore;
|
||||||
private Material item;
|
private final Material item;
|
||||||
|
|
||||||
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, Material item) {
|
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, Material item) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
@ -27,8 +28,7 @@ public class SkillSlot {
|
|||||||
this.formula = section.contains("expression") ? section.getString("expression") : "true";
|
this.formula = section.contains("expression") ? section.getString("expression") : "true";
|
||||||
this.name = section.getString("name");
|
this.name = section.getString("name");
|
||||||
this.lore = section.getStringList("lore");
|
this.lore = section.getStringList("lore");
|
||||||
if (section.contains("item"))
|
this.item = section.contains("item") ? Material.valueOf(section.getString("item")) : null;
|
||||||
this.item = Material.valueOf(section.getString("item"));
|
|
||||||
this.modelData = section.getInt("model-data", 0);
|
this.modelData = section.getInt("model-data", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ public class SkillSlot {
|
|||||||
return lore;
|
return lore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Material getItem() {
|
public Material getItem() {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ public class SkillSlot {
|
|||||||
return modelData;
|
return modelData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPlaceSkill(ClassSkill classSkill) {
|
public boolean acceptsSkill(ClassSkill classSkill) {
|
||||||
return classSkill.getSkill().matchesFormula(formula);
|
return classSkill.getSkill().matchesFormula(formula);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,18 +18,19 @@ import java.util.function.BiFunction;
|
|||||||
public class SkillCommandTreeNode extends CommandTreeNode {
|
public class SkillCommandTreeNode extends CommandTreeNode {
|
||||||
public SkillCommandTreeNode(CommandTreeNode parent) {
|
public SkillCommandTreeNode(CommandTreeNode parent) {
|
||||||
super(parent, "skill");
|
super(parent, "skill");
|
||||||
|
|
||||||
addChild(new LockSkillCommandTreeNode(this, "lock", true));
|
addChild(new LockSkillCommandTreeNode(this, "lock", true));
|
||||||
addChild(new LockSkillCommandTreeNode(this, "unlock", false));
|
addChild(new LockSkillCommandTreeNode(this, "unlock", false));
|
||||||
addChild(new ActionCommandTreeNode(this, "give", (old, amount) -> old + amount));
|
addChild(new LevelCommandTreeNode(this, "give", (old, amount) -> old + amount));
|
||||||
addChild(new ActionCommandTreeNode(this, "set", (old, amount) -> amount));
|
addChild(new LevelCommandTreeNode(this, "set", (old, amount) -> amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LevelCommandTreeNode extends CommandTreeNode {
|
||||||
public class ActionCommandTreeNode extends CommandTreeNode {
|
|
||||||
private final BiFunction<Integer, Integer, Integer> change;
|
private final BiFunction<Integer, Integer, Integer> change;
|
||||||
|
|
||||||
public ActionCommandTreeNode(CommandTreeNode parent, String type, BiFunction<Integer, Integer, Integer> change) {
|
public LevelCommandTreeNode(CommandTreeNode parent, String type, BiFunction<Integer, Integer, Integer> change) {
|
||||||
super(parent, type);
|
super(parent, type);
|
||||||
|
|
||||||
this.change = change;
|
this.change = change;
|
||||||
addParameter(Parameter.PLAYER);
|
addParameter(Parameter.PLAYER);
|
||||||
addParameter(new Parameter("<skill>",
|
addParameter(new Parameter("<skill>",
|
||||||
|
@ -17,7 +17,6 @@ import net.Indyuce.mmocore.skill.ClassSkill;
|
|||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
import net.Indyuce.mmocore.api.SoundEvent;
|
import net.Indyuce.mmocore.api.SoundEvent;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -421,7 +420,7 @@ public class SkillList extends EditableInventory {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!skillSlot.canPlaceSkill(selected)){
|
if(!skillSlot.acceptsSkill(selected)){
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("not-compatible-skill").send(player);
|
MMOCore.plugin.configManager.getSimpleMessage("not-compatible-skill").send(player);
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||||
return;
|
return;
|
||||||
|
@ -51,6 +51,7 @@ public class StatManager implements MMOCoreManager {
|
|||||||
* - in stats.yml which defines default stat formulas
|
* - in stats.yml which defines default stat formulas
|
||||||
*
|
*
|
||||||
* @return A list of stats that must be taken into account in MMOCore
|
* @return A list of stats that must be taken into account in MMOCore
|
||||||
|
* in the player stat calculation.
|
||||||
*/
|
*/
|
||||||
public Set<String> getRegistered() {
|
public Set<String> getRegistered() {
|
||||||
return usedStats;
|
return usedStats;
|
||||||
|
@ -72,12 +72,10 @@ public class RegisteredSkill implements Unlockable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenLocked(PlayerData playerData) {
|
public void whenLocked(PlayerData playerData) {
|
||||||
playerData.mapBoundSkills()
|
playerData.mapBoundSkills().forEach((slot, skill) -> {
|
||||||
.forEach((slot, skill) ->
|
if (skill.equals(getUnlockNamespacedKey().split(":")[1]))
|
||||||
{
|
playerData.unbindSkill(slot);
|
||||||
if (skill.equals(getUnlockNamespacedKey().split(":")[1]))
|
});
|
||||||
playerData.unbindSkill(slot);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -143,8 +141,7 @@ public class RegisteredSkill implements Unlockable {
|
|||||||
parsedExpression = parsedExpression.replace("<" + category + ">", "true");
|
parsedExpression = parsedExpression.replace("<" + category + ">", "true");
|
||||||
parsedExpression = parsedExpression.replaceAll("<.*>", "false");
|
parsedExpression = parsedExpression.replaceAll("<.*>", "false");
|
||||||
try {
|
try {
|
||||||
boolean res = (boolean) MythicLib.plugin.getInterpreter().eval(parsedExpression);
|
return (boolean) MythicLib.plugin.getInterpreter().eval(parsedExpression);
|
||||||
return res;
|
|
||||||
} catch (EvalError error) {
|
} catch (EvalError error) {
|
||||||
throw new RuntimeException(error);
|
throw new RuntimeException(error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user