mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-21 21:31:34 +01:00
Load all working item definitions even if one is not working
This commit is contained in:
parent
540f77965c
commit
0067202e8d
@ -14,16 +14,9 @@ Items:
|
||||
Lore:
|
||||
- "Right click to open your backpack."
|
||||
- "Drag items on it to place them in your backpack."
|
||||
Minepacks:
|
||||
Material: shulker_shell
|
||||
# Will set the damage value and unbreakable on MC versions older than 1.14 or the custom_model_data for MC 1.14 and newer
|
||||
Model: 10
|
||||
DisplayName: "&eBackpack"
|
||||
Lore:
|
||||
- "Right click to open your backpack."
|
||||
- "Drag items on it to place them in your backpack."
|
||||
MinepacksLegacy:
|
||||
Material: CARROT_STICK
|
||||
# Will set the damage value and unbreakable on MC versions older than 1.14 or the custom_model_data for MC 1.14 and newer
|
||||
Model: 1
|
||||
DisplayName: "&eBackpack"
|
||||
Lore:
|
||||
|
@ -50,24 +50,30 @@ private void loadItemConfigs()
|
||||
{
|
||||
getYamlE().getKeysFiltered("Items\\.[^.]*\\.Material").forEach(materialKey -> {
|
||||
final String key = materialKey.substring(0, materialKey.length() - ".Material".length());
|
||||
final List<String> lore = getConfigE().getStringList(key + ".Lore", new ArrayList<>(0));
|
||||
final List<String> loreFinal;
|
||||
if(lore.size() == 0) loreFinal = null;
|
||||
else
|
||||
{
|
||||
loreFinal = new ArrayList<>(lore.size());
|
||||
lore.forEach(loreEntry -> loreFinal.add(ChatColor.translateAlternateColorCodes('&', loreEntry)));
|
||||
try{
|
||||
final List<String> lore = getConfigE().getStringList(key + ".Lore", new ArrayList<>(0));
|
||||
final List<String> loreFinal;
|
||||
if(lore.size() == 0) loreFinal = null;
|
||||
else
|
||||
{
|
||||
loreFinal = new ArrayList<>(lore.size());
|
||||
lore.forEach(loreEntry -> loreFinal.add(ChatColor.translateAlternateColorCodes('&', loreEntry)));
|
||||
}
|
||||
final String displayName = ChatColor.translateAlternateColorCodes('&', getConfigE().getString(key + ".DisplayName", "&eBackpack"));
|
||||
final String material = getYamlE().getString(key + ".Material", "player_head");
|
||||
final int model = getYamlE().getInt(key + ".Model", 1);
|
||||
if(material.equalsIgnoreCase("player_head"))
|
||||
{
|
||||
itemConfigs.put(key, new ItemConfigHead(displayName, getConfigE().getString(key + ".HeadValue", ""), model, loreFinal));
|
||||
}
|
||||
else
|
||||
{
|
||||
itemConfigs.put(key, new ItemConfigItem(getMaterialFromString(material), displayName, model, loreFinal));
|
||||
}
|
||||
}
|
||||
final String displayName = ChatColor.translateAlternateColorCodes('&', getConfigE().getString(key + ".DisplayName", "&eBackpack"));
|
||||
final String material = getYamlE().getString(key + ".Material", "player_head");
|
||||
final int model = getYamlE().getInt(key + ".Model", 1);
|
||||
if(material.equalsIgnoreCase("player_head"))
|
||||
catch(Exception e)
|
||||
{
|
||||
itemConfigs.put(key, new ItemConfigHead(displayName, getConfigE().getString(key + ".HeadValue", ""), model, loreFinal));
|
||||
}
|
||||
else
|
||||
{
|
||||
itemConfigs.put(key, new ItemConfigItem(getMaterialFromString(material), displayName, model, loreFinal));
|
||||
plugin.getLogger().warning("Failed to load item definition for '" + key + "'! Error: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -78,6 +84,7 @@ private Material getMaterialFromString(String name)
|
||||
Material mat = Material.getMaterial(name);
|
||||
if(mat == null && MCVersion.isNewerOrEqualThan(MCVersion.MC_1_13)) mat = Material.getMaterial(name, true);
|
||||
//TODO from id
|
||||
if(mat == null) throw new IllegalArgumentException("Unable to find material: " + name);
|
||||
return mat;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user