From dca44b232d7759c7dbe4b0bd573d92e3b606f76a Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Wed, 29 Mar 2023 11:43:16 +0100 Subject: [PATCH 01/13] Added a fully detailed description and default modifiers for all the default registered skills. --- .../src/main/resources/default/skills/ambers.yml | 10 +++++----- .../main/resources/default/skills/backstab.yml | 8 ++++---- .../resources/default/skills/combo-attack.yml | 8 ++++---- .../main/resources/default/skills/control.yml | 6 +++--- .../main/resources/default/skills/deep-wound.yml | 4 ++-- .../default/skills/empowered-attack.yml | 6 +++--- .../src/main/resources/default/skills/evade.yml | 8 ++++---- .../resources/default/skills/fire-berserker.yml | 8 ++++---- .../main/resources/default/skills/fire-rage.yml | 10 +++++----- .../main/resources/default/skills/fire-storm.yml | 6 +++--- .../main/resources/default/skills/fireball.yml | 6 +++--- .../resources/default/skills/furtive-strike.yml | 6 +++--- .../default/skills/greater-healings.yml | 4 ++-- .../resources/default/skills/human-shield.yml | 8 ++++---- .../main/resources/default/skills/ice-spikes.yml | 6 +++--- .../resources/default/skills/minor-healings.yml | 4 ++-- .../main/resources/default/skills/power-mark.yml | 16 ++++++++-------- .../resources/default/skills/sneaky-picky.yml | 8 ++++---- .../main/resources/default/skills/telekinesy.yml | 6 +++--- .../src/main/resources/default/skills/warp.yml | 4 ++-- .../src/main/resources/default/skills/weaken.yml | 4 ++-- pom.xml | 2 +- 22 files changed, 74 insertions(+), 74 deletions(-) diff --git a/MMOCore-Dist/src/main/resources/default/skills/ambers.yml b/MMOCore-Dist/src/main/resources/default/skills/ambers.yml index 24eab92a..8da7b189 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/ambers.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/ambers.yml @@ -12,13 +12,13 @@ lore: - '&e{cooldown}s Cooldown' material: EMERALD mana: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: @@ -28,6 +28,6 @@ cooldown: min: 1.0 percent: base: 10.0 - per-level: 0.1 + per-level: 1.1 max: 20.0 min: 10.0 diff --git a/MMOCore-Dist/src/main/resources/default/skills/backstab.yml b/MMOCore-Dist/src/main/resources/default/skills/backstab.yml index f8a6704b..95d58ac3 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/backstab.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/backstab.yml @@ -8,13 +8,13 @@ mana: base: 8.0 per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 extra: base: 50.0 per-level: 20.0 cooldown: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 diff --git a/MMOCore-Dist/src/main/resources/default/skills/combo-attack.yml b/MMOCore-Dist/src/main/resources/default/skills/combo-attack.yml index fb8b986f..c44d5333 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/combo-attack.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/combo-attack.yml @@ -8,15 +8,15 @@ lore: material: IRON_SWORD damage: base: 9.0 - per-level: 0.3 + per-level: 1.3 mana: base: 10.0 per-level: -0.1 max: 5.0 min: 3.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: @@ -26,4 +26,4 @@ cooldown: min: 5.0 count: base: 3.0 - per-level: 0.2 + per-level: 1.2 diff --git a/MMOCore-Dist/src/main/resources/default/skills/control.yml b/MMOCore-Dist/src/main/resources/default/skills/control.yml index d674a4d8..6b2771d3 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/control.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/control.yml @@ -10,13 +10,13 @@ lore: material: MAGENTA_DYE duration: base: 2.0 - per-level: 0.0 + per-level: 1.0 mana: base: 15.0 per-level: 1.5 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/MMOCore-Dist/src/main/resources/default/skills/deep-wound.yml b/MMOCore-Dist/src/main/resources/default/skills/deep-wound.yml index bbb31d69..86777fc3 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/deep-wound.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/deep-wound.yml @@ -14,8 +14,8 @@ mana: base: 8.0 per-level: 3.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 extra: diff --git a/MMOCore-Dist/src/main/resources/default/skills/empowered-attack.yml b/MMOCore-Dist/src/main/resources/default/skills/empowered-attack.yml index 05c1173b..7d924914 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/empowered-attack.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/empowered-attack.yml @@ -12,8 +12,8 @@ mana: base: 4.0 per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 extra: @@ -26,7 +26,7 @@ cooldown: min: 5.0 radius: base: 4.0 - per-level: 0.0 + per-level: 1.0 ratio: base: 30.0 per-level: 10.0 diff --git a/MMOCore-Dist/src/main/resources/default/skills/evade.yml b/MMOCore-Dist/src/main/resources/default/skills/evade.yml index 3be455a1..acac3e3f 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/evade.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/evade.yml @@ -8,17 +8,17 @@ lore: material: LEATHER_BOOTS duration: base: 2.0 - per-level: 0.3 + per-level: 1.3 max: 10.0 min: 2.0 mana: base: 8.0 per-level: 3.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: base: 20.0 - per-level: 0.0 + per-level: 1.0 diff --git a/MMOCore-Dist/src/main/resources/default/skills/fire-berserker.yml b/MMOCore-Dist/src/main/resources/default/skills/fire-berserker.yml index f5cf6db3..7658ef43 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/fire-berserker.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/fire-berserker.yml @@ -3,13 +3,13 @@ lore: - You deal &c{extra}% &7more damage when on fire. material: FLINT_AND_STEEL mana: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 extra: diff --git a/MMOCore-Dist/src/main/resources/default/skills/fire-rage.yml b/MMOCore-Dist/src/main/resources/default/skills/fire-rage.yml index b45746e4..c7e33490 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/fire-rage.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/fire-rage.yml @@ -10,24 +10,24 @@ lore: material: FIRE_CHARGE duration: base: 8.0 - per-level: 0.0 + per-level: 1.0 damage: base: 5.0 per-level: 3.0 ignite: base: 2.0 - per-level: 0.1 + per-level: 1.1 mana: base: 15.0 per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 count: base: 4.0 - per-level: 0.0 + per-level: 1.0 cooldown: base: 9.0 per-level: -0.1 diff --git a/MMOCore-Dist/src/main/resources/default/skills/fire-storm.yml b/MMOCore-Dist/src/main/resources/default/skills/fire-storm.yml index 57f4fc02..07ff2ffc 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/fire-storm.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/fire-storm.yml @@ -13,13 +13,13 @@ damage: per-level: 3.0 ignite: base: 2.0 - per-level: 0.1 + per-level: 1.1 mana: base: 15.0 per-level: 2.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/MMOCore-Dist/src/main/resources/default/skills/fireball.yml b/MMOCore-Dist/src/main/resources/default/skills/fireball.yml index faec3105..b871ac9e 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/fireball.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/fireball.yml @@ -16,13 +16,13 @@ damage: per-level: 3.0 ignite: base: 2.0 - per-level: 0.1 + per-level: 1.1 mana: base: 15.0 per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/MMOCore-Dist/src/main/resources/default/skills/furtive-strike.yml b/MMOCore-Dist/src/main/resources/default/skills/furtive-strike.yml index ef1fd5e6..9dcf10bb 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/furtive-strike.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/furtive-strike.yml @@ -13,8 +13,8 @@ mana: base: 8.0 per-level: 3.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 extra: @@ -27,4 +27,4 @@ cooldown: min: 5.0 radius: base: 7.0 - per-level: 0.0 + per-level: 1.0 diff --git a/MMOCore-Dist/src/main/resources/default/skills/greater-healings.yml b/MMOCore-Dist/src/main/resources/default/skills/greater-healings.yml index 38fc7fe3..462f36a9 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/greater-healings.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/greater-healings.yml @@ -10,8 +10,8 @@ mana: base: 4.0 per-level: 2.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 heal: diff --git a/MMOCore-Dist/src/main/resources/default/skills/human-shield.yml b/MMOCore-Dist/src/main/resources/default/skills/human-shield.yml index 4c1bd8cf..19418a43 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/human-shield.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/human-shield.yml @@ -16,16 +16,16 @@ redirect: min: 20.0 duration: base: 7.0 - per-level: 0.0 + per-level: 1.0 mana: base: 15.0 per-level: 1.5 low: base: 10.0 - per-level: 0.0 + per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/MMOCore-Dist/src/main/resources/default/skills/ice-spikes.yml b/MMOCore-Dist/src/main/resources/default/skills/ice-spikes.yml index c366f960..d4fb3484 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/ice-spikes.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/ice-spikes.yml @@ -16,10 +16,10 @@ mana: per-level: 2.0 slow: base: 4.0 - per-level: 0.0 + per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/MMOCore-Dist/src/main/resources/default/skills/minor-healings.yml b/MMOCore-Dist/src/main/resources/default/skills/minor-healings.yml index 42c13963..37426698 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/minor-healings.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/minor-healings.yml @@ -10,8 +10,8 @@ mana: base: 4.0 per-level: 2.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 heal: diff --git a/MMOCore-Dist/src/main/resources/default/skills/power-mark.yml b/MMOCore-Dist/src/main/resources/default/skills/power-mark.yml index 5ab415fe..73cc6cb7 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/power-mark.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/power-mark.yml @@ -16,23 +16,23 @@ lore: material: WITHER_SKELETON_SKULL duration: base: 10.0 - per-level: 0.1 + per-level: 1.1 mana: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: base: 30.0 - per-level: 0.0 + per-level: 1.0 stun: - base: 0.4 - per-level: 0.03 + base: 2.4 + per-level: 1.03 ratio: base: 10.0 per-level: 5.0 diff --git a/MMOCore-Dist/src/main/resources/default/skills/sneaky-picky.yml b/MMOCore-Dist/src/main/resources/default/skills/sneaky-picky.yml index db00a5f1..07b00614 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/sneaky-picky.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/sneaky-picky.yml @@ -9,13 +9,13 @@ mana: base: 8.0 per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 extra: base: 50.0 per-level: 20.0 cooldown: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 diff --git a/MMOCore-Dist/src/main/resources/default/skills/telekinesy.yml b/MMOCore-Dist/src/main/resources/default/skills/telekinesy.yml index f965da4e..a5ca5a07 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/telekinesy.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/telekinesy.yml @@ -9,15 +9,15 @@ lore: material: MAGENTA_DYE duration: base: 3.0 - per-level: 0.1 + per-level: 1.1 max: 6.0 min: 3.0 mana: base: 20.0 per-level: 2.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/MMOCore-Dist/src/main/resources/default/skills/warp.yml b/MMOCore-Dist/src/main/resources/default/skills/warp.yml index 9a98be5b..358f5629 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/warp.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/warp.yml @@ -10,8 +10,8 @@ mana: base: 8.0 per-level: 3.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/MMOCore-Dist/src/main/resources/default/skills/weaken.yml b/MMOCore-Dist/src/main/resources/default/skills/weaken.yml index ad80071e..9835bfc1 100644 --- a/MMOCore-Dist/src/main/resources/default/skills/weaken.yml +++ b/MMOCore-Dist/src/main/resources/default/skills/weaken.yml @@ -16,8 +16,8 @@ mana: base: 4.0 per-level: 1.0 stamina: - base: 0.0 - per-level: 0.0 + base: 2.0 + per-level: 1.0 max: 0.0 min: 0.0 cooldown: diff --git a/pom.xml b/pom.xml index ec4f22e3..a998f2e7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ net.Indyuce MMOCore pom - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT MMOCore-API From 739f958d5aad9dc47ac4ed6c27fc314a4f11b390 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Fri, 31 Mar 2023 09:04:58 +0100 Subject: [PATCH 02/13] Refactor of the ClassSelect & ClassConfirmation GUI. Now you can fully customize the GUI depending on each class. Reload the GUI folder & add a class-confirm/... gui for each new class you created. --- MMOCore-API/pom.xml | 2 +- .../java/net/Indyuce/mmocore/MMOCore.java | 3 +- .../mmocore/gui/ClassConfirmation.java | 33 +++---------- .../net/Indyuce/mmocore/gui/ClassSelect.java | 35 +++++++------ .../mmocore/manager/InventoryManager.java | 22 ++++++--- MMOCore-Dist/pom.xml | 4 +- .../class-confirm-arcane-mage.yml} | 10 ---- .../gui/class-confirm/class-confirm-human.yml | 38 ++++++++++++++ .../gui/class-confirm/class-confirm-mage.yml | 38 ++++++++++++++ .../class-confirm/class-confirm-marksman.yml | 38 ++++++++++++++ .../class-confirm/class-confirm-paladin.yml | 38 ++++++++++++++ .../gui/class-confirm/class-confirm-rogue.yml | 38 ++++++++++++++ .../class-confirm/class-confirm-warrior.yml | 38 ++++++++++++++ .../resources/default/gui/class-select.yml | 49 +++++++++++++++++-- README.md | 2 +- 15 files changed, 321 insertions(+), 67 deletions(-) rename MMOCore-Dist/src/main/resources/default/gui/{class-confirm.yml => class-confirm/class-confirm-arcane-mage.yml} (79%) create mode 100644 MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-human.yml create mode 100644 MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-mage.yml create mode 100644 MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-marksman.yml create mode 100644 MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-paladin.yml create mode 100644 MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-rogue.yml create mode 100644 MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-warrior.yml diff --git a/MMOCore-API/pom.xml b/MMOCore-API/pom.xml index 1ac1239c..8add30f8 100644 --- a/MMOCore-API/pom.xml +++ b/MMOCore-API/pom.xml @@ -5,7 +5,7 @@ MMOCore net.Indyuce - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT 4.0.0 diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java index 8f3e5f00..ab5968b4 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -341,7 +341,6 @@ public class MMOCore extends JavaPlugin { statManager.initialize(clearBefore); professionManager.initialize(clearBefore); - InventoryManager.load(); skillTreeManager.initialize(clearBefore); classManager.initialize(clearBefore); questManager.initialize(clearBefore); @@ -351,6 +350,8 @@ public class MMOCore extends JavaPlugin { requestManager.initialize(clearBefore); soundManager.initialize(clearBefore); configItems.initialize(clearBefore); + //Needs to be loaded after the class manager. + InventoryManager.load(); if (getConfig().isConfigurationSection("action-bar")) actionBarManager.reload(getConfig().getConfigurationSection("action-bar")); 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 65fd4308..d5b81205 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 @@ -1,12 +1,12 @@ package net.Indyuce.mmocore.gui; +import io.lumine.mythic.lib.UtilityMethods; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.profess.PlayerClass; import net.Indyuce.mmocore.api.player.profess.SavedClassInformation; -import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.InventoryClickContext; @@ -21,21 +21,14 @@ import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Map; public class ClassConfirmation extends EditableInventory { - /** - * This enables to configure the name of the - * class confirmation GUI (for custom GUI textures). - */ - private final Map specificNames = new HashMap<>(); + private final PlayerClass playerClass; - public ClassConfirmation() { - super("class-confirm"); + public ClassConfirmation(PlayerClass playerClass) { + super("class-confirm-"+ UtilityMethods.ymlName(playerClass.getId())); + this.playerClass=playerClass; } @Override @@ -43,21 +36,13 @@ public class ClassConfirmation extends EditableInventory { return function.equalsIgnoreCase("yes") ? new YesItem(config) : new SimplePlaceholderItem(config); } - public GeneratedInventory newInventory(PlayerData data, PlayerClass profess, PluginInventory last) { - return new ClassConfirmationInventory(data, this, profess, last); + public GeneratedInventory newInventory(PlayerData data, PluginInventory last) { + return new ClassConfirmationInventory(data, this, playerClass, last); } @Override public void reload(FileConfiguration config) { super.reload(config); - - specificNames.clear(); - - if (config.contains("class-specific-name")) { - final ConfigurationSection section = config.getConfigurationSection("class-specific-name"); - for (String key : section.getKeys(false)) - specificNames.put(key, section.getString(key)); - } } public class UnlockedItem extends InventoryItem { @@ -154,9 +139,7 @@ public class ClassConfirmation extends EditableInventory { @Override public String calculateName() { - final String professKey = MMOCoreUtils.ymlName(profess.getId()); - final @Nullable String found = specificNames.get(professKey); - return found == null ? getName().replace("{class}", profess.getName()) : found; + return getName().replace("{class}", profess.getName()); } } } 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 9d91c8bf..083cd6b0 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 @@ -1,18 +1,21 @@ package net.Indyuce.mmocore.gui; import io.lumine.mythic.lib.MythicLib; +import io.lumine.mythic.lib.UtilityMethods; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.ConfigMessage; import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.profess.ClassOption; import net.Indyuce.mmocore.api.player.profess.PlayerClass; +import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.InventoryClickContext; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem; import net.Indyuce.mmocore.manager.InventoryManager; +import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.configuration.ConfigurationSection; @@ -24,6 +27,7 @@ import org.bukkit.persistence.PersistentDataType; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; public class ClassSelect extends EditableInventory { @@ -33,7 +37,7 @@ public class ClassSelect extends EditableInventory { @Override public InventoryItem load(String function, ConfigurationSection config) { - return function.equals("class") ? new ClassItem(config) : new SimplePlaceholderItem(config); + return function.startsWith("class") ? new ClassItem(config) : new SimplePlaceholderItem(config); } public GeneratedInventory newInventory(PlayerData data) { @@ -43,10 +47,13 @@ public class ClassSelect extends EditableInventory { public class ClassItem extends SimplePlaceholderItem { private final String name; private final List lore; + private final PlayerClass playerClass; public ClassItem(ConfigurationSection config) { super(Material.BARRIER, config); - + Validate.isTrue(config.getString("function").length()>6,"Couldn't find the class associated to: "+config.getString("function")); + String classId = UtilityMethods.enumName(config.getString("function").substring(6)); + this.playerClass = Objects.requireNonNull(MMOCore.plugin.classManager.get(classId),classId+" does not correspond to any classId."); this.name = config.getString("name"); this.lore = config.getStringList("lore"); } @@ -60,29 +67,28 @@ public class ClassSelect extends EditableInventory { if (n >= inv.classes.size()) return null; - PlayerClass profess = inv.classes.get(n); - ItemStack item = profess.getIcon(); + ItemStack item = playerClass.getIcon(); ItemMeta meta = item.getItemMeta(); if (hideFlags()) meta.addItemFlags(ItemFlag.values()); - meta.setDisplayName(MythicLib.plugin.parseColors(name).replace("{name}", profess.getName())); + meta.setDisplayName(MythicLib.plugin.parseColors(name).replace("{name}", playerClass.getName())); List lore = new ArrayList<>(this.lore); int index = lore.indexOf("{lore}"); if (index >= 0) { lore.remove(index); - for (int j = 0; j < profess.getDescription().size(); j++) - lore.add(index + j, profess.getDescription().get(j)); + for (int j = 0; j < playerClass.getDescription().size(); j++) + lore.add(index + j, playerClass.getDescription().get(j)); } index = lore.indexOf("{attribute-lore}"); if (index >= 0) { lore.remove(index); - for (int j = 0; j < profess.getAttributeDescription().size(); j++) - lore.add(index + j, profess.getAttributeDescription().get(j)); + for (int j = 0; j < playerClass.getAttributeDescription().size(); j++) + lore.add(index + j, playerClass.getAttributeDescription().get(j)); } - meta.getPersistentDataContainer().set(new NamespacedKey(MMOCore.plugin, "class_id"), PersistentDataType.STRING, profess.getId()); + meta.getPersistentDataContainer().set(new NamespacedKey(MMOCore.plugin, "class_id"), PersistentDataType.STRING, playerClass.getId()); meta.setLore(lore); item.setItemMeta(meta); return item; @@ -104,10 +110,8 @@ public class ClassSelect extends EditableInventory { @Override public void whenClicked(InventoryClickContext context, InventoryItem item) { - if (item.getFunction().equals("class")) { - String classId = context.getClickedItem().getItemMeta().getPersistentDataContainer().get(new NamespacedKey(MMOCore.plugin, "class_id"), PersistentDataType.STRING); - if (classId.equals("")) - return; + if (item instanceof ClassItem) { + PlayerClass profess = ((ClassItem) item).playerClass; if (playerData.getClassPoints() < 1) { MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player); @@ -115,7 +119,6 @@ public class ClassSelect extends EditableInventory { return; } - final PlayerClass profess = MMOCore.plugin.classManager.get(classId); if (profess.hasOption(ClassOption.NEEDS_PERMISSION) && !player.hasPermission("mmocore.class." + profess.getId().toLowerCase())) { MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player); new ConfigMessage("no-permission-for-class").send(player); @@ -129,7 +132,7 @@ public class ClassSelect extends EditableInventory { } final PlayerClass playerClass = findDeepestSubclass(playerData, profess); - InventoryManager.CLASS_CONFIRM.newInventory(playerData, playerClass, this).open(); + InventoryManager.CLASS_CONFIRM.get(MMOCoreUtils.ymlName(playerClass.getId())).newInventory(playerData, this).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 29d61c18..56953b6b 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 @@ -1,10 +1,11 @@ package net.Indyuce.mmocore.manager; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.logging.Level; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.player.profess.PlayerClass; +import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.gui.social.friend.EditableFriendList; import net.Indyuce.mmocore.gui.*; import net.Indyuce.mmocore.gui.social.friend.EditableFriendRemoval; @@ -20,7 +21,7 @@ public class InventoryManager { public static final SkillList SKILL_LIST = new SkillList(); public static final ClassSelect CLASS_SELECT = new ClassSelect(); public static final SubclassSelect SUBCLASS_SELECT = new SubclassSelect(); - public static final ClassConfirmation CLASS_CONFIRM = new ClassConfirmation(); + public static final Map CLASS_CONFIRM = new HashMap<>(); public static final SubclassConfirmation SUBCLASS_CONFIRM = new SubclassConfirmation(); public static final WaypointViewer WAYPOINTS = new WaypointViewer(); public static final EditableFriendList FRIEND_LIST = new EditableFriendList(); @@ -32,14 +33,21 @@ public class InventoryManager { public static final QuestViewer QUEST_LIST = new QuestViewer(); public static final AttributeView ATTRIBUTE_VIEW = new AttributeView(); public static final SkillTreeViewer TREE_VIEW = new SkillTreeViewer(); - public static final List list = Arrays.asList(PLAYER_STATS, ATTRIBUTE_VIEW, TREE_VIEW,SKILL_LIST, CLASS_SELECT, SUBCLASS_SELECT, SUBCLASS_CONFIRM, QUEST_LIST, WAYPOINTS, CLASS_CONFIRM, FRIEND_LIST, FRIEND_REMOVAL, PARTY_VIEW, PARTY_CREATION, GUILD_VIEW, GUILD_CREATION); + public static final List list = new ArrayList(Arrays.asList(PLAYER_STATS, ATTRIBUTE_VIEW, TREE_VIEW, SKILL_LIST, CLASS_SELECT, SUBCLASS_SELECT, SUBCLASS_CONFIRM, QUEST_LIST, WAYPOINTS, FRIEND_LIST, FRIEND_REMOVAL, PARTY_VIEW, PARTY_CREATION, GUILD_VIEW, GUILD_CREATION)); public static void load() { + for (PlayerClass playerClass : MMOCore.plugin.classManager.getAll()) { + ClassConfirmation GUI = new ClassConfirmation(playerClass); + CLASS_CONFIRM.put(MMOCoreUtils.ymlName(playerClass.getId()), GUI); + list.add(GUI); + } + list.forEach(inv -> { - MMOCore.plugin.configManager.loadDefaultFile("gui", inv.getId() + ".yml"); + String folder="gui"+(inv instanceof ClassConfirmation?"/class-confirm":""); + MMOCore.plugin.configManager.loadDefaultFile(folder, inv.getId() + ".yml"); try { - inv.reload(new ConfigFile("/gui", inv.getId()).getConfig()); - } catch (IllegalArgumentException exception) { + inv.reload(new ConfigFile("/"+folder, inv.getId()).getConfig()); + } catch (Exception exception) { MMOCore.log(Level.WARNING, "Could not load inventory '" + inv.getId() + "': " + exception.getMessage()); } }); diff --git a/MMOCore-Dist/pom.xml b/MMOCore-Dist/pom.xml index cf6bc6f3..447a720b 100644 --- a/MMOCore-Dist/pom.xml +++ b/MMOCore-Dist/pom.xml @@ -5,7 +5,7 @@ MMOCore net.Indyuce - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT 4.0.0 @@ -67,7 +67,7 @@ net.Indyuce MMOCore-API - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT true diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-confirm.yml b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-arcane-mage.yml similarity index 79% rename from MMOCore-Dist/src/main/resources/default/gui/class-confirm.yml rename to MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-arcane-mage.yml index 089e1b5f..5c06c186 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/class-confirm.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-arcane-mage.yml @@ -1,16 +1,6 @@ - # GUI display name, used by default name: 'Confirmation: {class}' -# GUI display name which overrides the default one. -# This can be used to apply custom textures to the GUI -class-specific-name: - mage: "Select Mage" - rogue: "Select Rogue" - marksman: "Select Marksman" - warrior: "Select Warrior" - paladin: "Select Paladin" - # Number of slots in your inventory. Must be # between 9 and 54 and must be a multiple of 9. slots: 27 diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-human.yml b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-human.yml new file mode 100644 index 00000000..9a3d74e3 --- /dev/null +++ b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-human.yml @@ -0,0 +1,38 @@ +# GUI display name, used by default +name: 'Confirmation: {class}' + +# Number of slots in your inventory. Must be +# between 9 and 54 and must be a multiple of 9. +slots: 27 + +items: + yes: + slots: [12] + function: 'yes' + + # Displayed when the player had already selected this class + # before (only if class slots are enabled in the config). + unlocked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: + - '' + - '&7Class Level: &e{level}' + - '&7Progression: &e{exp} / {next_level}' + - '&8[&e{progress}&8] &e{percent}%' + - '' + - '&7Skill Points: &6{skill_points}' + - '&7Skills You Unlocked: &6{unlocked_skills}&7/&6{class_skills}' + + # Displayed when the class is being chosen for the first time. + locked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: {} + + back: + slots: [14] + item: RED_TERRACOTTA + function: back + name: '&aBack' + lore: {} diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-mage.yml b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-mage.yml new file mode 100644 index 00000000..5c06c186 --- /dev/null +++ b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-mage.yml @@ -0,0 +1,38 @@ +# GUI display name, used by default +name: 'Confirmation: {class}' + +# Number of slots in your inventory. Must be +# between 9 and 54 and must be a multiple of 9. +slots: 27 + +items: + yes: + slots: [12] + function: 'yes' + + # Displayed when the player had already selected this class + # before (only if class slots are enabled in the config). + unlocked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: + - '' + - '&7Class Level: &e{level}' + - '&7Progression: &e{exp} / {next_level}' + - '&8[&e{progress}&8] &e{percent}%' + - '' + - '&7Skill Points: &6{skill_points}' + - '&7Skills You Unlocked: &6{unlocked_skills}&7/&6{class_skills}' + + # Displayed when the class is being chosen for the first time. + locked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: {} + + back: + slots: [14] + item: RED_TERRACOTTA + function: back + name: '&aBack' + lore: {} diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-marksman.yml b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-marksman.yml new file mode 100644 index 00000000..5c06c186 --- /dev/null +++ b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-marksman.yml @@ -0,0 +1,38 @@ +# GUI display name, used by default +name: 'Confirmation: {class}' + +# Number of slots in your inventory. Must be +# between 9 and 54 and must be a multiple of 9. +slots: 27 + +items: + yes: + slots: [12] + function: 'yes' + + # Displayed when the player had already selected this class + # before (only if class slots are enabled in the config). + unlocked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: + - '' + - '&7Class Level: &e{level}' + - '&7Progression: &e{exp} / {next_level}' + - '&8[&e{progress}&8] &e{percent}%' + - '' + - '&7Skill Points: &6{skill_points}' + - '&7Skills You Unlocked: &6{unlocked_skills}&7/&6{class_skills}' + + # Displayed when the class is being chosen for the first time. + locked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: {} + + back: + slots: [14] + item: RED_TERRACOTTA + function: back + name: '&aBack' + lore: {} diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-paladin.yml b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-paladin.yml new file mode 100644 index 00000000..5c06c186 --- /dev/null +++ b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-paladin.yml @@ -0,0 +1,38 @@ +# GUI display name, used by default +name: 'Confirmation: {class}' + +# Number of slots in your inventory. Must be +# between 9 and 54 and must be a multiple of 9. +slots: 27 + +items: + yes: + slots: [12] + function: 'yes' + + # Displayed when the player had already selected this class + # before (only if class slots are enabled in the config). + unlocked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: + - '' + - '&7Class Level: &e{level}' + - '&7Progression: &e{exp} / {next_level}' + - '&8[&e{progress}&8] &e{percent}%' + - '' + - '&7Skill Points: &6{skill_points}' + - '&7Skills You Unlocked: &6{unlocked_skills}&7/&6{class_skills}' + + # Displayed when the class is being chosen for the first time. + locked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: {} + + back: + slots: [14] + item: RED_TERRACOTTA + function: back + name: '&aBack' + lore: {} diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-rogue.yml b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-rogue.yml new file mode 100644 index 00000000..5c06c186 --- /dev/null +++ b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-rogue.yml @@ -0,0 +1,38 @@ +# GUI display name, used by default +name: 'Confirmation: {class}' + +# Number of slots in your inventory. Must be +# between 9 and 54 and must be a multiple of 9. +slots: 27 + +items: + yes: + slots: [12] + function: 'yes' + + # Displayed when the player had already selected this class + # before (only if class slots are enabled in the config). + unlocked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: + - '' + - '&7Class Level: &e{level}' + - '&7Progression: &e{exp} / {next_level}' + - '&8[&e{progress}&8] &e{percent}%' + - '' + - '&7Skill Points: &6{skill_points}' + - '&7Skills You Unlocked: &6{unlocked_skills}&7/&6{class_skills}' + + # Displayed when the class is being chosen for the first time. + locked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: {} + + back: + slots: [14] + item: RED_TERRACOTTA + function: back + name: '&aBack' + lore: {} diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-warrior.yml b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-warrior.yml new file mode 100644 index 00000000..5c06c186 --- /dev/null +++ b/MMOCore-Dist/src/main/resources/default/gui/class-confirm/class-confirm-warrior.yml @@ -0,0 +1,38 @@ +# GUI display name, used by default +name: 'Confirmation: {class}' + +# Number of slots in your inventory. Must be +# between 9 and 54 and must be a multiple of 9. +slots: 27 + +items: + yes: + slots: [12] + function: 'yes' + + # Displayed when the player had already selected this class + # before (only if class slots are enabled in the config). + unlocked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: + - '' + - '&7Class Level: &e{level}' + - '&7Progression: &e{exp} / {next_level}' + - '&8[&e{progress}&8] &e{percent}%' + - '' + - '&7Skill Points: &6{skill_points}' + - '&7Skills You Unlocked: &6{unlocked_skills}&7/&6{class_skills}' + + # Displayed when the class is being chosen for the first time. + locked: + item: GREEN_TERRACOTTA + name: '&aSelect {class}' + lore: {} + + back: + slots: [14] + item: RED_TERRACOTTA + function: back + name: '&aBack' + lore: {} diff --git a/MMOCore-Dist/src/main/resources/default/gui/class-select.yml b/MMOCore-Dist/src/main/resources/default/gui/class-select.yml index 0e6cad40..582fa074 100644 --- a/MMOCore-Dist/src/main/resources/default/gui/class-select.yml +++ b/MMOCore-Dist/src/main/resources/default/gui/class-select.yml @@ -7,10 +7,51 @@ name: Class Selection slots: 27 items: - class: - slots: [13,12,14,11,15,10,16] - function: class - name: '&a&lThe {name}' + + class-rogue: + slots: [11] + function: class-rogue + name: '&a&lThe Rogue' + hide-flags: true + lore: + - '{lore}' + - '' + - '{attribute-lore}' + + class-mage: + slots: [12] + function: class-mage + name: '&a&lThe Mage' + hide-flags: true + lore: + - '{lore}' + - '' + - '{attribute-lore}' + + class-marksman: + slots: [13] + function: class-marksman + name: '&a&lThe Marksman' + hide-flags: true + lore: + - '{lore}' + - '' + - '{attribute-lore}' + + class-warrior: + slots: [14] + function: class-warrior + name: '&a&lThe Warrior' + hide-flags: true + lore: + - '{lore}' + - '' + - '{attribute-lore}' + + class-paladin: + slots: [15] + function: class-paladin + name: '&a&lThe Paladin' hide-flags: true lore: - '{lore}' diff --git a/README.md b/README.md index 31b4de3a..0ea6e54e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ And then add MMOCore-API as dependency net.Indyuce MMOCore-API - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT provided ``` From de011349a1d7f819cc92918febb56a111db9cef7 Mon Sep 17 00:00:00 2001 From: Jules Date: Sat, 1 Apr 2023 20:00:56 +0200 Subject: [PATCH 03/13] Updated poms --- MMOCore-API/pom.xml | 2 +- MMOCore-Dist/pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MMOCore-API/pom.xml b/MMOCore-API/pom.xml index 1ac1239c..8add30f8 100644 --- a/MMOCore-API/pom.xml +++ b/MMOCore-API/pom.xml @@ -5,7 +5,7 @@ MMOCore net.Indyuce - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT 4.0.0 diff --git a/MMOCore-Dist/pom.xml b/MMOCore-Dist/pom.xml index cf6bc6f3..447a720b 100644 --- a/MMOCore-Dist/pom.xml +++ b/MMOCore-Dist/pom.xml @@ -5,7 +5,7 @@ MMOCore net.Indyuce - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT 4.0.0 @@ -67,7 +67,7 @@ net.Indyuce MMOCore-API - 1.11.2-SNAPSHOT + 1.11.3-SNAPSHOT true From 77f436200af9023644d7df61765e6a672d8ac77a Mon Sep 17 00:00:00 2001 From: Jules Date: Sat, 1 Apr 2023 23:00:46 +0200 Subject: [PATCH 04/13] Stat placeholder now more lenient --- .../Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 87607a74..a68ef21c 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 @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.comp.placeholder; import io.lumine.mythic.lib.MythicLib; +import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.manager.StatManager; import me.clip.placeholderapi.expansion.PlaceholderExpansion; @@ -183,8 +184,8 @@ public class RPGPlaceholders extends PlaceholderExpansion { } else if (identifier.startsWith("stat_")) { - final String stat = identifier.substring(5).toUpperCase(); - return StatManager.format(identifier.substring(5), playerData.getStats().getStat(stat)); + final String stat = UtilityMethods.caseOnWords(identifier.substring(5)); + return StatManager.format(stat, playerData.getMMOPlayerData()); } else if (identifier.equals("stellium")) From 06fbd52c55e313098804ab93fb0796571de14e8b Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 2 Apr 2023 16:24:39 +0200 Subject: [PATCH 05/13] Fixed stat placeholders.. again --- .../net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a68ef21c..208afce9 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 @@ -184,7 +184,7 @@ public class RPGPlaceholders extends PlaceholderExpansion { } else if (identifier.startsWith("stat_")) { - final String stat = UtilityMethods.caseOnWords(identifier.substring(5)); + final String stat = UtilityMethods.enumName(identifier.substring(5)); return StatManager.format(stat, playerData.getMMOPlayerData()); } From 253e2c38e0e55684dff35775abd3b35051bbd756 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 18:13:05 +0100 Subject: [PATCH 06/13] Fixed bug #771 that made people die when changing class under some conditions. --- .../mmocore/api/player/profess/SavedClassInformation.java | 2 ++ 1 file changed, 2 insertions(+) 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 31ac030c..bf771346 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 @@ -300,6 +300,8 @@ public class SavedClassInformation { player.setMana(mana); player.setStellium(stellium); player.setStamina(stamina); + double health=this.health; + health = health == 0 ? 20 : health; player.getPlayer().setHealth(Math.min(health,player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())); // Updates level on exp bar player.refreshVanillaExp(); From 2f17d56c402f5706cbcffcd12764850518593286 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 18:29:14 +0100 Subject: [PATCH 07/13] Fixed bug #772 about trigger at the end of a quest to launch a new one. --- .../java/net/Indyuce/mmocore/api/quest/QuestProgress.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java index 99abb972..92e8a6f5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java @@ -47,8 +47,6 @@ public class QuestProgress { objective++; objectiveProgress.close(); - // apply triggers - objectiveProgress.getObjective().getTriggers().forEach(trigger -> trigger.schedule(getPlayer())); // end quest if (objective >= quest.getObjectives().size()) @@ -57,6 +55,10 @@ public class QuestProgress { objectiveProgress = nextObjective().newProgress(this); player.getQuestData().updateBossBar(); + + + // apply triggers at the end so the quest is ended when a trigger quest start is launched. + objectiveProgress.getObjective().getTriggers().forEach(trigger -> trigger.schedule(getPlayer())); } public String getFormattedLore() { From 3a9b3b6f5635844b0c36c1cc304cb1b8392c2ff3 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 19:47:30 +0100 Subject: [PATCH 08/13] Fixed health issue when changing class. --- .../main/java/net/Indyuce/mmocore/api/player/PlayerData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 94c06980..abb701a0 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 @@ -950,7 +950,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc @Override public double getHealth() { - return health; + return getPlayer() == null ? health : getPlayer().getHealth(); } @Override From 395844c25a9a07e94eb15996e04fe2eedbe2d752 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 19:47:58 +0100 Subject: [PATCH 09/13] Better error handling & console messages for the new class-confirm GUI. --- .../java/net/Indyuce/mmocore/manager/InventoryManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 56953b6b..4d931033 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 @@ -44,11 +44,11 @@ public class InventoryManager { list.forEach(inv -> { String folder="gui"+(inv instanceof ClassConfirmation?"/class-confirm":""); - MMOCore.plugin.configManager.loadDefaultFile(folder, inv.getId() + ".yml"); try { + MMOCore.plugin.configManager.loadDefaultFile(folder, inv.getId() + ".yml"); inv.reload(new ConfigFile("/"+folder, inv.getId()).getConfig()); } catch (Exception exception) { - MMOCore.log(Level.WARNING, "Could not load inventory '" + inv.getId() + "': " + exception.getMessage()); + MMOCore.log(Level.WARNING, "Could not load inventory '" +(inv instanceof ClassConfirmation?"class-confirm/":""+ inv.getId() + "': " + exception.getMessage())); } }); } From c31a3fcec144790a33a9ca8312b004fdeff2ab70 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 23:09:37 +0100 Subject: [PATCH 10/13] Fixed the bug where player die when joining server. --- .../mmocore/manager/data/yaml/YAMLPlayerDataManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 40926977..cf0eb84a 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 @@ -121,8 +121,9 @@ public class YAMLPlayerDataManager extends PlayerDataManager { data.setMana(config.contains("mana") ? config.getDouble("mana") : data.getStats().getStat("MAX_MANA")); data.setStamina(config.contains("stamina") ? config.getDouble("stamina") : data.getStats().getStat("MAX_STAMINA")); data.setStellium(config.contains("stellium") ? config.getDouble("stellium") : data.getStats().getStat("MAX_STELLIUM")); - double health=config.contains("health") ? config.getDouble("health") : data.getStats().getStat("MAX_HEALTH"); - health=Math.min(health,data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); + double health = config.contains("health") ? config.getDouble("health") : data.getStats().getStat("MAX_HEALTH"); + health = health == 0 ? 20 : health; + health = Math.min(health, data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); data.getPlayer().setHealth(health); data.setFullyLoaded(); } @@ -148,7 +149,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager { data.mapSkillTreePoints().forEach((key1, value) -> config.set("skill-tree-points." + key1, value)); config.set("skill-tree-reallocation-points", data.getSkillTreeReallocationPoints()); config.set("skill", null); - config.set("health",data.getHealth()); + config.set("health", data.getHealth()); config.set("mana", data.getMana()); config.set("stellium", data.getStellium()); config.set("stamina", data.getStamina()); From d7db3f6d681712ff3428bd4ad84f1100a3a0d52d Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 23:23:11 +0100 Subject: [PATCH 11/13] Fixed bug related to fetching player health when he is offline. --- .../main/java/net/Indyuce/mmocore/api/player/PlayerData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 abb701a0..0479bd9a 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 @@ -950,7 +950,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc @Override public double getHealth() { - return getPlayer() == null ? health : getPlayer().getHealth(); + return isOnline() ? getPlayer().getHealth():health ; } @Override From 8192d6caa8f35794aa137a64250bc3040924ec60 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 2 Apr 2023 23:41:22 +0100 Subject: [PATCH 12/13] Test --- .../src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java | 1 + 1 file changed, 1 insertion(+) 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 94c06980..8a85f229 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 @@ -851,6 +851,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc new ConfigMessage("level-up").addPlaceholders("level", String.valueOf(level)).send(getPlayer()); MMOCore.plugin.soundManager.getSound(SoundEvent.LEVEL_UP).playTo(getPlayer()); new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT); + //TEST } getStats().updateStats(); } From e6cfde3ce79c17bf985ae845f2060fb38771bac9 Mon Sep 17 00:00:00 2001 From: Taner <11832079-Tanerx@users.noreply.gitlab.com> Date: Mon, 3 Apr 2023 15:11:40 +0000 Subject: [PATCH 13/13] Update Crowdin configuration file --- crowdin.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crowdin.yml b/crowdin.yml index 05dfa962..fee22a6d 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -3,3 +3,5 @@ files: translation: /**/MMOCore-Dist/src/main/resources/default/translation/%language%/gui/%file_name%.%file_extension% - source: MMOCore-Dist/src/main/resources/default/messages.yml translation: /**/MMOCore-Dist/src/main/resources/default/translation/%language%/%file_name%.%file_extension% + - source: MMOCore-Dist/src/main/resources/default/gui/class-confirm/*.yml + translation: /**/MMOCore-Dist/src/main/resources/default/translation/%language%/gui/class-confirm/%file_name%.%file_extension%