149 lines
5.0 KiB
Kotlin
149 lines
5.0 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.map.GameMap
|
|
import cc.maxmc.blastingcrisis.map.MapTeam
|
|
import cc.maxmc.blastingcrisis.misc.Area
|
|
import cc.maxmc.blastingcrisis.packet.BEntityVillager
|
|
import kotlinx.coroutines.cancel
|
|
import org.bukkit.Bukkit
|
|
import org.bukkit.ChatColor
|
|
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") {
|
|
execute<Player> { sender, _, _ ->
|
|
Bukkit.broadcastMessage(sender.name)
|
|
val homeArea = Area(sender.location, sender.location.add(10.0, 10.0, 10.0))
|
|
val area1 = Area(sender.location, sender.location.add(5.0, 5.0, 5.0))
|
|
val area2 = Area(sender.location, sender.location.add(5.0, 5.0, 5.0))
|
|
val area3 = Area(sender.location, sender.location.add(5.0, 5.0, 5.0))
|
|
val team = MapTeam(
|
|
"testTeam1",
|
|
ChatColor.AQUA,
|
|
sender.location,
|
|
homeArea,
|
|
area1,
|
|
area2,
|
|
listOf(area3),
|
|
area2,
|
|
sender.eyeLocation
|
|
)
|
|
val map = GameMap(
|
|
"test", listOf(
|
|
team
|
|
), 4
|
|
)
|
|
game = Game(map)
|
|
game.join(sender)
|
|
}
|
|
|
|
literal("state") {
|
|
dynamic {
|
|
execute<Player> { sender, ctx, 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> { sender, ctx, argument ->
|
|
game.timer.beginCountdown()
|
|
}
|
|
}
|
|
}
|
|
|
|
literal("scoreboard") {
|
|
execute { sender, context, argument ->
|
|
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(loc)
|
|
villager.addViewer(sender)
|
|
}
|
|
}
|
|
|
|
// literal("rename") {
|
|
// dynamic {
|
|
// execute<Player> { _, _, arg ->
|
|
// villager.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(area)
|
|
Bukkit.getScheduler().runTaskLater(BukkitPlugin.getInstance(), {
|
|
job.cancel("Stop by hand")
|
|
} ,60 * 20)
|
|
}
|
|
}
|
|
}
|
|
} |