forked from SteamWar/SteamWar
55 lines
1.9 KiB
Kotlin
55 lines
1.9 KiB
Kotlin
/*
|
|
* This file is a part of the SteamWar software.
|
|
*
|
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package de.steamwar.tntleague.config
|
|
|
|
import de.steamwar.tntleague.plugin
|
|
import org.bukkit.Material
|
|
import org.bukkit.configuration.ConfigurationSection
|
|
import org.bukkit.configuration.file.FileConfiguration
|
|
|
|
data class TNTLeagueConfig(
|
|
val startDelay: Int = 10,
|
|
val gameTime: Int = 60 * 20,
|
|
|
|
val prices: Map<Material, Price>
|
|
) {
|
|
companion object {
|
|
val config: TNTLeagueConfig by lazy { loadConfig(plugin.config) }
|
|
|
|
private fun loadConfig(config: FileConfiguration): TNTLeagueConfig {
|
|
return TNTLeagueConfig(config.getInt("startDelay"), config.getInt("gameTime"), loadPrices(config.getConfigurationSection("prices")!!))
|
|
}
|
|
|
|
private fun loadPrices(config: ConfigurationSection): Map<Material, Price> {
|
|
return config.getKeys(false).associateWith {
|
|
Price(
|
|
config.getInt("$it.amount"),
|
|
config.getInt("$it.price")
|
|
)
|
|
}.mapKeys { Material.getMaterial(it.key)!! }
|
|
}
|
|
}
|
|
|
|
data class Price(
|
|
val amount: Int,
|
|
val price: Int,
|
|
)
|
|
}
|