diff --git a/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSet.kt b/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSet.kt index 7cfc6736..d91de599 100644 --- a/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSet.kt +++ b/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSet.kt @@ -6,6 +6,7 @@ import net.rsprox.shared.filters.PropertyFilter import net.rsprox.shared.filters.PropertyFilterSet import net.rsprox.shared.filters.ProtCategory import java.nio.file.Path +import kotlin.io.path.deleteIfExists import kotlin.io.path.readText public class DefaultPropertyFilterSet( @@ -28,6 +29,10 @@ public class DefaultPropertyFilterSet( this.name = name } + override fun deleteBackingFile() { + path.deleteIfExists() + } + override fun get(filter: PropertyFilter): Boolean { return filters[filter.name] ?: filter.enabled } diff --git a/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSetStore.kt b/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSetStore.kt index 47337348..bf2c6d33 100644 --- a/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSetStore.kt +++ b/proxy/src/main/kotlin/net/rsprox/proxy/filters/DefaultPropertyFilterSetStore.kt @@ -25,6 +25,7 @@ public class DefaultPropertyFilterSetStore( override fun delete(index: Int): PropertyFilterSet? { if (index == 0) throw IllegalArgumentException("Element at index 0 cannot be deleted.") val element = filterSets.getOrNull(index) ?: return null + element.deleteBackingFile() filterSets.removeAt(index) return element } diff --git a/proxy/src/main/kotlin/net/rsprox/proxy/filters/UnmodifiablePropertyFilterSet.kt b/proxy/src/main/kotlin/net/rsprox/proxy/filters/UnmodifiablePropertyFilterSet.kt index 595d4dd1..679e90ab 100644 --- a/proxy/src/main/kotlin/net/rsprox/proxy/filters/UnmodifiablePropertyFilterSet.kt +++ b/proxy/src/main/kotlin/net/rsprox/proxy/filters/UnmodifiablePropertyFilterSet.kt @@ -17,6 +17,9 @@ public class UnmodifiablePropertyFilterSet : PropertyFilterSet { override fun setName(name: String) { } + override fun deleteBackingFile() { + } + override fun get(filter: PropertyFilter): Boolean { return filter.enabled } diff --git a/shared/src/main/kotlin/net/rsprox/shared/filters/PropertyFilterSet.kt b/shared/src/main/kotlin/net/rsprox/shared/filters/PropertyFilterSet.kt index 55a9337b..443541ce 100644 --- a/shared/src/main/kotlin/net/rsprox/shared/filters/PropertyFilterSet.kt +++ b/shared/src/main/kotlin/net/rsprox/shared/filters/PropertyFilterSet.kt @@ -9,6 +9,8 @@ public interface PropertyFilterSet { public fun setName(name: String) + public fun deleteBackingFile() + public operator fun get(filter: PropertyFilter): Boolean public operator fun set(