From 4eb7291a07698a8115e8d65ffd994d707310cf8d Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 3 Feb 2022 00:46:54 -0500 Subject: [PATCH] !init --- pom.xml | 2 +- .../mmocore/api/player/stats/PlayerStats.java | 24 +++++++++++++++++++ .../mmocore/experience/PlayerProfessions.java | 3 +++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 705a347f..61c9cd02 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 net.Indyuce MMOCore - 1.9-SNAPSHOT + 1.9.1-SNAPSHOT MMOCore Offer your players a brand new RPG experience!! diff --git a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java index 2aa6a2c9..3fc2eecd 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java @@ -7,7 +7,12 @@ import io.lumine.mythic.lib.api.stat.modifier.StatModifier; import io.lumine.mythic.lib.player.modifier.ModifierSource; import io.lumine.mythic.lib.player.modifier.ModifierType; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmocore.skill.ClassSkill; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Locale; public class PlayerStats { private final PlayerData data; @@ -37,6 +42,25 @@ public class PlayerStats { return getMap().getInstance(stat); } + /** + * Allows for stat type enum to have dynamic professions. + * ID FORMAT: STAT_TYPE_HERE_PROFESSION_HERE + * + * @param type the type of stat + * @param profession the stat's specific permission + * @return instance of found stat + * @author Ehhthan + */ + @NotNull + public StatInstance getInstance(StatType type, @Nullable Profession profession) { + if (profession == null) + return getInstance(type); + else { + String id = (type.name() + '_' + profession.getId()).replace('-', '_').replace(' ', '_').toUpperCase(Locale.ROOT); + return getInstance(id); + } + } + /* * applies relative attributes on the base stat too */ diff --git a/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java b/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java index 5a257b20..3a6e7651 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java +++ b/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java @@ -10,6 +10,7 @@ import net.Indyuce.mmocore.api.SoundEvent; import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect; import org.apache.commons.lang.Validate; @@ -163,6 +164,8 @@ public class PlayerProfessions { } value = MMOCore.plugin.boosterManager.calculateExp(profession, value); + // Adds functionality for additional experience per profession. + value *= 1 + playerData.getStats().getInstance(StatType.ADDITIONAL_EXPERIENCE, profession).getTotal() / 100; // Display hologram if (hologramLocation != null)