diff --git a/build.gradle.kts b/build.gradle.kts index a02c16f..7040c95 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.7.20" - application + id("io.izzel.taboolib") version "1.42" } group = "cc.maxmc.blastingcrisis" @@ -10,20 +10,33 @@ version = "1.0-SNAPSHOT" repositories { mavenCentral() + maven("https://repo.maxmc.cn/repository/maven-snapshots/") { + name = "maxmc" + credentials(PasswordCredentials::class.java) + } } + dependencies { - testImplementation(kotlin("test")) + implementation(kotlin("stdlib")) + implementation("ink.ptms.core:v10800:10800") } -tasks.test { - useJUnitPlatform() +taboolib { + description { + contributors { + name("坏黑") + name("TONY_All") + } + } + install("common", "common-5") + install("platform-bukkit") + install("module-nms", "module-nms-util", "module-chat") + + options("skip-kotlin-relocate") + version = "6.0.9-117" } tasks.withType { kotlinOptions.jvmTarget = "1.8" -} - -application { - mainClass.set("MainKt") } \ No newline at end of file diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt deleted file mode 100644 index f2a59b6..0000000 --- a/src/main/kotlin/Main.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun main(args: Array) { - println("Hello World!") - - // Try adding program arguments via Run/Debug configuration. - // Learn more about running applications: https://www.jetbrains.com/help/idea/running-applications.html. - println("Program arguments: ${args.joinToString()}") -} \ No newline at end of file diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/BlastingCrisis.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/BlastingCrisis.kt new file mode 100644 index 0000000..834a311 --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/BlastingCrisis.kt @@ -0,0 +1,11 @@ +package cc.maxmc.blastingcrisis + +import taboolib.common.platform.Plugin + +object BlastingCrisis: Plugin() { + + override fun onEnable() { + + } + +} \ No newline at end of file diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/game/Game.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/game/Game.kt new file mode 100644 index 0000000..9f43011 --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/game/Game.kt @@ -0,0 +1,5 @@ +package cc.maxmc.blastingcrisis.game + +class Game { + +} \ No newline at end of file diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/game/GamePlayer.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/game/GamePlayer.kt new file mode 100644 index 0000000..8b3e540 --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/game/GamePlayer.kt @@ -0,0 +1,2 @@ +package cc.maxmc.blastingcrisis.game + diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/game/GameTeam.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/game/GameTeam.kt new file mode 100644 index 0000000..dfc5f92 --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/game/GameTeam.kt @@ -0,0 +1,4 @@ +package cc.maxmc.blastingcrisis.game + +class GameTeam { +} \ No newline at end of file diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/map/GameMap.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/map/GameMap.kt new file mode 100644 index 0000000..c62b66f --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/map/GameMap.kt @@ -0,0 +1,5 @@ +package cc.maxmc.blastingcrisis.map + +class GameMap(val name: String,) { + +} \ No newline at end of file diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/map/MapInitializer.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/map/MapInitializer.kt new file mode 100644 index 0000000..77066f1 --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/map/MapInitializer.kt @@ -0,0 +1,18 @@ +package cc.maxmc.blastingcrisis.map + +import cc.maxmc.blastingcrisis.misc.Area + +object MapInitializer { + + +} + +class MapInfo( + var name: String, + var waitArea: Area, + val teams: List, + val maxPlayersPerTeam: Int, + +) { + +} \ No newline at end of file diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/map/MapTeam.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/map/MapTeam.kt new file mode 100644 index 0000000..7d65c54 --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/map/MapTeam.kt @@ -0,0 +1,17 @@ +package cc.maxmc.blastingcrisis.map + +import cc.maxmc.blastingcrisis.misc.Area +import org.bukkit.ChatColor +import org.bukkit.Location + +data class MapTeam( + val name: String, + val color: ChatColor, + val spawn: Location, + val home: Area, + val wall: Area, + val mine: Area, + val sides: List, + val teleport: Area, + val upgrade: Location, +) \ No newline at end of file diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/misc/Area.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/misc/Area.kt new file mode 100644 index 0000000..5d8ac9c --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/misc/Area.kt @@ -0,0 +1,84 @@ +package cc.maxmc.blastingcrisis.misc + +import org.bukkit.Location +import org.bukkit.Material +import org.bukkit.configuration.serialization.ConfigurationSerializable +import org.bukkit.configuration.serialization.SerializableAs +import kotlin.math.max +import kotlin.math.min + +@SerializableAs("Area") +class Area(loc1: Location, loc2: Location) : ConfigurationSerializable { + val locTop: Location + val locMin: Location + + constructor(map: Map) : this(map["locTop"] as Location, map["locMin"] as Location) + + init { + if (loc1.world != loc2.world) throw IllegalArgumentException("Locations must be of the same world.") + locTop = Location(loc1.world, max(loc1.x, loc2.x), max(loc1.y, loc2.y), max(loc1.z, loc2.z)) + locMin = Location(loc1.world, min(loc1.x, loc2.x), min(loc1.y, loc2.y), min(loc1.z, loc2.z)) + } + + /** + * check if the given location is in this area + * + * @param location location to check + * + * @return true if the location is in this area + */ + fun isInArea(location: Location): Boolean { + if (location.world != locTop.world) return false + if (location.x !in locTop.x..locMin.x) return false + if (location.y !in locTop.y..locMin.y) return false + if (location.z !in locTop.z..locMin.z) return false + return true + } + + /** + * get all locations of the blocks in this area + * + * @return all locations of the blocks in this area + */ + fun forBlocksInArea(): List { + val blocks = arrayListOf() + for (x in locTop.blockX..locMin.blockX) { + for (y in locTop.blockY..locMin.blockY) { + for (z in locTop.blockZ..locMin.blockZ) { + blocks.add(Location(locTop.world, x.toDouble(), y.toDouble(), z.toDouble())) + } + } + } + return blocks + } + + /** + * get all locations of the non air blocks in this area + * + * @return all locations of the non air blocks in this area + */ + fun forBlocksWithoutAir(): List { + return forBlocksInArea().filter { it.block.type != Material.AIR } + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Area + + if (locTop != other.locTop) return false + if (locMin != other.locMin) return false + + return true + } + + override fun hashCode(): Int { + var result = locTop.hashCode() + result = 31 * result + locMin.hashCode() + return result + } + + override fun serialize() = mutableMapOf("locTop" to locTop, "locMin" to locMin) + +} diff --git a/src/main/kotlin/cc/maxmc/blastingcrisis/misc/GameManager.kt b/src/main/kotlin/cc/maxmc/blastingcrisis/misc/GameManager.kt new file mode 100644 index 0000000..99efdc4 --- /dev/null +++ b/src/main/kotlin/cc/maxmc/blastingcrisis/misc/GameManager.kt @@ -0,0 +1,5 @@ +package cc.maxmc.blastingcrisis.misc + +object GameManager { + +} \ No newline at end of file