exp-sources.yml to have predownloaded exp sources you can refer to anywhere (like experience tables)

This commit is contained in:
Ka0rX 2022-07-27 17:52:36 +02:00
parent 6af4c2ee46
commit eac9cfa74e
5 changed files with 23 additions and 4 deletions

View File

@ -1,5 +1,7 @@
package net.Indyuce.mmocore.api.load;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigFile;
import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.api.block.SkullBlockType;
import net.Indyuce.mmocore.api.block.VanillaBlockType;
@ -30,6 +32,9 @@ import net.Indyuce.mmocore.api.quest.trigger.StaminaTrigger;
import net.Indyuce.mmocore.api.quest.trigger.StelliumTrigger;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import io.lumine.mythic.lib.api.MMOLineConfig;
import org.checkerframework.checker.units.qual.C;
import java.util.logging.Level;
public class DefaultMMOLoader extends MMOLoader {
@ -118,6 +123,19 @@ public class DefaultMMOLoader extends MMOLoader {
@Override
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
if(config.getKey().equals("from")) {
String source=config.getString("source");
ConfigFile configFile= new ConfigFile("exp-sources");
if(!configFile.getConfig().contains(source)) {
MMOCore.plugin.getLogger().log(Level.WARNING,"Couldn't find "+source+" in experience-sources.yml");
return null;
}
for(String expSource: configFile.getConfig().getStringList(source)) {
loadExperienceSource(new MMOLineConfig(expSource),dispenser);
}
}
if (config.getKey().equals("resource"))
return new ResourceExperienceSource(dispenser, config);

View File

@ -156,8 +156,8 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
}
if (config.contains("main-exp-sources")) {
for (String key : config.getStringList("main-exp-sources"))
if (config.contains("main-exp-sources.yml")) {
for (String key : config.getStringList("main-exp-sources.yml"))
try {
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this);
MMOCore.plugin.experience.registerSource(source);

View File

@ -64,8 +64,8 @@ public class Profession extends PostLoadObject implements ExperienceObject {
maxLevel = config.getInt("max-level");
if (config.contains("exp-sources"))
for (String key : config.getStringList("exp-sources"))
if (config.contains("exp-sources.yml"))
for (String key : config.getStringList("exp-sources.yml"))
try {
MMOCore.plugin.experience.registerSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this));
} catch (IllegalArgumentException exception) {

View File

@ -87,6 +87,7 @@ public class ConfigManager {
loadDefaultFile("loot-chests.yml");
loadDefaultFile("commands.yml");
loadDefaultFile("exp-tables.yml");
loadDefaultFile("exp-sources.yml");
loadDefaultFile("guilds.yml");
commandVerbose.reload(MMOCore.plugin.getConfig().getConfigurationSection("command-verbose"));