mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-02 21:20:55 +00:00
Blindly wrote a command.
This commit is contained in:
parent
3ac24f6912
commit
203ecd1ca9
@ -0,0 +1,50 @@
|
|||||||
|
package cloud.kubelet.foundation.core.features.player
|
||||||
|
|
||||||
|
import org.bukkit.GameMode
|
||||||
|
import org.bukkit.WeatherType
|
||||||
|
import org.bukkit.command.Command
|
||||||
|
import org.bukkit.command.CommandExecutor
|
||||||
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.command.TabCompleter
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
class LocalWeatherCommand : CommandExecutor, TabCompleter {
|
||||||
|
private val weatherTypes = WeatherType.values().associateBy { it.name.lowercase() }
|
||||||
|
|
||||||
|
override fun onCommand(
|
||||||
|
sender: CommandSender,
|
||||||
|
command: Command,
|
||||||
|
label: String,
|
||||||
|
args: Array<out String>
|
||||||
|
): Boolean {
|
||||||
|
if (sender !is Player) {
|
||||||
|
sender.sendMessage("You are not a player.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (args.size != 1) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
val name = args[0].lowercase()
|
||||||
|
val weatherType = weatherTypes[name]
|
||||||
|
if (weatherType == null) {
|
||||||
|
sender.sendMessage("Not a valid weather type.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.setPlayerWeather(weatherType)
|
||||||
|
sender.sendMessage("Weather set to \"$name\"")
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTabComplete(
|
||||||
|
sender: CommandSender,
|
||||||
|
command: Command,
|
||||||
|
alias: String,
|
||||||
|
args: Array<out String>
|
||||||
|
): List<String> = when {
|
||||||
|
args.isEmpty() -> weatherTypes.keys.toList()
|
||||||
|
else -> listOf()
|
||||||
|
}
|
||||||
|
}
|
@ -9,5 +9,6 @@ class PlayerFeature : Feature() {
|
|||||||
registerCommandExecutor(listOf("creative", "c"), GamemodeCommand(GameMode.CREATIVE))
|
registerCommandExecutor(listOf("creative", "c"), GamemodeCommand(GameMode.CREATIVE))
|
||||||
registerCommandExecutor(listOf("adventure", "a"), GamemodeCommand(GameMode.ADVENTURE))
|
registerCommandExecutor(listOf("adventure", "a"), GamemodeCommand(GameMode.ADVENTURE))
|
||||||
registerCommandExecutor(listOf("spectator", "sp"), GamemodeCommand(GameMode.SPECTATOR))
|
registerCommandExecutor(listOf("spectator", "sp"), GamemodeCommand(GameMode.SPECTATOR))
|
||||||
|
registerCommandExecutor(listOf("localweather", "lw"), LocalWeatherCommand())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,3 +57,6 @@ commands:
|
|||||||
description: Teleport to the spawn of the current world.
|
description: Teleport to the spawn of the current world.
|
||||||
usage: /spawn
|
usage: /spawn
|
||||||
permission: foundation.command.spawn
|
permission: foundation.command.spawn
|
||||||
|
localweather:
|
||||||
|
description: Set the player's local weather in the client.
|
||||||
|
usage: /localweather <type>
|
||||||
|
Loading…
Reference in New Issue
Block a user