From c12a24895efea6042beb54a8c9744dd9399d5820 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 26 Oct 2020 19:54:28 +0100 Subject: [PATCH] Fix config comments, improve pregen Also only showing a warning if something is missing from the command yml --- .../main/java/buttondevteam/buttonproc/ConfigProcessor.java | 6 +++++- .../java/buttondevteam/lib/architecture/ButtonPlugin.java | 5 +++-- .../java/buttondevteam/lib/architecture/ConfigData.java | 1 + .../src/main/java/buttondevteam/lib/chat/Command2.java | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ButtonProcessor/src/main/java/buttondevteam/buttonproc/ConfigProcessor.java b/ButtonProcessor/src/main/java/buttondevteam/buttonproc/ConfigProcessor.java index a2c3fd8..bddf284 100644 --- a/ButtonProcessor/src/main/java/buttondevteam/buttonproc/ConfigProcessor.java +++ b/ButtonProcessor/src/main/java/buttondevteam/buttonproc/ConfigProcessor.java @@ -69,15 +69,19 @@ public class ConfigProcessor { if (doc == null) continue; System.out.println("DOC: " + doc); yc.set(path + "." + e.getSimpleName(), doc.trim()); + /*System.out.println("Set " + path + "." + e.getSimpleName() + " to " + doc.trim()); + System.out.println("Check: " + yc.getString(path + "." + e.getSimpleName())); + System.out.println("Wut2: " + yc.getString("components.MemberComponent.memberGroup"));*/ } String javadoc = procEnv.getElementUtils().getDocComment(targetcl); if (javadoc != null) { System.out.println("JAVADOC"); System.out.println(javadoc.trim()); - yc.set(path, javadoc.trim()); + yc.set(path + ".generalDescriptionInsteadOfAConfig", javadoc.trim()); } try { yc.save(file); + //System.out.println("Wut: " + yc.getString("components.MemberComponent.memberGroup")); } catch (IOException e) { e.printStackTrace(); } diff --git a/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java b/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java index 4112591..5b50d8b 100644 --- a/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java +++ b/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java @@ -124,8 +124,9 @@ public abstract class ButtonPlugin extends JavaPlugin { var yc = YamlConfiguration.loadConfiguration(res); for (var kv : yc.getValues(true).entrySet()) if (kv.getValue() instanceof String) - yaml.addComment(kv.getKey(), Arrays.stream(((String) kv.getValue()).split("\n")) - .map(str -> "# " + str.trim()).toArray(String[]::new)); + yaml.addComment(kv.getKey().replace(".generalDescriptionInsteadOfAConfig", ""), + Arrays.stream(((String) kv.getValue()).split("\n")) + .map(str -> "# " + str.trim()).toArray(String[]::new)); return true; } diff --git a/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ConfigData.java b/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ConfigData.java index 079b979..783e1dd 100644 --- a/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ConfigData.java +++ b/Chroma-Core/src/main/java/buttondevteam/lib/architecture/ConfigData.java @@ -63,6 +63,7 @@ public class ConfigData { this.primitiveDef = primitiveDef; this.getter = getter; this.setter = setter; + get(); //Generate config automatically } @Override diff --git a/Chroma-Core/src/main/java/buttondevteam/lib/chat/Command2.java b/Chroma-Core/src/main/java/buttondevteam/lib/chat/Command2.java index a9e5e01..b1b923f 100644 --- a/Chroma-Core/src/main/java/buttondevteam/lib/chat/Command2.java +++ b/Chroma-Core/src/main/java/buttondevteam/lib/chat/Command2.java @@ -373,9 +373,9 @@ public abstract class Command2, TP extends Command2Send } else TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("Method '" + method.toString() + "' != " + mname + " or params is " + params), MainPlugin.Instance); } else - TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("cs is " + cs), MainPlugin.Instance); + MainPlugin.Instance.getLogger().warning("Failed to get command data for " + method + " (cs is null)! Make sure to use 'clean install' when building the project."); } else - TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("ccs is " + ccs + " - class: " + method.getDeclaringClass().getCanonicalName()), MainPlugin.Instance); + MainPlugin.Instance.getLogger().warning("Failed to get command data for " + method + " (ccs is null)! Make sure to use 'clean install' when building the project."); } return ht; }