Skip to content

Commit

Permalink
CM
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed Jun 17, 2024
1 parent 67821db commit 3c74011
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,22 @@ private void register(Class<?> clazz, List<String> path, Map<Class<?>, Object> i

try {
CommandRef ref = (CommandRef) clazz.getDeclaredField("cmd").get(null);
Method create = ref.getClass().getDeclaredMethods()[0];
for (Parameter parameter : create.getParameters()) {
String name = parameter.getName().toLowerCase(Locale.ROOT);
if (userParamsLower.contains(name)) continue;
// replace camelCase with under_case
String nameUnder = parameter.getName().replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase(Locale.ROOT);
if (userParamsLower.contains(nameUnder)) continue;
System.out.println("Missing parameter `" + name + "` for " + methodInfo.clazz().getSimpleName() + " | " + methodInfo.method() + " | " + methodInfo.field() + " | " + clazz.getSimpleName() + " | " + callable.getUserParameterMap().keySet());
Set<String> argsPresent = new LinkedHashSet<>();
for (Method method : ref.getClass().getDeclaredMethods()) {
if (method.getReturnType().equals(ref.getClass()) && method.getParameterCount() == 1 && method.getParameterTypes()[0].equals(String.class)) {
argsPresent.add(method.getName().toLowerCase(Locale.ROOT));
}
}
for (String arg : userParamsLower) {
if (!argsPresent.contains(arg)) {
System.out.println("Missing method for " + methodInfo.clazz().getSimpleName() + " | " + methodInfo.method() + " | " + methodInfo.field() + " | " + clazz.getSimpleName() + " | " + arg);
}
}
for (String arg : argsPresent) {
if (!userParamsLower.contains(arg)) {
System.out.println("Missing parameter (2) for " + methodInfo.clazz().getSimpleName() + " | " + methodInfo.method() + " | " + methodInfo.field() + " | " + clazz.getSimpleName() + " | " + arg);
}
}

} catch (IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6353,7 +6353,7 @@ public unregister alliance(String value) {
}
public static class selection_alias{
public static class add{
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.AlliancePlaceholders.class,method="addSelectionAlias")
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.PlaceholdersMap.class,method="addSelectionAlias", field="ALLIANCES")
public static class alliance extends CommandRef {
public static final alliance cmd = new alliance();
public alliance name(String value) {
Expand Down Expand Up @@ -6497,7 +6497,7 @@ public militaryunit military_units(String value) {
}

}
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.NationPlaceholders.class,method="addSelectionAlias")
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.PlaceholdersMap.class,method="addSelectionAlias", field="NATIONS")
public static class nation extends CommandRef {
public static final nation cmd = new nation();
public nation name(String value) {
Expand Down Expand Up @@ -7883,7 +7883,7 @@ public view sheet(String value) {
}
public static class sheet_template{
public static class add{
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.AlliancePlaceholders.class,method="addColumns")
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.PlaceholdersMap.class,method="addColumns", field="ALLIANCES")
public static class alliance extends CommandRef {
public static final alliance cmd = new alliance();
public alliance sheet(String value) {
Expand Down Expand Up @@ -9131,7 +9131,7 @@ public militaryunit x(String value) {
}

}
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.NationPlaceholders.class,method="addColumns")
@AutoRegister(clazz=link.locutus.discord.commands.manager.v2.impl.pw.filter.PlaceholdersMap.class,method="addColumns", field="NATIONS")
public static class nation extends CommandRef {
public static final nation cmd = new nation();
public nation sheet(String value) {
Expand Down

0 comments on commit 3c74011

Please sign in to comment.