Improved console error warnings

This commit is contained in:
Indyuce 2020-05-01 19:07:00 +02:00
parent 1ce01d7be0
commit dc97cbeac9
14 changed files with 89 additions and 112 deletions

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.block;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Location; import org.bukkit.Location;
@ -12,7 +13,6 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.DropTable; import net.Indyuce.mmocore.api.droptable.DropTable;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.loot.LootBuilder; import net.Indyuce.mmocore.api.loot.LootBuilder;
import net.Indyuce.mmocore.api.quest.trigger.ExperienceTrigger; import net.Indyuce.mmocore.api.quest.trigger.ExperienceTrigger;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;
@ -48,8 +48,9 @@ public class BlockInfo {
for (String key : list) for (String key : list)
try { try {
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key))); triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("BlockRegen", "trigger"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load trigger '" + key + "' from block info '" + block.generateKey() + "': " + exception.getMessage());
} }
} }

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.droptable;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -10,48 +11,54 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem; import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.load.MMOLoadException; import net.Indyuce.mmocore.api.load.PostLoadObject;
import net.Indyuce.mmocore.api.loot.LootBuilder; import net.Indyuce.mmocore.api.loot.LootBuilder;
import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.api.MMOLineConfig;
public class DropTable { public class DropTable extends PostLoadObject {
private final String id; private final String id;
private final Set<DropItem> drops = new LinkedHashSet<>(); private final Set<DropItem> drops = new LinkedHashSet<>();
/* public DropTable(ConfigurationSection config) {
* cached in order to load other items. super(config);
*/
private ConfigurationSection loaded;
public DropTable(ConfigurationSection section) { id = config.getName();
id = section.getName(); }
loaded = section;
public DropTable(String id) {
super(null);
this.id = id;
} }
/* /*
* must be loaded after since drop tables must be initialized first * must be loaded after since drop tables must be initialized first
* otherwise no reference for drop table drop items. * otherwise no reference for drop table drop items.
*/ */
public DropTable load() { @Override
protected void whenPostLoaded(ConfigurationSection config) {
List<String> list = loaded.getStringList("items"); List<String> list = config.getStringList("items");
Validate.notNull(list, "Could not find drop item list"); Validate.notNull(list, "Could not find drop item list");
for (String key : list) for (String key : list)
try { try {
drops.add(MMOCore.plugin.loadManager.loadDropItem(new MMOLineConfig(key))); drops.add(MMOCore.plugin.loadManager.loadDropItem(new MMOLineConfig(key)));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("DropTables", "drop item"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load drop item '" + key + "' from table '" + id + "': " + exception.getMessage());
} }
loaded = null;
return this;
} }
public String getId() { public String getId() {
return id; return id;
} }
public void registerDropItem(DropItem item) {
Validate.notNull(item);
drops.add(item);
}
public List<ItemStack> collect(LootBuilder builder) { public List<ItemStack> collect(LootBuilder builder) {
for (DropItem item : drops) for (DropItem item : drops)

View File

@ -4,18 +4,19 @@ import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.potion.PotionType; import org.bukkit.potion.PotionType;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLoadException; import net.Indyuce.mmocore.api.load.PostLoadObject;
import net.Indyuce.mmocore.api.player.ExpCurve; import net.Indyuce.mmocore.api.player.ExpCurve;
import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.api.MMOLineConfig;
public class Profession { public class Profession extends PostLoadObject {
private final String id, name; private final String id, name;
private final ExpCurve expCurve; private final ExpCurve expCurve;
@ -25,15 +26,10 @@ public class Profession {
*/ */
private final LinearValue experience; private final LinearValue experience;
/*
* removed when loaded
*/
private FileConfiguration config;
public Profession(String id, FileConfiguration config) { public Profession(String id, FileConfiguration config) {
this.id = id.toLowerCase().replace("_", "-").replace(" ", "-"); super(config);
this.config = config;
this.id = id.toLowerCase().replace("_", "-").replace(" ", "-");
this.name = config.getString("name"); this.name = config.getString("name");
Validate.notNull(name, "Could not load name"); Validate.notNull(name, "Could not load name");
@ -46,15 +42,17 @@ public class Profession {
for (String key : config.getStringList("exp-sources")) for (String key : config.getStringList("exp-sources"))
try { try {
MMOCore.plugin.professionManager.registerExpSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this)); MMOCore.plugin.professionManager.registerExpSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("PlayerProfessions", "exp source"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not register exp source '" + key + "' from profession '" + id + "': " + exception.getMessage());
} }
} }
/* /*
* drop tables must be loaded after professions are initialized * drop tables must be loaded after professions are initialized
*/ */
public void loadOptions() { @Override
protected void whenPostLoaded(ConfigurationSection config) {
if (config.contains("on-fish")) if (config.contains("on-fish"))
MMOCore.plugin.fishingManager.loadDropTables(config.getConfigurationSection("on-fish")); MMOCore.plugin.fishingManager.loadDropTables(config.getConfigurationSection("on-fish"));
@ -103,11 +101,10 @@ public class Profession {
// MMOCore.plugin.alchemyManager.registerEffectWeight(PotionEffectType.getByName(key.toUpperCase().replace("-", // MMOCore.plugin.alchemyManager.registerEffectWeight(PotionEffectType.getByName(key.toUpperCase().replace("-",
// "_").replace(" ", "_")), config.getDouble("effect-weight." + key)); // "_").replace(" ", "_")), config.getDouble("effect-weight." + key));
// } catch (IllegalArgumentException exception) { // } catch (IllegalArgumentException exception) {
// MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not read // MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not
// read
// potion effect type from " + key); // potion effect type from " + key);
// } // }
config = null;
} }
public String getId() { public String getId() {

View File

@ -1,30 +0,0 @@
package net.Indyuce.mmocore.api.load;
import java.util.logging.Level;
import net.Indyuce.mmocore.MMOCore;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MMOLoadException extends IllegalArgumentException {
private static final long serialVersionUID = -8839506644440697800L;
private MMOLineConfig config;
public MMOLoadException(String message) {
super(message);
}
public MMOLoadException(MMOLineConfig config, Exception exception) {
super(exception.getMessage());
this.config = config;
}
public boolean hasConfig() {
return config != null;
}
public void printConsole(String prefix, String obj) {
MMOCore.plugin.getLogger().log(Level.WARNING, "[" + prefix + "] " + (hasConfig() ? "Could not load " + obj + " '" + config.toString() + "': " : "") + getMessage());
}
}

View File

@ -25,7 +25,6 @@ import com.mojang.authlib.properties.Property;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.load.PostLoadObject; import net.Indyuce.mmocore.api.load.PostLoadObject;
import net.Indyuce.mmocore.api.player.ExpCurve; import net.Indyuce.mmocore.api.player.ExpCurve;
import net.Indyuce.mmocore.api.player.profess.event.EventTrigger; import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
@ -98,7 +97,8 @@ public class PlayerClass extends PostLoadObject {
stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")), stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")),
new LinearValue(config.getConfigurationSection("attributes." + key))); new LinearValue(config.getConfigurationSection("attributes." + key)));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load stat info '" + key + "': " + exception.getMessage()); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load stat info '" + key + "' from class '" + id + "': " + exception.getMessage());
} }
if (config.contains("skills")) if (config.contains("skills"))
@ -107,7 +107,8 @@ public class PlayerClass extends PostLoadObject {
Validate.isTrue(MMOCore.plugin.skillManager.has(key), "Could not find skill " + key); Validate.isTrue(MMOCore.plugin.skillManager.has(key), "Could not find skill " + key);
skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key).newSkillInfo(config.getConfigurationSection("skills." + key))); skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key).newSkillInfo(config.getConfigurationSection("skills." + key)));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load skill info '" + key + "': " + exception.getMessage()); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load skill info '" + key + "' from class '" + id + "': " + exception.getMessage());
} }
castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle")) castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle"))
@ -118,7 +119,8 @@ public class PlayerClass extends PostLoadObject {
try { try {
setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")), config.getBoolean("options." + key)); setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")), config.getBoolean("options." + key));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not read class option from '" + key + "'"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
} }
if (config.contains("main-exp-sources")) if (config.contains("main-exp-sources"))
@ -127,8 +129,9 @@ public class PlayerClass extends PostLoadObject {
ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), null); ExperienceSource<?> source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), null);
source.setClass(this); source.setClass(this);
MMOCore.plugin.professionManager.registerExpSource(source); MMOCore.plugin.professionManager.registerExpSource(source);
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("PlayerClasses:" + id, "exp source"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load exp source '" + key + "' from class '" + id + "': " + exception.getMessage());
} }
if (config.contains("triggers")) if (config.contains("triggers"))

View File

@ -3,11 +3,11 @@ package net.Indyuce.mmocore.api.player.profess.event;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.api.MMOLineConfig;
@ -23,8 +23,9 @@ public class EventTrigger {
for (String format : list) for (String format : list)
try { try {
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format))); triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format)));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("EventTrigger:" + event, "trigger"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load trigger '" + format + "' from event trigger '" + event + "': " + exception.getMessage());
} }
} }

View File

@ -13,7 +13,6 @@ import org.bukkit.configuration.file.FileConfiguration;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession; import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.load.PostLoadObject; import net.Indyuce.mmocore.api.load.PostLoadObject;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.objective.Objective; import net.Indyuce.mmocore.api.quest.objective.Objective;
@ -64,8 +63,9 @@ public class Quest extends PostLoadObject {
Validate.notNull(format, "Objective is missing format"); Validate.notNull(format, "Objective is missing format");
objectives.add(MMOCore.plugin.loadManager.loadObjective(new MMOLineConfig(format), section)); objectives.add(MMOCore.plugin.loadManager.loadObjective(new MMOLineConfig(format), section));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("Quests:" + id, "objective"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load objective '" + key + "' from quest '" + id + "': " + exception.getMessage());
} }
} }

View File

@ -2,13 +2,13 @@ package net.Indyuce.mmocore.api.quest.objective;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress; import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress; import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;
@ -17,7 +17,7 @@ import net.mmogroup.mmolib.api.MMOLineConfig;
public abstract class Objective { public abstract class Objective {
private final String id, lore; private final String id, lore;
private BarColor barColor; private final BarColor barColor;
private final List<Trigger> triggers = new ArrayList<>(); private final List<Trigger> triggers = new ArrayList<>();
public Objective(ConfigurationSection config) { public Objective(ConfigurationSection config) {
@ -27,19 +27,15 @@ public abstract class Objective {
Validate.notNull(lore, "Could not find objective lore"); Validate.notNull(lore, "Could not find objective lore");
Validate.notNull(config.getStringList("triggers"), "Could not load trigger list"); Validate.notNull(config.getStringList("triggers"), "Could not load trigger list");
try { String format = config.getString("bar-color", "PURPLE");
String format = config.getString("bar-color");
Validate.notNull(format);
barColor = BarColor.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_")); barColor = BarColor.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
} catch (IllegalArgumentException exeption) {
barColor = BarColor.PURPLE;
}
for (String key : config.getStringList("triggers")) for (String key : config.getStringList("triggers"))
try { try {
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key))); triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("Objectives:" + id, "trigger"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load trigger '" + key + "' from objective '" + id + "': " + exception.getMessage());
} }
} }

View File

@ -10,14 +10,14 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.item.ConfigItem; import net.Indyuce.mmocore.api.util.item.ConfigItem;
public class ConfigItemManager { public class ConfigItemManager {
private Map<String, ConfigItem> map = new HashMap<>(); private final Map<String, ConfigItem> map = new HashMap<>();
public ConfigItemManager(FileConfiguration config) { public ConfigItemManager(FileConfiguration config) {
for (String key : config.getKeys(false)) for (String key : config.getKeys(false))
try { try {
register(new ConfigItem(config.getConfigurationSection(key))); register(new ConfigItem(config.getConfigurationSection(key)));
} catch (NullPointerException | IllegalArgumentException exception) { } catch (NullPointerException | IllegalArgumentException exception) {
MMOCore.plugin.getLogger().log(Level.INFO, "Could not load config item " + key); MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load config item " + key);
} }
} }

View File

@ -24,7 +24,6 @@ import net.Indyuce.mmocore.api.block.SkullBlockType;
import net.Indyuce.mmocore.api.block.VanillaBlockType; import net.Indyuce.mmocore.api.block.VanillaBlockType;
import net.Indyuce.mmocore.api.droptable.condition.Condition; import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance; import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.api.MMOLineConfig;
@ -126,8 +125,8 @@ public class CustomBlockManager extends MMOManager {
for (String key : MMOCore.plugin.getConfig().getStringList("custom-mine-conditions")) for (String key : MMOCore.plugin.getConfig().getStringList("custom-mine-conditions"))
try { try {
customMineConditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key))); customMineConditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("CustomMine", "condition"); MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load custom mining condition '" + key + "': " + exception.getMessage());
} }
} }

View File

@ -47,8 +47,11 @@ public class DropTableManager extends MMOManager {
if (obj instanceof String) if (obj instanceof String)
return get((String) obj); return get((String) obj);
if (obj instanceof ConfigurationSection) if (obj instanceof ConfigurationSection) {
return new DropTable((ConfigurationSection) obj).load(); DropTable table = new DropTable((ConfigurationSection) obj);
table.postLoad();
return table;
}
throw new IllegalArgumentException("Could not parse drop table."); throw new IllegalArgumentException("Could not parse drop table.");
} }
@ -70,7 +73,7 @@ public class DropTableManager extends MMOManager {
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load drop table file '" + file.getName() + "': " + exception.getMessage()); MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load drop table file '" + file.getName() + "': " + exception.getMessage());
} }
map.values().forEach(table -> table.load()); map.values().forEach(table -> table.postLoad());
} }
@Override @Override

View File

@ -15,7 +15,6 @@ import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.experience.Profession; import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.DefaultMMOLoader; import net.Indyuce.mmocore.api.load.DefaultMMOLoader;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.load.MMOLoader; import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective; import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger;
@ -67,10 +66,11 @@ public class MMOLoadManager {
if (found != null) if (found != null)
return found; return found;
} catch (IllegalArgumentException | JsonParseException | IndexOutOfBoundsException exception) { } catch (IllegalArgumentException | JsonParseException | IndexOutOfBoundsException exception) {
throw new MMOLoadException("Could not load '" + config.toString() + "': " + exception.getMessage()); throw new IllegalArgumentException("Could not load '" + config.toString() + "': " + exception.getMessage());
} }
} }
throw new MMOLoadException("Could not load '" + config.toString() + "': Could not find corresponding " + c.getSimpleName() + " in database"); throw new IllegalArgumentException(
"Could not load '" + config.toString() + "': Could not find corresponding " + c.getSimpleName() + " in database");
} }
} }

View File

@ -16,7 +16,6 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.condition.Condition; import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance; import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
import net.Indyuce.mmocore.api.droptable.dropitem.fishing.FishingDropItem; import net.Indyuce.mmocore.api.droptable.dropitem.fishing.FishingDropItem;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.manager.MMOManager; import net.Indyuce.mmocore.manager.MMOManager;
import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.api.MMOLineConfig;
@ -62,8 +61,9 @@ public class FishingManager extends MMOManager {
for (String str : list) for (String str : list)
try { try {
conditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(str))); conditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(str)));
} catch (MMOLoadException exception) { } catch (IllegalArgumentException exception) {
exception.printConsole("FishDropTables", "fish drop item"); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load condition '" + str + "' from fishing drop table '" + id + "': " + exception.getMessage());
} }
} }
@ -75,10 +75,9 @@ public class FishingManager extends MMOManager {
FishingDropItem dropItem = new FishingDropItem(str); FishingDropItem dropItem = new FishingDropItem(str);
maxWeight += dropItem.getWeight(); maxWeight += dropItem.getWeight();
items.add(dropItem); items.add(dropItem);
} catch (MMOLoadException exception) {
exception.printConsole("FishDropTables:" + id, "drop item");
} catch (IllegalArgumentException | IndexOutOfBoundsException exception) { } catch (IllegalArgumentException | IndexOutOfBoundsException exception) {
MMOCore.log(Level.WARNING, "[FishDropTables:" + id + "] Could not load item '" + str + "': " + exception.getMessage()); MMOCore.plugin.getLogger().log(Level.WARNING,
"Could not load item '" + str + "' from fishing drop table '" + id + "': " + exception.getMessage());
} }
Validate.notEmpty(list, "The item list must not be empty."); Validate.notEmpty(list, "The item list must not be empty.");
@ -101,7 +100,8 @@ public class FishingManager extends MMOManager {
for (FishingDropItem item : items) { for (FishingDropItem item : items) {
weight -= item.getWeight(); weight -= item.getWeight();
if(weight <= 0) return item; if (weight <= 0)
return item;
} }
throw new NullPointerException("Could not find item in drop table"); throw new NullPointerException("Could not find item in drop table");

View File

@ -66,7 +66,7 @@ public class ProfessionManager extends MMOManager {
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load profession " + file.getName() + ": " + exception.getMessage()); MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load profession " + file.getName() + ": " + exception.getMessage());
} }
getAll().forEach(profession -> profession.loadOptions()); getAll().forEach(profession -> profession.postLoad());
} }
@Override @Override