Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static Method getArgHelperMethod(String name) {
public static final Method HELPER_PREFIX_ENTRY_ARG_METHOD = getArgHelperMethod("helperPrefixEntryArg");
public static final Method HELPER_BOOLEAN_ARG_METHOD = getArgHelperMethod("helperBooleanArg");
public static final Method HELPER_ENUM_ARG_METHOD = getArgHelperMethod("helperEnumArg");
public static final Method HELPER_PREFIX_UNPARSED_METHOD = getArgHelperMethod("getUnparsedPrefixedArg");
public static final Method HELPER_PREFIX_LIST_OBJECT_METHOD = getArgHelperMethod("helperPrefixListObject");
public static final Method HELPER_PREFIX_LIST_ENUM_METHOD = getArgHelperMethod("helperPrefixListEnum");
public static final Method HELPER_PREFIX_STRING_METHOD = getArgHelperMethod("helperPrefixString");
Expand Down Expand Up @@ -311,6 +312,15 @@ public static String helperDebugFormat(Object value, ArgData arg) {
return ArgumentHelper.debugObj(arg.name, value);
}

public static String getUnparsedPrefixedArg(ScriptEntry scriptEntry, ArgData arg) {
Integer index = scriptEntry.internal.prefixedArgMapper[arg.index];
if (index != null) {
String fullRawValue = scriptEntry.internal.all_arguments[index].fullOriginalRawValue;
return fullRawValue.substring((arg.name + ":").length());
}
return arg.defaultValue;
}

public static CommandExecutor generateExecutorFor(Class<? extends AbstractCommand> cmdClass, AbstractCommand cmd) {
try {
Method method = Arrays.stream(cmdClass.getDeclaredMethods()).filter(m -> Modifier.isStatic(m.getModifiers()) && m.getName().equals("autoExecute")).findFirst().orElse(null);
Expand Down Expand Up @@ -403,6 +413,9 @@ else if (argData.type == List.class && argData.subType != null) {
cmd.generatorInfiniteArgs = true;
argMethod = HELPER_GET_UNPARSED_ARG_LIST;
}
else if (paramType == String.class && !argData.isLinear && !argData.shouldParse) {
argMethod = HELPER_PREFIX_UNPARSED_METHOD;
}
else if (paramType == List.class && argData.subType != null && ObjectTag.class.isAssignableFrom(argData.subType)) {
argMethod = HELPER_PREFIX_LIST_OBJECT_METHOD;
}
Expand Down