From d16d5e32354d917876050803be84018844c56724 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Mon, 18 May 2026 22:58:49 +0100 Subject: [PATCH 1/2] feat: Enhance mob spawning command with quantity support --- .../willfp/ecomobs/commands/CommandSpawn.kt | 28 +++++++++++++++++-- .../core-plugin/src/main/resources/lang.yml | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt index 8679e83..5fbe7af 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt @@ -110,12 +110,30 @@ object CommandSpawn : Subcommand( return } - val living = mob.spawn(location, SpawnReason.COMMAND) + var qty = 1 + if (args.size >= 6) { + qty = try { + args[5].toInt().coerceAtLeast(1) + } catch (e: NumberFormatException) { + 1 + } + } - if (living != null) { + var spawned = 0 + var displayName = "" + repeat(qty) { + val living = mob.spawn(location, SpawnReason.COMMAND) + if (living != null) { + spawned++ + displayName = living.displayName + } + } + + if (spawned > 0) { sender.sendMessage( plugin.langYml.getMessage("spawned") - .replace("%mob%", living.displayName) + .replace("%mob%", displayName) + .replace("%qty%", spawned.toString()) ) } } @@ -146,6 +164,10 @@ object CommandSpawn : Subcommand( StringUtil.copyPartialMatches(args[4], Bukkit.getWorlds().map { it.name }, completions) } + if (args.size == 6) { + StringUtil.copyPartialMatches(args[5], listOf("1", "5", "10", "25", "50"), completions) + } + completions.sort() return completions } diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index 6b41fb1..03d9cfa 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -9,7 +9,7 @@ messages: invalid-player: "&cInvalid player!" specify-mob: "&cYou must specify a valid mob!" invalid-location: "&cInvalid location!" - spawned: "Spawned %mob%&f!" + spawned: "Spawned &c%qty%x %mob%&f!" gave-egg: "Gave %player%&f a %mob%&f egg!" spawner-give: "Gave %player% a &c%mob%&f spawner!" From 26bca6e53d270ed384b39b8105bc73525b452f91 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Sat, 23 May 2026 02:56:59 +0100 Subject: [PATCH 2/2] feat: Rename quantity variable and update message placeholders in spawn command --- .../kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt | 8 ++++---- eco-core/core-plugin/src/main/resources/lang.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt index 5fbe7af..fa7d054 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecomobs/commands/CommandSpawn.kt @@ -110,9 +110,9 @@ object CommandSpawn : Subcommand( return } - var qty = 1 + var quantity = 1 if (args.size >= 6) { - qty = try { + quantity = try { args[5].toInt().coerceAtLeast(1) } catch (e: NumberFormatException) { 1 @@ -121,7 +121,7 @@ object CommandSpawn : Subcommand( var spawned = 0 var displayName = "" - repeat(qty) { + repeat(quantity) { val living = mob.spawn(location, SpawnReason.COMMAND) if (living != null) { spawned++ @@ -133,7 +133,7 @@ object CommandSpawn : Subcommand( sender.sendMessage( plugin.langYml.getMessage("spawned") .replace("%mob%", displayName) - .replace("%qty%", spawned.toString()) + .replace("%quantity%", spawned.toString()) ) } } diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index 03d9cfa..10c99e0 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -9,7 +9,7 @@ messages: invalid-player: "&cInvalid player!" specify-mob: "&cYou must specify a valid mob!" invalid-location: "&cInvalid location!" - spawned: "Spawned &c%qty%x %mob%&f!" + spawned: "Spawned &c%quantity%x %mob%&f!" gave-egg: "Gave %player%&f a %mob%&f egg!" spawner-give: "Gave %player% a &c%mob%&f spawner!"