From ab5926206d33fa1f3d381c7a482d888ba555cdfa Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 6 Mar 2022 16:24:57 +0100 Subject: [PATCH] Added lightness and darkness elemental stats to default config files --- .../mmoitems/manager/LoreFormatManager.java | 79 +++++++++---------- src/main/resources/default/lore-format.yml | 4 + src/main/resources/default/stats.yml | 4 + 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/manager/LoreFormatManager.java b/src/main/java/net/Indyuce/mmoitems/manager/LoreFormatManager.java index e5e585c5..579030b8 100644 --- a/src/main/java/net/Indyuce/mmoitems/manager/LoreFormatManager.java +++ b/src/main/java/net/Indyuce/mmoitems/manager/LoreFormatManager.java @@ -1,12 +1,10 @@ package net.Indyuce.mmoitems.manager; import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.api.Type; import org.apache.commons.lang.Validate; import org.bukkit.configuration.file.YamlConfiguration; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; import java.io.File; import java.util.Collection; import java.util.HashMap; @@ -15,48 +13,49 @@ import java.util.Map; import java.util.logging.Level; public class LoreFormatManager implements Reloadable { - private final Map> formats = new HashMap<>(); + private final Map> formats = new HashMap<>(); - public void reload() { - formats.clear(); - File dir = new File(MMOItems.plugin.getDataFolder() + "/language/lore-formats"); - for (File file : dir.listFiles()) - try { - YamlConfiguration config = YamlConfiguration.loadConfiguration(file); - Validate.isTrue(config.isList("lore-format"), "Invalid lore-format! (" + file.getName() + ")"); - formats.put(file.getName().substring(0, file.getName().length() - 4), config.getStringList("lore-format")); - } catch (IllegalArgumentException exception) { - MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load layout '" + file.getName() + "': " + exception.getMessage()); - } - } + public void reload() { + formats.clear(); + File dir = new File(MMOItems.plugin.getDataFolder() + "/language/lore-formats"); + for (File file : dir.listFiles()) + try { + YamlConfiguration config = YamlConfiguration.loadConfiguration(file); + Validate.isTrue(config.isList("lore-format"), "Invalid lore-format! (" + file.getName() + ")"); + formats.put(file.getName().substring(0, file.getName().length() - 4), config.getStringList("lore-format")); + } catch (IllegalArgumentException exception) { + MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load layout '" + file.getName() + "': " + exception.getMessage()); + } + } - public boolean hasFormat(@Nullable String id) { - if (id == null) { return false; } - return formats.containsKey(id); - } + public boolean hasFormat(@NotNull String id) { + return formats.containsKey(id); + } - public Collection> getFormats() { - return formats.values(); - } + public Collection> getFormats() { + return formats.values(); + } - /** - * Find a lore format file by specifying its name - * - * @param prioritizedFormatNames The names of the formats to search. - * - * @return The lore format first found from the ones specified, or the default one. - */ - @NotNull public List getFormat(@NotNull String... prioritizedFormatNames) { + /** + * Find a lore format file by specifying its name + * + * @param prioritizedFormatNames The names of the formats to search. + * @return The lore format first found from the ones specified, or the default one. + */ + @NotNull + public List getFormat(@NotNull String... prioritizedFormatNames) { - /* - * Check each specified lore format in order, the first one - * to succeed will be the winner. - */ - for (String format : prioritizedFormatNames) { - if (hasFormat(format)) { return formats.get(format); } - } + /* + * Check each specified lore format in order, the first one + * to succeed will be the winner. + */ + for (String format : prioritizedFormatNames) { + List found = formats.get(format); + if (found != null) + return found; + } - // No lore format found / specified. Go with default. - return MMOItems.plugin.getLanguage().getDefaultLoreFormat(); - } + // No lore format found / specified. Go with default. + return MMOItems.plugin.getLanguage().getDefaultLoreFormat(); + } } diff --git a/src/main/resources/default/lore-format.yml b/src/main/resources/default/lore-format.yml index 01ab3f4c..58b9d336 100644 --- a/src/main/resources/default/lore-format.yml +++ b/src/main/resources/default/lore-format.yml @@ -126,6 +126,10 @@ lore-format: - '#thunder-defense#' - '#water-damage#' - '#water-defense#' +- '#darkness-damage#' +- '#darkness-defense#' +- '#lightness-damage#' +- '#lightness-defense#' # - '{bar}&8&m--------&b&l &nEffects&8 &m---------------' - '{bar}' - '#effects#' diff --git a/src/main/resources/default/stats.yml b/src/main/resources/default/stats.yml index 2ae24c53..c81ae03a 100644 --- a/src/main/resources/default/stats.yml +++ b/src/main/resources/default/stats.yml @@ -141,6 +141,8 @@ earth-damage: '&2 ❖ #% Earth Damage' wind-damage: '&3 &7❖ #% Wind Damage' thunder-damage: '&e ❖ #% Thunder Damage' water-damage: '&3 ❖ #% Water Damage' +darkness-damage: '&8 ❖ #% Darkness Damage' +lightness-damage: '&f ❖ #% Light Damage' # Elemental Defense fire-defense: '&c ❖ #% Fire Defense' @@ -149,3 +151,5 @@ earth-defense: '&2 ❖ #% Earth Defense' wind-defense: '&3 &7❖ #% Wind Defense' thunder-defense: '&e ❖ #% Thunder Defense' water-defense: '&3 ❖ #% Water Defense' +darkness-defense: '&8 ❖ #% Darkness Defense' +lightness-defense: '&f ❖ #% Light Defense'