56 lines
No EOL
2.2 KiB
Kotlin
56 lines
No EOL
2.2 KiB
Kotlin
package xyz.ineanto.dragon.commands
|
|
|
|
import net.kyori.adventure.text.Component
|
|
import net.kyori.adventure.text.format.NamedTextColor
|
|
import net.kyori.adventure.text.format.TextDecoration
|
|
import org.bukkit.Bukkit
|
|
import org.bukkit.command.Command
|
|
import org.bukkit.command.CommandExecutor
|
|
import org.bukkit.command.CommandSender
|
|
import org.bukkit.entity.Player
|
|
import xyz.ineanto.dragon.RunnerDragon
|
|
|
|
class MainCommand : CommandExecutor {
|
|
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean {
|
|
if (sender is Player) {
|
|
val player: Player = sender
|
|
val dragonPlayer = RunnerDragon.instance.playerManager.getPlayer(player.uniqueId)
|
|
|
|
if (player.isOp.not()) {
|
|
dragonPlayer.sendMessage(Component.text("Erreur: Status d'opérateur requis."))
|
|
return true
|
|
}
|
|
|
|
if (args.isEmpty()) {
|
|
dragonPlayer.sendMessage(Component.text("Argument manquant: /rd (teams/game/say)"))
|
|
return true
|
|
}
|
|
|
|
when (args[0]) {
|
|
"game" -> GameSubCommand().run(dragonPlayer, args.drop(1).toTypedArray())
|
|
"teams" -> TeamsSubCommand().run(dragonPlayer, args.drop(1).toTypedArray())
|
|
"say" -> {
|
|
if (args.drop(1).isEmpty()) {
|
|
player.sendMessage(
|
|
Component
|
|
.text()
|
|
.append(RunnerDragon.PREFIX)
|
|
.append(Component.text("Veuillez préciser un message.", NamedTextColor.RED))
|
|
.build()
|
|
)
|
|
return true
|
|
}
|
|
|
|
val announcementComponent = Component.text()
|
|
.append(Component.text("(ANNONCE)", NamedTextColor.RED, TextDecoration.BOLD))
|
|
.appendSpace()
|
|
.append(Component.text(args.drop(1).joinToString(" ", "", "")))
|
|
.build()
|
|
|
|
Bukkit.broadcast(announcementComponent)
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
} |