Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class Tier(
*/
val properties = notNullMutableMapOf<ArmorSlot, TierProperties>()

/**
* If any slot uses the deprecated stat options.
*/
val usesLegacyStats: Boolean
get() = properties.values.any { it.hasLegacyStats }

/**
* Create a new Tier.
*/
Expand All @@ -88,11 +94,9 @@ class Tier(
out.amount = 1 // who knows
crystal = out
val context = ViolationContext(plugin, "Tier $id")
val legacySlots = mutableListOf<String>()

for (slot in ArmorSlot.entries) {
val slotName = slot.name.lowercase(Locale.getDefault())
val path = "properties.$slotName"
val path = "properties.${slot.name.lowercase(Locale.getDefault())}"

properties[slot] = TierProperties(
modifiers = readModifiers(slot, "$path.components", context),
Expand Down Expand Up @@ -120,21 +124,6 @@ class Tier(
blockInteractionRangePercentage = config.getIntOrNull("$path.blockReachPercentage")
?: config.getIntOrNull("$path.blockInteractionRangePercentage")
)

if (properties[slot]?.hasLegacyStats == true) {
legacySlots += slotName
}
}

if (legacySlots.isNotEmpty()) {
context.log(
ConfigWarning(
"properties",
"The stat options on ${legacySlots.joinToString()} are deprecated and will be " +
"removed in a future version. Use a components section with " +
"attribute_modifiers instead."
)
)
}

CustomItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,14 @@
override fun afterReload(plugin: LibreforgePlugin) {
cachedValues = ImmutableList.copyOf(registry.values())
defaultTier = getByID("default")!!

val legacyTierIds = cachedValues.filter { it.usesLegacyStats }.map { it.id }.sorted()

Check failure on line 71 in eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tiers.kt

View workflow job for this annotation

GitHub Actions / jvm-lint

PF002 (CouldBeSequence)

PF002 (CouldBeSequence) filter { it.usesLegacyStats } could be .asSequence().filter { it.usesLegacyStats }
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
if (legacyTierIds.isNotEmpty()) {
plugin.logger.warning(
"Tiers using deprecated stat options: ${legacyTierIds.joinToString()}. " +
"They still work but will be removed in a future version; " +
"move them to components with attribute_modifiers."
)
}
}
}
Loading