repositories {
maven { url 'https://www.jitpack.io' }
}
dependencies {
implementation 'com.github.Kowkodivka:CargoCommands:1.0.2'
}repositories {
maven(url = "https://www.jitpack.io")
}
dependencies {
implementation("com.github.Kowkodivka:CargoCommands:1.0.2")
}If you'd rather compile on your own, follow these instructions. First, make sure you have JDK 19 installed. Other JDK versions will not work. Open a terminal your working directory and run the following commands:
Building: gradlew jar
Building: ./gradlew jar
If the terminal returns Permission denied or Command not found on Mac/Linux, run chmod +x ./gradlew before running ./gradlew. This is a one-time procedure.
Plugin main class:
import arc.util.CommandHandler
import io.lucin.core.CargoRegister
import mindustry.mod.Plugin
class ExamplePlugin : Plugin() {
override fun registerServerCommands(handler: CommandHandler) {
CargoRegister().add(ExampleServerCommand()).build(handler)
}
override fun registerClientCommands(handler: CommandHandler) {
CargoRegister().add(ExampleClientCommand()).build(handler)
}
}Client command:
import arc.util.CommandHandler.CommandRunner
import io.lucin.core.annotations.Command
import mindustry.gen.Player
@Command("echo", "Replies with your message.", "<message...>")
class ExampleClientCommand : CommandRunner<Player> {
override fun accept(args: Array<out String>, player: Player) {
player.sendMessage("[accent]You said: []{args[0]}[]")
}
}Server command:
import arc.func.Cons
import arc.util.Log.err
import io.lucin.core.annotations.Command
import mindustry.gen.Groups
import mindustry.gen.Player
@Command("send", "Send message to a player.", "<player> <message...>")
class ExampleServerCommand : Cons<Array<String>> {
override fun get(
args: Array<String>
) {
var target: Player? = null
Groups.player.each { player ->
if (player.name == args[0]) target = player else err("Cannot find player '${args[0]}'!")
}
if (target != null) {
target!!.sendMessage(args[1])
}
}
}