Fix config comments, improve pregen

Also only showing a warning if something is missing from the command yml
This commit is contained in:
Norbi Peti 2020-10-26 19:54:28 +01:00
parent 51e0ca4f4c
commit c12a24895e
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 11 additions and 5 deletions

View file

@ -69,15 +69,19 @@ public class ConfigProcessor {
if (doc == null) continue; if (doc == null) continue;
System.out.println("DOC: " + doc); System.out.println("DOC: " + doc);
yc.set(path + "." + e.getSimpleName(), doc.trim()); 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); String javadoc = procEnv.getElementUtils().getDocComment(targetcl);
if (javadoc != null) { if (javadoc != null) {
System.out.println("JAVADOC"); System.out.println("JAVADOC");
System.out.println(javadoc.trim()); System.out.println(javadoc.trim());
yc.set(path, javadoc.trim()); yc.set(path + ".generalDescriptionInsteadOfAConfig", javadoc.trim());
} }
try { try {
yc.save(file); yc.save(file);
//System.out.println("Wut: " + yc.getString("components.MemberComponent.memberGroup"));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -124,7 +124,8 @@ public abstract class ButtonPlugin extends JavaPlugin {
var yc = YamlConfiguration.loadConfiguration(res); var yc = YamlConfiguration.loadConfiguration(res);
for (var kv : yc.getValues(true).entrySet()) for (var kv : yc.getValues(true).entrySet())
if (kv.getValue() instanceof String) if (kv.getValue() instanceof String)
yaml.addComment(kv.getKey(), Arrays.stream(((String) kv.getValue()).split("\n")) yaml.addComment(kv.getKey().replace(".generalDescriptionInsteadOfAConfig", ""),
Arrays.stream(((String) kv.getValue()).split("\n"))
.map(str -> "# " + str.trim()).toArray(String[]::new)); .map(str -> "# " + str.trim()).toArray(String[]::new));
return true; return true;
} }

View file

@ -63,6 +63,7 @@ public class ConfigData<T> {
this.primitiveDef = primitiveDef; this.primitiveDef = primitiveDef;
this.getter = getter; this.getter = getter;
this.setter = setter; this.setter = setter;
get(); //Generate config automatically
} }
@Override @Override

View file

@ -373,9 +373,9 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
} else } else
TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("Method '" + method.toString() + "' != " + mname + " or params is " + params), MainPlugin.Instance); TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("Method '" + method.toString() + "' != " + mname + " or params is " + params), MainPlugin.Instance);
} else } 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 } 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; return ht;
} }