Fixed forceopen not being able to be run by console

This commit is contained in:
Sedri05
2022-06-11 18:38:22 +02:00
parent 7f55dd7fc0
commit 46ad994da5

View File

@@ -13,20 +13,20 @@ class CommandForceOpen(plugin: EcoPlugin) : Subcommand(
plugin, plugin,
"forceopen", "forceopen",
"ecocrates.command.forceopen", "ecocrates.command.forceopen",
true false
) { ) {
override fun onExecute(sender: CommandSender, args: List<String>) { override fun onExecute(sender: CommandSender, args: List<String>) {
var player: Player = sender as Player var player = sender
if (args.isEmpty()) { if (args.isEmpty()) {
player.sendMessage(plugin.langYml.getMessage("must-specify-crate")) sender.sendMessage(plugin.langYml.getMessage("must-specify-crate"))
return return
} }
val crate = Crates.getByID(args[0]) val crate = Crates.getByID(args[0])
if (crate == null) { if (crate == null) {
player.sendMessage(plugin.langYml.getMessage("invalid-crate")) sender.sendMessage(plugin.langYml.getMessage("invalid-crate"))
return return
} }
@@ -40,8 +40,9 @@ class CommandForceOpen(plugin: EcoPlugin) : Subcommand(
player = specificPlayer player = specificPlayer
} }
if (player is Player) {
crate.open(player, OpenMethod.OTHER) crate.open(player, OpenMethod.OTHER)
}
} }
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> { override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {