Fixed SpecificExpSource

This commit is contained in:
Indyuce 2022-10-14 13:12:55 +02:00
parent 2c9a9bec4b
commit 60127bcad7

View File

@ -2,40 +2,38 @@ package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import net.Indyuce.mmocore.api.ConfigFile;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.apache.commons.lang.Validate;
import java.util.ArrayList;
import java.util.List;
public class FromExperienceSource extends SpecificExperienceSource {
public class FromExperienceSource extends ExperienceSource {
/**
* Register all the children experience sources defined in experience-source.yml.
*/
private final ArrayList<ExperienceSource> experienceSources = new ArrayList<>();
private final List<ExperienceSource> experienceSources = new ArrayList<>();
public FromExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
super(dispenser, config);
List<String> list = new ConfigFile("exp-sources")
.getConfig().getStringList(config.getString("source"));
super(dispenser);
List<String> list = new ConfigFile("exp-sources").getConfig().getStringList(config.getString("source"));
Validate.isTrue(list.size() != 0, "There is no source matching " + config.getString("key"));
list.stream()
.map(MMOLineConfig::new)
.forEach(mmoLineConfig ->
experienceSources.add(MMOCore.plugin.loadManager.loadExperienceSource(mmoLineConfig, dispenser)));
}
@Override
public ExperienceSourceManager<FromExperienceSource> newManager() {
return new ExperienceSourceManager<FromExperienceSource>() {
return new ExperienceSourceManager<>() {
/**
* Used to register all the children experience sources.
*/