Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,30 @@ object CommandSpawn : Subcommand(
return
}

val living = mob.spawn(location, SpawnReason.COMMAND)
var quantity = 1
if (args.size >= 6) {
quantity = try {
args[5].toInt().coerceAtLeast(1)
} catch (e: NumberFormatException) {
1
}
}

if (living != null) {
var spawned = 0
var displayName = ""
repeat(quantity) {
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("%quantity%", spawned.toString())
)
}
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion eco-core/core-plugin/src/main/resources/lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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%quantity%x %mob%&f!"
gave-egg: "Gave %player%&f a %mob%&f egg!"

spawner-give: "Gave %player% a &c%mob%&f spawner!"
Expand Down
Loading