From 35484b589311113e47319aabe5519a2206d876ff Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 8 Oct 2023 00:36:07 +0200 Subject: [PATCH 1/8] Removed "size" from skill trees --- .../net/Indyuce/mmocore/gui/api/item/InventoryItem.java | 2 +- .../Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java | 1 - .../java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java | 8 +------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java index 49b7294b..cf13065e 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java @@ -125,7 +125,7 @@ public abstract class InventoryItem { @NotNull public ItemStack display(T inv) { - return display(inv, modelData); + return display(inv, 0); } @NotNull diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java index d0c232df..e7532f7f 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java @@ -307,7 +307,6 @@ public class SkillTreeViewer extends EditableInventory { holders.register("current-state", statusNames.getOrDefault(status, status.name())); holders.register("max-level", node.getMaxLevel()); holders.register("max-children", node.getMaxChildren()); - holders.register("size", node.getSize()); holders.register("point-consumed", node.getSkillTreePointsConsumed()); holders.register("display-type", node.getNodeType()); } else { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java index 795ca380..8e670950 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java @@ -46,7 +46,7 @@ public class SkillTreeNode implements ExperienceObject { private final ExperienceTable experienceTable; // The max level the skill tree node can have and the max amount of children it can have. - private final int maxLevel, maxChildren, size; + private final int maxLevel, maxChildren; private final List children = new ArrayList<>(); /** @@ -77,7 +77,6 @@ public class SkillTreeNode implements ExperienceObject { } } name = Objects.requireNonNull(config.getString("name"), "Could not find node name"); - size = Objects.requireNonNull(config.getInt("size")); isRoot = config.getBoolean("is-root", false); skillTreePointsConsumed = config.getInt("point-consumed", 1); permissionRequired = config.getString("permission-required"); @@ -180,10 +179,6 @@ public class SkillTreeNode implements ExperienceObject { return children; } - public int getSize() { - return size; - } - /** * @return The node identifier relative to its skill tree, like "extra_strength" */ @@ -255,7 +250,6 @@ public class SkillTreeNode implements ExperienceObject { Placeholders holders = new Placeholders(); holders.register("name", getName()); holders.register("node-state", playerData.getNodeStatus(this)); - holders.register("size", getSize()); holders.register("level", playerData.getNodeLevel(this)); holders.register("max-level", getMaxLevel()); holders.register("max-children", getMaxChildren()); From 90706ae97c18d87c11c1b40dea2934fc9986b263 Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 8 Oct 2023 01:22:44 +0200 Subject: [PATCH 2/8] Default color for skill tree node names --- .../mmocore/gui/api/item/InventoryItem.java | 1 - .../gui/skilltree/SkillTreeViewer.java | 3 +- .../mmocore/skilltree/SkillTreeNode.java | 6 ++-- .../main/resources/default/gui/skill-tree.yml | 29 +++++++++---------- .../specific-skill-tree-default.yml | 18 ++++++------ 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java index cf13065e..41a49334 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/item/InventoryItem.java @@ -112,7 +112,6 @@ public abstract class InventoryItem { inv.setItem(slot, display); } else for (int j = 0; j < slots.size(); j++) inv.setItem(slots.get(j), display(generated, j)); - } public boolean hasDifferentDisplay() { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java index e7532f7f..ee774ee2 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java @@ -263,7 +263,8 @@ public class SkillTreeViewer extends EditableInventory { lore.add(holders.apply(inv.getPlayer(), str)); }); meta.setLore(lore); - meta.setDisplayName(node.getName()); + final String name = meta.getDisplayName(); + meta.setDisplayName(name == null || name.isEmpty() ? node.getName() : name); } //If it is path we remove the display name and the lore. else { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java index 8e670950..42dce8eb 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java @@ -85,8 +85,8 @@ public class SkillTreeNode implements ExperienceObject { for (String key : config.getConfigurationSection("lores").getKeys(false)) try { lores.put(Integer.parseInt(key), config.getStringList("lores." + key)); - } catch (NumberFormatException e) { - throw new RuntimeException("You must only specifiy integers in lores."); + } catch (NumberFormatException exception) { + throw new RuntimeException("You shall only specify integers in the 'lores' config section"); } Validate.isTrue(config.contains("experience-table"), "You must specify an exp table"); @@ -232,7 +232,6 @@ public class SkillTreeNode implements ExperienceObject { return NodeType.getNodeType(hasUpPathOrNode, hasRightPathOrNode, hasDownPathOrNode, hasLeftPathOrNode); } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -261,6 +260,7 @@ public class SkillTreeNode implements ExperienceObject { List parsedLore = new ArrayList<>(); if (!lores.containsKey(playerData.getNodeLevel(this))) return parsedLore; + List lore = lores.get(playerData.getNodeLevel(this)); lore.forEach(string -> parsedLore.add( MythicLib.plugin.parseColors(holders.apply(playerData.getPlayer(), string)))); diff --git a/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml b/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml index 37f31414..4ebbfeed 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/skill-tree.yml @@ -38,14 +38,11 @@ items: slots: [ 9,18,27 ] lore: - '' - - '&aDescription:' - '{tree-lore}' - '' - - '--------------------' - - '&e◆Max points&e: &6{max-point-spent}' - - '&e◆Points spent&e:&6 {point-spent}' - - '&e◆Current {name} &epoints: &6{skill-tree-points}' - - '&e◆Current Global points: &6{global-points}' + - '&e◆ Points: &6{max-point-spent}&e/&6{point-spent}' + - '&e◆ Current {name} &ePoints: &6{skill-tree-points}' + - '&e◆ Current Global Points: &6{global-points}' next-tree-list-page: function: 'next-tree-list-page' @@ -77,6 +74,7 @@ items: function: 'skill-tree-node' slots: [ 1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44 ] + name: '&a{name}' #The lore that will be displayed after the lore of the node. #The {node-lore} placeholder will be replaced by the lore specified in the skill tree node config. #All the placeholders you see here can also be used in the node lore. @@ -86,24 +84,23 @@ items: - '&7Current Level: &6{current-level}' - '&7Max Level: &6{max-level}' - '&7Max Children: &6{max-children}' - - '&7Points required: &6{point-consumed}' + - '&7Points Required: &6{point-consumed}' - '&7Size: &6{size}' - - '--------------------' + - '' - '&7⧆ &6Requirements: ' - '&fStrong Parents: ' - '{strong-parents}' - '' - '&fSoft Parents: ' - '{soft-parents}' - - '--------------------' - - '{node-lore}' - - '--------------------' - - '&e◆Max points for {skill-tree}&e: &6{max-point-spent}' - - '&e◆Points spent for {skill-tree}&e:&6 {point-spent}' - - '&e◆Current {skill-tree} &epoints: &6{skill-tree-points}' - - '&e◆Current &6global&e points: &6{global-points}' - path-lore: - '' + - '{node-lore}' + - '' + - '&e◆ Max points for {skill-tree}&e: &6{max-point-spent}' + - '&e◆ Points spent for {skill-tree}&e:&6 {point-spent}' + - '&e◆ Current {skill-tree} &ePoints: &6{skill-tree-points}' + - '&e◆ Current &6global&e points: &6{global-points}' + path-lore: [] #This is the name that will be displayed for each status. status-names: diff --git a/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml b/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml index bd169b6c..8c341f01 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/specific-skill-tree/specific-skill-tree-default.yml @@ -50,6 +50,7 @@ items: function: 'skill-tree-node' slots: [ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44 ] + name: '&a{name}' #The lore that will be displayed after the lore of the node. #The {node-lore} placeholder will be replaced by the lore specified in the skill tree node config. #All the placeholders you see here can also be used in the node lore. @@ -61,22 +62,21 @@ items: - '&7Max Children: &6{max-children}' - '&7Points required: &6{point-consumed}' - '&7Size: &6{size}' - - '--------------------' + - '' - '&7⧆ &6Requirements: ' - '&fStrong Parents: ' - '{strong-parents}' - '' - '&fSoft Parents: ' - '{soft-parents}' - - '--------------------' - - '{node-lore}' - - '--------------------' - - '&e◆Max points for {skill-tree}&e: &6{max-point-spent}' - - '&e◆Points spent for {skill-tree}&e:&6 {point-spent}' - - '&e◆Current {skill-tree} &epoints: &6{skill-tree-points}' - - '&e◆Current &6global&e points: &6{global-points}' - path-lore: - '' + - '{node-lore}' + - '' + - '&e◆ Max points for {skill-tree}&e: &6{max-point-spent}' + - '&e◆ Points spent for {skill-tree}&e:&6 {point-spent}' + - '&e◆ Current {skill-tree} &epoints: &6{skill-tree-points}' + - '&e◆ Current &6global&e points: &6{global-points}' + path-lore: [] #This is the name that will be displayed for each status. status-names: From 6bcfc0aad8e249739aa0512e89c5f167c1af24ac Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 8 Oct 2023 01:25:10 +0200 Subject: [PATCH 3/8] Added 'name' placeholder to skill tree nodes --- .../java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java index ee774ee2..6d63c51b 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/skilltree/SkillTreeViewer.java @@ -307,6 +307,7 @@ public class SkillTreeViewer extends EditableInventory { SkillTreeStatus status = inv.getPlayerData().getNodeStatus(node); holders.register("current-state", statusNames.getOrDefault(status, status.name())); holders.register("max-level", node.getMaxLevel()); + holders.register("name", node.getName()); holders.register("max-children", node.getMaxChildren()); holders.register("point-consumed", node.getSkillTreePointsConsumed()); holders.register("display-type", node.getNodeType()); From bc9f5ac6f88cdfccc68a061512dcfc51e7c95f5b Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 8 Oct 2023 01:48:36 +0200 Subject: [PATCH 4/8] Tree node will get latest level lore available --- .../mmocore/skilltree/SkillTreeNode.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java index 42dce8eb..250e7a7d 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skilltree/SkillTreeNode.java @@ -256,16 +256,19 @@ public class SkillTreeNode implements ExperienceObject { } public List getLore(PlayerData playerData) { - Placeholders holders = getPlaceholders(playerData); - List parsedLore = new ArrayList<>(); - if (!lores.containsKey(playerData.getNodeLevel(this))) - return parsedLore; + final int nodeLevel = playerData.getNodeLevel(this); + final List parsedLore = new ArrayList<>(); + + for (int i = nodeLevel; i >= 0; i--) { + final List found = lores.get(i); + if (found == null) continue; + + final Placeholders holders = getPlaceholders(playerData); + found.forEach(string -> parsedLore.add(MythicLib.plugin.parseColors(holders.apply(playerData.getPlayer(), string)))); + break; + } - List lore = lores.get(playerData.getNodeLevel(this)); - lore.forEach(string -> parsedLore.add( - MythicLib.plugin.parseColors(holders.apply(playerData.getPlayer(), string)))); return parsedLore; - } @Override From 7810e3695bdb2212191440b9fae5d8ba477b9d53 Mon Sep 17 00:00:00 2001 From: Jules Date: Sat, 14 Oct 2023 12:42:27 +0200 Subject: [PATCH 5/8] Fixed attributes not reseting --- .../player/attribute/AttributeModifier.java | 69 ++++++++----------- .../player/attribute/PlayerAttributes.java | 8 +-- .../player/profess/SavedClassInformation.java | 6 +- .../Indyuce/mmocore/gui/AttributeView.java | 2 +- .../mmocore/manager/ConfigManager.java | 4 +- .../mmocore/player/ClassDataContainer.java | 2 - .../resources/default/gui/attribute-view.yml | 4 +- 7 files changed, 41 insertions(+), 54 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java index fb171884..d68e7132 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/AttributeModifier.java @@ -1,36 +1,30 @@ package net.Indyuce.mmocore.api.player.attribute; -import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.api.player.MMOPlayerData; -import io.lumine.mythic.lib.api.stat.modifier.StatModifier; +import io.lumine.mythic.lib.api.stat.api.InstanceModifier; import io.lumine.mythic.lib.player.modifier.ModifierSource; import io.lumine.mythic.lib.player.modifier.ModifierType; -import io.lumine.mythic.lib.player.modifier.PlayerModifier; import io.lumine.mythic.lib.util.configobject.ConfigObject; import net.Indyuce.mmocore.api.player.PlayerData; -import org.apache.commons.lang.Validate; -import java.text.DecimalFormat; -import java.util.Objects; +import java.util.UUID; -public class AttributeModifier extends PlayerModifier { +public class AttributeModifier extends InstanceModifier { private final String attribute; - private final double value; - private final ModifierType type; - - private static final DecimalFormat oneDigit = MythicLib.plugin.getMMOConfig().newDecimalFormat("0.#"); /** * Flat attribute modifier (simplest modifier you can think about) */ public AttributeModifier(String key, String attribute, double value) { - this(key, attribute, value, ModifierType.FLAT, EquipmentSlot.OTHER, ModifierSource.OTHER); + super(key, value); + + this.attribute = attribute; } /** - * Attribute modifier given by an external mecanic, like a party buff, item set bonuses, - * skills or abilities... Anything apart from items and armor. + * Attribute modifier given by an external mechanic, like a party buff, item + * set bonuses, skills or abilities... Anything apart from items and armor. */ public AttributeModifier(String key, String attribute, double value, ModifierType type) { this(key, attribute, value, type, EquipmentSlot.OTHER, ModifierSource.OTHER); @@ -47,11 +41,23 @@ public class AttributeModifier extends PlayerModifier { * @param source Type of the item granting the stat modifier */ public AttributeModifier(String key, String attribute, double value, ModifierType type, EquipmentSlot slot, ModifierSource source) { - super(key, slot, source); + this(UUID.randomUUID(), key, attribute, value, type, slot, source); + } + + /** + * Attribute modifier given by an item, either a weapon or an armor piece. + * + * @param key Player modifier key + * @param attribute Attribute being modified + * @param value Value of stat modifier + * @param type Is the modifier flat or multiplicative + * @param slot Slot of the item granting the stat modifier + * @param source Type of the item granting the stat modifier + */ + public AttributeModifier(UUID uniqueId, String key, String attribute, double value, ModifierType type, EquipmentSlot slot, ModifierSource source) { + super(uniqueId, key, slot, source, value, type); this.attribute = attribute; - this.value = value; - this.type = type; } /** @@ -62,22 +68,14 @@ public class AttributeModifier extends PlayerModifier { * @param str The string to be parsed */ public AttributeModifier(String key, String attribute, String str) { - super(key, EquipmentSlot.OTHER, ModifierSource.OTHER); + super(key, EquipmentSlot.OTHER, ModifierSource.OTHER, str); - Validate.notNull(str, "String cannot be null"); - Validate.notEmpty(str, "String cannot be empty"); - - type = str.toCharArray()[str.length() - 1] == '%' ? ModifierType.RELATIVE : ModifierType.FLAT; - value = Double.parseDouble(type == ModifierType.RELATIVE ? str.substring(0, str.length() - 1) : str); this.attribute = attribute; } public AttributeModifier(ConfigObject object) { - super(object.getString("key"), EquipmentSlot.OTHER, ModifierSource.OTHER); + super(object); - String str = Objects.requireNonNull(object.getString("value")); - type = str.toCharArray()[str.length() - 1] == '%' ? ModifierType.RELATIVE : ModifierType.FLAT; - value = Double.parseDouble(type == ModifierType.RELATIVE ? str.substring(0, str.length() - 1) : str); this.attribute = object.getString("attribute"); } @@ -85,14 +83,6 @@ public class AttributeModifier extends PlayerModifier { return attribute; } - public ModifierType getType() { - return type; - } - - public double getValue() { - return value; - } - /** * Used to multiply some existing stat modifier by a constant, usually an * integer, for instance when MMOCore party modifiers scale with the @@ -101,8 +91,8 @@ public class AttributeModifier extends PlayerModifier { * @param coef The multiplicative constant * @return A new instance of StatModifier with modified value */ - public StatModifier multiply(double coef) { - return new StatModifier(getKey(), attribute, value * coef, type, getSlot(), getSource()); + public AttributeModifier multiply(double coef) { + return new AttributeModifier(getUniqueId(), getKey(), attribute, value * coef, type, getSlot(), getSource()); } @Override @@ -116,9 +106,4 @@ public class AttributeModifier extends PlayerModifier { PlayerData playerData = PlayerData.get(mmoPlayerData); playerData.getAttributes().getInstance(attribute).removeModifier(getKey()); } - - @Override - public String toString() { - return oneDigit.format(value) + (type == io.lumine.mythic.lib.player.modifier.ModifierType.RELATIVE ? "%" : ""); - } } \ No newline at end of file diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java index 53738674..d3ce3d3d 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java @@ -113,6 +113,7 @@ public class PlayerAttributes { return n; } + // TODO have it extend ModifiedInstance public class AttributeInstance { private int spent; @@ -223,10 +224,9 @@ public class PlayerAttributes { } } + @Deprecated public void setBaseAttribute(String id, int value) { - getInstances().forEach(ins -> { - if (ins.getId().equals(id)) - ins.setBase(value); - }); + AttributeInstance ins = instances.get(id); + if (ins != null) ins.setBase(value); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java index ef4436b8..5a07f44c 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java @@ -5,6 +5,7 @@ import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; +import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes; import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.player.ClassDataContainer; import net.Indyuce.mmocore.skill.RegisteredSkill; @@ -327,7 +328,10 @@ public class SavedClassInformation implements ClassDataContainer { player.bindSkill(slot, profess.getSkill(boundSkills.get(slot))); skillLevels.forEach(player::setSkillLevel); - attributeLevels.forEach((id, pts) -> player.getAttributes().setBaseAttribute(id, pts)); + attributeLevels.forEach((id, pts) -> { + final PlayerAttributes.AttributeInstance ins = player.getAttributes().getInstance(id); + if (ins != null) ins.setBase(pts); + }); // Careful, the global points must not be forgotten. player.setSkillTreePoints("global", skillTreePoints.getOrDefault("global", 0)); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java index b6e6439a..970ae7f7 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java @@ -109,7 +109,7 @@ public class AttributeView extends EditableInventory { playerData.getAttributes().getInstances().forEach(ins -> ins.setBase(0)); playerData.giveAttributePoints(spent); playerData.giveAttributeReallocationPoints(-1); - MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", "" + playerData.getAttributePoints()).send(player); + MMOCore.plugin.configManager.getSimpleMessage("attribute-points-reallocated", "points", String.valueOf(playerData.getAttributePoints())).send(player); MMOCore.plugin.soundManager.getSound(SoundEvent.RESET_ATTRIBUTES).playTo(getPlayer()); open(); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index a5855bf7..420427b5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -207,7 +207,7 @@ public class ConfigManager { } /** - * Merge with {@link net.Indyuce.mmocore.api.ConfigMessage} + * @deprecated TODO Merge with {@link net.Indyuce.mmocore.api.ConfigMessage} */ @Deprecated public SimpleMessage getSimpleMessage(String key, String... placeholders) { @@ -218,7 +218,7 @@ public class ConfigManager { } /** - * Merge with {@link net.Indyuce.mmocore.api.ConfigMessage} + * @deprecated TODO Merge with {@link net.Indyuce.mmocore.api.ConfigMessage} */ @Deprecated public static class SimpleMessage { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java index c711c590..6b5405d8 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/ClassDataContainer.java @@ -8,8 +8,6 @@ import java.util.Set; /** * All the class-specific information i.e information being saved * in {@link SavedClassInformation} when a player changes its current class. - * - * TODO move {@link SavedClassInformation} method to ClassDataContainer */ public interface ClassDataContainer { diff --git a/MMOCore-Dist/src/main/resources/default/gui/attribute-view.yml b/MMOCore-Dist/src/main/resources/default/gui/attribute-view.yml index 4722590d..71286aa6 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/attribute-view.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/attribute-view.yml @@ -32,7 +32,7 @@ items: - '' - '&8When Leveled Up:' - '&7 +{buff_weapon_damage}% Weapon Damage (&a+{total_weapon_damage}%&7)' - - '&7 +{buff_max_health} Max Health (&a+{total_max_health}&7)' + - '&7 +{buff_max_health}% Max Health (&a+{total_max_health}%&7)' - '' - '&eClick to level up for 1 attribute point.' - '&e◆ Current Attribute Points: {attribute_points}' @@ -50,7 +50,7 @@ items: - '&8When Leveled Up:' - '&7 +{buff_physical_damage}% Physical Damage (&a+{total_physical_damage}%&7)' - '&7 +{buff_projectile_damage}% Projectile Damage (&a+{total_projectile_damage}%&7)' - - '&7 +{buff_attack_speed} Attack Speed (&a+{total_attack_speed}&7)' + - '&7 +{buff_attack_speed}% Attack Speed (&a+{total_attack_speed}%&7)' - '' - '&eClick to level up for 1 attribute point.' - '&e◆ Current Attribute Points: {attribute_points}' From dbe5aa5fab203e5bf6d9a77926534313999f0794 Mon Sep 17 00:00:00 2001 From: Jules Date: Sat, 14 Oct 2023 15:30:36 +0200 Subject: [PATCH 6/8] Fixed attributes not reloading when switching profiles --- .../mmocore/api/player/profess/SavedClassInformation.java | 4 ++-- .../mmocore/manager/data/sql/MMOCoreDataSynchronizer.java | 2 ++ .../mmocore/manager/data/yaml/YAMLPlayerDataHandler.java | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java index 5a07f44c..47e2cfe6 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/SavedClassInformation.java @@ -305,7 +305,8 @@ public class SavedClassInformation implements ClassDataContainer { * Resets information which much be reset after everything is saved. */ player.mapSkillLevels().forEach((skill, level) -> player.resetSkillLevel(skill)); - player.getAttributes().getInstances().forEach(ins -> ins.setBase(0)); + for (PlayerAttribute attribute : MMOCore.plugin.attributeManager.getAll()) + player.getAttributes().getInstance(attribute).setBase(0); player.clearSkillTreePoints(); player.clearNodeLevels(); player.clearNodeStates(); @@ -346,7 +347,6 @@ public class SavedClassInformation implements ClassDataContainer { // Add the values to the times claimed table and claims the corresponding stat triggers. nodeTimesClaimed.forEach((str, val) -> player.setClaims(str, val)); - // Unload current class information player.unloadClassInfo(profess); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java index 2ce01a59..99d2f774 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java @@ -81,6 +81,8 @@ public class MMOCoreDataSynchronizer extends SQLDataSynchronizer { if (guild != null) getData().setGuild(guild.hasMember(getData().getUniqueId()) ? guild : null); } if (!isEmpty(result.getString("attributes"))) getData().getAttributes().load(result.getString("attributes")); + if (getData().isOnline()) + MMOCore.plugin.attributeManager.getAll().forEach(attribute -> getData().getAttributes().getInstance(attribute).updateStats()); if (!isEmpty(result.getString("professions"))) getData().getCollectionSkills().load(result.getString("professions")); if (!isEmpty(result.getString("quests"))) getData().getQuestData().load(result.getString("quests")); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataHandler.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataHandler.java index 9542a275..fd1e2a74 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataHandler.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataHandler.java @@ -64,6 +64,8 @@ public class YAMLPlayerDataHandler extends YAMLSynchronizedDataHandler data.getAttributes().getInstance(attribute).updateStats()); if (config.contains("profession")) data.getCollectionSkills().load(config.getConfigurationSection("profession")); if (config.contains("quest")) From 160c5d5699877fd32dff494b1f181a3c033a4ac1 Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 15 Oct 2023 18:43:06 +0200 Subject: [PATCH 7/8] Fixed exp resetting on death --- .../option/VanillaExperienceOverride.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/option/VanillaExperienceOverride.java b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/option/VanillaExperienceOverride.java index 530390f7..a95e8d40 100644 --- a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/option/VanillaExperienceOverride.java +++ b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/option/VanillaExperienceOverride.java @@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerExpChangeEvent; +import org.bukkit.event.player.PlayerRespawnEvent; public class VanillaExperienceOverride implements Listener { @@ -16,10 +18,20 @@ public class VanillaExperienceOverride implements Listener { * When picking up exp orbs or any action like that */ @EventHandler(priority = EventPriority.HIGHEST) - public void a(PlayerExpChangeEvent event) { + public void cancelChange(PlayerExpChangeEvent event) { event.setAmount(0); } + @EventHandler(priority = EventPriority.HIGHEST) + public void cancelDrop(PlayerDeathEvent event) { + event.setDroppedExp(0); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void cancelChange(PlayerRespawnEvent event) { + Bukkit.getScheduler().runTask(MMOCore.plugin, () -> PlayerData.get(event.getPlayer()).refreshVanillaExp()); + } + /** * This event is not supported by the expChangeEvent. Since the event is * actually called before applying the enchant and consuming levels, we must @@ -28,7 +40,7 @@ public class VanillaExperienceOverride implements Listener { * {@link EnchantItemEvent#setExpLevelCost(int)} does NOT work */ @EventHandler - public void b(EnchantItemEvent event) { + public void cancelChange(EnchantItemEvent event) { Player player = event.getEnchanter(); Bukkit.getScheduler().runTask(MMOCore.plugin, () -> player.setLevel(PlayerData.get(player).getLevel())); } From 6565d7106b43544975d5a40dc14c6b60bd903129 Mon Sep 17 00:00:00 2001 From: Jules Date: Mon, 16 Oct 2023 01:40:38 +0200 Subject: [PATCH 8/8] Fixed skill buffs not applying on cooldown & other mods --- .../mmocore/api/player/PlayerData.java | 30 +++++++++---------- .../mmocore/api/player/stats/PlayerStats.java | 26 ++++++---------- .../quest/trigger/SkillModifierTrigger.java | 4 +-- .../api/quest/trigger/StatTrigger.java | 13 ++++---- .../mmocore/api/quest/trigger/Trigger.java | 2 +- .../comp/placeholder/RPGPlaceholders.java | 24 +++++++++------ .../Indyuce/mmocore/skill/CastableSkill.java | 12 ++++---- .../mmocore/skill/list/Neptune_Gift.java | 4 ++- .../resources/default/classes/arcane-mage.yml | 4 +++ .../main/resources/default/classes/human.yml | 4 +++ .../main/resources/default/classes/mage.yml | 17 +++++++++-- .../resources/default/classes/marksman.yml | 4 +++ .../resources/default/classes/paladin.yml | 4 +++ .../main/resources/default/classes/rogue.yml | 4 +++ .../resources/default/classes/warrior.yml | 4 +++ 15 files changed, 92 insertions(+), 64 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index e112550a..1c37c842 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -176,8 +176,8 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD public void setupRemovableTrigger() { //We remove all the stats and buffs associated to triggers. - getMMOPlayerData().getStatMap().getInstances().forEach(statInstance -> statInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX))); - getMMOPlayerData().getSkillModifierMap().getInstances().forEach(skillModifierInstance -> skillModifierInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX))); + getMMOPlayerData().getStatMap().getInstances().forEach(statInstance -> statInstance.removeIf(Trigger.STAT_MODIFIER_KEY::equals)); + getMMOPlayerData().getSkillModifierMap().getInstances().forEach(skillModifierInstance -> skillModifierInstance.removeIf(Trigger.STAT_MODIFIER_KEY::equals)); if (profess.hasExperienceTable()) profess.getExperienceTable().claimRemovableTrigger(this, profess); @@ -250,7 +250,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD Iterator iter = instance.getModifiers().iterator(); while (iter.hasNext()) { StatModifier modifier = iter.next(); - if (modifier.getKey().startsWith(StatTrigger.TRIGGER_PREFIX)) iter.remove(); + if (modifier.getKey().startsWith(StatTrigger.STAT_MODIFIER_KEY)) iter.remove(); } } } @@ -357,7 +357,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD /** * @return If the item is unlocked by the player - * This is used for skills that can be locked & unlocked. + * This is used for skills that can be locked & unlocked. */ public boolean hasUnlocked(Unlockable unlockable) { return unlockable.isUnlockedByDefault() || unlockedItems.contains(unlockable.getUnlockNamespacedKey()); @@ -1017,7 +1017,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD /** * @return If the PlayerEnterCastingModeEvent successfully put the player - * into casting mode, otherwise if the event is cancelled, returns false. + * into casting mode, otherwise if the event is cancelled, returns false. */ public boolean setSkillCasting() { Validate.isTrue(!isCasting(), "Player already in casting mode"); @@ -1036,7 +1036,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD /** * @return If player successfully left skill casting i.e the Bukkit - * event has not been cancelled + * event has not been cancelled */ public boolean leaveSkillCasting() { return leaveSkillCasting(false); @@ -1045,7 +1045,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD /** * @param skipEvent Skip firing the exit event * @return If player successfully left skill casting i.e the Bukkit - * event has not been cancelled + * event has not been cancelled */ public boolean leaveSkillCasting(boolean skipEvent) { Validate.isTrue(isCasting(), "Player not in casting mode"); @@ -1161,6 +1161,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD boundSkills.forEach((slot, info) -> info.close()); boundSkills.clear(); setupRemovableTrigger(); + // Update stats if (isOnline()) getStats().updateStats(); } @@ -1187,15 +1188,12 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD */ public void bindSkill(int slot, @NotNull ClassSkill skill) { Validate.notNull(skill, "Skill cannot be null"); + if (slot < 0) return; - if (slot >= 0) { - - // Unbinds the previous skill (important for passive skills) - unbindSkill(slot); - - final SkillSlot skillSlot = getProfess().getSkillSlot(slot); - boundSkills.put(slot, new BoundSkillInfo(skillSlot, skill, this)); - } + // Unbinds the previous skill (important for passive skills) + unbindSkill(slot); + final SkillSlot skillSlot = getProfess().getSkillSlot(slot); + boundSkills.put(slot, new BoundSkillInfo(skillSlot, skill, this)); } public void unbindSkill(int slot) { @@ -1221,7 +1219,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD * checks if they could potentially upgrade to one of these * * @return If the player can change its current class to - * a subclass + * a subclass */ @Deprecated public boolean canChooseSubclass() { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java index ae983ae4..05e4c4d5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java @@ -12,11 +12,6 @@ import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.player.stats.StatInfo; -import net.Indyuce.mmocore.skill.ClassSkill; - -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; public class PlayerStats { private final PlayerData data; @@ -78,6 +73,8 @@ public class PlayerStats { * see {@link PlayerData#reload()} for more info */ public synchronized void updateStats() { + + // Update player stats for (String stat : MMOCore.plugin.statManager.getRegistered()) { final StatInstance instance = getMap().getInstance(stat); final StatInstance.ModifierPacket packet = instance.newPacket(); @@ -94,22 +91,17 @@ public class PlayerStats { packet.runUpdate(); } - /* - * This is here because it requires updates for the same reasons - * as statistics (when the player level changes, when his class - * changes, when he logs on..) - * - * This updates the player's PASSIVE skills - */ + // Updates the player's unbindable passive skills. final PassiveSkillMap skillMap = data.getMMOPlayerData().getPassiveSkillMap(); - skillMap.removeModifiers("MMOCorePassiveSkillNotBound"); - data.getProfess().getSkills() - .stream() - .filter((classSkill) -> !classSkill.needsBound()&&classSkill.getSkill().getTrigger().isPassive() && data.hasUnlocked(classSkill) && data.hasUnlockedLevel(classSkill)) + data.getProfess().getSkills().stream() + .filter((classSkill) -> !classSkill.needsBound() && classSkill.getSkill().getTrigger().isPassive() && data.hasUnlocked(classSkill) && data.hasUnlockedLevel(classSkill)) .forEach(classSkill -> skillMap.addModifier(classSkill.toPassive(data))); - // This updates the player's class SCRIPTS + /* + * Updates the player's class scripts, which act just + * like non-bindable passive skills. + */ skillMap.removeModifiers("MMOCoreClassScript"); for (PassiveSkill script : data.getProfess().getScripts()) skillMap.addModifier(script); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillModifierTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillModifierTrigger.java index 817ff2cc..9e6c5097 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillModifierTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillModifierTrigger.java @@ -12,11 +12,9 @@ import net.Indyuce.mmocore.skill.RegisteredSkill; import java.util.ArrayList; import java.util.List; -import java.util.UUID; public class SkillModifierTrigger extends Trigger implements Removable { private final SkillModifier mod; - private final String buffKey = TRIGGER_PREFIX + "." + UUID.randomUUID(); private final double amount; public SkillModifierTrigger(MMOLineConfig config) { @@ -34,7 +32,7 @@ public class SkillModifierTrigger extends Trigger implements Removable { if (skill.matchesFormula(formula)) targetSkills.add(skill.getHandler()); - mod = new SkillModifier(buffKey, skillModifier, targetSkills, amount, type); + mod = new SkillModifier(Trigger.STAT_MODIFIER_KEY, skillModifier, targetSkills, amount, type); } public List> getTargetSkills() { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java index e95c0668..6fe25c60 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java @@ -7,12 +7,9 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.quest.trigger.api.Removable; import org.apache.commons.lang.Validate; -import java.util.UUID; - public class StatTrigger extends Trigger implements Removable { - private final StatModifier statModifier; + private final StatModifier modifier; private final String stat; - private final String modifierKey = TRIGGER_PREFIX + "." + UUID.randomUUID(); private final double amount; public StatTrigger(MMOLineConfig config) { @@ -25,14 +22,14 @@ public class StatTrigger extends Trigger implements Removable { Validate.isTrue(type.equals("FLAT") || type.equals("RELATIVE")); stat = config.getString("stat"); amount = config.getDouble("amount"); - statModifier = new StatModifier(modifierKey, stat, amount, ModifierType.valueOf(type)); + modifier = new StatModifier(Trigger.STAT_MODIFIER_KEY, stat, amount, ModifierType.valueOf(type)); } @Override public void apply(PlayerData player) { - StatModifier prevModifier = player.getMMOPlayerData().getStatMap().getInstance(stat).getModifier(modifierKey); + StatModifier prevModifier = player.getMMOPlayerData().getStatMap().getInstance(stat).getModifier(modifier.getUniqueId()); if (prevModifier == null) - statModifier.register(player.getMMOPlayerData()); + modifier.register(player.getMMOPlayerData()); else { prevModifier.unregister(player.getMMOPlayerData()); prevModifier.add(amount).register(player.getMMOPlayerData()); @@ -41,6 +38,6 @@ public class StatTrigger extends Trigger implements Removable { @Override public void remove(PlayerData playerData) { - playerData.getMMOPlayerData().getStatMap().getInstance(stat).remove(modifierKey); + modifier.unregister(playerData.getMMOPlayerData()); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java index 2f1bb537..0fe2d107 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java @@ -7,7 +7,7 @@ import org.bukkit.Bukkit; public abstract class Trigger { - public static String TRIGGER_PREFIX = "mmocore_trigger"; + public static String STAT_MODIFIER_KEY = "mmocore_trigger"; private final long delay; public Trigger(MMOLineConfig config) { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java index 52019585..7668912a 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java @@ -12,6 +12,7 @@ import net.Indyuce.mmocore.api.quest.PlayerQuests; import net.Indyuce.mmocore.experience.PlayerProfessions; import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.party.AbstractParty; +import net.Indyuce.mmocore.skill.CastableSkill; import net.Indyuce.mmocore.skill.ClassSkill; import net.Indyuce.mmocore.skill.RegisteredSkill; import org.bukkit.Bukkit; @@ -58,10 +59,11 @@ public class RPGPlaceholders extends PlaceholderExpansion { public String onRequest(OfflinePlayer player, String identifier) { if (!PlayerData.has(player.getUniqueId())) return null; + final PlayerData playerData = PlayerData.get(player); - PlayerData playerData = PlayerData.get(player); if (identifier.equals("mana_icon")) return playerData.getProfess().getManaDisplay().getIcon(); + if (identifier.equals("mana_name")) return playerData.getProfess().getManaDisplay().getName(); @@ -72,15 +74,19 @@ public class RPGPlaceholders extends PlaceholderExpansion { String id = identifier.substring(12); RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(id), "Could not find skill with ID '" + id + "'"); return String.valueOf(playerData.getSkillLevel(skill)); - } else if (identifier.startsWith("skill_modifier_") || identifier.startsWith("skill_parameter_")) { - String[] ids = (identifier.startsWith("skill_modifier_") ? identifier.substring(15) : identifier.substring(16)).split(":"); - String parameterId = ids[0]; - String skillId = ids[1]; - RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(skillId), "Could not find skill with ID '" + skillId + "'"); - ClassSkill classSkill = playerData.getProfess().getSkill(skill); - double value = classSkill.toCastable(playerData).getParameter(parameterId); + } + + else if (identifier.startsWith("skill_modifier_") || identifier.startsWith("skill_parameter_")) { + final String[] ids = (identifier.startsWith("skill_modifier_") ? identifier.substring(15) : identifier.substring(16)).split(":"); + final String parameterId = ids[0]; + final String skillId = ids[1]; + final RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(skillId), "Could not find skill with ID '" + skillId + "'"); + final CastableSkill castable = playerData.getProfess().getSkill(skill).toCastable(playerData); + final double value = playerData.getMMOPlayerData().getSkillModifierMap().calculateValue(castable, parameterId); return MythicLib.plugin.getMMOConfig().decimal.format(value); - } else if (identifier.startsWith("attribute_points_spent_")) { + } + + else if (identifier.startsWith("attribute_points_spent_")) { String attributeId = identifier.substring(31); PlayerAttributes.AttributeInstance attributeInstance = Objects.requireNonNull(playerData.getAttributes().getInstance(attributeId), "Could not find attribute with ID '" + attributeId + "'"); return String.valueOf(attributeInstance.getSpent()); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/CastableSkill.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/CastableSkill.java index b7154cfb..670b48d0 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/CastableSkill.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/CastableSkill.java @@ -65,15 +65,15 @@ public class CastableSkill extends Skill { } // Mana cost - if (playerData.getMana() < getParameter("mana")) { + if (playerData.getMana() < skillMeta.getParameter("mana")) { if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.no-mana", - "mana-required", MythicLib.plugin.getMMOConfig().decimal.format((getParameter("mana") - playerData.getMana())), + "mana-required", MythicLib.plugin.getMMOConfig().decimal.format((skillMeta.getParameter("mana") - playerData.getMana())), "mana", playerData.getProfess().getManaDisplay().getName()).send(playerData.getPlayer()); return false; } // Stamina cost - if (playerData.getStamina() < getParameter("stamina")) { + if (playerData.getStamina() < skillMeta.getParameter("stamina")) { if (loud) MMOCore.plugin.configManager.getSimpleMessage("casting.no-stamina").send(playerData.getPlayer()); return false; @@ -95,11 +95,11 @@ public class CastableSkill extends Skill { // Cooldown double flatCooldownReduction = Math.max(0, Math.min(1, skillMeta.getCaster().getStat("COOLDOWN_REDUCTION") / 100)); - CooldownInfo cooldownHandler = skillMeta.getCaster().getData().getCooldownMap().applyCooldown(this, getParameter("cooldown")); + CooldownInfo cooldownHandler = skillMeta.getCaster().getData().getCooldownMap().applyCooldown(this, skillMeta.getParameter("cooldown")); cooldownHandler.reduceInitialCooldown(flatCooldownReduction); - casterData.giveMana(-getParameter("mana"), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST); - casterData.giveStamina(-getParameter("stamina"), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST); + casterData.giveMana(-skillMeta.getParameter("mana"), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST); + casterData.giveStamina(-skillMeta.getParameter("stamina"), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST); } if (!getTrigger().isPassive()) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java index eb1bb50a..5fe28639 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Neptune_Gift.java @@ -4,6 +4,8 @@ import io.lumine.mythic.lib.player.skill.PassiveSkill; import io.lumine.mythic.lib.skill.SkillMetadata; import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.skill.result.def.SimpleSkillResult; +import io.lumine.mythic.lib.skill.trigger.TriggerMetadata; +import io.lumine.mythic.lib.skill.trigger.TriggerType; import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -33,7 +35,7 @@ public class Neptune_Gift extends SkillHandler implements Lis if (skill == null) return; - event.setAmount(event.getAmount() * (1 + skill.getTriggeredSkill().getParameter("extra") / 100)); + event.setAmount(event.getAmount() * (1 + event.getData().getMMOPlayerData().getSkillModifierMap().calculateValue(skill.getTriggeredSkill(), "extra") / 100)); } } } diff --git a/MMOCore-Dist/src/main/resources/default/classes/arcane-mage.yml b/MMOCore-Dist/src/main/resources/default/classes/arcane-mage.yml index c06c092c..6821d6d1 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/arcane-mage.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/arcane-mage.yml @@ -35,15 +35,19 @@ skill-slots: 1: name: "&aSkill Slot I" unlocked-by-default: true + lore: [] 2: name: "&aSkill Slot II" unlocked-by-default: true + lore: [] 3: name: "&aSkill Slot III" unlocked-by-default: true + lore: [] 4: name: "&aSkill Slot IV" unlocked-by-default: true + lore: [] # The maximum level players can reach max-level: 100 diff --git a/MMOCore-Dist/src/main/resources/default/classes/human.yml b/MMOCore-Dist/src/main/resources/default/classes/human.yml index 6c6af78c..78befa74 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/human.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/human.yml @@ -26,15 +26,19 @@ skill-slots: 1: name: "&aSkill Slot I" unlocked-by-default: true + lore: [] 2: name: "&aSkill Slot II" unlocked-by-default: true + lore: [] 3: name: "&aSkill Slot III" unlocked-by-default: true + lore: [] 4: name: "&aSkill Slot IV" unlocked-by-default: true + lore: [] # Experience sources for main class experience. main-exp-sources: diff --git a/MMOCore-Dist/src/main/resources/default/classes/mage.yml b/MMOCore-Dist/src/main/resources/default/classes/mage.yml index 0ff41c6a..c39f1ce5 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/mage.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/mage.yml @@ -42,15 +42,26 @@ skill-slots: 1: name: "&aSkill Slot I" unlocked-by-default: true + lore: + - '' + - '&a-50% Cooldown &7for Active Skills' + - '&a+30% Damage &7for Active Skills' + formula: "" + skill-buffs: + - 'skill_buff{modifier="cooldown";amount=-50;type="RELATIVE"}' + - 'skill_buff{modifier="damage";amount=30;type="RELATIVE"}' 2: name: "&aSkill Slot II" unlocked-by-default: true + lore: [] 3: name: "&aSkill Slot III" unlocked-by-default: true + lore: [] 4: name: "&aSkill Slot IV" unlocked-by-default: true + lore: [] # This is the default mana display options, however it is not mandatory # to have it in your class config file. Other classes do not have this @@ -81,13 +92,13 @@ resource: # Scales with max mana. type: MAX - + # Regen from 3 to 10% of max mana every second value: base: 3 per-level: .1 max: 10 - + # Only regen when out of combat. off-combat: true @@ -116,7 +127,7 @@ skills: FIRE_STORM: level: 1 max-level: 30 - + # Specific skill modifiers based on class. # Arcane mage's fire storm may deal more damage # than an apprentice mage's fire storm. diff --git a/MMOCore-Dist/src/main/resources/default/classes/marksman.yml b/MMOCore-Dist/src/main/resources/default/classes/marksman.yml index 61f41268..cdd45b62 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/marksman.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/marksman.yml @@ -37,15 +37,19 @@ skill-slots: 1: name: "&aSkill Slot I" unlocked-by-default: true + lore: [] 2: name: "&aSkill Slot II" unlocked-by-default: true + lore: [] 3: name: "&aSkill Slot III" unlocked-by-default: true + lore: [] 4: name: "&aSkill Slot IV" unlocked-by-default: true + lore: [] skill-trees: - 'general' diff --git a/MMOCore-Dist/src/main/resources/default/classes/paladin.yml b/MMOCore-Dist/src/main/resources/default/classes/paladin.yml index b4488662..5bf21af8 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/paladin.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/paladin.yml @@ -34,15 +34,19 @@ skill-slots: 1: name: "&aSkill Slot I" unlocked-by-default: true + lore: [] 2: name: "&aSkill Slot II" unlocked-by-default: true + lore: [] 3: name: "&aSkill Slot III" unlocked-by-default: true + lore: [] 4: name: "&aSkill Slot IV" unlocked-by-default: true + lore: [] skill-trees: - 'general' diff --git a/MMOCore-Dist/src/main/resources/default/classes/rogue.yml b/MMOCore-Dist/src/main/resources/default/classes/rogue.yml index 20c6ccd0..5437b15a 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/rogue.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/rogue.yml @@ -37,15 +37,19 @@ skill-slots: 1: name: "&aSkill Slot I" unlocked-by-default: true + lore: [] 2: name: "&aSkill Slot II" unlocked-by-default: true + lore: [] 3: name: "&aSkill Slot III" unlocked-by-default: true + lore: [] 4: name: "&aSkill Slot IV" unlocked-by-default: true + lore: [] skill-trees: - 'general' diff --git a/MMOCore-Dist/src/main/resources/default/classes/warrior.yml b/MMOCore-Dist/src/main/resources/default/classes/warrior.yml index 81ef9731..8435dda5 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/warrior.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/warrior.yml @@ -40,15 +40,19 @@ skill-slots: 1: name: "Skill Slot I" unlocked-by-default: true + lore: [] 2: name: "Skill Slot II" unlocked-by-default: true + lore: [] 3: name: "Skill Slot III" unlocked-by-default: true + lore: [] 4: name: "Skill Slot IV" unlocked-by-default: true + lore: [] skill-trees: - 'general'