mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-25 00:26:21 +01:00
Improved some config error messages
This commit is contained in:
parent
daa052cabd
commit
7edd17962c
@ -85,7 +85,7 @@ public class PlayerAttribute implements ExperienceObject {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ExperienceTable getExperienceTable() {
|
public ExperienceTable getExperienceTable() {
|
||||||
return Objects.requireNonNull(expTable);
|
return Objects.requireNonNull(expTable, "Attribute has no exp table");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,7 +8,6 @@ import net.Indyuce.mmocore.skill.ClassSkill;
|
|||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class BindSkillTrigger extends Trigger implements Removable {
|
public class BindSkillTrigger extends Trigger implements Removable {
|
||||||
private final RegisteredSkill skill;
|
private final RegisteredSkill skill;
|
||||||
@ -19,14 +18,13 @@ public class BindSkillTrigger extends Trigger implements Removable {
|
|||||||
|
|
||||||
config.validateKeys("skill", "slot");
|
config.validateKeys("skill", "slot");
|
||||||
slot = config.getInt("slot");
|
slot = config.getInt("slot");
|
||||||
skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(config.getString("skill")));
|
skill = MMOCore.plugin.skillManager.getSkillOrThrow(config.getString("skill"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(PlayerData playerData) {
|
public void apply(PlayerData playerData) {
|
||||||
final @Nullable ClassSkill found = playerData.getProfess().getSkill(skill);
|
final @Nullable ClassSkill found = playerData.getProfess().getSkill(skill);
|
||||||
if (found != null)
|
if (found != null) playerData.bindSkill(slot, found);
|
||||||
playerData.bindSkill(slot, found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,7 +8,6 @@ import net.Indyuce.mmocore.skill.ClassSkill;
|
|||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class UnlockSkillTrigger extends Trigger implements Removable {
|
public class UnlockSkillTrigger extends Trigger implements Removable {
|
||||||
private final RegisteredSkill skill;
|
private final RegisteredSkill skill;
|
||||||
@ -17,7 +16,7 @@ public class UnlockSkillTrigger extends Trigger implements Removable {
|
|||||||
super(config);
|
super(config);
|
||||||
|
|
||||||
config.validateKeys("skill");
|
config.validateKeys("skill");
|
||||||
skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(config.getString("skill")));
|
skill = MMOCore.plugin.skillManager.getSkillOrThrow(config.getString("skill"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,7 +15,6 @@ import net.Indyuce.mmocore.party.AbstractParty;
|
|||||||
import net.Indyuce.mmocore.skill.CastableSkill;
|
import net.Indyuce.mmocore.skill.CastableSkill;
|
||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
import net.Indyuce.mmocore.skill.binding.BoundSkillInfo;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -73,7 +72,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
|||||||
|
|
||||||
else if (identifier.startsWith("skill_level_")) {
|
else if (identifier.startsWith("skill_level_")) {
|
||||||
String id = identifier.substring(12);
|
String id = identifier.substring(12);
|
||||||
RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(id), "Could not find skill with ID '" + id + "'");
|
RegisteredSkill skill = MMOCore.plugin.skillManager.getSkillOrThrow(id);
|
||||||
return String.valueOf(playerData.getSkillLevel(skill));
|
return String.valueOf(playerData.getSkillLevel(skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import org.bukkit.persistence.PersistentDataType;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class ClassSelect extends EditableInventory {
|
public class ClassSelect extends EditableInventory {
|
||||||
public ClassSelect() {
|
public ClassSelect() {
|
||||||
@ -59,7 +58,7 @@ public class ClassSelect extends EditableInventory {
|
|||||||
|
|
||||||
Validate.isTrue(config.getString("function").length() > 6, "Couldn't find the class associated to: " + config.getString("function"));
|
Validate.isTrue(config.getString("function").length() > 6, "Couldn't find the class associated to: " + config.getString("function"));
|
||||||
String classId = UtilityMethods.enumName(config.getString("function").substring(6));
|
String classId = UtilityMethods.enumName(config.getString("function").substring(6));
|
||||||
this.playerClass = Objects.requireNonNull(MMOCore.plugin.classManager.get(classId), classId + " does not correspond to any classId.");
|
this.playerClass = MMOCore.plugin.classManager.getOrThrow(classId);
|
||||||
this.name = config.getString("name");
|
this.name = config.getString("name");
|
||||||
this.lore = config.getStringList("lore");
|
this.lore = config.getStringList("lore");
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,17 @@ package net.Indyuce.mmocore.gui;
|
|||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.UtilityMethods;
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||||
|
import net.Indyuce.mmocore.api.SoundEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||||
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
|
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
|
||||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||||
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
|
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
|
||||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
|
||||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
|
||||||
import net.Indyuce.mmocore.api.SoundEvent;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@ -25,7 +25,6 @@ import org.bukkit.persistence.PersistentDataType;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class SubclassSelect extends EditableInventory {
|
public class SubclassSelect extends EditableInventory {
|
||||||
public SubclassSelect() {
|
public SubclassSelect() {
|
||||||
@ -50,7 +49,7 @@ public class SubclassSelect extends EditableInventory {
|
|||||||
super(config.contains("item") ? Material.valueOf(UtilityMethods.enumName(config.getString("item"))) : Material.BARRIER, config);
|
super(config.contains("item") ? Material.valueOf(UtilityMethods.enumName(config.getString("item"))) : Material.BARRIER, config);
|
||||||
Validate.isTrue(config.getString("function").length() > 10, "Couldn't find the class associated to: " + config.getString("function"));
|
Validate.isTrue(config.getString("function").length() > 10, "Couldn't find the class associated to: " + config.getString("function"));
|
||||||
String classId = UtilityMethods.enumName(config.getString("function").substring(10));
|
String classId = UtilityMethods.enumName(config.getString("function").substring(10));
|
||||||
this.playerClass = Objects.requireNonNull(MMOCore.plugin.classManager.get(classId), classId + " does not correspond to any classId.");
|
this.playerClass = MMOCore.plugin.classManager.getOrThrow(classId);
|
||||||
this.name = config.getString("name");
|
this.name = config.getString("name");
|
||||||
this.lore = config.getStringList("lore");
|
this.lore = config.getStringList("lore");
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ public class Icon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Icon(ConfigurationSection config) {
|
public Icon(ConfigurationSection config) {
|
||||||
this(Material.valueOf(Objects.requireNonNull(UtilityMethods.enumName(
|
this(Material.valueOf(UtilityMethods.enumName(
|
||||||
config.getString("item")))), config.contains("custom-model-data") ? config.getInt("custom-model-data") : 0);
|
config.getString("item", "DIRT"))), config.contains("custom-model-data") ? config.getInt("custom-model-data") : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Icon(Material material, int customModelData) {
|
public Icon(Material material, int customModelData) {
|
||||||
|
@ -58,8 +58,9 @@ public class ClassManager implements MMOCoreManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerClass getOrThrow(String id) {
|
public PlayerClass getOrThrow(String id) {
|
||||||
Validate.isTrue(map.containsKey(id), "Could not find class with ID '" + id + "'");
|
final PlayerClass found = map.get(id);
|
||||||
return map.get(id);
|
Validate.notNull(found, "Could not find class with ID '" + id + "'");
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<PlayerClass> getAll() {
|
public Collection<PlayerClass> getAll() {
|
||||||
|
@ -216,7 +216,7 @@ public class SkillTreeNode implements ExperienceObject {
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public ExperienceTable getExperienceTable() {
|
public ExperienceTable getExperienceTable() {
|
||||||
return Objects.requireNonNull(experienceTable);
|
return Objects.requireNonNull(experienceTable, "Skill tree has no exp table");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.skilltree.tree;
|
|||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.UtilityMethods;
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
import io.lumine.mythic.lib.api.util.PostLoadObject;
|
||||||
|
import io.lumine.mythic.lib.util.PreloadedObject;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
@ -32,7 +33,7 @@ import java.util.*;
|
|||||||
* @author Ka0rX
|
* @author Ka0rX
|
||||||
* @see {@link SkillTreeNode}
|
* @see {@link SkillTreeNode}
|
||||||
*/
|
*/
|
||||||
public abstract class SkillTree extends PostLoadObject implements RegisteredObject {
|
public abstract class SkillTree extends PostLoadObject implements RegisteredObject, PreloadedObject {
|
||||||
private final String id, name;
|
private final String id, name;
|
||||||
private final List<String> lore = new ArrayList<>();
|
private final List<String> lore = new ArrayList<>();
|
||||||
private final Material item;
|
private final Material item;
|
||||||
@ -64,7 +65,7 @@ public abstract class SkillTree extends PostLoadObject implements RegisteredObje
|
|||||||
this.id = Objects.requireNonNull(config.getString("id"), "Could not find skill tree id");
|
this.id = Objects.requireNonNull(config.getString("id"), "Could not find skill tree id");
|
||||||
this.name = MythicLib.plugin.parseColors(Objects.requireNonNull(config.getString("name"), "Could not find skill tree name"));
|
this.name = MythicLib.plugin.parseColors(Objects.requireNonNull(config.getString("name"), "Could not find skill tree name"));
|
||||||
Objects.requireNonNull(config.getStringList("lore"), "Could not find skill tree lore").forEach(str -> lore.add(MythicLib.plugin.parseColors(str)));
|
Objects.requireNonNull(config.getStringList("lore"), "Could not find skill tree lore").forEach(str -> lore.add(MythicLib.plugin.parseColors(str)));
|
||||||
this.item = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("item"))));
|
this.item = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("item"), "Could not find item")));
|
||||||
this.customModelData = config.getInt("custom-model-data", 0);
|
this.customModelData = config.getInt("custom-model-data", 0);
|
||||||
Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree");
|
Validate.isTrue(config.isConfigurationSection("nodes"), "Could not find any nodes in the tree");
|
||||||
this.maxPointSpent = config.getInt("max-point-spent", Integer.MAX_VALUE);
|
this.maxPointSpent = config.getInt("max-point-spent", Integer.MAX_VALUE);
|
||||||
|
Loading…
Reference in New Issue
Block a user