You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Now arguments are global!
* Added Bungee API
* Added Bungee/Bukkit Argument Processors
* Arguments are now just one class (Instead of indexed and named arguments)
* Added permission check for commands
* Added tab completer
* Added custom completions for tab commands
* Fixed register process for commands
error("You're currently running on an unsupported server software! Please contact us at https://go.theprogramsrc.xyz/discord so we can help you further.")
69
+
}
66
70
71
+
if(SimpleCoreAPI.instance.softwareType in arrayOf(SoftwareType.BUNGEE, SoftwareType.WATERFALL)) { // Proxies!
if(args.isNotEmpty()){ // If we have at least 1 argument
40
+
val subCommands = subCommands.filter { it.name.lowercase().startsWith(args[0].lowercase()) } // Get the sub commands to show
41
+
if(args.size >1){ // If there are more than 1 arguments
42
+
subCommands.flatMap {
43
+
val argument = it.arguments.getOrNull(args.size-2) // Get the argument. We remove 2 because the first argument is the sub command and the second is the argument
44
+
val completions = it.tabCompletions(sender)
45
+
if(argument !=null&& completions.isNotEmpty() && completions.keys.any { key -> key.lowercase() == argument.lowercase() }){ // Get the available completions for the current argument if any
46
+
completions.filter { entry -> entry.key.lowercase() == argument.lowercase() }.values.flatten() // Get the completions
47
+
} elseif(argument !=null) {
48
+
listOf("<$argument>") // If there are no completions show the argument with <>
49
+
} else {
50
+
emptyList() // If there are no completions nor arguments show nothing
if(args.isNotEmpty() && cmd.subCommands.isNotEmpty()){ // Now that we have sub commands, let's find one!
173
+
val subCommandName = args.first() // Here we get the subcommand name
174
+
val rawArguments = args.drop(1) // Arguments provided by bukkit
175
+
val subCommand = cmd.subCommands.find { it.name.lowercase() == subCommandName.lowercase() && it.arguments.size == rawArguments.size } // Let's look for a sub command. And because we can specify multiple sub commands with the same name, we need to check the amount of arguments too
176
+
if(subCommand ==null) { // No sub commands? No worries, let's run the main action
"argument" to name // Apply the placeholder to let know the user which argument is missing
189
+
))))
190
+
}
191
+
return@BungeeCommandHandler
192
+
}
193
+
inputArguments[name] = rawArguments[index] // Here we add the argument to the map
194
+
}
195
+
}
196
+
val arguments =Arguments(indexedArguments = args.toList(), namedArguments = inputArguments) // The sub commands always uses indexed and named arguments
197
+
subCommand.executor(CommandExecutor(sender, arguments)) // Now we execute it!
0 commit comments