Fix Locations

This commit is contained in:
2024-12-13 09:43:18 +01:00
parent b90884ee1d
commit 56c66b33b7
@@ -54,7 +54,7 @@ object TNTLeagueWorldConfig {
val blueTeam: TeamConfig = TeamConfig.fromConfig(config.getConfigurationSection("blueTeam")!!) val blueTeam: TeamConfig = TeamConfig.fromConfig(config.getConfigurationSection("blueTeam")!!)
val redTeam: TeamConfig = TeamConfig.fromConfig(config.getConfigurationSection("redTeam")!!) val redTeam: TeamConfig = TeamConfig.fromConfig(config.getConfigurationSection("redTeam")!!)
val lobby: Location = config.getLocation("lobby", blueTeam.spawnLocation.clone().add(redTeam.spawnLocation).multiply(0.5))!! val lobby: Location = config.getWorldLocation("lobby", blueTeam.spawnLocation.clone().add(redTeam.spawnLocation).multiply(0.5))!!
val targetMaterial: Material = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!! val targetMaterial: Material = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!!
val minHeight: Int = config.getInt("minHeight", 0) val minHeight: Int = config.getInt("minHeight", 0)
val target: Int = config.getInt("target", -1) val target: Int = config.getInt("target", -1)
@@ -68,11 +68,11 @@ object TNTLeagueWorldConfig {
) { ) {
companion object { companion object {
fun fromConfig(config: ConfigurationSection): TeamConfig { fun fromConfig(config: ConfigurationSection): TeamConfig {
val spawnLocation = config.getWorldLocation("spawn")!! val spawnLocation = config.getWorldLocation("spawn")
val dealerSpawn = config.getWorldLocation("dealerSpawn")!! val dealerSpawn = config.getWorldLocation("dealerSpawn")
val itemSpawn = config.getWorldLocation("itemSpawn")!! val itemSpawn = config.getWorldLocation("itemSpawn")
val targetPos1 = config.getWorldLocation("targetMin")!! val targetPos1 = config.getWorldLocation("targetMin")
val targetPos2 = config.getWorldLocation("targetMax")!! val targetPos2 = config.getWorldLocation("targetMax")
spawnDealer(dealerSpawn) spawnDealer(dealerSpawn)
@@ -93,8 +93,8 @@ object TNTLeagueWorldConfig {
} }
} }
fun ConfigurationSection.getWorldLocation(s: String): Location { fun ConfigurationSection.getWorldLocation(s: String, default: Location? = null): Location {
val section = getConfigurationSection(s)!! val section = getConfigurationSection(s) ?: return default!!
val x = section.getDouble("x") val x = section.getDouble("x")
val y = section.getDouble("y") val y = section.getDouble("y")