Add debug messages in HologramFormat

This commit is contained in:
Flowsqy 2022-02-24 13:12:36 +01:00
parent 60ef6410ab
commit 87f4a8808e

View File

@ -32,7 +32,7 @@ public class HologramFormat {
// Get lines // Get lines
final ConfigurationSection linesSection = config.getConfigurationSection("lines"); final ConfigurationSection linesSection = config.getConfigurationSection("lines");
if (linesSection == null) { if (linesSection == null) {
// TODO Inform that there is no lines section plugin.debug("Can not the hologram format, there is no 'lines' section");
return; return;
} }
// Get options // Get options
@ -40,12 +40,12 @@ public class HologramFormat {
for (String linesId : linesSection.getKeys(false)) { for (String linesId : linesSection.getKeys(false)) {
final ConfigurationSection lineSection = linesSection.getConfigurationSection(linesId); final ConfigurationSection lineSection = linesSection.getConfigurationSection(linesId);
if (lineSection == null) { if (lineSection == null) {
// TODO Inform that a line must be a section plugin.debug("'" + linesId + "' is not a line section, skip it in hologram format");
continue; continue;
} }
final ConfigurationSection optionSection = lineSection.getConfigurationSection("options"); final ConfigurationSection optionSection = lineSection.getConfigurationSection("options");
if (optionSection == null) { if (optionSection == null) {
// TODO Inform that a line must contain an option section plugin.debug("The line '" + linesId + "' does not contain 'options' section, skip it in hologram format");
continue; continue;
} }
optionSections.put(linesId, optionSection); optionSections.put(linesId, optionSection);
@ -70,7 +70,7 @@ public class HologramFormat {
for (final String optionKey : optionsSection.getKeys(false)) { for (final String optionKey : optionsSection.getKeys(false)) {
final ConfigurationSection optionSection = optionsSection.getConfigurationSection(optionKey); final ConfigurationSection optionSection = optionsSection.getConfigurationSection(optionKey);
if (optionSection == null) { if (optionSection == null) {
// TODO Inform that an 'options' key must refer to a section plugin.debug("'" + optionKey + "' is not an option section, skip it in hologram format");
continue; continue;
} }
// Get the requirements // Get the requirements
@ -89,7 +89,8 @@ public class HologramFormat {
data.getRequirementsTypes() data.getRequirementsTypes()
); );
} catch (Exception e) { } catch (Exception e) {
// TODO Inform that it can not be deserialized plugin.debug("Failed to parse the requirement '" + requirement + "'");
plugin.debug(e);
continue; continue;
} }
@ -101,13 +102,13 @@ public class HologramFormat {
} }
continue; continue;
} }
// TODO Inform that there is a requirement that is not a condition plugin.debug("The requirement '" + requirement + "' does not represent a condition");
} }
// Get the format // Get the format
final String format = optionSection.getString("format"); final String format = optionSection.getString("format");
if (format == null) { if (format == null) {
// TODO Inform that format does not exist for this option plugin.debug("The option '" + optionKey + "' does not contains format. Skip it in hologram format");
continue; continue;
} }
@ -131,7 +132,7 @@ public class HologramFormat {
} }
} }
if (options.isEmpty()) { if (options.isEmpty()) {
// TODO Inform that this line does not contain any valid option plugin.debug("The line does not contain any options, skip it in hologram format");
continue; continue;
} }
@ -165,8 +166,9 @@ public class HologramFormat {
try { try {
result = parser.parse(script, data.getPlaceholders(), data.getPlaceholderTypes()); result = parser.parse(script, data.getPlaceholders(), data.getPlaceholderTypes());
} catch (Exception e) { } catch (Exception e) {
// TODO Inform that the script can not be deserialized
parsedScripts.put(withBrackets, new ParserResult<>(null, null, null, null)); parsedScripts.put(withBrackets, new ParserResult<>(null, null, null, null));
plugin.debug("Failed to evaluate the script '" + script + "'");
plugin.debug(e);
continue; continue;
} }
parsedScripts.put(withBrackets, result); parsedScripts.put(withBrackets, result);