diff --git a/docs/en/create-commands/command-trees.md b/docs/en/create-commands/command-trees.md index 9cc111ad3..0b433ad24 100644 --- a/docs/en/create-commands/command-trees.md +++ b/docs/en/create-commands/command-trees.md @@ -16,7 +16,7 @@ So far in this documentation, we've described many different ways to register co The Command Tree represents command structures in a tree-like fashion, in a very similar way that Brigadier's API lets you declare commands. Command tree commands effectively revolve around two methods: ```java -public T executes(CommandExecutor executor); +public T executes(NormalExecutor executor); public CommandTree then(ArgumentTree branch); public ArgumentTree then(ArgumentTree branch); diff --git a/docs/en/create-commands/registration.md b/docs/en/create-commands/registration.md index b72c39f62..bd7953377 100644 --- a/docs/en/create-commands/registration.md +++ b/docs/en/create-commands/registration.md @@ -142,39 +142,6 @@ CommandAPICommand executesNative(info -> {}) Executes a command regardless of what the command sender is, using the `NativeProxyCommandSender`. Read more about native proxied command senders [here](./executors/native-sender). -:::info - -Sometimes, the Java compiler throws an error saying that a method is ambiguous for the type CommandAPICommand. This is due to a limitation in Java's type inference system and is not a fault of the CommandAPI. If we take the following code, used to spawn a pig: - -```java -new CommandAPICommand("spawnpigs") - .executesPlayer((player, args) -> { - for(int i = 0; i < 10; i++) { - player.getWorld().spawnEntity(player.getLocation(), (EntityType) args.get(0)); - } - }) - .register(); -``` - -The Java type inference system can’t determine what the type of the lambda `(player, args) -> ()` is, therefore, it produces the following compilation error: - -```log -The method executesPlayer(PlayerCommandExecutor) is ambiguous for the type CommandAPICommand -``` - -This can easily be resolved by declaring the specific type of the command sender and the arguments. For example: - -```java -new CommandAPICommand("spawnpigs") - .executesPlayer((Player player, CommandArguments args) -> { - for(int i = 0; i < 10; i++) { - player.getWorld().spawnEntity(player.getLocation(), (EntityType) args.get(0)); - } - }) - .register(); -``` -::: - #### Registering the command ```java diff --git a/docs/en/dev-setup/annotations.md b/docs/en/dev-setup/annotations.md index fec95c6b9..41e02600d 100644 --- a/docs/en/dev-setup/annotations.md +++ b/docs/en/dev-setup/annotations.md @@ -22,7 +22,7 @@ The annotation system effectively needs to be added twice: Once for compilation dev.jorel commandapi-annotations - 9.7.0 + 9.7.1-SNAPSHOT provided @@ -42,7 +42,7 @@ The annotation system effectively needs to be added twice: Once for compilation dev.jorel commandapi-annotations - 9.7.0 + 9.7.1-SNAPSHOT @@ -81,8 +81,8 @@ The annotation system effectively needs to be added twice: Once for compilation ```groovy dependencies { - compileOnly "dev.jorel:commandapi-annotations:9.7.0" - annotationProcessor "dev.jorel:commandapi-annotations:9.7.0" + compileOnly "dev.jorel:commandapi-annotations:9.7.1-SNAPSHOT" + annotationProcessor "dev.jorel:commandapi-annotations:9.7.1-SNAPSHOT" } ``` @@ -90,8 +90,8 @@ The annotation system effectively needs to be added twice: Once for compilation ```kotlin dependencies { - compileOnly("dev.jorel:commandapi-annotations:9.7.0") - annotationProcessor("dev.jorel:commandapi-annotations:9.7.0") + compileOnly("dev.jorel:commandapi-annotations:9.7.1-SNAPSHOT") + annotationProcessor("dev.jorel:commandapi-annotations:9.7.1-SNAPSHOT") } ``` diff --git a/docs/en/dev-setup/setup.md b/docs/en/dev-setup/setup.md index 3cbb98e20..73d53302c 100644 --- a/docs/en/dev-setup/setup.md +++ b/docs/en/dev-setup/setup.md @@ -51,7 +51,7 @@ If you've never used a build system before, I highly recommend it! It makes it e dev.jorel commandapi-bukkit-core - 9.7.0 + 9.7.1-SNAPSHOT provided @@ -90,7 +90,7 @@ If you've never used a build system before, I highly recommend it! It makes it e ```groovy dependencies { - compileOnly "dev.jorel:commandapi-bukkit-core:9.7.0" + compileOnly "dev.jorel:commandapi-bukkit-core:9.7.1-SNAPSHOT" } ``` @@ -99,7 +99,7 @@ If you've never used a build system before, I highly recommend it! It makes it e ```kotlin dependencies { - compileOnly("dev.jorel:commandapi-bukkit-core:9.7.0") + compileOnly("dev.jorel:commandapi-bukkit-core:9.7.1-SNAPSHOT") } ``` diff --git a/docs/en/dev-setup/shading.md b/docs/en/dev-setup/shading.md index 6266baa18..07d6cdc34 100644 --- a/docs/en/dev-setup/shading.md +++ b/docs/en/dev-setup/shading.md @@ -114,7 +114,7 @@ Add the CommandAPI shade dependency: dev.jorel commandapi-bukkit-shade - 9.7.0 + 9.7.1-SNAPSHOT ``` @@ -126,7 +126,7 @@ Add the CommandAPI shade dependency: dev.jorel commandapi-bukkit-shade-mojang-mapped - 9.7.0 + 9.7.1-SNAPSHOT ``` @@ -222,7 +222,7 @@ Next, we declare our dependencies: ```groovy dependencies { - implementation "dev.jorel:commandapi-bukkit-shade:9.7.0" + implementation "dev.jorel:commandapi-bukkit-shade:9.7.1-SNAPSHOT" } ``` @@ -230,7 +230,7 @@ dependencies { ```groovy dependencies { - implementation "dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.7.0" + implementation "dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.7.1-SNAPSHOT" } ``` @@ -240,7 +240,7 @@ dependencies { ```kotlin dependencies { - implementation("dev.jorel:commandapi-bukkit-shade:9.7.0") + implementation("dev.jorel:commandapi-bukkit-shade:9.7.1-SNAPSHOT") } ``` @@ -248,7 +248,7 @@ dependencies { ```kotlin dependencies { - implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.7.0") + implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.7.1-SNAPSHOT") } ``` diff --git a/docs/en/kotlin-dsl/intro.md b/docs/en/kotlin-dsl/intro.md index fef7ea7d5..7bb8864d4 100644 --- a/docs/en/kotlin-dsl/intro.md +++ b/docs/en/kotlin-dsl/intro.md @@ -26,7 +26,7 @@ To install the DSL, you need to add the `commandapi-bukkit-kotlin` dependency in dev.jorel commandapi-bukkit-kotlin - 9.7.0 + 9.7.1-SNAPSHOT ``` @@ -106,7 +106,7 @@ Next, you need to add the dependency: ```groovy dependencies { - implementation "dev.jorel:commandapi-bukkit-kotlin:9.7.0" + implementation "dev.jorel:commandapi-bukkit-kotlin:9.7.1-SNAPSHOT" } ``` @@ -115,7 +115,7 @@ dependencies { ```kotlin dependencies { - implementation("dev.jorel:commandapi-bukkit-kotlin:9.7.0") + implementation("dev.jorel:commandapi-bukkit-kotlin:9.7.1-SNAPSHOT") } ``` diff --git a/docs/en/kotlin-dsl/usage.md b/docs/en/kotlin-dsl/usage.md index 2dbb1c5aa..5a9da3bf7 100644 --- a/docs/en/kotlin-dsl/usage.md +++ b/docs/en/kotlin-dsl/usage.md @@ -126,7 +126,9 @@ We want to create a `/give` command with the following syntax: /optionalArgument give ``` -To declare an argument as optional you need to set the `optional` value to `true`: +When using a CommandTree, you can do this by using the same executor in two places. + +When using a CommandAPICommand, you can create an optional Argument by setting the `optional` value to `true`: :::tabs key:dsl-usage-page ===CommandTree diff --git a/docs/en/test/setup.md b/docs/en/test/setup.md index c65717476..7dad7011d 100644 --- a/docs/en/test/setup.md +++ b/docs/en/test/setup.md @@ -29,7 +29,7 @@ When you add the dependencies for MockBukkit and `commandapi-bukkit-test-toolkit dev.jorel commandapi-bukkit-test-toolkit - 9.7.0 + 9.7.1-SNAPSHOT test @@ -37,7 +37,7 @@ When you add the dependencies for MockBukkit and `commandapi-bukkit-test-toolkit dev.jorel commandapi-bukkit-core - 9.7.0 + 9.7.1-SNAPSHOT provided @@ -70,10 +70,10 @@ dependencies { // See https://github.com/MockBukkit/MockBukkit?tab=readme-ov-file#mag-usage for latest version testImplementation 'com.github.seeseemelk:MockBukkit-v1.21:3.128.0' - testImplementation 'dev.jorel:commandapi-bukkit-test-toolkit:9.7.0' + testImplementation 'dev.jorel:commandapi-bukkit-test-toolkit:9.7.1-SNAPSHOT' // May be the shade dependency and/or mojang-mapped - compileOnly 'dev.jorel:commandapi-bukkit-core:9.7.0' + compileOnly 'dev.jorel:commandapi-bukkit-core:9.7.1-SNAPSHOT' // Can also be paper-api compileOnly 'org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT' @@ -91,10 +91,10 @@ dependencies { // See https://github.com/MockBukkit/MockBukkit?tab=readme-ov-file#mag-usage for latest version testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.128.0") - testImplementation("dev.jorel:commandapi-bukkit-test-toolkit:9.7.0") + testImplementation("dev.jorel:commandapi-bukkit-test-toolkit:9.7.1-SNAPSHOT") // May be the shade dependency and/or mojang-mapped - compileOnly("dev.jorel:commandapi-bukkit-core:9.7.0") + compileOnly("dev.jorel:commandapi-bukkit-core:9.7.1-SNAPSHOT") // Can also be paper-api compileOnly("org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT") diff --git a/reference-code/gradle/libs.versions.toml b/reference-code/gradle/libs.versions.toml index 6c49a384c..7f6339ce3 100644 --- a/reference-code/gradle/libs.versions.toml +++ b/reference-code/gradle/libs.versions.toml @@ -7,11 +7,11 @@ com-mojang-authlib = "3.3.39" com-mojang-brigadier = "1.0.17" com-velocitypowered-velocity-api = "3.4.0-SNAPSHOT" de-tr7zw-item-nbt-api = "2.11.1" -dev-jorel-commandapi-annotations = "9.7.0" -dev-jorel-commandapi-bukkit-core = "9.7.0" -dev-jorel-commandapi-bukkit-kotlin = "9.7.0" -dev-jorel-commandapi-bukkit-test-toolkit = "9.7.0" -dev-jorel-commandapi-velocity-shade = "9.6.2-SNAPSHOT" +dev-jorel-commandapi-annotations = "9.7.1-SNAPSHOT" +dev-jorel-commandapi-bukkit-core = "9.7.1-SNAPSHOT" +dev-jorel-commandapi-bukkit-kotlin = "9.7.1-SNAPSHOT" +dev-jorel-commandapi-bukkit-test-toolkit = "9.7.1-SNAPSHOT" +dev-jorel-commandapi-velocity-shade = "9.7.1-SNAPSHOT" io-papermc-paper-paper-api = "1.21-R0.1-SNAPSHOT" net-kyori-adventure-platform-bukkit = "4.2.0" org-jetbrains-kotlin-kotlin-stdlib = "2.0.0" diff --git a/reference-code/src/main/kotlin/createcommands/Aliases.kt b/reference-code/src/main/kotlin/createcommands/Aliases.kt index 6ab666047..4b1525b49 100644 --- a/reference-code/src/main/kotlin/createcommands/Aliases.kt +++ b/reference-code/src/main/kotlin/createcommands/Aliases.kt @@ -1,11 +1,12 @@ package createcommands import dev.jorel.commandapi.CommandAPICommand -import dev.jorel.commandapi.executors.CommandBlockCommandExecutor -import dev.jorel.commandapi.executors.EntityCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.commandBlockExecutor import dev.jorel.commandapi.kotlindsl.entityExecutor +import org.bukkit.command.BlockCommandSender +import org.bukkit.entity.Entity fun aliases() { // #region aliasesExample @@ -14,11 +15,11 @@ fun aliases() { .withAliases("getposition", "getloc", "getlocation", "whereami") // Declare your implementation - .executesEntity(EntityCommandExecutor { entity, _ -> + .executesEntity(NormalExecutor { entity, _ -> val loc = entity.location entity.sendMessage("You are at ${loc.blockX}, ${loc.blockY}, ${loc.blockZ}") }) - .executesCommandBlock(CommandBlockCommandExecutor { block, _ -> + .executesCommandBlock(NormalExecutor { block, _ -> val loc = block.block.location block.sendMessage("You are at ${loc.blockX}, ${loc.blockY}, ${loc.blockZ}") }) diff --git a/reference-code/src/main/kotlin/createcommands/CommandTrees.kt b/reference-code/src/main/kotlin/createcommands/CommandTrees.kt index 943a7cd5e..e0e284a4e 100644 --- a/reference-code/src/main/kotlin/createcommands/CommandTrees.kt +++ b/reference-code/src/main/kotlin/createcommands/CommandTrees.kt @@ -3,10 +3,10 @@ package createcommands import dev.jorel.commandapi.CommandAPI import dev.jorel.commandapi.CommandTree import dev.jorel.commandapi.arguments.* -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.* import org.bukkit.block.Sign +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.metadata.FixedMetadataValue import org.bukkit.plugin.java.JavaPlugin @@ -14,12 +14,12 @@ import org.bukkit.plugin.java.JavaPlugin fun commandTrees() { // #region commandTreesExample CommandTree("sayhi") - .executes(CommandExecutor { sender, _ -> + .executes(NormalExecutor { sender, _ -> sender.sendMessage("Hi!") }) .then( PlayerArgument("target") - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["target"] as Player target.sendMessage("Hi") }) @@ -35,7 +35,7 @@ fun commandTrees() { .then(StringArgument("arg3") .then(DoubleArgument("arg4", 0.0) .then(StringArgument("arg5") - .executes(CommandExecutor { sender, _ -> + .executes(NormalExecutor { sender, _ -> // your code here })))))) .register() @@ -50,7 +50,7 @@ fun commandTrees() { StringArgument("arg3"), DoubleArgument("arg4", 0.0), StringArgument("arg5") - .executes(CommandExecutor { sender, _ -> + .executes(NormalExecutor { sender, _ -> // your code here }) ).register() @@ -64,7 +64,7 @@ fun commandTrees() { .then(LiteralArgument("set") .then(IntegerArgument("line_number", 1, 4) .then(GreedyStringArgument("text") - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // /signedit set val sign: Sign = getTargetSign(player) val line_number = args["line_number"] as Int @@ -74,7 +74,7 @@ fun commandTrees() { })))) .then(LiteralArgument("clear") .then(IntegerArgument("line_number", 1, 4) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // /signedit clear val sign: Sign = getTargetSign(player) val line_number = args["line_number"] as Int @@ -83,7 +83,7 @@ fun commandTrees() { }))) .then(LiteralArgument("copy") .then(IntegerArgument("line_number", 1, 4) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // /signedit copy val sign: Sign = getTargetSign(player) val line_number = args["line_number"] as Int @@ -91,7 +91,7 @@ fun commandTrees() { }))) .then(LiteralArgument("paste") .then(IntegerArgument("line_number", 1, 4) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // /signedit copy val sign: Sign = getTargetSign(player) val line_number = args["line_number"] as Int diff --git a/reference-code/src/main/kotlin/createcommands/Help.kt b/reference-code/src/main/kotlin/createcommands/Help.kt index 644d2ffe9..fdeb6a392 100644 --- a/reference-code/src/main/kotlin/createcommands/Help.kt +++ b/reference-code/src/main/kotlin/createcommands/Help.kt @@ -1,7 +1,7 @@ package createcommands import dev.jorel.commandapi.CommandAPICommand -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import org.bukkit.Bukkit @@ -14,7 +14,7 @@ fun help() { CommandAPICommand("mycmd") .withShortDescription("Says hi") .withFullDescription("Broadcasts hi to everyone on the server") - .executes(CommandExecutor { _, _ -> + .executes(NormalExecutor { _, _ -> Bukkit.broadcastMessage("Hi!") }) .register() @@ -23,7 +23,7 @@ fun help() { // #region helpExampleStep2 CommandAPICommand("mycmd") .withHelp("Says hi", "Broadcasts hi to everyone on the server") - .executes(CommandExecutor { _, _ -> + .executes(NormalExecutor { _, _ -> Bukkit.broadcastMessage("Hi!") }) .register() @@ -57,7 +57,7 @@ fun help() { // #region helpTopicExampleStep2 return CommandAPICommand("mycmd") .withHelp(makeHelp("mycmd")) - .executes(CommandExecutor { _, _ -> + .executes(NormalExecutor { _, _ -> Bukkit.broadcastMessage("Hi!") }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/Permissions.kt b/reference-code/src/main/kotlin/createcommands/Permissions.kt index 93f2235df..beb06159b 100644 --- a/reference-code/src/main/kotlin/createcommands/Permissions.kt +++ b/reference-code/src/main/kotlin/createcommands/Permissions.kt @@ -5,7 +5,7 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.CommandPermission import dev.jorel.commandapi.arguments.DoubleArgument import dev.jorel.commandapi.arguments.PlayerArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.entity.Player fun permissions() { @@ -13,7 +13,7 @@ fun permissions() { // Register the /god command with the permission node "command.god" CommandAPICommand("god") .withPermission(CommandPermission.fromString("command.god")) - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> player.isInvulnerable = true }) .register() @@ -23,7 +23,7 @@ fun permissions() { // Register the /god command with the permission node "command.god", without creating a CommandPermission CommandAPICommand("god") .withPermission("command.god") - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> player.isInvulnerable = true player.sendMessage("God mode enabled") }) @@ -33,7 +33,7 @@ fun permissions() { // #region argumentPermissionExampleStep1 // Register /kill command normally. Since no permissions are applied, anyone can run this command CommandAPICommand("kill") - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> player.health = 0.0 player.sendMessage("God mode enabled") }) @@ -44,7 +44,7 @@ fun permissions() { // Adds the OP permission to the "target" argument. The sender requires OP to execute /kill CommandAPICommand("kill") .withArguments(PlayerArgument("target").withPermission(CommandPermission.OP)) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> (args["target"] as Player).health = 0.0 }) .register() @@ -54,7 +54,7 @@ fun permissions() { // /economy - requires the permission "economy.self" to exectue CommandAPICommand("economy") .withPermission("economy.self") - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> // send the executor their own balance here. }) .register() @@ -63,7 +63,7 @@ fun permissions() { CommandAPICommand("economy") .withPermission("economy.other") // The important part of this example .withArguments(PlayerArgument("target")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target = args["target"] as Player // send the executor the target's balance @@ -76,7 +76,7 @@ fun permissions() { .withPermission("economy.admin.give") // The important part of this example .withArguments(PlayerArgument("target")) .withArguments(DoubleArgument("amount")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target = args["target"] as Player val amount = args["amount"] as Double @@ -89,7 +89,7 @@ fun permissions() { CommandAPICommand("economy") .withPermission("economy.admin.reset") // The important part of this example .withArguments(PlayerArgument("target")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target = args["target"] as Player // reset the target's balance diff --git a/reference-code/src/main/kotlin/createcommands/Registration.kt b/reference-code/src/main/kotlin/createcommands/Registration.kt index b94d724f3..4f066e03b 100644 --- a/reference-code/src/main/kotlin/createcommands/Registration.kt +++ b/reference-code/src/main/kotlin/createcommands/Registration.kt @@ -3,8 +3,9 @@ package createcommands import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.CommandPermission import dev.jorel.commandapi.arguments.GreedyStringArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Bukkit +import org.bukkit.command.CommandSender fun registrationExample() { // #region registrationExample @@ -13,7 +14,7 @@ fun registrationExample() { .withArguments(GreedyStringArgument("message")) // The arguments .withAliases("broadcast", "broadcastmessage") // Command aliases .withPermission(CommandPermission.OP) // Required permissions - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> val message = args["message"] as String Bukkit.getServer().broadcastMessage(message) }) diff --git a/reference-code/src/main/kotlin/createcommands/Requirements.kt b/reference-code/src/main/kotlin/createcommands/Requirements.kt index 767442301..b11fc1475 100644 --- a/reference-code/src/main/kotlin/createcommands/Requirements.kt +++ b/reference-code/src/main/kotlin/createcommands/Requirements.kt @@ -3,7 +3,7 @@ package createcommands import dev.jorel.commandapi.CommandAPI import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.* -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.entity.Player @@ -14,7 +14,7 @@ fun requirements() { // #region baseOnPlayerLevelExample CommandAPICommand("repair") .withRequirement { (it as Player).level >= 30 } - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> // Repair the item back to full durability val item = player.inventory.itemInMainHand @@ -48,7 +48,7 @@ fun requirements() { // #region partySystemExampleStep3 CommandAPICommand("party") .withArguments(*arguments.toTypedArray()) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // Get the name of the party to create val partyName = args["partyName"] as String @@ -96,7 +96,7 @@ fun requirements() { // #region partySystemExampleStep5 CommandAPICommand("party") .withArguments(arguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target = args["player"] as Player player.teleport(target) }) @@ -106,7 +106,7 @@ fun requirements() { // #region updateRequirementsExample CommandAPICommand("party") .withArguments(arguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // Get the name of the party to create val partyName = args["partyName"] as String @@ -123,7 +123,7 @@ fun requirements() { .withRequirement { (it as Player).level >= 30 } .withRequirement { (it as Player).inventory.contains(Material.DIAMOND_PICKAXE) } .withRequirement { (it as Player).isInvulnerable } - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // Code goes here }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/Subcommands.kt b/reference-code/src/main/kotlin/createcommands/Subcommands.kt index 88d0bbbf5..12cb97e7e 100644 --- a/reference-code/src/main/kotlin/createcommands/Subcommands.kt +++ b/reference-code/src/main/kotlin/createcommands/Subcommands.kt @@ -2,18 +2,19 @@ package createcommands import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.stringArgument import dev.jorel.commandapi.kotlindsl.subcommand +import org.bukkit.command.CommandSender fun subcommands() { // #region subcommandsExampleStep1 val groupAdd = CommandAPICommand("add") .withArguments(StringArgument("permission")) .withArguments(StringArgument("groupName")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // perm group add code }) // #endregion subcommandsExampleStep1 @@ -22,7 +23,7 @@ fun subcommands() { val groupRemove = CommandAPICommand("remove") .withArguments(StringArgument("permission")) .withArguments(StringArgument("groupName")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // perm group remove code }) @@ -43,14 +44,14 @@ fun subcommands() { .withSubcommand(CommandAPICommand("add") .withArguments(StringArgument("permission")) .withArguments(StringArgument("groupName")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // perm group add code }) ) .withSubcommand(CommandAPICommand("remove") .withArguments(StringArgument("permission")) .withArguments(StringArgument("groupName")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // perm group remove code }) ) @@ -59,14 +60,14 @@ fun subcommands() { .withSubcommand(CommandAPICommand("add") .withArguments(StringArgument("permission")) .withArguments(StringArgument("userName")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // perm user add code }) ) .withSubcommand(CommandAPICommand("remove") .withArguments(StringArgument("permission")) .withArguments(StringArgument("userName")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // perm user remove code }) ) diff --git a/reference-code/src/main/kotlin/createcommands/Unregistration.kt b/reference-code/src/main/kotlin/createcommands/Unregistration.kt index eb3788ccf..64e27047c 100644 --- a/reference-code/src/main/kotlin/createcommands/Unregistration.kt +++ b/reference-code/src/main/kotlin/createcommands/Unregistration.kt @@ -4,7 +4,8 @@ import dev.jorel.commandapi.CommandAPI import dev.jorel.commandapi.CommandAPIBukkit import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.MultiLiteralArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor +import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin import org.bukkit.scheduler.BukkitRunnable @@ -33,7 +34,7 @@ fun unregistration() { // Register our new /gamemode, with survival, creative, adventure and spectator CommandAPICommand("gamemode") .withArguments(MultiLiteralArgument("gamemodes", "survival", "creative", "adventure", "spectator")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // Implementation of our /gamemode command }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt index ed4967726..004277f55 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt @@ -4,12 +4,13 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.LocationArgument import dev.jorel.commandapi.arguments.PotionEffectArgument import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.arguments import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.stringArgument import org.bukkit.Location +import org.bukkit.command.CommandSender import org.bukkit.potion.PotionEffectType fun arguments() { @@ -52,7 +53,7 @@ fun arguments() { CommandAPICommand("cmd") .withArguments(commandArguments) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val stringArg = args["arg0"] as String val potionArg = args["arg1"] as PotionEffectType val locationArg = args["arg2"] as Location diff --git a/reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt index 4a5818f6f..857836d57 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt @@ -2,7 +2,7 @@ package createcommands.arguments import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.* -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.entity.Player fun commandArguments() { @@ -13,7 +13,7 @@ fun commandArguments() { .withOptionalArguments(PlayerArgument("player")) .withOptionalArguments(PlayerArgument("target")) .withOptionalArguments(GreedyStringArgument("message")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val name = args[0] as String // Access arguments by index val amount = args["amount"] as Int // Access arguments by node name val p = args.getOrDefault("player", player) as Player // Access arguments using the getOrDefault(String, Object) method @@ -27,7 +27,7 @@ fun commandArguments() { // #region getRawExample CommandAPICommand("mycommand") .withArguments(EntitySelectorArgument.ManyEntities("entities")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val entitySelector = args.getRaw("entities")!! // Access the raw argument with getRaw(String) // Do whatever with the entity selector }) @@ -37,7 +37,7 @@ fun commandArguments() { // #region getUncheckedExample CommandAPICommand("mycommand") .withArguments(PlayerArgument("player")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val p: Player = args.getUnchecked("player")!! // Do whatever with the player }) @@ -57,7 +57,7 @@ fun commandArguments() { .withOptionalArguments(playerArgument) .withOptionalArguments(targetArgument) .withOptionalArguments(messageArgument) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val name: String = args.getByArgument(nameArgument)!! val amount: Int = args.getByArgument(amountArgument)!! val p: Player = args.getByArgumentOrDefault(playerArgument, player) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/ListedArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/ListedArguments.kt index e276e45d2..e73806959 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/ListedArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/ListedArguments.kt @@ -4,12 +4,13 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.GreedyStringArgument import dev.jorel.commandapi.arguments.IntegerArgument import dev.jorel.commandapi.arguments.PlayerArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.greedyStringArgument import dev.jorel.commandapi.kotlindsl.integerArgument import dev.jorel.commandapi.kotlindsl.playerArgument +import org.bukkit.command.CommandSender import org.bukkit.entity.Player fun listedArguments() { @@ -18,7 +19,7 @@ fun listedArguments() { .withArguments(PlayerArgument("player")) .withArguments(IntegerArgument("value").setListed(false)) .withArguments(GreedyStringArgument("message")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> // args == [player, message] val player = args["player"] as Player val message = args["message"] as String // Note that the IntegerArgument is not available in the CommandArguments diff --git a/reference-code/src/main/kotlin/createcommands/arguments/OptionalArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/OptionalArguments.kt index 10512917c..796e0311d 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/OptionalArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/OptionalArguments.kt @@ -4,13 +4,8 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.IntegerArgument import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.PlayerCommandExecutor -import dev.jorel.commandapi.kotlindsl.anyExecutor -import dev.jorel.commandapi.kotlindsl.argument -import dev.jorel.commandapi.kotlindsl.commandAPICommand -import dev.jorel.commandapi.kotlindsl.playerArgument -import dev.jorel.commandapi.kotlindsl.playerExecutor +import dev.jorel.commandapi.executors.NormalExecutor +import dev.jorel.commandapi.kotlindsl.* import org.bukkit.command.CommandSender import org.bukkit.entity.Player @@ -18,7 +13,7 @@ fun optionalArguments() { // #region simpleOptionalArgumentsExample CommandAPICommand("sayhi") .withOptionalArguments(PlayerArgument("target")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target: Player? = args["target"] as Player? if (target != null) { target.sendMessage("Hi!") @@ -32,7 +27,7 @@ fun optionalArguments() { // #region getOptionalExample CommandAPICommand("sayhi") .withOptionalArguments(PlayerArgument("target")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target: Player = args.getOptional("target").orElse(player) as Player target.sendMessage("Hi!") }) @@ -43,7 +38,7 @@ fun optionalArguments() { CommandAPICommand("rate") .withOptionalArguments(StringArgument("topic").combineWith(IntegerArgument("rating", 0, 10))) .withOptionalArguments(PlayerArgument("target")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> val topic: String? = args["topic"] as String? if (topic == null) { sender.sendMessage( @@ -51,7 +46,7 @@ fun optionalArguments() { "Select a topic to rate, then give a rating between 0 and 10", "You can optionally add a player at the end to give the rating to" ) - return@CommandExecutor + return@NormalExecutor } // We know this is not null because rating is required if a topic is given @@ -93,7 +88,7 @@ fun optionalArgumentsDSL() { // #region argumentsAfterOptionalArgumentsExampleDSL commandAPICommand("rate") { - argument(StringArgument("topic").setOptional(true).combineWith(IntegerArgument("rating", 0, 10))) + optionalArgument(StringArgument("topic").combineWith(IntegerArgument("rating", 0, 10))) playerArgument("target", optional = true) anyExecutor { sender, args -> val topic: String? = args["topic"] as String? diff --git a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/AsyncSuggestions.kt b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/AsyncSuggestions.kt index 02f3280a1..285319c18 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/AsyncSuggestions.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/AsyncSuggestions.kt @@ -4,11 +4,12 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ArgumentSuggestions import dev.jorel.commandapi.arguments.StringArgument import dev.jorel.commandapi.arguments.TextArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.stringArgument import dev.jorel.commandapi.kotlindsl.textArgument +import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin import java.util.concurrent.CompletableFuture @@ -25,7 +26,7 @@ fun asyncSuggestions() { } )) .withArguments(TextArgument("value")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val key = args["key"] as String val value = args["value"] as String plugin.config.set(key, value) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/SafeSuggestions.kt b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/SafeSuggestions.kt index f65cbf45b..facf7cc2f 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/SafeSuggestions.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/SafeSuggestions.kt @@ -7,7 +7,7 @@ import dev.jorel.commandapi.arguments.EntityTypeArgument import dev.jorel.commandapi.arguments.PotionEffectArgument import dev.jorel.commandapi.arguments.RecipeArgument import dev.jorel.commandapi.arguments.SafeSuggestions -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Bukkit.getServer import org.bukkit.Material import org.bukkit.NamespacedKey @@ -55,7 +55,7 @@ fun safeSuggestions() { // Register our command CommandAPICommand("giverecipe") .withArguments(arguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val recipe = args["recipe"] as Recipe player.inventory.addItem(recipe.result) }) @@ -85,7 +85,7 @@ fun safeSuggestions() { // #region registerSpawnMobCommand CommandAPICommand("spawnmob") .withArguments(safeArguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val entityType = args["mob"] as EntityType player.world.spawnEntity(player.location, entityType) }) @@ -108,7 +108,7 @@ fun safeSuggestions() { // #region registerRemoveEffectCommand CommandAPICommand("removeeffect") .withArguments(safeArgs) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> val target = args["target"] as Player val potionEffect = args["potioneffect"] as PotionEffectType target.removePotionEffect(potionEffect) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/StringSuggestions.kt b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/StringSuggestions.kt index c54656de8..5a841e2d0 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/StringSuggestions.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/StringSuggestions.kt @@ -8,7 +8,7 @@ import dev.jorel.commandapi.arguments.GreedyStringArgument import dev.jorel.commandapi.arguments.IntegerArgument import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Location import org.bukkit.command.CommandSender import org.bukkit.entity.EntityType @@ -43,7 +43,7 @@ fun stringSuggestions() { CommandAPICommand("warp") .withArguments(arguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val warp = args["world"] as String player.teleport(warps[warp]!!) // Look up the warp in a map, for example }) @@ -63,7 +63,7 @@ fun stringSuggestions2() { CommandAPICommand("friendtp") .withArguments(arguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target = args["friend"] as Player player.teleport(target) }) @@ -98,7 +98,7 @@ fun stringSuggestions2() { // Declare our command as normal CommandAPICommand("localmsg") .withArguments(*commandArgs.toTypedArray()) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> val target = args["target"] as Player val message = args["message"] as String target.sendMessage(message) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/Tooltips.kt b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/Tooltips.kt index d1329fb9e..ade83aa1c 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/suggestions/Tooltips.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/suggestions/Tooltips.kt @@ -11,7 +11,7 @@ import dev.jorel.commandapi.arguments.LocationArgument import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.SafeSuggestions import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Location import org.bukkit.Material import org.bukkit.entity.Player @@ -36,7 +36,7 @@ fun tooltips() { // #region registerEmoteCommand CommandAPICommand("emote") .withArguments(*arguments.toTypedArray()) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val emote = args["emote"] as String val target = args["target"] as Player @@ -72,7 +72,7 @@ fun tooltips() { CommandAPICommand("giveitem") .withArguments(StringArgument("item").replaceSuggestions(ArgumentSuggestions.stringsWithTooltips(*customItems))) // We use customItems[] as the input for our suggestions with tooltips - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val itemName = args["item"] as String // Give them the item @@ -106,7 +106,7 @@ fun tooltips2() { // #region registerWarpCommand CommandAPICommand("warp") .withArguments(arguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> player.teleport(args["location"] as Location) }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/CommandArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/CommandArguments.kt index 1c313862a..e771bbbca 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/CommandArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/CommandArguments.kt @@ -5,7 +5,7 @@ import dev.jorel.commandapi.arguments.ArgumentSuggestions import dev.jorel.commandapi.arguments.CommandArgument import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.SuggestionsBranch -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.commandArgument @@ -20,7 +20,7 @@ fun commandArguments() { CommandAPICommand("sudo") .withArguments(PlayerArgument("target")) .withArguments(CommandArgument("command")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["target"] as Player val command = args["command"] as CommandResult diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/CustomArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/CustomArguments.kt index 15dd32460..76e1af899 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/CustomArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/CustomArguments.kt @@ -7,11 +7,12 @@ import dev.jorel.commandapi.arguments.CustomArgument import dev.jorel.commandapi.arguments.CustomArgument.CustomArgumentException import dev.jorel.commandapi.arguments.CustomArgument.MessageBuilder import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.Bukkit import org.bukkit.World +import org.bukkit.entity.Player // #region declareCustomArgumentsExample // Function that returns our custom argument @@ -38,7 +39,7 @@ fun customArguments() { // #region useCustomArgumentsExample CommandAPICommand("tpworld") .withArguments(worldArgument("world")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> player.teleport((args["world"] as World).spawnLocation) }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/EntitiesArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/EntitiesArguments.kt index b36173bea..7774cfbc7 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/EntitiesArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/EntitiesArguments.kt @@ -7,8 +7,7 @@ import dev.jorel.commandapi.arguments.EntityTypeArgument import dev.jorel.commandapi.arguments.IntegerArgument import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.SafeSuggestions -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.asyncOfflinePlayerArgument @@ -18,6 +17,7 @@ import dev.jorel.commandapi.kotlindsl.integerArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.Bukkit import org.bukkit.OfflinePlayer +import org.bukkit.command.CommandSender import org.bukkit.entity.Entity import org.bukkit.entity.EntityType import org.bukkit.entity.Player @@ -28,7 +28,7 @@ fun entitiesArguments() { CommandAPICommand("remove") // Using a collective entity selector to select multiple entities .withArguments(EntitySelectorArgument.ManyEntities("entities")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // Parse the argument as a collection of entities (as stated above in the documentation) val entities = args["entities"] as Collection @@ -50,7 +50,7 @@ fun entitiesArguments() { // #region noSelectorSuggestionsExample CommandAPICommand("warp") .withArguments(noSelectorSuggestions) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val target = args["target"] as Player player.teleport(target) }) @@ -60,7 +60,7 @@ fun entitiesArguments() { // #region playedBeforeArgumentExample CommandAPICommand("playedbefore") .withArguments(AsyncOfflinePlayerArgument("player")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> val player = args["player"] as CompletableFuture // Directly sends a message to the sender, indicating that the command is running to prevent confusion @@ -88,7 +88,7 @@ fun entitiesArguments() { CommandAPICommand("spawnmob") .withArguments(EntityTypeArgument("entity")) .withArguments(IntegerArgument("amount", 1, 100)) // Prevent spawning too many entities - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> for (i in 0 until args["amount"] as Int) { player.world.spawnEntity(player.location, args["entity"] as EntityType) } diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/ListArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/ListArguments.kt index 384ba1c5a..ea4d7a671 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/ListArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/ListArguments.kt @@ -3,12 +3,13 @@ package createcommands.arguments.types import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.IntegerArgument import dev.jorel.commandapi.arguments.ListArgumentBuilder -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.argument import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.integerArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.Material +import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack fun listArguments() { @@ -20,7 +21,7 @@ fun listArguments() { .withMapper { material -> material.name.lowercase() } .buildGreedy() ) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val amount = args["amount"] as Int val theList = args["materials"] as List diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/MapArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/MapArguments.kt index 5c107498b..915bbfc14 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/MapArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/MapArguments.kt @@ -2,7 +2,7 @@ package createcommands.arguments.types import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.MapArgumentBuilder -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.argument import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerExecutor @@ -31,7 +31,7 @@ fun mapArguments() { // Build the MapArgument .build() ) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> // The MapArgument returns a LinkedHashMap val map: LinkedHashMap = args["message"] as LinkedHashMap diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/NBTArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/NBTArguments.kt index 5a5758f85..b31fd20b3 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/NBTArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/NBTArguments.kt @@ -5,10 +5,11 @@ import dev.jorel.commandapi.CommandAPI import dev.jorel.commandapi.CommandAPIBukkitConfig import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.NBTCompoundArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.nbtCompoundArgument +import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin val nbtArguments = object : JavaPlugin() { @@ -25,7 +26,7 @@ fun nbtArguments() { // #region nbtCompoundArgumentsExample CommandAPICommand("award") .withArguments(NBTCompoundArgument("nbt")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val nbt = args["nbt"] as NBTContainer // Do something with "nbt" here... }) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/PrimitiveArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/PrimitiveArguments.kt index ca2b1d46d..98aca1e1a 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/PrimitiveArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/PrimitiveArguments.kt @@ -4,11 +4,12 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ArgumentSuggestions import dev.jorel.commandapi.arguments.BooleanArgument import dev.jorel.commandapi.arguments.TextArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.argument import dev.jorel.commandapi.kotlindsl.booleanArgument import dev.jorel.commandapi.kotlindsl.commandAPICommand +import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin val primitiveArguments = object : JavaPlugin() { @@ -24,7 +25,7 @@ val primitiveArguments = object : JavaPlugin() { ArgumentSuggestions.strings { _ -> configKeys }) ) .withArguments(BooleanArgument("value")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> // Update the config with the boolean argument config.set(args["config-key"] as String, args["value"] as Boolean) }) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/RangedArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/RangedArguments.kt index 0711401f1..ec9d043e0 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/RangedArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/RangedArguments.kt @@ -3,7 +3,7 @@ package createcommands.arguments.types import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.IntegerRangeArgument import dev.jorel.commandapi.arguments.ItemStackArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.integerRangeArgument import dev.jorel.commandapi.kotlindsl.itemStackArgument @@ -11,6 +11,7 @@ import dev.jorel.commandapi.kotlindsl.playerExecutor import dev.jorel.commandapi.wrappers.IntegerRange import org.bukkit.Location import org.bukkit.block.Chest +import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack fun rangedArguments() { @@ -18,7 +19,7 @@ fun rangedArguments() { CommandAPICommand("searchchests") .withArguments(IntegerRangeArgument("range")) // Range argument .withArguments(ItemStackArgument("item")) // The item to search for - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // Retrieve the range from the arguments val range = args["range"] as IntegerRange val itemStack = args["item"] as ItemStack diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/StringsArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/StringsArguments.kt index 041b5925a..9273c36f6 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/StringsArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/StringsArguments.kt @@ -3,11 +3,12 @@ package createcommands.arguments.types import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.GreedyStringArgument import dev.jorel.commandapi.arguments.PlayerArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.greedyStringArgument import dev.jorel.commandapi.kotlindsl.playerArgument +import org.bukkit.command.CommandSender import org.bukkit.entity.Player fun stringsArguments() { @@ -15,7 +16,7 @@ fun stringsArguments() { CommandAPICommand("message") .withArguments(PlayerArgument("target")) .withArguments(GreedyStringArgument("message")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> (args["target"] as Player).sendMessage(args["message"] as String) }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/chat/AdventureChatArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/chat/AdventureChatArguments.kt index 15f1d117a..4e98d7517 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/chat/AdventureChatArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/chat/AdventureChatArguments.kt @@ -7,8 +7,7 @@ import dev.jorel.commandapi.arguments.AdventureChatComponentArgument import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.StringArgument import dev.jorel.commandapi.arguments.TextArgument -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.adventureChatArgument import dev.jorel.commandapi.kotlindsl.adventureChatComponentArgument import dev.jorel.commandapi.kotlindsl.anyExecutor @@ -23,13 +22,14 @@ import net.kyori.adventure.text.Component import net.kyori.adventure.text.format.NamedTextColor import org.bukkit.Bukkit import org.bukkit.Server +import org.bukkit.command.CommandSender import org.bukkit.entity.Player fun adventureChatArguments() { // #region namedTextColorExample CommandAPICommand("namecolor") .withArguments(AdventureChatColorArgument("chatcolor")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val color = args["chatcolor"] as NamedTextColor player.displayName(Component.text().color(color).append(Component.text(player.name)).build()) }) @@ -42,7 +42,7 @@ fun adventureChatArguments() { .withArguments(TextArgument("title")) .withArguments(StringArgument("author")) .withArguments(AdventureChatComponentArgument("contents")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["target"] as Player val title = args["title"] as String val author = args["author"] as String @@ -58,7 +58,7 @@ fun adventureChatArguments() { // #region chatArgumentExample CommandAPICommand("pbroadcast") .withArguments(AdventureChatArgument("message")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val message = args["message"] as Component // Broadcast the message to everyone with broadcast permissions. diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/chat/ChatPreview.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/chat/ChatPreview.kt index 1143a0828..ef075dbe5 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/chat/ChatPreview.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/chat/ChatPreview.kt @@ -3,7 +3,7 @@ package createcommands.arguments.types.chat import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.AdventureChatArgument import dev.jorel.commandapi.arguments.ChatArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import net.kyori.adventure.text.Component import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer @@ -11,6 +11,7 @@ import net.md_5.bungee.api.chat.BaseComponent import net.md_5.bungee.api.chat.TextComponent import org.bukkit.Bukkit import org.bukkit.ChatColor +import org.bukkit.entity.Player fun chatPreview() { // #region chatPreviewAdventureExample @@ -22,7 +23,7 @@ fun chatPreview() { // Translate the & in plain text and generate a new Component LegacyComponentSerializer.legacyAmpersand().deserialize(plainText) } ) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> // The user still entered a legacy text. We need to properly convert this // to a Component by converting to plain text then to Component val plainText: String = PlainTextComponentSerializer.plainText().serialize(args["message"] as Component) @@ -40,7 +41,7 @@ fun chatPreview() { // Translate the & in plain text and generate a new BaseComponent[] TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', plainText)) } ) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> // The user still entered a legacy text. We need to properly convert this // to a BaseComponent[] by converting to plain text then to BaseComponent[] val plainText: String = BaseComponent.toPlainText(*args["message"] as Array) @@ -59,7 +60,7 @@ fun chatPreview() { // Translate the & in plain text and generate a new Component LegacyComponentSerializer.legacyAmpersand().deserialize(plainText) } ) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> Bukkit.broadcast(args["message"] as Component) }) .register() @@ -74,7 +75,7 @@ fun chatPreview() { // Translate the & in plain text and generate a new BaseComponent[] TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', plainText)) } ) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> Bukkit.spigot().broadcast(*args["message"] as Array) }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/chat/SpigotChatArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/chat/SpigotChatArguments.kt index ec5ea83c2..b02348b97 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/chat/SpigotChatArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/chat/SpigotChatArguments.kt @@ -5,8 +5,7 @@ import dev.jorel.commandapi.arguments.ChatArgument import dev.jorel.commandapi.arguments.ChatColorArgument import dev.jorel.commandapi.arguments.ChatComponentArgument import dev.jorel.commandapi.arguments.PlayerArgument -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.chatArgument import dev.jorel.commandapi.kotlindsl.chatColorArgument @@ -18,6 +17,7 @@ import net.md_5.bungee.api.chat.BaseComponent import org.bukkit.Bukkit import org.bukkit.ChatColor import org.bukkit.Material +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import org.bukkit.inventory.meta.BookMeta @@ -26,7 +26,7 @@ fun spigotChatArguments() { // #region chatColorArgumentExample CommandAPICommand("namecolor") .withArguments(ChatColorArgument("chatColor")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val color = args["chatColor"] as ChatColor player.setDisplayName("$color${player.name}") }) @@ -37,7 +37,7 @@ fun spigotChatArguments() { CommandAPICommand("makebook") .withArguments(PlayerArgument("player")) .withArguments(ChatComponentArgument("contents")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val player = args["player"] as Player val arr = args["contents"] as Array @@ -58,7 +58,7 @@ fun spigotChatArguments() { // #region chatArgumentExample CommandAPICommand("pbroadcast") .withArguments(ChatArgument("message")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val message = args["message"] as Array // Broadcast the message to everyone on the server diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/literal/LiteralArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/literal/LiteralArguments.kt index d27448fb9..ded779e21 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/literal/LiteralArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/literal/LiteralArguments.kt @@ -3,8 +3,7 @@ package createcommands.arguments.types.literal import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.LiteralArgument import dev.jorel.commandapi.arguments.TextArgument -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.argument import dev.jorel.commandapi.kotlindsl.commandAPICommand @@ -12,13 +11,15 @@ import dev.jorel.commandapi.kotlindsl.literalArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import dev.jorel.commandapi.kotlindsl.textArgument import org.bukkit.GameMode +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player fun literalArguments() { // #region showLiteralArgumentsIsNotListed CommandAPICommand("mycommand") .withArguments(LiteralArgument("hello")) .withArguments(TextArgument("text")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> // This gives the variable "text" the contents of the TextArgument, and not the literal "hello" val text = args[0] as String }) @@ -29,7 +30,7 @@ fun literalArguments() { CommandAPICommand("mycommand") .withArguments(LiteralArgument.of("hello")) .withArguments(TextArgument("text")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val text = args[0] as String }) .register() @@ -37,7 +38,7 @@ fun literalArguments() { CommandAPICommand("mycommand") .withArguments(LiteralArgument.literal("hello")) .withArguments(TextArgument("text")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val text = args[0] as String }) .register() @@ -57,7 +58,7 @@ fun literalArguments() { // Register the command as usual CommandAPICommand("changegamemode") .withArguments(LiteralArgument(key)) - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> // Retrieve the object from the map via the key and NOT the args[] player.gameMode = gamemodes[key]!! }) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/literal/MultiLiteralArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/literal/MultiLiteralArguments.kt index 271375910..ba522ce19 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/literal/MultiLiteralArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/literal/MultiLiteralArguments.kt @@ -2,17 +2,18 @@ package createcommands.arguments.types.literal import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.MultiLiteralArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.multiLiteralArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.GameMode +import org.bukkit.entity.Player fun multiliteralArguments() { // #region multiliteralArgumentsExample CommandAPICommand("gamemode") .withArguments(MultiLiteralArgument("gamemodes", "adventure", "creative", "spectator", "survival")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // The literal string that the player enters IS available in the args[] when (args["gamemodes"] as String) { "adventure" -> player.gameMode = GameMode.ADVENTURE diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/AdvancementArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/AdvancementArguments.kt index eccdf56f8..5a8f4c8ae 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/AdvancementArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/AdvancementArguments.kt @@ -3,12 +3,13 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.AdvancementArgument import dev.jorel.commandapi.arguments.PlayerArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.advancementArgument import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerArgument import org.bukkit.advancement.Advancement +import org.bukkit.command.CommandSender import org.bukkit.entity.Player fun advancementArguments() { @@ -16,7 +17,7 @@ fun advancementArguments() { CommandAPICommand("award") .withArguments(PlayerArgument("player")) .withArguments(AdvancementArgument("advancement")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["player"] as Player val advancement = args["advancement"] as Advancement diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BiomeArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BiomeArguments.kt index 575c1f7d4..de654ccf9 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BiomeArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BiomeArguments.kt @@ -2,17 +2,18 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.BiomeArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.biomeArgument import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.block.Biome +import org.bukkit.entity.Player fun biomeArguments() { // #region biomeArgumentsExample CommandAPICommand("setbiome") .withArguments(BiomeArgument("biome")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val biome = args["biome"] as Biome val chunk = player.location.chunk diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BlockStateArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BlockStateArguments.kt index bba5283f3..adc37b0fa 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BlockStateArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/BlockStateArguments.kt @@ -2,17 +2,18 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.BlockStateArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.blockStateArgument import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.block.data.BlockData +import org.bukkit.entity.Player fun blockStateArguments() { // #region blockStateArgumentsExample CommandAPICommand("set") .withArguments(BlockStateArgument("block")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val blockdata = args["block"] as BlockData val targetBlock = player.getTargetBlockExact(256) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/EnchantmentArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/EnchantmentArguments.kt index efc62166f..911af155a 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/EnchantmentArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/EnchantmentArguments.kt @@ -3,19 +3,20 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.EnchantmentArgument import dev.jorel.commandapi.arguments.IntegerArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.enchantmentArgument import dev.jorel.commandapi.kotlindsl.integerArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.enchantments.Enchantment +import org.bukkit.entity.Player fun enchantmentArguments() { // #region enchantmentArgumentsExample CommandAPICommand("enchantitem") .withArguments(EnchantmentArgument("enchantment")) .withArguments(IntegerArgument("level", 1, 5)) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val enchantment = args["enchantment"] as Enchantment val level = args["level"] as Int diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ItemStackArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ItemStackArguments.kt index 06a3ff187..2cc6e587e 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ItemStackArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ItemStackArguments.kt @@ -2,17 +2,18 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ItemStackArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.itemStackArgument import dev.jorel.commandapi.kotlindsl.playerExecutor +import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack fun itemStackArguments() { // #region itemStackArgumentsExample CommandAPICommand("item") .withArguments(ItemStackArgument("itemStack")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> player.inventory.addItem(args["itemStack"] as ItemStack) }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/LootTableArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/LootTableArguments.kt index eb84d588d..88684f8be 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/LootTableArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/LootTableArguments.kt @@ -4,13 +4,14 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.LocationArgument import dev.jorel.commandapi.arguments.LocationType import dev.jorel.commandapi.arguments.LootTableArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.locationArgument import dev.jorel.commandapi.kotlindsl.lootTableArgument import org.bukkit.Location import org.bukkit.block.Container +import org.bukkit.command.CommandSender import org.bukkit.loot.LootTable import org.bukkit.loot.Lootable @@ -19,7 +20,7 @@ fun lootTableArguments() { CommandAPICommand("giveloottable") .withArguments(LootTableArgument("lootTable")) .withArguments(LocationArgument("location", LocationType.BLOCK_POSITION)) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val lootTable = args["lootTable"] as LootTable val location = args["location"] as Location diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/MathOperationArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/MathOperationArguments.kt index db30c1c06..39b974714 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/MathOperationArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/MathOperationArguments.kt @@ -4,9 +4,10 @@ import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.IntegerArgument import dev.jorel.commandapi.arguments.MathOperationArgument import dev.jorel.commandapi.arguments.PlayerArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.* import dev.jorel.commandapi.wrappers.MathOperation +import org.bukkit.command.CommandSender import org.bukkit.entity.Player fun mathOperationArguments() { @@ -15,7 +16,7 @@ fun mathOperationArguments() { .withArguments(PlayerArgument("player")) .withArguments(MathOperationArgument("operation")) .withArguments(IntegerArgument("value")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["player"] as Player val op = args["operation"] as MathOperation val value = args["value"] as Int diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ParticleArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ParticleArguments.kt index 599207ac5..d8bb63cd0 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ParticleArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/ParticleArguments.kt @@ -2,17 +2,18 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ParticleArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.particleArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import dev.jorel.commandapi.wrappers.ParticleData +import org.bukkit.entity.Player fun particleArguments() { // #region withoutParticleDataExample CommandAPICommand("showparticle") .withArguments(ParticleArgument("particle")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val particleData = args["particle"] as ParticleData player.world.spawnParticle(particleData.particle(), player.location, 1) }) @@ -22,7 +23,7 @@ fun particleArguments() { // #region withParticleDataExample CommandAPICommand("showparticle") .withArguments(ParticleArgument("particle")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val particleData = args["particle"] as ParticleData player.world.spawnParticle(particleData.particle(), player.location, 1, particleData.data()) }) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/PotionArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/PotionArguments.kt index aee9cc27a..a35edc882 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/PotionArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/PotionArguments.kt @@ -5,9 +5,10 @@ import dev.jorel.commandapi.arguments.IntegerArgument import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.PotionEffectArgument import dev.jorel.commandapi.arguments.TimeArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.* import org.bukkit.NamespacedKey +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.potion.PotionEffect import org.bukkit.potion.PotionEffectType @@ -19,7 +20,7 @@ fun potionArguments() { .withArguments(PotionEffectArgument("potion")) .withArguments(TimeArgument("duration")) .withArguments(IntegerArgument("strength")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["target"] as Player val potion = args["potion"] as PotionEffectType val duration = args["duration"] as Int @@ -37,7 +38,7 @@ fun potionArguments() { .withArguments(PotionEffectArgument.NamespacedKey("potion")) .withArguments(TimeArgument("duration")) .withArguments(IntegerArgument("strength")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["target"] as Player val potionKey = args["potion"] as NamespacedKey val duration = args["duration"] as Int diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/RecipeArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/RecipeArguments.kt index 3ea1aed74..d4583a899 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/RecipeArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/RecipeArguments.kt @@ -3,9 +3,9 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.RecipeArgument -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.* +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.inventory.ComplexRecipe @@ -13,7 +13,7 @@ fun recipeArguments() { // #region getResultExample CommandAPICommand("giverecipe") .withArguments(RecipeArgument("recipe")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val recipe = args["recipe"] as ComplexRecipe player.inventory.addItem(recipe.result) }) @@ -24,7 +24,7 @@ fun recipeArguments() { CommandAPICommand("unlockrecipe") .withArguments(PlayerArgument("player")) .withArguments(RecipeArgument("recipe")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val target = args["player"] as Player val recipe = args["recipe"] as ComplexRecipe diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/SoundArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/SoundArguments.kt index 2b51fdcdb..68cddc023 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/SoundArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/SoundArguments.kt @@ -2,18 +2,19 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.SoundArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerExecutor import dev.jorel.commandapi.kotlindsl.soundArgument import org.bukkit.NamespacedKey import org.bukkit.Sound +import org.bukkit.entity.Player fun soundArguments() { // #region soundArgumentsExample CommandAPICommand("sound") .withArguments(SoundArgument("sound")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> player.world.playSound(player.location, args["sound"] as Sound, 100.0f, 1.0f) }) .register() @@ -22,7 +23,7 @@ fun soundArguments() { // #region soundArgumentsNamespacedKeyExample CommandAPICommand("sound") .withArguments(SoundArgument.NamespacedKey("sound")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> player.world.playSound(player.location, (args["sound"] as NamespacedKey).asString(), 100.0f, 1.0f) }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/TimeArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/TimeArguments.kt index 76eea3b09..471ae22df 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/TimeArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/TimeArguments.kt @@ -3,19 +3,20 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.GreedyStringArgument import dev.jorel.commandapi.arguments.TimeArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.greedyStringArgument import dev.jorel.commandapi.kotlindsl.timeArgument import org.bukkit.Bukkit +import org.bukkit.command.CommandSender fun timeArguments() { // #region timeArgumentsExample CommandAPICommand("bigmsg") .withArguments(TimeArgument("duration")) .withArguments(GreedyStringArgument("message")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> // Duration in ticks val duration = args["duration"] as Int val message = args["message"] as String diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/WorldArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/WorldArguments.kt index 1ced2244c..c015565e7 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/misc/WorldArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/misc/WorldArguments.kt @@ -2,18 +2,19 @@ package createcommands.arguments.types.misc import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.WorldArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.worldArgument import org.bukkit.Bukkit import org.bukkit.World +import org.bukkit.command.CommandSender fun worldArguments() { // #region worldArgumentsExample CommandAPICommand("unloadworld") .withArguments(WorldArgument("world")) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> val world = args["world"] as World // Unload the world (and save the world's chunks) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/position/LocationArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/position/LocationArguments.kt index 7cb9f82b4..67e5f9e83 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/position/LocationArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/position/LocationArguments.kt @@ -3,12 +3,13 @@ package createcommands.arguments.types.position import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.LocationArgument import dev.jorel.commandapi.arguments.LocationType -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.locationArgument import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.Location import org.bukkit.Material +import org.bukkit.entity.Player fun locationArguments() { // #region centerPositionExample @@ -23,7 +24,7 @@ fun locationArguments() { CommandAPICommand("break") // We want to focus on blocks in particular, so use BLOCK_POSITION .withArguments(LocationArgument("block", LocationType.BLOCK_POSITION)) - .executesPlayer(PlayerCommandExecutor { _, args -> + .executesPlayer(NormalExecutor { _, args -> (args["block"] as Location).block.type = Material.AIR }) .register() diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/position/RotationArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/position/RotationArguments.kt index 8d096105b..f6f684ee4 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/position/RotationArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/position/RotationArguments.kt @@ -3,12 +3,13 @@ package createcommands.arguments.types.position import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.EntitySelectorArgument import dev.jorel.commandapi.arguments.RotationArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.entitySelectorArgumentOneEntity import dev.jorel.commandapi.kotlindsl.rotationArgument import dev.jorel.commandapi.wrappers.Rotation +import org.bukkit.command.CommandSender import org.bukkit.entity.ArmorStand import org.bukkit.entity.Entity import org.bukkit.util.EulerAngle @@ -18,7 +19,7 @@ fun rotationArguments() { CommandAPICommand("rotate") .withArguments(RotationArgument("rotation")) .withArguments(EntitySelectorArgument.OneEntity("target")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val rotation = args["rotation"] as Rotation val target = args["target"] as Entity diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/BlockPredicateArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/BlockPredicateArguments.kt index 6ad517c6a..b484cfc92 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/BlockPredicateArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/BlockPredicateArguments.kt @@ -5,12 +5,13 @@ import dev.jorel.commandapi.arguments.Argument import dev.jorel.commandapi.arguments.BlockPredicateArgument import dev.jorel.commandapi.arguments.BlockStateArgument import dev.jorel.commandapi.arguments.IntegerArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.arguments import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerExecutor import org.bukkit.block.Block import org.bukkit.block.data.BlockData +import org.bukkit.entity.Player import java.util.function.Predicate import kotlin.math.sqrt @@ -26,7 +27,7 @@ fun blockPredicateArguments() { // #region blockPredicateArgumentsExample CommandAPICommand("replace") .withArguments(*arguments) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // Parse the arguments val radius = args["radius"] as Int val predicate = args["fromBlock"] as Predicate diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/ItemStackPredicateArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/ItemStackPredicateArguments.kt index 9e527bfdb..68d1faa74 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/ItemStackPredicateArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/predicate/ItemStackPredicateArguments.kt @@ -2,10 +2,11 @@ package createcommands.arguments.types.predicate import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ItemStackPredicateArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.itemStackPredicateArgument import dev.jorel.commandapi.kotlindsl.playerExecutor +import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import java.util.function.Predicate @@ -14,7 +15,7 @@ fun itemStackPredicateArguments() { // Register our command CommandAPICommand("rem") .withArguments(ItemStackPredicateArgument("items")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> // Get our predicate val predicate = args["items"] as Predicate diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ObjectiveArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ObjectiveArguments.kt index 8ef27d4ff..3eccf99e1 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ObjectiveArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ObjectiveArguments.kt @@ -3,12 +3,13 @@ package createcommands.arguments.types.scoreboard import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ObjectiveArgument import dev.jorel.commandapi.arguments.ObjectiveCriteriaArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.objectiveArgument import dev.jorel.commandapi.kotlindsl.objectiveCriteriaArgument import org.bukkit.Bukkit +import org.bukkit.command.CommandSender import org.bukkit.scoreboard.DisplaySlot import org.bukkit.scoreboard.Objective @@ -16,7 +17,7 @@ fun objectiveArguments() { // #region objectiveArgumentsExample CommandAPICommand("sidebar") .withArguments(ObjectiveArgument("objective")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val objective = args["objective"] as Objective // Set display slot @@ -28,7 +29,7 @@ fun objectiveArguments() { // #region objectiveCriteriaArgumentsExample CommandAPICommand("unregisterall") .withArguments(ObjectiveCriteriaArgument("objective criteria")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val objectiveCriteria = args["objective criteria"] as String val objectives = Bukkit.getScoreboardManager().mainScoreboard.getObjectivesByCriteria(objectiveCriteria) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ScoreboardArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ScoreboardArguments.kt index 03677ecda..c7ff14ea9 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ScoreboardArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/ScoreboardArguments.kt @@ -3,7 +3,7 @@ package createcommands.arguments.types.scoreboard import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ScoreHolderArgument import dev.jorel.commandapi.arguments.ScoreboardSlotArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.scoreHolderArgumentMultiple @@ -11,6 +11,7 @@ import dev.jorel.commandapi.kotlindsl.scoreboardSlotArgument import dev.jorel.commandapi.wrappers.ScoreboardSlot import org.bukkit.Bukkit import org.bukkit.Material +import org.bukkit.command.CommandSender import org.bukkit.inventory.ItemStack fun scoreboardArguments() { @@ -18,7 +19,7 @@ fun scoreboardArguments() { CommandAPICommand("reward") // We want multiple players, so we use the ScoreHolderArgument.Multiple constructor .withArguments(ScoreHolderArgument.Multiple("players")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> // Get player names by casting to Collection val players = args["players"] as Collection @@ -32,7 +33,7 @@ fun scoreboardArguments() { // #region scoreboardSlotArgumentExample CommandAPICommand("clearobjectives") .withArguments(ScoreboardSlotArgument("slot")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val scoreboard = Bukkit.getScoreboardManager().mainScoreboard val slot = (args["slot"] as ScoreboardSlot).displaySlot scoreboard.clearSlot(slot) diff --git a/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/TeamArguments.kt b/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/TeamArguments.kt index 8602631e6..9eeaaf651 100644 --- a/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/TeamArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/arguments/types/scoreboard/TeamArguments.kt @@ -2,17 +2,18 @@ package createcommands.arguments.types.scoreboard import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.TeamArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.teamArgument +import org.bukkit.command.CommandSender import org.bukkit.scoreboard.Team fun teamArguments() { // #region teamArgumentsExample CommandAPICommand("togglepvp") .withArguments(TeamArgument("team")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val team = args["team"] as Team // Toggle pvp diff --git a/reference-code/src/main/kotlin/createcommands/executors/HandleFailures.kt b/reference-code/src/main/kotlin/createcommands/executors/HandleFailures.kt index 6354557ae..55b9513c3 100644 --- a/reference-code/src/main/kotlin/createcommands/executors/HandleFailures.kt +++ b/reference-code/src/main/kotlin/createcommands/executors/HandleFailures.kt @@ -4,7 +4,8 @@ import dev.jorel.commandapi.CommandAPI import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ArgumentSuggestions import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor +import org.bukkit.command.CommandSender fun handleFailures() { // #region handleFailuresExample @@ -14,7 +15,7 @@ fun handleFailures() { // Register the command CommandAPICommand("getfruit") .withArguments(StringArgument("item").replaceSuggestions(ArgumentSuggestions.strings(fruit))) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val inputFruit = args["item"] as String if (fruit.any { it == inputFruit }) { diff --git a/reference-code/src/main/kotlin/createcommands/executors/NativeSender.kt b/reference-code/src/main/kotlin/createcommands/executors/NativeSender.kt index 249dbf881..e3d87ef8d 100644 --- a/reference-code/src/main/kotlin/createcommands/executors/NativeSender.kt +++ b/reference-code/src/main/kotlin/createcommands/executors/NativeSender.kt @@ -1,14 +1,15 @@ package createcommands.executors import dev.jorel.commandapi.CommandAPICommand -import dev.jorel.commandapi.executors.NativeCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.nativeExecutor +import dev.jorel.commandapi.wrappers.NativeProxyCommandSender fun nativeSender() { // #region breakCommandExample CommandAPICommand("break") - .executesNative(NativeCommandExecutor { sender, _ -> + .executesNative(NormalExecutor { sender, _ -> val location = sender.location location.block.breakNaturally() }) diff --git a/reference-code/src/main/kotlin/createcommands/executors/NormalExecutors.kt b/reference-code/src/main/kotlin/createcommands/executors/NormalExecutors.kt index b0b790a59..bed04cc67 100644 --- a/reference-code/src/main/kotlin/createcommands/executors/NormalExecutors.kt +++ b/reference-code/src/main/kotlin/createcommands/executors/NormalExecutors.kt @@ -3,13 +3,14 @@ package createcommands.executors import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.CommandPermission import dev.jorel.commandapi.arguments.GreedyStringArgument -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.EntityCommandExecutor import dev.jorel.commandapi.executors.ExecutorType -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Bukkit +import org.bukkit.command.CommandSender import org.bukkit.command.ProxiedCommandSender +import org.bukkit.entity.Entity import org.bukkit.entity.LivingEntity +import org.bukkit.entity.Player fun normalExecutors() { // #region broadcastExample @@ -18,7 +19,7 @@ fun normalExecutors() { .withArguments(GreedyStringArgument("message")) // The arguments .withAliases("broadcast", "broadcastmessage") // Command aliases .withPermission(CommandPermission.OP) // Required permissions - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val message = args["message"] as String Bukkit.getServer().broadcastMessage(message) }) @@ -27,7 +28,7 @@ fun normalExecutors() { // #region suicideExample CommandAPICommand("suicide") - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> player.health = 0.0 }) .register() @@ -35,10 +36,10 @@ fun normalExecutors() { // #region differentImplExample CommandAPICommand("suicide") - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> player.health = 0.0 }) - .executesEntity(EntityCommandExecutor { entity, _ -> + .executesEntity(NormalExecutor { entity, _ -> entity.world.createExplosion(entity.location, 4f) entity.remove() }) @@ -47,7 +48,7 @@ fun normalExecutors() { // #region sameImplExample CommandAPICommand("suicide") - .executes(CommandExecutor { sender, _ -> + .executes(NormalExecutor { sender, _ -> val entity = (if (sender is ProxiedCommandSender) sender.callee else sender) as LivingEntity entity.health = 0.0 }, ExecutorType.PLAYER, ExecutorType.PROXY) diff --git a/reference-code/src/main/kotlin/createcommands/executors/ProxySender.kt b/reference-code/src/main/kotlin/createcommands/executors/ProxySender.kt index e2f3307b7..3e53da0d1 100644 --- a/reference-code/src/main/kotlin/createcommands/executors/ProxySender.kt +++ b/reference-code/src/main/kotlin/createcommands/executors/ProxySender.kt @@ -1,17 +1,18 @@ package createcommands.executors import dev.jorel.commandapi.CommandAPICommand -import dev.jorel.commandapi.executors.PlayerCommandExecutor -import dev.jorel.commandapi.executors.ProxyCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.playerExecutor import dev.jorel.commandapi.kotlindsl.proxyExecutor +import dev.jorel.commandapi.wrappers.NativeProxyCommandSender import org.bukkit.entity.LivingEntity +import org.bukkit.entity.Player fun proxySender() { // #region simpleKillCommandExample CommandAPICommand("killme") - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> player.health = 0.0 }) .register() @@ -19,10 +20,10 @@ fun proxySender() { // #region proxyKillCommandExample CommandAPICommand("killme") - .executesPlayer(PlayerCommandExecutor { player, _ -> + .executesPlayer(NormalExecutor { player, _ -> player.health = 0.0 }) - .executesProxy(ProxyCommandExecutor { proxy, _ -> + .executesProxy(NormalExecutor { proxy, _ -> // Check if the callee (target) is an Entity and kill it if (proxy.callee is LivingEntity) { (proxy.callee as LivingEntity).health = 0.0 diff --git a/reference-code/src/main/kotlin/createcommands/executors/ResultingExecutors.kt b/reference-code/src/main/kotlin/createcommands/executors/ResultingExecutors.kt index 6775beb1e..5b8cafb2c 100644 --- a/reference-code/src/main/kotlin/createcommands/executors/ResultingExecutors.kt +++ b/reference-code/src/main/kotlin/createcommands/executors/ResultingExecutors.kt @@ -2,14 +2,15 @@ package createcommands.executors import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.EntitySelectorArgument -import dev.jorel.commandapi.executors.CommandExecutor -import dev.jorel.commandapi.executors.ResultingCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor +import dev.jorel.commandapi.executors.ResultingExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.anyResultingExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.entitySelectorArgumentOnePlayer import org.bukkit.Bukkit import org.bukkit.Material +import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import kotlin.random.Random @@ -17,7 +18,7 @@ import kotlin.random.Random fun resultingExecutors() { // #region randomResultCommandExample CommandAPICommand("randnum") - .executes(ResultingCommandExecutor { _, _ -> + .executes(ResultingExecutor { _, _ -> Random.nextInt() }) .register() @@ -26,7 +27,7 @@ fun resultingExecutors() { // #region randomNumberCommandExample // Register random number generator command from 1 to 99 (inclusive) CommandAPICommand("randomnumber") - .executes(ResultingCommandExecutor { _, _ -> + .executes(ResultingExecutor { _, _ -> (1..100).random() // Returns random number from 1 <= x < 100 }) .register() @@ -36,7 +37,7 @@ fun resultingExecutors() { // Register reward giving system for a target player CommandAPICommand("givereward") .withArguments(EntitySelectorArgument.OnePlayer("target")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val player = args["target"] as Player player.inventory.addItem(ItemStack(Material.DIAMOND, 64)) Bukkit.broadcastMessage("${player.name} won a rare 64 diamonds from a loot box!") diff --git a/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionArguments.kt b/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionArguments.kt index fbe40ae46..d4ef1f8ae 100644 --- a/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionArguments.kt +++ b/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionArguments.kt @@ -2,17 +2,18 @@ package createcommands.functionsandtags import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.FunctionArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandAPICommand import dev.jorel.commandapi.kotlindsl.functionArgument import dev.jorel.commandapi.wrappers.FunctionWrapper +import org.bukkit.command.CommandSender fun functionArguments() { // #region functionArgumentsExample CommandAPICommand("runfunction") .withArguments(FunctionArgument("function")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val functions = args["function"] as Array // Run all functions in our FunctionWrapper[] diff --git a/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionWrapperRef.kt b/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionWrapperRef.kt index a48645883..e68254fef 100644 --- a/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionWrapperRef.kt +++ b/reference-code/src/main/kotlin/createcommands/functionsandtags/FunctionWrapperRef.kt @@ -2,14 +2,15 @@ package createcommands.functionsandtags import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.FunctionArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.wrappers.FunctionWrapper +import org.bukkit.command.CommandSender fun functionWrapper() { // #region runExample CommandAPICommand("runfunc") .withArguments(FunctionArgument("function")) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> val functions = args["function"] as Array for (function in functions) { function.run() // The command executor in this case is 'sender' diff --git a/reference-code/src/main/kotlin/createcommands/functionsandtags/Functions.kt b/reference-code/src/main/kotlin/createcommands/functionsandtags/Functions.kt index 3265a0aa4..22eca92ca 100644 --- a/reference-code/src/main/kotlin/createcommands/functionsandtags/Functions.kt +++ b/reference-code/src/main/kotlin/createcommands/functionsandtags/Functions.kt @@ -1,8 +1,9 @@ package createcommands.functionsandtags import dev.jorel.commandapi.CommandAPICommand -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Bukkit +import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin // #region functionsExample @@ -11,7 +12,7 @@ class Main : JavaPlugin() { // Commands which will be used in Minecraft functions are registered here CommandAPICommand("killall") - .executes(CommandExecutor { _, _ -> + .executes(NormalExecutor { _, _ -> // Kills all enemies in all worlds Bukkit.getWorlds().forEach { world -> world.livingEntities.forEach { entity -> entity.health = 0.0 } } }) diff --git a/reference-code/src/main/kotlin/devsetup/Shading.kt b/reference-code/src/main/kotlin/devsetup/Shading.kt index 3f37a5f9d..9e3e2c24d 100644 --- a/reference-code/src/main/kotlin/devsetup/Shading.kt +++ b/reference-code/src/main/kotlin/devsetup/Shading.kt @@ -3,7 +3,8 @@ package devsetup import dev.jorel.commandapi.CommandAPI import dev.jorel.commandapi.CommandAPIBukkitConfig import dev.jorel.commandapi.CommandAPICommand -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor +import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin fun shading() { @@ -19,7 +20,7 @@ class MyPlugin : JavaPlugin() { CommandAPI.onLoad(CommandAPIBukkitConfig(this).verboseOutput(true)) // Load with verbose output CommandAPICommand("ping") - .executes(CommandExecutor { sender, _ -> + .executes(NormalExecutor { sender, _ -> sender.sendMessage("pong!") }) .register() diff --git a/reference-code/src/main/kotlin/internal/BrigadierSuggestions.kt b/reference-code/src/main/kotlin/internal/BrigadierSuggestions.kt index 2dc402130..e41234357 100644 --- a/reference-code/src/main/kotlin/internal/BrigadierSuggestions.kt +++ b/reference-code/src/main/kotlin/internal/BrigadierSuggestions.kt @@ -9,7 +9,7 @@ import dev.jorel.commandapi.Brigadier import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.ArgumentSuggestions import dev.jorel.commandapi.arguments.GreedyStringArgument -import dev.jorel.commandapi.executors.CommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import org.bukkit.Bukkit import org.bukkit.command.CommandSender import java.util.concurrent.CompletableFuture @@ -59,7 +59,7 @@ fun brigadierSuggestions() { CommandAPICommand("emoji") .withArguments(messageArgument) - .executes(CommandExecutor { _, args -> + .executes(NormalExecutor { _, args -> Bukkit.broadcastMessage(args["message"] as String) }) .register() @@ -106,7 +106,7 @@ fun brigadierSuggestions() { // #region commandArgumentsExampleStep2 CommandAPICommand("commandargument") .withArguments(GreedyStringArgument("command").replaceSuggestions(commandSuggestions)) - .executes(CommandExecutor { sender, args -> + .executes(NormalExecutor { sender, args -> // Run the command using Bukkit.dispatchCommand() Bukkit.dispatchCommand(sender, args["command"] as String) }) diff --git a/reference-code/src/main/kotlin/kotlindsl/DelegatedProperties.kt b/reference-code/src/main/kotlin/kotlindsl/DelegatedProperties.kt index c1691b905..0cb616fa0 100644 --- a/reference-code/src/main/kotlin/kotlindsl/DelegatedProperties.kt +++ b/reference-code/src/main/kotlin/kotlindsl/DelegatedProperties.kt @@ -3,7 +3,7 @@ package kotlindsl import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.PlayerArgument import dev.jorel.commandapi.arguments.StringArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import dev.jorel.commandapi.kotlindsl.* import org.bukkit.entity.Player @@ -12,7 +12,7 @@ fun delegatedProperties() { CommandAPICommand("mycommand") .withArguments(StringArgument("string")) .withArguments(PlayerArgument("target")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val string: String by args val target: Player by args // Implementation... diff --git a/reference-code/src/main/kotlin/kotlindsl/Usage.kt b/reference-code/src/main/kotlin/kotlindsl/Usage.kt index d13a564b0..7da1db267 100644 --- a/reference-code/src/main/kotlin/kotlindsl/Usage.kt +++ b/reference-code/src/main/kotlin/kotlindsl/Usage.kt @@ -1,6 +1,7 @@ package kotlindsl import dev.jorel.commandapi.arguments.ArgumentSuggestions +import dev.jorel.commandapi.executors.CommandArguments import dev.jorel.commandapi.kotlindsl.* import org.bukkit.Bukkit import org.bukkit.command.CommandSender @@ -131,19 +132,22 @@ fun usageTree() { // #endregion commandRequirementsTreeExample // #region optionalArgumentsTreeExample + fun giveOptionalAmount(player: Player, args: CommandArguments) { + // This command will let you execute: + // "/optionalArgument give minecraft:stick" + // "/optionalArgument give minecraft:stick 5" + val itemStack: ItemStack = args["item"] as ItemStack + val amount: Int = args.getOptional("amount").orElse(1) as Int + itemStack.amount = amount + player.inventory.addItem(itemStack) + } + commandTree("optionalArgument") { literalArgument("give") { itemStackArgument("item") { - integerArgument("amount", optional = true) { - playerExecutor { player, args -> - // This command will let you execute: - // "/optionalArgument give minecraft:stick" - // "/optionalArgument give minecraft:stick 5" - val itemStack: ItemStack = args["item"] as ItemStack - val amount: Int = args.getOptional("amount").orElse(1) as Int - itemStack.amount = amount - player.inventory.addItem(itemStack) - } + playerExecutor(::giveOptionalAmount) + integerArgument("amount") { + playerExecutor(::giveOptionalAmount) } } } diff --git a/reference-code/src/main/kotlin/velocity/Intro.kt b/reference-code/src/main/kotlin/velocity/Intro.kt index 37e9efe57..cbbeb5a37 100644 --- a/reference-code/src/main/kotlin/velocity/Intro.kt +++ b/reference-code/src/main/kotlin/velocity/Intro.kt @@ -2,8 +2,9 @@ package velocity import dev.jorel.commandapi.CommandAPICommand import dev.jorel.commandapi.arguments.IntegerArgument -import dev.jorel.commandapi.executors.PlayerCommandExecutor +import dev.jorel.commandapi.executors.NormalExecutor import net.kyori.adventure.text.Component +import org.bukkit.entity.Player import java.util.concurrent.ThreadLocalRandom fun intro() { @@ -11,7 +12,7 @@ fun intro() { CommandAPICommand("randomnumber") .withArguments(IntegerArgument("min")) .withArguments(IntegerArgument("max")) - .executesPlayer(PlayerCommandExecutor { player, args -> + .executesPlayer(NormalExecutor { player, args -> val min = args["min"] as Int val max = args["max"] as Int val random = ThreadLocalRandom.current() diff --git a/update.sh b/update.sh index f8e258ce5..0108b83f8 100644 --- a/update.sh +++ b/update.sh @@ -29,4 +29,5 @@ sed -i "s/dev.jorel:commandapi-bukkit-core:$oldVer/dev.jorel:commandapi-bukkit-c # Possible manual updates echo "These may have to be updated manually:" echo " docs/en/velocity/intro.md" +echo " reference-code/gradle/libs.versions.toml -> dev-jorel-commandapi-velocity-shade version" echo " docs/public/versions.yml" \ No newline at end of file