All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tealcube.minecraft.bukkit.mythicdrops.settings.spawning.MythicCreature.kt Maven / Gradle / Ivy

There is a newer version: 9.0.4
Show newest version
package com.tealcube.minecraft.bukkit.mythicdrops.settings.spawning

import com.tealcube.minecraft.bukkit.mythicdrops.api.settings.spawning.Creature
import com.tealcube.minecraft.bukkit.mythicdrops.api.settings.spawning.NumberOfPasses
import com.tealcube.minecraft.bukkit.mythicdrops.getOrCreateSection
import org.bukkit.configuration.ConfigurationSection
import org.bukkit.entity.EntityType

internal data class MythicCreature(
    override val entityType: EntityType,
    override val dropMultiplier: Double = 0.0,
    override val tierDrops: List = emptyList(),
    override val numberOfLootPasses: NumberOfPasses = MythicNumberOfPasses(0, 0)
) : Creature {
    companion object {
        fun fromConfigurationSection(
            configurationSection: ConfigurationSection,
            entityType: EntityType
        ): MythicCreature {
            val dropMultiplier = configurationSection.getDouble("drop-multiplier", 0.0)
            val tierDrops = configurationSection.getStringList("tier-drops")
            val numberOfLootPasses = if (configurationSection.isConfigurationSection("number-of-loot-passes")) {
                val minimum = configurationSection.getOrCreateSection("number-of-loot-passes").getInt("minimum")
                val maximum = configurationSection.getOrCreateSection("number-of-loot-passes").getInt("maximum")
                MythicNumberOfPasses(minimum, maximum)
            } else {
                val num = configurationSection.getInt("number-of-loot-passes")
                MythicNumberOfPasses(num, num)
            }
            return MythicCreature(
                entityType = entityType,
                dropMultiplier = dropMultiplier,
                tierDrops = tierDrops,
                numberOfLootPasses = numberOfLootPasses
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy