added exp tables to classes

This commit is contained in:
Indyuce 2022-01-30 13:00:55 +01:00
parent 333ecf93da
commit 77fd7892ef
4 changed files with 18 additions and 3 deletions

View File

@ -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();

View File

@ -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() {

View File

@ -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();
}

View File

@ -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");
}