diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/commands/CommandResetWins.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/commands/CommandResetWins.kt index 4f2ae43..224ba12 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/commands/CommandResetWins.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecocrates/commands/CommandResetWins.kt @@ -5,6 +5,7 @@ import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.util.savedDisplayName import com.willfp.ecocrates.crate.Crates import org.bukkit.Bukkit +import org.bukkit.OfflinePlayer import org.bukkit.command.CommandSender import org.bukkit.util.StringUtil @@ -20,21 +21,29 @@ class CommandResetWins(plugin: EcoPlugin) : Subcommand( return } - @Suppress("DEPRECATION") - val player = Bukkit.getOfflinePlayer(args[0]) + if (args[0] == "all") { + for (player in Bukkit.getOfflinePlayers()) { + resetWinsFor(sender, player) + } + } else { + @Suppress("DEPRECATION") + resetWinsFor(sender, Bukkit.getOfflinePlayer(args[0])) + } + } + private fun resetWinsFor(sender: CommandSender, player: OfflinePlayer) { if (!player.hasPlayedBefore()) { sender.sendMessage(plugin.langYml.getMessage("invalid-player")) return } - sender.sendMessage(plugin.langYml.getMessage("resetting-wins").replace("%player%", player.savedDisplayName)) + sender.sendMessage(plugin.langYml.getMessage("resetting-wins").replace("%user%", player.savedDisplayName)) for (crate in Crates.values()) { crate.rewards.forEach { it.resetWins(player) } } - sender.sendMessage(plugin.langYml.getMessage("reset-wins").replace("%player%", player.savedDisplayName)) + sender.sendMessage(plugin.langYml.getMessage("reset-wins").replace("%user%", player.savedDisplayName)) } override fun tabComplete(sender: CommandSender, args: List): List { @@ -47,7 +56,7 @@ class CommandResetWins(plugin: EcoPlugin) : Subcommand( if (args.size == 1) { StringUtil.copyPartialMatches( args[0], - Bukkit.getOnlinePlayers().map { it.name }, + Bukkit.getOnlinePlayers().map { it.name } union listOf("all"), completions ) diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index 4f3d45d..5e32219 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -14,5 +14,5 @@ messages: set-block-as-crate: "Set block to be a crate!" removed-crate: "Removed crate!" all-rewards-used: "&cYou have already won all things in this crate!" - resetting-wins: "&fResetting wins for %player%f..." - reset-wins: "&fReset wins for %player%&f!" \ No newline at end of file + resetting-wins: "&fResetting wins for %user%&f..." + reset-wins: "&fReset wins for %user%&f!" \ No newline at end of file