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 0358bbb..97e5086 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 @@ -2,6 +2,7 @@ package me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations. import me.gabytm.minecraft.arcanevouchers.Constant.Requirement import me.gabytm.minecraft.arcanevouchers.actions.ArcaneActionManager +import me.gabytm.minecraft.arcanevouchers.functions.warning import me.gabytm.minecraft.arcanevouchers.voucher.requirements.ArcaneRequirementFactory import me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations.common.variable.DoubleVariable import me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations.common.variable.LocationVariable @@ -24,8 +25,18 @@ class DistanceRequirementFactory : ArcaneRequirementFactory val negated = type.startsWith(Requirement.NEGATION) val optional = source.getBoolean(Requirement.OPTIONAL) - val location = LocationVariable(source.getString("location") ?: return null) - val distance = DoubleVariable(source.getString("distance") ?: return null) + val location = LocationVariable( + source.getString("location") ?: kotlin.run { + warning("Could not load 'distance' requirement from ${source.currentPath}: missing required property 'location'") + return null + } + ) + val distance = DoubleVariable( + source.getString("distance") ?: kotlin.run { + warning("Could not load 'distance' requirement from ${source.currentPath}: missing required property 'distance'") + return null + } + ) val failActions = actionManager.parseActions(source.getStringList(Requirement.FAIL_ACTIONS)) return DistanceRequirement(source.name, optional, negated, failActions, actionManager, location, distance) } diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirement.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirement.kt index a994660..ad36185 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirement.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/number/NumberRequirement.kt @@ -35,7 +35,7 @@ class NumberRequirement( } @Suppress("unused") - enum class Operation(private val identifier: String) { + enum class Operation(val identifier: String) { EQUAL("==") { override fun check(left: Double, right: Double, negated: Boolean): Boolean { 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 d26b8fe..9eee23e 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 @@ -2,6 +2,7 @@ package me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations. import me.gabytm.minecraft.arcanevouchers.Constant.Requirement import me.gabytm.minecraft.arcanevouchers.actions.ArcaneActionManager +import me.gabytm.minecraft.arcanevouchers.functions.warning import me.gabytm.minecraft.arcanevouchers.voucher.requirements.ArcaneRequirementFactory import me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations.common.variable.DoubleVariable import org.bukkit.configuration.ConfigurationSection @@ -27,9 +28,20 @@ class NumberRequirementFactory : ArcaneRequirementFactory() { type = type.substring(1) } + // Not adding a warning for this because it won't get to this point if the factory couldn't find an Operation val operation = NumberRequirement.Operation.find(type) ?: return null - val left = DoubleVariable(source.getString("left") ?: return null) - val right = DoubleVariable(source.getString("right") ?: return null) + val left = DoubleVariable( + source.getString("left") ?: kotlin.run { + warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property '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'") + return null + } + ) val failActions = actionManager.parseActions(source.getStringList(Requirement.FAIL_ACTIONS)) return NumberRequirement(source.name, optional, negated, failActions, actionManager, left, right, operation) } diff --git a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirement.kt b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirement.kt index 11d1f39..778bc1d 100644 --- a/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirement.kt +++ b/plugin/src/main/kotlin/me/gabytm/minecraft/arcanevouchers/voucher/requirements/implementations/string/StringRequirement.kt @@ -26,7 +26,7 @@ class StringRequirement( } @Suppress("unused") - enum class Operation(private val identifier: String) { + enum class Operation(val identifier: String) { EQUALS("string equals") { override fun check(left: String?, right: String?, negated: Boolean): Boolean { 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 c0fa36a..f31ff08 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 @@ -2,6 +2,7 @@ package me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations. import me.gabytm.minecraft.arcanevouchers.Constant.Requirement import me.gabytm.minecraft.arcanevouchers.actions.ArcaneActionManager +import me.gabytm.minecraft.arcanevouchers.functions.warning import me.gabytm.minecraft.arcanevouchers.voucher.requirements.ArcaneRequirementFactory import org.bukkit.configuration.ConfigurationSection @@ -27,8 +28,14 @@ class StringRequirementFactory : ArcaneRequirementFactory() { } val operation = StringRequirement.Operation.find(type) ?: return null - val left = source.getString("left") ?: return null - val right = source.getString("right") ?: return null + val left = source.getString("left") ?: kotlin.run { + warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property 'left'") + return null + } + val right = source.getString("right") ?: kotlin.run { + warning("Could not load '${operation.identifier}' requirement from ${source.currentPath}: missing required property 'right'") + return null + } val failActions = actionManager.parseActions(source.getStringList(Requirement.FAIL_ACTIONS)) return StringRequirement(source.name, optional, negated, failActions, actionManager, left, right, operation) }