133 lines
4.2 KiB
Kotlin
133 lines
4.2 KiB
Kotlin
package cc.maxmc.blastingcrisis.command
|
|
|
|
import cc.maxmc.blastingcrisis.game.Game
|
|
import cc.maxmc.blastingcrisis.game.GameOreGenerator
|
|
import cc.maxmc.blastingcrisis.game.GameState
|
|
import cc.maxmc.blastingcrisis.misc.Area
|
|
import cc.maxmc.blastingcrisis.misc.UniArea
|
|
import cc.maxmc.blastingcrisis.packet.BEntityVillager
|
|
import kotlinx.coroutines.cancel
|
|
import org.bukkit.Bukkit
|
|
import org.bukkit.entity.Player
|
|
import taboolib.common.platform.ProxyPlayer
|
|
import taboolib.common.platform.command.command
|
|
import taboolib.common.platform.function.adaptCommandSender
|
|
import taboolib.common.platform.function.getDataFolder
|
|
import taboolib.module.configuration.Configuration
|
|
import taboolib.platform.BukkitPlugin
|
|
import taboolib.platform.util.sendActionBar
|
|
import java.io.File
|
|
|
|
object DebugCommand {
|
|
lateinit var game: Game
|
|
lateinit var villager: BEntityVillager
|
|
fun debug(cmd: String) = command(cmd) {
|
|
literal("game") {
|
|
literal("join") {
|
|
execute<Player> { sender, _, _ ->
|
|
game.join(sender)
|
|
}
|
|
}
|
|
|
|
literal("state") {
|
|
dynamic {
|
|
execute<Player> { sender, _, argument ->
|
|
if (!GameState.values().map { it.name }
|
|
.contains(argument.uppercase())) return@execute sender.sendMessage("NO STATE")
|
|
val state = GameState.valueOf(argument.uppercase())
|
|
game.state = state
|
|
sender.sendMessage("changed to $argument")
|
|
}
|
|
suggestion<Player> { _, _ ->
|
|
GameState.values().map { it.name }
|
|
}
|
|
}
|
|
}
|
|
|
|
literal("timer") {
|
|
execute<Player> { _, _, _ ->
|
|
game.timer.beginCountdown()
|
|
}
|
|
}
|
|
}
|
|
|
|
literal("scoreboard") {
|
|
execute { sender, _, _ ->
|
|
game.scoreboard.sendScoreboardPlayer(sender)
|
|
}
|
|
}
|
|
|
|
literal("title") {
|
|
execute<Player> { sender, _, _ ->
|
|
val adapt = adaptCommandSender(sender) as ProxyPlayer
|
|
adapt.sendTitle("Title", "sub", 20, 20, 20)
|
|
}
|
|
}
|
|
|
|
literal("actionBar") {
|
|
execute<Player> { sender, _, _ ->
|
|
sender.sendActionBar("This is an action bar msg")
|
|
}
|
|
}
|
|
|
|
literal("spawnEntity") {
|
|
execute<Player> { sender, _, _ ->
|
|
val loc = sender.location
|
|
villager = BEntityVillager.create(loc)
|
|
villager.addViewer(sender)
|
|
}
|
|
}
|
|
|
|
literal("respawn") {
|
|
execute<Player> { sender, _, _ ->
|
|
villager.spawnForPlayer(sender)
|
|
}
|
|
}
|
|
|
|
literal("rename") {
|
|
dynamic {
|
|
execute<Player> { _, _, arg ->
|
|
villager.name = { it.name + ":" + arg }
|
|
}
|
|
}
|
|
}
|
|
|
|
literal("destroy") {
|
|
execute { sender, _, _ ->
|
|
villager.removeViewer(sender)
|
|
}
|
|
}
|
|
|
|
literal("hurt") {
|
|
execute<Player> { _, _, _ ->
|
|
villager.hurtAnimate()
|
|
}
|
|
}
|
|
|
|
literal("die") {
|
|
execute<Player> { _, _, _ ->
|
|
villager.dieAnimate()
|
|
}
|
|
}
|
|
|
|
literal("update") {
|
|
execute<Player> { _, _, _ ->
|
|
villager.update()
|
|
}
|
|
}
|
|
|
|
literal("genOre") {
|
|
execute<Player> { sender, _, _ ->
|
|
val area = Area(sender.location.block.location, sender.location.block.location.add(20.0, 20.0, 20.0))
|
|
BukkitPlugin.getInstance().saveResource("ore-generators/default.yml", false)
|
|
println("saved")
|
|
val config = Configuration.loadFromFile(File(getDataFolder(), "ore-generators/default.yml"))
|
|
val gen = GameOreGenerator(config)
|
|
val job = gen.enable(UniArea(listOf(area)))
|
|
Bukkit.getScheduler().runTaskLater(BukkitPlugin.getInstance(), {
|
|
job.cancel("Stop by hand")
|
|
}, 60 * 20)
|
|
}
|
|
}
|
|
}
|
|
} |