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 46594c81..25d0f5cf 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 @@ -264,8 +264,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc } } - public Map getNodeLevels() { - return new HashMap<>(nodeLevels); + @Override + public Map getNodeLevels() { + final Map mapped = new HashMap<>(); + this.nodeLevels.forEach((node, level) -> mapped.put(node.getFullId(), level)); + return mapped; } public void clearNodeLevels() { 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 b307c634..43f67d23 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 @@ -7,7 +7,6 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.player.ClassDataContainer; -import net.Indyuce.mmocore.skill.ClassSkill; import net.Indyuce.mmocore.skill.RegisteredSkill; import net.Indyuce.mmocore.skilltree.SkillTreeNode; import net.Indyuce.mmocore.skilltree.tree.SkillTree; @@ -20,7 +19,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -public class SavedClassInformation { +public class SavedClassInformation implements ClassDataContainer { private final int level, skillPoints, attributePoints, attributeReallocationPoints, skillTreeReallocationPoints, skillReallocationPoints; private final double experience, health, mana, stellium, stamina; private final Map attributeLevels = new HashMap<>(); @@ -128,44 +127,53 @@ public class SavedClassInformation { data.mapAttributeLevels().forEach((key, val) -> this.attributeLevels.put(key, val)); data.mapSkillLevels().forEach((key, val) -> skillLevels.put(key, val)); data.mapSkillTreePoints().forEach((key, val) -> skillTreePoints.put(key, val)); - data.getNodeLevels().forEach((node, level) -> nodeLevels.put(node.getFullId(), level)); + data.getNodeLevels().forEach((node, level) -> nodeLevels.put(node, level)); data.getNodeTimesClaimed().forEach((key, val) -> nodeTimesClaimed.put(key, val)); data.mapBoundSkills().forEach((slot, skill) -> boundSkills.put(slot, skill)); - data.getUnlockedItems().forEach(item->unlockedItems.add(item)); + data.getUnlockedItems().forEach(item -> unlockedItems.add(item)); } + @Override public int getLevel() { return level; } + @Override public double getExperience() { return experience; } + @Override public int getSkillPoints() { return skillPoints; } + @Override public int getAttributePoints() { return attributePoints; } + @Override public int getAttributeReallocationPoints() { return attributeReallocationPoints; } + @Override public double getHealth() { return health; } + @Override public double getMana() { return mana; } + @Override public double getStellium() { return stellium; } + @Override public double getStamina() { return stamina; } @@ -186,14 +194,27 @@ public class SavedClassInformation { registerSkillLevel(skill.getHandler().getId(), level); } - public Map getBoundSkills() { - return boundSkills; + @Override + public Map mapSkillLevels() { + return skillLevels; } + @Override + public Map mapSkillTreePoints() { + return skillTreePoints; + } + + @Deprecated + public Map getBoundSkills() { + return mapBoundSkills(); + } + + @Override public int getSkillTreeReallocationPoints() { return skillTreeReallocationPoints; } + @Override public int getSkillReallocationPoints() { return skillReallocationPoints; } @@ -210,6 +231,26 @@ public class SavedClassInformation { return nodeLevels.get(node); } + @Override + public Map mapAttributeLevels() { + return attributeLevels; + } + + @Override + public Map mapBoundSkills() { + return boundSkills; + } + + @Override + public Map getNodeLevels() { + return nodeLevels; + } + + @Override + public Map getNodeTimesClaimed() { + return nodeTimesClaimed; + } + public Set getSkillTreePointsKeys() { return skillTreePoints.keySet(); } @@ -234,6 +275,7 @@ public class SavedClassInformation { attributeLevels.put(attribute, level); } + @Override public Set getUnlockedItems() { return unlockedItems; } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java index 20068519..fbdecc30 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java @@ -14,20 +14,20 @@ import net.Indyuce.mmocore.gui.api.PluginInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.Placeholders; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; +import net.Indyuce.mmocore.player.ClassDataContainer; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; public class ClassConfirmation extends EditableInventory { - private final PlayerClass playerClass; public ClassConfirmation(PlayerClass playerClass, boolean isDefault) { super("class-confirm-" + (isDefault ? "default" : UtilityMethods.ymlName(playerClass.getId()))); + this.playerClass = playerClass; } @@ -36,13 +36,8 @@ public class ClassConfirmation extends EditableInventory { return function.equalsIgnoreCase("yes") ? new YesItem(config) : new SimplePlaceholderItem(config); } - public GeneratedInventory newInventory(PlayerData data, PluginInventory last) { - return new ClassConfirmationInventory(data, this, playerClass, last); - } - - @Override - public void reload(FileConfiguration config) { - super.reload(config); + public GeneratedInventory newInventory(PlayerData data, PluginInventory last, boolean subclass) { + return new ClassConfirmationInventory(data, this, playerClass, last, subclass); } public class UnlockedItem extends InventoryItem { @@ -53,7 +48,7 @@ public class ClassConfirmation extends EditableInventory { @Override public Placeholders getPlaceholders(ClassConfirmationInventory inv, int n) { PlayerClass profess = inv.profess; - SavedClassInformation info = inv.getPlayerData().getClassInfo(profess); + ClassDataContainer info = inv.subclass ? inv.getPlayerData() : inv.getPlayerData().getClassInfo(profess); Placeholders holders = new Placeholders(); final double nextLevelExp = inv.getPlayerData().getLevelUpExperience(); @@ -67,7 +62,7 @@ public class ClassConfirmation extends EditableInventory { holders.register("percent", decimal.format(ratio * 100)); holders.register("progress", bar.toString()); holders.register("class", profess.getName()); - holders.register("unlocked_skills", info.getSkillKeys().size()); + holders.register("unlocked_skills", info.mapSkillLevels().size()); holders.register("class_skills", profess.getSkills().size()); holders.register("next_level", "" + nextLevelExp); holders.register("level", info.getLevel()); @@ -108,12 +103,14 @@ public class ClassConfirmation extends EditableInventory { public class ClassConfirmationInventory extends GeneratedInventory { private final PlayerClass profess; private final PluginInventory last; + private final boolean subclass; - public ClassConfirmationInventory(PlayerData playerData, EditableInventory editable, PlayerClass profess, PluginInventory last) { + public ClassConfirmationInventory(PlayerData playerData, EditableInventory editable, PlayerClass profess, PluginInventory last, boolean subclass) { super(playerData, editable); this.profess = profess; this.last = last; + this.subclass = subclass; } @Override @@ -129,8 +126,11 @@ public class ClassConfirmation extends EditableInventory { return; playerData.giveClassPoints(-1); - (playerData.hasSavedClass(profess) ? playerData.getClassInfo(profess) - : new SavedClassInformation(MMOCore.plugin.dataProvider.getDataManager().getDefaultData())).load(profess, playerData); + if (subclass) + playerData.setClass(profess); + else + (playerData.hasSavedClass(profess) ? playerData.getClassInfo(profess) + : new SavedClassInformation(MMOCore.plugin.dataProvider.getDataManager().getDefaultData())).load(profess, playerData); MMOCore.plugin.configManager.getSimpleMessage("class-select", "class", profess.getName()).send(player); MMOCore.plugin.soundManager.getSound(SoundEvent.SELECT_CLASS).playTo(player); player.closeInventory(); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java index 58f816a4..7ada1ba9 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java @@ -90,14 +90,9 @@ public class ClassSelect extends EditableInventory { item.setItemMeta(meta); return item; } - - } public class ProfessSelectionInventory extends GeneratedInventory { - private final List classes = MMOCore.plugin.classManager.getAll().stream().filter(c -> c.hasOption(ClassOption.DISPLAY)) - .sorted(Comparator.comparingInt(PlayerClass::getDisplayOrder)).collect(Collectors.toList()); - public ProfessSelectionInventory(PlayerData playerData, EditableInventory editable) { super(playerData, editable); } @@ -131,7 +126,7 @@ public class ClassSelect extends EditableInventory { } final PlayerClass playerClass = findDeepestSubclass(playerData, profess); - InventoryManager.CLASS_CONFIRM.get(MMOCoreUtils.ymlName(playerClass.getId())).newInventory(playerData, this).open(); + InventoryManager.CLASS_CONFIRM.get(MMOCoreUtils.ymlName(playerClass.getId())).newInventory(playerData, this, false).open(); } } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java index 0dec5911..946da3bc 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java @@ -96,13 +96,8 @@ public class SubclassSelect extends EditableInventory { } public class SubclassSelectionInventory extends GeneratedInventory { - private final List subclasses; - public SubclassSelectionInventory(PlayerData playerData, EditableInventory editable) { super(playerData, editable); - - subclasses = playerData.getProfess().getSubclasses().stream().filter(sub -> playerData.getLevel() >= sub.getLevel()) - .collect(Collectors.toList()); } @Override @@ -116,7 +111,7 @@ public class SubclassSelect extends EditableInventory { InventoryManager.CLASS_SELECT.newInventory(playerData).open(); if (item.getFunction().startsWith("sub-class")) { - String classId= item.getFunction().substring(10); + String classId = item.getFunction().substring(10); if (playerData.getClassPoints() < 1) { player.closeInventory(); @@ -124,7 +119,8 @@ public class SubclassSelect extends EditableInventory { new ConfigMessage("cant-choose-new-class").send(player); return; } - InventoryManager.CLASS_CONFIRM.get(classId).newInventory(playerData, this).open(); + + InventoryManager.CLASS_CONFIRM.get(classId).newInventory(playerData, this, true).open(); } } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/InventoryManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/InventoryManager.java index e043636a..47d0b33c 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/InventoryManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/InventoryManager.java @@ -35,26 +35,20 @@ public class InventoryManager { public static final List list = new ArrayList(Arrays.asList(PLAYER_STATS, ATTRIBUTE_VIEW, TREE_VIEW, SKILL_LIST, CLASS_SELECT, SUBCLASS_SELECT, QUEST_LIST, WAYPOINTS, FRIEND_LIST, FRIEND_REMOVAL, PARTY_VIEW, PARTY_CREATION, GUILD_VIEW, GUILD_CREATION)); - private static List defaultClass = Arrays.asList(new String[]{"human", "mage", "paladin", "warrior", "rogue", "arcane-mage"}); - public static void load() { - String classConfirmFolder = "gui/class-confirm"; + final String classConfirmFolder = "gui/class-confirm"; try { MMOCore.plugin.configManager.loadDefaultFile(classConfirmFolder, "class-confirm-default.yml"); } catch (Exception exception) { MMOCore.log(Level.WARNING, "Could not load inventory 'class-confirm/class-confirm-default" + "': " + exception.getMessage()); } + for (PlayerClass playerClass : MMOCore.plugin.classManager.getAll()) { - String classId = MMOCoreUtils.ymlName(playerClass.getId()); - ConfigFile configFile = new ConfigFile(classConfirmFolder, "class-confirm-" + classId); - ClassConfirmation GUI; - if (configFile.exists()) - GUI = new ClassConfirmation(playerClass, false); - else { - GUI = new ClassConfirmation(playerClass, true); - } + final String classId = MMOCoreUtils.ymlName(playerClass.getId()); + final ConfigFile configFile = new ConfigFile(classConfirmFolder, "class-confirm-" + classId); + final ClassConfirmation GUI = configFile.exists() ? new ClassConfirmation(playerClass, false) : new ClassConfirmation(playerClass, true); CLASS_CONFIRM.put(MMOCoreUtils.ymlName(playerClass.getId()), GUI); - GUI.reload(new ConfigFile("/" +classConfirmFolder, GUI.getId()).getConfig()); + GUI.reload(new ConfigFile("/" + classConfirmFolder, GUI.getId()).getConfig()); } list.forEach(inv -> diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java index 2151f965..36a87b18 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java @@ -115,8 +115,8 @@ public class MySQLPlayerDataManager extends PlayerDataManager { classinfo.add("skill-tree-points", skillTreePointsInfo); JsonObject boundSkillInfo = new JsonObject(); - for (int slot : info.getBoundSkills().keySet()) - boundSkillInfo.addProperty(slot + "", info.getBoundSkills().get(slot)); + for (int slot : info.mapBoundSkills().keySet()) + boundSkillInfo.addProperty(String.valueOf(slot), info.mapBoundSkills().get(slot)); classinfo.add("bound-skills", boundSkillInfo); json.add(c, classinfo); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java index 74de40e6..b43e4040 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java @@ -191,7 +191,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager { info.getAttributeKeys().forEach(attribute -> config.set("class-info." + key + ".attribute." + attribute, info.getAttributeLevel(attribute))); info.getNodeKeys().forEach(node -> config.set("class-info." + key + ".node-levels." + node, info.getNodeLevel(node))); info.getSkillTreePointsKeys().forEach(skillTreeId -> config.set("class-info." + key + ".skill-tree-points." + skillTreeId, info.getAttributeLevel(skillTreeId))); - info.getBoundSkills().forEach((slot, skill) -> config.set("class-info." + key + ".bound-skills." + slot, skill)); + info.mapBoundSkills().forEach((slot, skill) -> config.set("class-info." + key + ".bound-skills." + slot, skill)); config.set("class-info." + key + ".unlocked-items", new ArrayList<>(info.getUnlockedItems())); } 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 0aa8a759..c711c590 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 @@ -1,15 +1,15 @@ package net.Indyuce.mmocore.player; import net.Indyuce.mmocore.api.player.profess.SavedClassInformation; -import net.Indyuce.mmocore.skilltree.SkillTreeNode; import java.util.Map; import java.util.Set; /** * All the class-specific information i.e information being saved - * in {@link SavedClassInformation} when a player changes its current - * class. + * in {@link SavedClassInformation} when a player changes its current class. + * + * TODO move {@link SavedClassInformation} method to ClassDataContainer */ public interface ClassDataContainer { @@ -43,7 +43,7 @@ public interface ClassDataContainer { Map mapBoundSkills(); - Map getNodeLevels(); + Map getNodeLevels(); Map getNodeTimesClaimed(); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java index b03f33e9..bd905048 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/player/DefaultPlayerData.java @@ -110,7 +110,7 @@ public class DefaultPlayerData implements ClassDataContainer { } @Override - public Map getNodeLevels() { + public Map getNodeLevels() { return new HashMap<>(); } diff --git a/MMOCore-Dist/src/main/resources/config.yml b/MMOCore-Dist/src/main/resources/config.yml index 10439ea2..dfb67de9 100644 --- a/MMOCore-Dist/src/main/resources/config.yml +++ b/MMOCore-Dist/src/main/resources/config.yml @@ -200,11 +200,10 @@ death-exp-loss: # Maximum number of skill slots. This means that you cannot unlock more than X skill slots. max-skill-slots: 8 -#If you want players to bound their passive skills. -#If false, all the passive skills unlocked will be active -#Also set max-bound-passive-skills to 0 if seting passive-skill-need-bound to false. -passive-skill-need-bound: true - +# When set to true, passive skills must be bound in order to take effect. +# When set to false, unlocked skills will take effect right away. +# Temporarily disabled. +# passive-skill-need-bound: true # Fun extra RPG feature that switches the player's hotbar with # the 9 lower row items of his inventory. This allows the player diff --git a/MMOCore-Dist/src/main/resources/default/classes/warrior.yml b/MMOCore-Dist/src/main/resources/default/classes/warrior.yml index 2cf4aac5..81ef9731 100644 --- a/MMOCore-Dist/src/main/resources/default/classes/warrior.yml +++ b/MMOCore-Dist/src/main/resources/default/classes/warrior.yml @@ -39,12 +39,16 @@ max-level: 100 skill-slots: 1: name: "Skill Slot I" + unlocked-by-default: true 2: name: "Skill Slot II" + unlocked-by-default: true 3: name: "Skill Slot III" + unlocked-by-default: true 4: name: "Skill Slot IV" + unlocked-by-default: true skill-trees: - 'general' diff --git a/MMOCore-Dist/src/main/resources/default/skills/ambers.yml b/MMOCore-Dist/src/main/resources/default/skills/ambers.yml index 8da7b189..561917bc 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/ambers.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/ambers.yml @@ -1,13 +1,9 @@ -name: Ambers +name: Mana Ambers lore: - Dealing magic damage has &630% &7chance - of dropping an amber on the ground. - '' -- When picked up, ambers stack and -- refund &9{percent}% &7of your missing mana. -- '' -- '&oAmbers can be used in other damaging skills.' -- '&oThe more you collect, the more powerful the skills.' +- When picked up, ambers refund &9{percent}% &7of your missing mana. - '' - '&e{cooldown}s Cooldown' material: EMERALD