Skip to content

Commit

Permalink
Improved filter deprecation messages
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Aug 26, 2023
1 parent f57a6c7 commit 60b136a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ object Filters : Registry<Filter<*, *>>() {

for (key in config.getKeys(false)) {
val filter = get(key) ?: get(key.removePrefix("not_")) ?: continue

if (filter.deprecationMessage != null) {
context.log(
ConfigWarning(
key,
"Filter $key is deprecated: ${filter.deprecationMessage}. It will be removed in the future."
)
)
}

blocks += makeBlock(filter, config, context) ?: continue
}

Expand All @@ -62,6 +52,15 @@ object Filters : Registry<Filter<*, *>>() {
config: Config,
context: ViolationContext
): FilterBlock<T, V>? {
if (filter.deprecationMessage != null) {
context.log(
ConfigWarning(
filter.id,
"Filter ${filter.id} is deprecated: ${filter.deprecationMessage}. It will be removed in the future."
)
)
}

if (!filter.checkConfig(config, context)) {
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.bukkit.entity.Boss
import org.bukkit.entity.ElderGuardian
import org.bukkit.persistence.PersistentDataType

@Deprecated("Use 'is_boss' filter instead")
@Deprecated("Use is_boss instead")
object FilterOnlyBosses : Filter<NoCompileData, Boolean>("only_bosses") {
override fun getValue(config: Config, data: TriggerData?, key: String): Boolean {
return config.getBool(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.bukkit.entity.Boss
import org.bukkit.entity.ElderGuardian
import org.bukkit.persistence.PersistentDataType

@Deprecated("Use 'is_boss' filter instead")
@Deprecated("Use is_boss instead")
object FilterOnlyNonBosses : Filter<NoCompileData, Boolean>("only_non_bosses") {
override fun getValue(config: Config, data: TriggerData?, key: String): Boolean {
return config.getBool(key)
Expand Down

0 comments on commit 60b136a

Please sign in to comment.