use of net.robinfriedli.aiode.entities.xml.ArgumentContribution in project aiode by robinfriedli.
the class InitialiseCommandContributionsTask method perform.
@Override
public void perform(@Nullable JDA shard) throws Exception {
Context commandContributionContext = commandManager.getCommandContributionContext();
@SuppressWarnings("rawtypes") List<CommandHierarchyNode> commandHierarchyNodes = commandContributionContext.getInstancesOf(CommandHierarchyNode.class);
for (@SuppressWarnings("unchecked") CommandHierarchyNode<ArgumentContributionDelegate> commandHierarchyNode : commandHierarchyNodes) {
Map<String, ArgumentContributionDelegate> argumentContributions = commandHierarchyNode.getArguments();
for (ArgumentContributionDelegate argumentContributionDelegate : argumentContributions.values()) {
ArgumentContribution argumentContribution = argumentContributionDelegate.unwrapArgumentContribution();
List<XmlElement> excludedArguments = argumentContribution.getExcludedArguments();
List<XmlElement> requiredArguments = argumentContribution.getRequiredArguments();
validateReferencedArguments(commandHierarchyNode, argumentContribution, excludedArguments);
validateReferencedArguments(commandHierarchyNode, argumentContribution, requiredArguments);
}
}
}
use of net.robinfriedli.aiode.entities.xml.ArgumentContribution in project aiode by robinfriedli.
the class InitialiseCommandContributionsTask method validateReferencedArguments.
private void validateReferencedArguments(CommandHierarchyNode<?> commandHierarchyNode, ArgumentContribution argumentContribution, Collection<XmlElement> arguments) {
for (XmlElement argument : arguments) {
String argumentIdentifier = argument.getAttribute("argument").getValue();
ArgumentContribution referencedArgument = commandHierarchyNode.getArgument(argumentIdentifier).unwrapArgumentContribution();
if (referencedArgument == null) {
throw new IllegalStateException(String.format("Invalid command configuration for node '%s'. Cannot find referenced argument identifier '%s' required for element %s on argument %s.", commandHierarchyNode.getId(), argumentIdentifier, argument, argumentContribution));
}
}
}
Aggregations