diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index c7842b85..1f85a8ed 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -580,6 +580,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc new SmallParticleEffect(getPlayer(), Particle.SPELL_INSTANT); } getStats().updateStats(); + + // Apply class experience table + if (getProfess().hasExperienceTable()) + getProfess().getExperienceTable().claim(this, level, getProfess()); } refreshVanillaExp(); diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java index d6b1fc20..a7ca96e8 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java @@ -245,9 +245,14 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { return expCurve; } - @Override + @NotNull public ExperienceTable getExperienceTable() { - return expTable; + return Objects.requireNonNull(expTable, "Class has no exp table"); + } + + @Override + public boolean hasExperienceTable() { + return expTable != null; } public ItemStack getIcon() { diff --git a/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java b/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java index e57a64bb..3f9e6cc8 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java +++ b/src/main/java/net/Indyuce/mmocore/experience/ExperienceObject.java @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.experience; import net.Indyuce.mmocore.experience.droptable.ExperienceTable; +import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; @@ -24,6 +25,8 @@ public interface ExperienceObject { /** * @return Table read when leveling up */ - @Nullable + @NotNull ExperienceTable getExperienceTable(); + + boolean hasExperienceTable(); } diff --git a/src/main/java/net/Indyuce/mmocore/experience/Profession.java b/src/main/java/net/Indyuce/mmocore/experience/Profession.java index 8058b847..48d307b0 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/Profession.java +++ b/src/main/java/net/Indyuce/mmocore/experience/Profession.java @@ -10,6 +10,7 @@ import net.Indyuce.mmocore.experience.provider.ProfessionExperienceDispenser; import org.apache.commons.lang.Validate; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; @@ -113,10 +114,12 @@ public class Profession extends PostLoadObject implements ExperienceObject { return experience; } + @Override public boolean hasExperienceTable() { return expTable != null; } + @NotNull public ExperienceTable getExperienceTable() { return Objects.requireNonNull(expTable, "Profession has no exp table"); }