From b90884ee1dce4eb22f8154c5975d1792bd5e14b4 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 13 Dec 2024 09:31:15 +0100 Subject: [PATCH] Fix Locations --- .../tntleague/config/TNTLeagueWorldConfig.kt | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt b/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt index 44405103..979904f3 100644 --- a/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt +++ b/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt @@ -21,6 +21,7 @@ package de.steamwar.tntleague.config import de.steamwar.tntleague.plugin import de.steamwar.kotlin.util.Area +import de.steamwar.tntleague.TNTLeague import net.kyori.adventure.text.Component import org.bukkit.Location import org.bukkit.Material @@ -67,11 +68,11 @@ object TNTLeagueWorldConfig { ) { companion object { fun fromConfig(config: ConfigurationSection): TeamConfig { - val spawnLocation = config.getLocation("spawn")!! - val dealerSpawn = config.getLocation("dealerSpawn")!! - val itemSpawn = config.getLocation("itemSpawn")!! - val targetPos1 = config.getLocation("targetMin")!! - val targetPos2 = config.getLocation("targetMax")!! + val spawnLocation = config.getWorldLocation("spawn")!! + val dealerSpawn = config.getWorldLocation("dealerSpawn")!! + val itemSpawn = config.getWorldLocation("itemSpawn")!! + val targetPos1 = config.getWorldLocation("targetMin")!! + val targetPos2 = config.getWorldLocation("targetMax")!! spawnDealer(dealerSpawn) @@ -91,3 +92,19 @@ object TNTLeagueWorldConfig { } } } + +fun ConfigurationSection.getWorldLocation(s: String): Location { + val section = getConfigurationSection(s)!! + + val x = section.getDouble("x") + val y = section.getDouble("y") + val z = section.getDouble("z") + val pitch = section.getDouble("pitch") + val yaw = section.getDouble("yaw") + + return Location( + plugin.server.worlds.first(), + x, y, z, + pitch.toFloat(), yaw.toFloat() + ) +}