forked from SteamWar/SteamWar
Make TNTLeague Event System Capable
This commit is contained in:
@@ -54,8 +54,8 @@ object TNTLeagueWorldConfig {
|
||||
)
|
||||
}
|
||||
|
||||
lateinit var blueTeam: TeamConfig
|
||||
lateinit var redTeam: TeamConfig
|
||||
lateinit var blueTeam: TeamWorldConfig
|
||||
lateinit var redTeam: TeamWorldConfig
|
||||
lateinit var lobby: Location
|
||||
var teamsOnSameLine by Delegates.notNull<Boolean>()
|
||||
lateinit var targetMaterial: Material
|
||||
@@ -64,8 +64,8 @@ object TNTLeagueWorldConfig {
|
||||
|
||||
init {
|
||||
try {
|
||||
blueTeam = TeamConfig.fromConfig(config.getConfigurationSection("blueTeam")!!)
|
||||
redTeam = TeamConfig.fromConfig(config.getConfigurationSection("redTeam")!!)
|
||||
blueTeam = TeamWorldConfig.fromConfig(config.getConfigurationSection("blueTeam")!!)
|
||||
redTeam = TeamWorldConfig.fromConfig(config.getConfigurationSection("redTeam")!!)
|
||||
teamsOnSameLine = abs(blueTeam.spawnLocation.blockX - redTeam.spawnLocation.blockX) < 20
|
||||
lobby = config.getWorldLocation("lobby", blueTeam.spawnLocation.clone().add(redTeam.spawnLocation).multiply(0.5))
|
||||
targetMaterial = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!!
|
||||
@@ -76,39 +76,6 @@ object TNTLeagueWorldConfig {
|
||||
Bukkit.shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmRecord
|
||||
data class TeamConfig(
|
||||
val spawnLocation: Location,
|
||||
val dealerSpawn: Location,
|
||||
val itemSpawn: Location,
|
||||
val target: Area
|
||||
) {
|
||||
companion object {
|
||||
fun fromConfig(config: ConfigurationSection): TeamConfig {
|
||||
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)
|
||||
|
||||
return TeamConfig(spawnLocation, dealerSpawn, itemSpawn, Area(targetPos1, targetPos2))
|
||||
}
|
||||
|
||||
private fun spawnDealer(loc: Location) = world.spawn(loc, WanderingTrader::class.java)
|
||||
.apply {
|
||||
customName(Component.text("Shop"))
|
||||
isCustomNameVisible = false
|
||||
isInvulnerable = true
|
||||
isSilent = true
|
||||
isCollidable = false
|
||||
isAware = false
|
||||
setAI(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun ConfigurationSection.getWorldLocation(s: String, default: Location? = null): Location {
|
||||
|
||||
Reference in New Issue
Block a user