diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/location/DistanceRequirementFactory.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/location/DistanceRequirementFactory.kt index 97e5086..6ff3e6f 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/location/DistanceRequirementFactory.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/location/DistanceRequirementFactory.kt @@ -10,6 +10,10 @@ import org.bukkit.configuration.ConfigurationSection class DistanceRequirementFactory : ArcaneRequirementFactory() { + private fun warnMissingProperty(source: ConfigurationSection, property: String) { + warning("Could not load '${DistanceRequirement.TYPE}' requirement from ${source.currentPath}: missing required property '${property}'") + } + override fun matches(source: ConfigurationSection): Boolean { var type = source.getString(Requirement.TYPE)?.trim() ?: return false @@ -27,13 +31,13 @@ class DistanceRequirementFactory : ArcaneRequirementFactory val location = LocationVariable( source.getString("location") ?: kotlin.run { - warning("Could not load 'distance' requirement from ${source.currentPath}: missing required property 'location'") + warnMissingProperty(source, "location") return null } ) val distance = DoubleVariable( source.getString("distance") ?: kotlin.run { - warning("Could not load 'distance' requirement from ${source.currentPath}: missing required property 'distance'") + warnMissingProperty(source, "distance") return null } ) diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirementFactory.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirementFactory.kt index 9eee23e..870da5b 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirementFactory.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirementFactory.kt @@ -9,6 +9,14 @@ import org.bukkit.configuration.ConfigurationSection class NumberRequirementFactory : ArcaneRequirementFactory() { + private fun warnMissingProperty( + operation: NumberRequirement.Operation, + source: ConfigurationSection, + property: String + ) { + warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property '${property}'") + } + override fun matches(source: ConfigurationSection): Boolean { var type = source.getString(Requirement.TYPE)?.trim() ?: return false @@ -32,13 +40,13 @@ class NumberRequirementFactory : ArcaneRequirementFactory() { val operation = NumberRequirement.Operation.find(type) ?: return null val left = DoubleVariable( source.getString("left") ?: kotlin.run { - warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property 'left'") + warnMissingProperty(operation, source, "left") return null } ) val right = DoubleVariable( source.getString("right") ?: kotlin.run { - warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property 'right'") + warnMissingProperty(operation, source, "right") return null } ) diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirementFactory.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirementFactory.kt index f31ff08..92b4e6d 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirementFactory.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirementFactory.kt @@ -8,6 +8,14 @@ import org.bukkit.configuration.ConfigurationSection class StringRequirementFactory : ArcaneRequirementFactory() { + private fun warnMissingProperty( + operation: StringRequirement.Operation, + source: ConfigurationSection, + property: String + ) { + warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property '${property}'") + } + override fun matches(source: ConfigurationSection): Boolean { var type = source.getString(Requirement.TYPE)?.trim() ?: return false @@ -29,11 +37,11 @@ class StringRequirementFactory : ArcaneRequirementFactory() { val operation = StringRequirement.Operation.find(type) ?: return null val left = source.getString("left") ?: kotlin.run { - warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property 'left'") + warnMissingProperty(operation, source, "left") return null } val right = source.getString("right") ?: kotlin.run { - warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property 'right'") + warnMissingProperty(operation, source, "right") return null } val failActions = actionManager.parseActions(source.getStringList(Requirement.FAIL_ACTIONS))