蚯嫁嚎坏事做尽!!!(主体部分完成)
This commit is contained in:
parent
5124478878
commit
4c37dff413
|
|
@ -1,9 +1,17 @@
|
|||
package cc.maxmc.blastingcrisis
|
||||
|
||||
import cc.maxmc.blastingcrisis.command.DebugCommand
|
||||
import cc.maxmc.blastingcrisis.game.Game
|
||||
import cc.maxmc.blastingcrisis.map.GameMap
|
||||
import cc.maxmc.blastingcrisis.map.MapTeam
|
||||
import cc.maxmc.blastingcrisis.misc.Area
|
||||
import cc.maxmc.blastingcrisis.misc.GameManager
|
||||
import cc.maxmc.blastingcrisis.misc.info
|
||||
import cc.maxmc.blastingcrisis.misc.pluginScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.ChatColor
|
||||
import org.bukkit.Location
|
||||
import taboolib.common.env.RuntimeDependency
|
||||
import taboolib.common.platform.Plugin
|
||||
|
||||
|
|
@ -15,9 +23,55 @@ object BlastingCrisis : Plugin() {
|
|||
info("§a| §7Loading BlastingCrisis")
|
||||
DebugCommand.debug("debugcmd")
|
||||
info("§a| §7Loading BlastingCrisis")
|
||||
createDefaultGame()
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
pluginScope.cancel()
|
||||
}
|
||||
|
||||
private fun createDefaultGame() {
|
||||
fun location(x: Int, y: Int, z: Int) =
|
||||
Location(Bukkit.getWorlds().first(), x.toDouble(), y.toDouble(), z.toDouble())
|
||||
|
||||
val teamRed = MapTeam(
|
||||
"红队",
|
||||
ChatColor.RED,
|
||||
location(0, 72, -44),
|
||||
location(0, 72, -44),
|
||||
location(-8, 73, -47),
|
||||
Area(location(14, 72, -48), location(-13, 78, -34)),
|
||||
Area(location(-13, 78, -33), location(13, 72, -33)),
|
||||
Area(location(-13, 78, -32), location(13, 71, -1)),
|
||||
Area(location(7, 72, -45), location(9, 74, -48)),
|
||||
listOf(
|
||||
Area(location(15, 72, -1), location(19, 78, -48)), Area(location(19, 78, -48), location(-15, 72, -1))
|
||||
),
|
||||
)
|
||||
val teamGreen = MapTeam(
|
||||
"绿队",
|
||||
ChatColor.GREEN,
|
||||
location(0, 72, 44),
|
||||
location(0, 72, 44),
|
||||
location(8, 73, 47),
|
||||
Area(location(-14, 72, 48), location(13, 78, 34)),
|
||||
Area(location(13, 78, 33), location(-13, 72, 33)),
|
||||
Area(location(13, 78, 32), location(-13, 71, 1)),
|
||||
Area(location(-7, 72, 45), location(-9, 74, 48)),
|
||||
listOf(
|
||||
Area(location(-15, 72, 1), location(-19, 78, 48)), Area(location(-19, 78, 48), location(15, 72, 1))
|
||||
),
|
||||
)
|
||||
val map = GameMap(
|
||||
"test",
|
||||
Area(location(20, 70, -49), location(-20, 79, 49)),
|
||||
Area(location(-13, 78, 0), location(13, 72, 0)),
|
||||
listOf(
|
||||
teamRed, teamGreen
|
||||
),
|
||||
1
|
||||
)
|
||||
DebugCommand.game = Game(map)
|
||||
GameManager.currentGame = DebugCommand.game
|
||||
}
|
||||
}
|
||||
|
|
@ -3,15 +3,10 @@ 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.misc.GameManager
|
||||
import cc.maxmc.blastingcrisis.packet.BEntityVillager
|
||||
import kotlinx.coroutines.cancel
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.ChatColor
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.entity.Player
|
||||
import taboolib.common.platform.ProxyPlayer
|
||||
import taboolib.common.platform.command.command
|
||||
|
|
@ -27,52 +22,6 @@ object DebugCommand {
|
|||
lateinit var villager: BEntityVillager
|
||||
fun debug(cmd: String) = command(cmd) {
|
||||
literal("game") {
|
||||
execute<Player> { sender, _, _ ->
|
||||
fun location(x: Int, y: Int, z: Int) = Location(sender.world, x.toDouble(), y.toDouble(), z.toDouble())
|
||||
Bukkit.broadcastMessage(sender.name)
|
||||
val teamRed = MapTeam(
|
||||
"红队",
|
||||
ChatColor.RED,
|
||||
location(0, 72, -44),
|
||||
location(0, 72, -44),
|
||||
location(-8, 73, -47),
|
||||
Area(location(14, 72, -48), location(-13, 78, -34)),
|
||||
Area(location(-13, 78, -33), location(13, 72, -33)),
|
||||
Area(location(-13, 78, -32), location(13, 71, -1)),
|
||||
Area(location(7, 72, -45), location(9, 74, -48)),
|
||||
listOf(
|
||||
Area(location(15, 72, -1), location(19, 78, -48)),
|
||||
Area(location(19, 78, -48), location(-15, 72, -1))
|
||||
),
|
||||
)
|
||||
val teamGreen = MapTeam(
|
||||
"绿队",
|
||||
ChatColor.GREEN,
|
||||
location(0, 72, 44),
|
||||
location(0, 72, 44),
|
||||
location(8, 73, 47),
|
||||
Area(location(-14, 72, 48), location(13, 78, 34)),
|
||||
Area(location(13, 78, 33), location(-13, 72, 33)),
|
||||
Area(location(13, 78, 32), location(-13, 71, 1)),
|
||||
Area(location(-7, 72, 45), location(-9, 74, 48)),
|
||||
listOf(
|
||||
Area(location(-15, 72, 1), location(-19, 78, 48)),
|
||||
Area(location(-19, 78, 48), location(15, 72, 1))
|
||||
),
|
||||
)
|
||||
val map = GameMap(
|
||||
"test",
|
||||
Area(location(20, 70, -49), location(-20, 79, 49)),
|
||||
Area(location(-13, 78, 0), location(13, 72, 0)),
|
||||
listOf(
|
||||
teamRed, teamGreen
|
||||
),
|
||||
1
|
||||
)
|
||||
game = Game(map)
|
||||
GameManager.currentGame = game
|
||||
}
|
||||
|
||||
literal("join") {
|
||||
execute<Player> { sender, _, _ ->
|
||||
game.join(sender)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package cc.maxmc.blastingcrisis.game
|
|||
|
||||
import cc.maxmc.blastingcrisis.map.GameMap
|
||||
import cc.maxmc.blastingcrisis.misc.debug
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
import taboolib.common.platform.function.submit
|
||||
|
|
@ -52,7 +51,7 @@ class Game(
|
|||
timer.startTimer()
|
||||
timer.submitEvent("wall_fall", Duration.ofMinutes(1)) {
|
||||
broadcast { it.sendLang("game_wall_fall") }
|
||||
submit(now = true) {
|
||||
submit {
|
||||
map.wall.forBlocksInArea().forEach {
|
||||
it.block.type = Material.AIR
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package cc.maxmc.blastingcrisis.game
|
||||
|
||||
import cc.maxmc.blastingcrisis.game.GameState.*
|
||||
import cc.maxmc.blastingcrisis.misc.debug
|
||||
import org.bukkit.entity.Player
|
||||
import taboolib.module.nms.sendScoreboard
|
||||
import taboolib.platform.util.asLangText
|
||||
|
|
@ -14,7 +13,6 @@ class GameScoreboard(val game: Game) {
|
|||
}
|
||||
|
||||
fun sendScoreboardPlayer(player: Player) {
|
||||
debug("sending Scoreboard to ${player.name}")
|
||||
val scoreboardText = when (game.state) {
|
||||
WAITING -> {
|
||||
player.asLangText("scoreboard_waiting", game.players.size, game.map.maxPlayer)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package cc.maxmc.blastingcrisis.game
|
|||
import cc.maxmc.blastingcrisis.listener.GameListener
|
||||
import cc.maxmc.blastingcrisis.map.MapTeam
|
||||
import cc.maxmc.blastingcrisis.misc.debug
|
||||
import cc.maxmc.blastingcrisis.misc.toPlayerLocation
|
||||
import org.bukkit.entity.Player
|
||||
import taboolib.platform.util.sendLang
|
||||
|
||||
|
|
@ -14,7 +15,7 @@ class GameTeam(val game: Game, val teamInfo: MapTeam) {
|
|||
private set
|
||||
|
||||
fun start() {
|
||||
players.forEach { it.teleport(teamInfo.spawn) }
|
||||
players.forEach { it.teleport(teamInfo.spawn.toPlayerLocation()) }
|
||||
villager.spawn()
|
||||
GameListener.interactSubscribed[teamInfo.upgrade] = {
|
||||
debug("interact team ${teamInfo.name} upgrade.")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package cc.maxmc.blastingcrisis.game
|
||||
|
||||
import cc.maxmc.blastingcrisis.configuration.GlobalSettings
|
||||
import cc.maxmc.blastingcrisis.misc.info
|
||||
import cc.maxmc.blastingcrisis.misc.pluginScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package cc.maxmc.blastingcrisis.game
|
||||
|
||||
import cc.maxmc.blastingcrisis.configuration.GlobalSettings
|
||||
import cc.maxmc.blastingcrisis.misc.toPlayerLocation
|
||||
import cc.maxmc.blastingcrisis.packet.BEntityVillager
|
||||
import org.bukkit.Bukkit
|
||||
import taboolib.platform.BukkitPlugin
|
||||
import taboolib.platform.util.asLangText
|
||||
|
||||
class TeamVillager(private val team: GameTeam) {
|
||||
private val packetVillager = BEntityVillager.create(team.teamInfo.villager)
|
||||
private val packetVillager = BEntityVillager.create(team.teamInfo.villager.toPlayerLocation())
|
||||
var health: Int = GlobalSettings.GameSettings.villagerMaxHealth
|
||||
private set
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ package cc.maxmc.blastingcrisis.listener
|
|||
import cc.maxmc.blastingcrisis.game.team
|
||||
import cc.maxmc.blastingcrisis.misc.GameManager
|
||||
import cc.maxmc.blastingcrisis.misc.debug
|
||||
import cc.maxmc.blastingcrisis.misc.toPlayerLocation
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.event.block.BlockExplodeEvent
|
||||
import org.bukkit.event.entity.EntityExplodeEvent
|
||||
import org.bukkit.event.player.PlayerInteractEvent
|
||||
import org.bukkit.event.player.PlayerMoveEvent
|
||||
import taboolib.common.platform.event.SubscribeEvent
|
||||
|
|
@ -19,7 +20,7 @@ object GameListener {
|
|||
val team = player.team ?: return
|
||||
if (!team.teamInfo.teleport.isInArea(event.to)) return
|
||||
debug("teleporting ${event.player} to battle field")
|
||||
player.teleport(team.teamInfo.mine.randomLocation())
|
||||
player.teleport(team.teamInfo.mine.randomLocation().toPlayerLocation())
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -29,11 +30,12 @@ object GameListener {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTNT(tntExplode: BlockExplodeEvent) {
|
||||
debug("tnt exploded at ${tntExplode.block.location}")
|
||||
fun onTNT(tntExplode: EntityExplodeEvent) {
|
||||
debug("${tntExplode.entityType} exploded at ${tntExplode.location}")
|
||||
tntExplode.blockList().clear()
|
||||
if (!GameManager.currentGame.state.isStarted()) return
|
||||
GameManager.currentGame.teams.findLast {
|
||||
it.teamSurvive && it.teamInfo.home.isInArea(tntExplode.block.location)
|
||||
it.teamSurvive && it.teamInfo.home.isInArea(tntExplode.location)
|
||||
}?.apply {
|
||||
villager.damage()
|
||||
debug("team ${teamInfo.name}'s villager damaged")
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ package cc.maxmc.blastingcrisis.map
|
|||
|
||||
import cc.maxmc.blastingcrisis.misc.Area
|
||||
|
||||
object MapInitializer {
|
||||
|
||||
|
||||
}
|
||||
object MapInitializer
|
||||
|
||||
class MapInfo(
|
||||
var name: String,
|
||||
|
|
@ -13,6 +10,4 @@ class MapInfo(
|
|||
val teams: List<MapTeam>,
|
||||
val maxPlayersPerTeam: Int,
|
||||
|
||||
) {
|
||||
|
||||
}
|
||||
)
|
||||
|
|
@ -2,6 +2,7 @@ package cc.maxmc.blastingcrisis.misc
|
|||
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable
|
||||
import org.bukkit.configuration.serialization.SerializableAs
|
||||
import org.bukkit.util.Vector
|
||||
|
|
@ -30,10 +31,19 @@ class Area(loc1: Location, loc2: Location) : ConfigurationSerializable {
|
|||
* @return true if the location is in this area
|
||||
*/
|
||||
fun isInArea(location: Location): Boolean {
|
||||
if (location.world != locTop.world) return debug("world").let { false }
|
||||
if (location.x !in locTop.x..locMin.x) return debug("x").let { false }
|
||||
if (location.y !in locTop.y..locMin.y) return debug("y").let { false }
|
||||
if (location.z !in locTop.z..locMin.z) return debug("z").let { false }
|
||||
if (location.world != locTop.world) return false
|
||||
if (location.x !in (locMin.x - 1)..(locTop.x + 1)) return false
|
||||
if (location.y !in locMin.y..locTop.y + 1) return false
|
||||
if (location.z !in (locMin.z - 1)..(locTop.z + 1)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
fun isBlockInArea(block: Block): Boolean {
|
||||
val location = block.location
|
||||
if (location.world != locTop.world) return false
|
||||
if (location.x !in locMin.x..locTop.x) return false
|
||||
if (location.y !in locMin.y..locTop.y) return false
|
||||
if (location.z !in locMin.z..locTop.z) return false
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -44,9 +54,9 @@ class Area(loc1: Location, loc2: Location) : ConfigurationSerializable {
|
|||
*/
|
||||
fun forBlocksInArea(): List<Location> {
|
||||
val blocks = arrayListOf<Location>()
|
||||
for (x in locTop.blockX..locMin.blockX) {
|
||||
for (y in locTop.blockY..locMin.blockY) {
|
||||
for (z in locTop.blockZ..locMin.blockZ) {
|
||||
for (x in locMin.blockX..locTop.blockX) {
|
||||
for (y in locMin.blockY..locTop.blockY) {
|
||||
for (z in locMin.blockZ..locTop.blockZ) {
|
||||
blocks.add(Location(locTop.world, x.toDouble(), y.toDouble(), z.toDouble()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ package cc.maxmc.blastingcrisis.misc
|
|||
import cc.maxmc.blastingcrisis.game.Game
|
||||
|
||||
object GameManager {
|
||||
lateinit var currentGame : Game
|
||||
lateinit var currentGame: Game
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package cc.maxmc.blastingcrisis.misc
|
||||
|
||||
import com.google.common.base.Preconditions
|
||||
import org.bukkit.Location
|
||||
import java.util.*
|
||||
|
||||
|
||||
|
|
@ -22,3 +23,9 @@ class WeightRandom<K, V : Number>(list: List<Pair<K, V>>) {
|
|||
return weightMap[tailMap.firstKey()]!!
|
||||
}
|
||||
}
|
||||
|
||||
fun Location.toPlayerLocation(): Location = clone().apply {
|
||||
x = blockX + 0.5
|
||||
y = blockY.toDouble()
|
||||
z = blockZ + 0.5
|
||||
}
|
||||
|
|
@ -2,6 +2,6 @@ package cc.maxmc.blastingcrisis.packet
|
|||
|
||||
import net.minecraft.server.v1_8_R3.DataWatcher
|
||||
import taboolib.library.reflex.Reflex.Companion.invokeMethod
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
fun DataWatcher.getWatchableObject(id: Int): DataWatcher.WatchableObject = this.invokeMethod<DataWatcher.WatchableObject>("j", id) ?: throw IllegalStateException("Object not exists.")
|
||||
fun DataWatcher.getWatchableObject(id: Int): DataWatcher.WatchableObject =
|
||||
this.invokeMethod<DataWatcher.WatchableObject>("j", id) ?: throw IllegalStateException("Object not exists.")
|
||||
Loading…
Reference in New Issue