forked from Upstream/mmocore
Fixed MMOloaders
This commit is contained in:
parent
83ab7ef523
commit
b38fda4aa7
@ -52,7 +52,7 @@ public class BlockInfo {
|
||||
|
||||
for (String key : list)
|
||||
try {
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load trigger '" + key + "' from block info '" + block.generateKey() + "': " + exception.getMessage());
|
||||
|
@ -1,85 +1,45 @@
|
||||
package net.Indyuce.mmocore.api.load;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.block.BlockType;
|
||||
import net.Indyuce.mmocore.api.block.SkullBlockType;
|
||||
import net.Indyuce.mmocore.api.block.VanillaBlockType;
|
||||
import net.Indyuce.mmocore.api.quest.objective.*;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.*;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.*;
|
||||
import net.Indyuce.mmocore.loot.chest.condition.*;
|
||||
import org.apache.commons.math3.analysis.function.Exp;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
|
||||
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.DropTableDropItem;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.GoldDropItem;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.NoteDropItem;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.VanillaDropItem;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.api.quest.objective.ClickonObjective;
|
||||
import net.Indyuce.mmocore.api.quest.objective.GoToObjective;
|
||||
import net.Indyuce.mmocore.api.quest.objective.KillMobObjective;
|
||||
import net.Indyuce.mmocore.api.quest.objective.MineBlockObjective;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.CommandTrigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.ExperienceTrigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.ItemTrigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.ManaTrigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.MessageTrigger;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.SoundTrigger;
|
||||
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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import net.Indyuce.mmocore.loot.chest.condition.*;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class DefaultMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
if (config.getKey().equals("from")) {
|
||||
String source = config.getString("source");
|
||||
ConfigFile configFile = new ConfigFile("triggers");
|
||||
if (!configFile.getConfig().contains(source)) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Couldn't find " + source + " in experience-sources.yml");
|
||||
return null;
|
||||
}
|
||||
List<Trigger> list = new ArrayList<>();
|
||||
for (String trigger : configFile.getConfig().getStringList(source)) {
|
||||
list.addAll(loadTrigger(new MMOLineConfig(trigger)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
if (config.getKey().equals("message"))
|
||||
return Arrays.asList(new MessageTrigger(config));
|
||||
return new MessageTrigger(config);
|
||||
|
||||
if (config.getKey().equals("sound") || config.getKey().equals("playsound"))
|
||||
return Arrays.asList(new SoundTrigger(config));
|
||||
return new SoundTrigger(config);
|
||||
|
||||
if (config.getKey().equals("mana"))
|
||||
return Arrays.asList(new ManaTrigger(config));
|
||||
return new ManaTrigger(config);
|
||||
|
||||
if (config.getKey().equals("stamina"))
|
||||
return Arrays.asList(new StaminaTrigger(config));
|
||||
return new StaminaTrigger(config);
|
||||
|
||||
if (config.getKey().equals("stellium"))
|
||||
return Arrays.asList(new StelliumTrigger(config));
|
||||
return new StelliumTrigger(config);
|
||||
|
||||
if (config.getKey().equals("command"))
|
||||
return Arrays.asList(new CommandTrigger(config));
|
||||
return new CommandTrigger(config);
|
||||
|
||||
if (config.getKey().equals("item") || config.getKey().equals("vanilla"))
|
||||
return Arrays.asList(new ItemTrigger(config));
|
||||
return new ItemTrigger(config);
|
||||
|
||||
if (config.getKey().equals("exp") || config.getKey().equals("experience"))
|
||||
return Arrays.asList(new ExperienceTrigger(config));
|
||||
return new ExperienceTrigger(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -119,111 +79,80 @@ public class DefaultMMOLoader extends MMOLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Condition> loadCondition(MMOLineConfig config) {
|
||||
if (config.getKey().equals("from")) {
|
||||
String source = config.getString("source");
|
||||
ConfigFile configFile = new ConfigFile("conditions");
|
||||
if (!configFile.getConfig().contains(source)) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Couldn't find " + source + " in experience-sources.yml");
|
||||
return null;
|
||||
}
|
||||
List<Condition> list = new ArrayList<>();
|
||||
for (String condition : configFile.getConfig().getStringList(source)) {
|
||||
list.addAll(loadCondition(new MMOLineConfig(condition)));
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
public Condition loadCondition(MMOLineConfig config) {
|
||||
if (config.getKey().equals("distance"))
|
||||
return Arrays.asList(new DistanceCondition(config));
|
||||
return new DistanceCondition(config);
|
||||
|
||||
if (config.getKey().equals("world"))
|
||||
return Arrays.asList(new WorldCondition(config));
|
||||
return new WorldCondition(config);
|
||||
|
||||
if (config.getKey().equals("biome"))
|
||||
return Arrays.asList(new BiomeCondition(config));
|
||||
return new BiomeCondition(config);
|
||||
|
||||
if (config.getKey().equals("level"))
|
||||
return Arrays.asList(new LevelCondition(config));
|
||||
return new LevelCondition(config);
|
||||
|
||||
if (config.getKey().equals("permission"))
|
||||
return Arrays.asList(new PermissionCondition(config));
|
||||
return new PermissionCondition(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<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;
|
||||
}
|
||||
List<ExperienceSource<?>> list = new ArrayList<>();
|
||||
for (String expSource : configFile.getConfig().getStringList(source)) {
|
||||
list.addAll(loadExperienceSource(new MMOLineConfig(expSource), dispenser));
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
if (config.getKey().equals("resource"))
|
||||
return Arrays.asList(new ResourceExperienceSource(dispenser, config));
|
||||
return new ResourceExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("climb"))
|
||||
return Arrays.asList(new ClimbExperienceSource(dispenser, config));
|
||||
return new ClimbExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("eat")) {
|
||||
return Arrays.asList(new EatExperienceSource(dispenser, config));
|
||||
}
|
||||
if (config.getKey().equals("eat"))
|
||||
return new EatExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("damagedealt"))
|
||||
return Arrays.asList(new DamageDealtExperienceSource(dispenser, config));
|
||||
return new DamageDealtExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("damagetaken"))
|
||||
return Arrays.asList(new DamageTakenExperienceSource(dispenser, config));
|
||||
return new DamageTakenExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("move"))
|
||||
return Arrays.asList(new MoveExperienceSource(dispenser, config));
|
||||
return new MoveExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("play"))
|
||||
return Arrays.asList(new PlayExperienceSource(dispenser, config));
|
||||
return new PlayExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("projectile"))
|
||||
return Arrays.asList(new ProjectileExperienceSource(dispenser, config));
|
||||
return new ProjectileExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("ride"))
|
||||
return Arrays.asList(new RideExperienceSource(dispenser, config));
|
||||
return new RideExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("tame"))
|
||||
return Arrays.asList(new TameExperienceSource(dispenser, config));
|
||||
return new TameExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("killmob"))
|
||||
return Arrays.asList(new KillMobExperienceSource(dispenser, config));
|
||||
return new KillMobExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("mineblock"))
|
||||
return Arrays.asList(new MineBlockExperienceSource(dispenser, config));
|
||||
return new MineBlockExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("placeblock"))
|
||||
return Arrays.asList(new PlaceBlockExperienceSource(dispenser, config));
|
||||
return new PlaceBlockExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("brewpotion"))
|
||||
return Arrays.asList(new BrewPotionExperienceSource(dispenser, config));
|
||||
return new BrewPotionExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("smeltitem"))
|
||||
return Arrays.asList(new SmeltItemExperienceSource(dispenser, config));
|
||||
return new SmeltItemExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("enchantitem"))
|
||||
return Arrays.asList(new EnchantItemExperienceSource(dispenser, config));
|
||||
return new EnchantItemExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("repairitem"))
|
||||
return Arrays.asList(new RepairItemExperienceSource(dispenser, config));
|
||||
return new RepairItemExperienceSource(dispenser, config);
|
||||
|
||||
if (config.getKey().equals("craftitem"))
|
||||
return Arrays.asList(new CraftItemExperienceSource(dispenser, config));
|
||||
return new CraftItemExperienceSource(dispenser, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -2,16 +2,14 @@ package net.Indyuce.mmocore.api.load;
|
||||
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.block.BlockType;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MMOLoader was initially an interface but it is now a
|
||||
* class so devs do not have to add a new method
|
||||
@ -19,11 +17,11 @@ import java.util.List;
|
||||
*/
|
||||
public class MMOLoader {
|
||||
|
||||
public List<Condition> loadCondition(MMOLineConfig config) {
|
||||
public Condition loadCondition(MMOLineConfig config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -35,7 +33,7 @@ public class MMOLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ExperienceSource<?>> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.experience.ExpCurve;
|
||||
import net.Indyuce.mmocore.experience.ExperienceObject;
|
||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.loot.chest.particle.CastingParticle;
|
||||
import net.Indyuce.mmocore.player.playerclass.ClassTrigger;
|
||||
import net.Indyuce.mmocore.player.playerclass.ClassTriggerType;
|
||||
@ -27,7 +26,6 @@ import net.Indyuce.mmocore.player.stats.StatInfo;
|
||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
@ -159,9 +157,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
||||
if (config.contains("main-exp-sources.yml")) {
|
||||
for (String key : config.getStringList("main-exp-sources.yml"))
|
||||
try {
|
||||
List<ExperienceSource<?>> list = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this);
|
||||
for (ExperienceSource source : list)
|
||||
MMOCore.plugin.experience.registerSource(source);
|
||||
MMOCore.plugin.experience.registerSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp source '" + key + "' from class '"
|
||||
+ id + "': " + exception.getMessage());
|
||||
|
@ -25,7 +25,7 @@ public class EventTrigger {
|
||||
|
||||
for (String format : list)
|
||||
try {
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format)));
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load trigger '" + format + "' from event trigger '" + event + "': " + exception.getMessage());
|
||||
|
@ -30,7 +30,7 @@ public abstract class Objective {
|
||||
|
||||
for (String key : config.getStringList("triggers"))
|
||||
try {
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load trigger '" + key + "' from objective '" + id + "': " + exception.getMessage());
|
||||
|
@ -1,25 +1,22 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.*;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.*;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MythicMobsMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill"))
|
||||
return Arrays.asList(new MythicSkillTrigger(config));
|
||||
return new MythicSkillTrigger(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -45,12 +42,12 @@ public class MythicMobsMMOLoader extends MMOLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExperienceSource<?>> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("killmythicmob"))
|
||||
return Arrays.asList(new KillMythicMobExperienceSource(dispenser, config));
|
||||
return new KillMythicMobExperienceSource(dispenser, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
|
||||
return Arrays.asList(new KillMythicFactionExperienceSource(dispenser, config));
|
||||
return new KillMythicFactionExperienceSource(dispenser, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -1,20 +1,17 @@
|
||||
package net.Indyuce.mmocore.comp.region;
|
||||
|
||||
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
||||
|
||||
public class WorldGuardMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public List<Condition> loadCondition(MMOLineConfig config) {
|
||||
@Override
|
||||
public Condition loadCondition(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equals("region"))
|
||||
return Arrays.asList(new RegionCondition(config));
|
||||
if (config.getKey().equals("region"))
|
||||
return new RegionCondition(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,17 @@
|
||||
package net.Indyuce.mmocore.comp.vault;
|
||||
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
|
||||
public class VaultMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("money"))
|
||||
return Arrays.asList(new MoneyTrigger(config));
|
||||
if (config.getKey().equalsIgnoreCase("money"))
|
||||
return new MoneyTrigger(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -15,7 +14,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
@ -69,10 +67,7 @@ public class Profession extends PostLoadObject implements ExperienceObject {
|
||||
if (config.contains("exp-sources"))
|
||||
for (String key : config.getStringList("exp-sources"))
|
||||
try {
|
||||
List<ExperienceSource<?>> experienceSourceList=MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this);
|
||||
for(ExperienceSource experienceSource: experienceSourceList) {
|
||||
MMOCore.plugin.experience.registerSource(experienceSource);
|
||||
}
|
||||
MMOCore.plugin.experience.registerSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not register exp source '" + key + "' from profession '" + id + "': " + exception.getMessage());
|
||||
|
@ -63,7 +63,7 @@ public class ExperienceItem {
|
||||
triggers = new ArrayList<>();
|
||||
|
||||
for (String triggerFormat : config.getStringList("triggers"))
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(triggerFormat)));
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(triggerFormat)));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -100,7 +100,7 @@ public abstract class GeneratedInventory extends PluginInventory {
|
||||
return;
|
||||
|
||||
if (item instanceof TriggerItem)
|
||||
((TriggerItem) item).getTriggers().forEach(trigger->trigger.apply(getPlayerData()));
|
||||
((TriggerItem) item).getTrigger().apply(getPlayerData());
|
||||
else
|
||||
whenClicked(event, item);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import java.util.List;
|
||||
|
||||
public class TriggerItem extends InventoryItem {
|
||||
private final List<Trigger> triggers;
|
||||
private final Trigger triggers;
|
||||
|
||||
public TriggerItem(ConfigurationSection config, String format) {
|
||||
super(config);
|
||||
@ -22,7 +22,7 @@ public class TriggerItem extends InventoryItem {
|
||||
return new Placeholders();
|
||||
}
|
||||
|
||||
public List<Trigger> getTriggers() {
|
||||
public Trigger getTrigger() {
|
||||
return triggers;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class DropTable extends PostLoadObject {
|
||||
}
|
||||
for (String key : conditionsList)
|
||||
try {
|
||||
conditions.addAll(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));
|
||||
conditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load condition '" + key + "' from table '" + id + "': " + exception.getMessage());
|
||||
|
@ -1,78 +1,76 @@
|
||||
package net.Indyuce.mmocore.manager;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.block.BlockType;
|
||||
import net.Indyuce.mmocore.api.load.DefaultMMOLoader;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.Indyuce.mmocore.api.block.BlockType;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import net.Indyuce.mmocore.loot.chest.condition.Condition;
|
||||
import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import net.Indyuce.mmocore.api.load.DefaultMMOLoader;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
||||
public class MMOLoadManager {
|
||||
private final List<MMOLoader> loaders = new ArrayList<>();
|
||||
private final List<MMOLoader> loaders = new ArrayList<>();
|
||||
|
||||
public MMOLoadManager() {
|
||||
loaders.add(new DefaultMMOLoader());
|
||||
}
|
||||
public MMOLoadManager() {
|
||||
loaders.add(new DefaultMMOLoader());
|
||||
}
|
||||
|
||||
public void registerLoader(MMOLoader loader) {
|
||||
Validate.notNull(loader, "Loader must not be null");
|
||||
public void registerLoader(MMOLoader loader) {
|
||||
Validate.notNull(loader, "Loader must not be null");
|
||||
|
||||
loaders.add(loader);
|
||||
}
|
||||
loaders.add(loader);
|
||||
}
|
||||
|
||||
public List<Condition> loadCondition(MMOLineConfig config) {
|
||||
return load(List.class, config, loader -> loader.loadCondition(config));
|
||||
}
|
||||
public Condition loadCondition(MMOLineConfig config) {
|
||||
return load("condition", config, loader -> loader.loadCondition(config));
|
||||
}
|
||||
|
||||
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
|
||||
return load(Objective.class, config, loader -> loader.loadObjective(config, section));
|
||||
}
|
||||
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
|
||||
return load("objective", config, loader -> loader.loadObjective(config, section));
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a List of Experience Source as one experience source can be linked to others.
|
||||
Loading one exp source can in fact oad multiples if they are linked
|
||||
*/
|
||||
@Deprecated
|
||||
public List<ExperienceSource<?>> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
return load(List.class, config, loader -> loader.loadExperienceSource(config, dispenser));
|
||||
}
|
||||
/**
|
||||
* Returns a List of Experience Source as one experience source can be linked to others.
|
||||
* Loading one exp source can in fact oad multiples if they are linked
|
||||
*/
|
||||
@Deprecated
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
return load("exp source", config, loader -> loader.loadExperienceSource(config, dispenser));
|
||||
}
|
||||
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
return load(List.class, config, loader -> loader.loadTrigger(config));
|
||||
}
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
return load("trigger", config, loader -> loader.loadTrigger(config));
|
||||
}
|
||||
|
||||
public DropItem loadDropItem(MMOLineConfig config) {
|
||||
return load(DropItem.class, config, loader -> loader.loadDropItem(config));
|
||||
}
|
||||
public DropItem loadDropItem(MMOLineConfig config) {
|
||||
return load("drop item", config, loader -> loader.loadDropItem(config));
|
||||
}
|
||||
|
||||
public BlockType loadBlockType(MMOLineConfig config) {
|
||||
return load(BlockType.class, config, loader -> loader.loadBlockType(config));
|
||||
}
|
||||
public BlockType loadBlockType(MMOLineConfig config) {
|
||||
return load("block type", config, loader -> loader.loadBlockType(config));
|
||||
}
|
||||
|
||||
private <T> T load(Class<T> c, MMOLineConfig config, Function<MMOLoader, T> func) {
|
||||
private <T> T load(String objName, MMOLineConfig config, Function<MMOLoader, T> func) {
|
||||
|
||||
for (MMOLoader loader : loaders)
|
||||
try {
|
||||
T found = func.apply(loader);
|
||||
if (found != null)
|
||||
return found;
|
||||
} catch (IllegalArgumentException | JsonParseException | IndexOutOfBoundsException exception) {
|
||||
throw new IllegalArgumentException(exception.getMessage());
|
||||
}
|
||||
for (MMOLoader loader : loaders)
|
||||
try {
|
||||
T found = func.apply(loader);
|
||||
if (found != null)
|
||||
return found;
|
||||
} catch (IllegalArgumentException | JsonParseException | IndexOutOfBoundsException exception) {
|
||||
throw new IllegalArgumentException(exception.getMessage());
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Could not match any " + c.getSimpleName() + " to '" + config.getKey() + "' in database");
|
||||
}
|
||||
throw new IllegalArgumentException("Could not match any " + objName + " to '" + config.getKey() + "' in database");
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public class CustomBlockManager extends SpecificProfessionManager {
|
||||
|
||||
for (String key : MMOCore.plugin.getConfig().getStringList("custom-mine-conditions"))
|
||||
try {
|
||||
customMineConditions.addAll(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));
|
||||
customMineConditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load custom mining condition '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class FishingManager extends SpecificProfessionManager {
|
||||
|
||||
for (String str : list)
|
||||
try {
|
||||
conditions.addAll(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(str)));
|
||||
conditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(str)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load condition '" + str + "' from fishing drop table '" + id + "': " + exception.getMessage());
|
||||
|
@ -60,7 +60,7 @@ public class Waypoint extends PostLoadObject implements Unlockable {
|
||||
List<String> conditions = config.getStringList("dynamic-conditions");
|
||||
for (String condition : conditions)
|
||||
try {
|
||||
dynamicUseConditions.addAll(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(condition)));
|
||||
dynamicUseConditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(condition)));
|
||||
} catch (RuntimeException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load condition '" + condition + "' from waypoint '" + id + "': " + exception.getMessage());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user