-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[plugin] add warning for invalid requirement variables
- Loading branch information
Showing
6 changed files
with
47 additions
and
13 deletions.
There are no files selected for viewing
14 changes: 11 additions & 3 deletions
14
...ft/arcanevouchers/voucher/requirements/implementations/common/variable/BooleanVariable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
package me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations.common.variable | ||
|
||
import me.gabytm.minecraft.arcanevouchers.functions.papi | ||
import me.gabytm.minecraft.arcanevouchers.functions.warning | ||
import org.bukkit.entity.Player | ||
|
||
data class BooleanVariable( | ||
private val stringValue: String | ||
private val string: String | ||
) : Variable<Boolean>( | ||
{ player -> stringValue.toBooleanStrictOrNull() ?: stringValue.papi(player).toBooleanStrictOrNull() } | ||
) | ||
{ player -> string.toBooleanStrictOrNull() ?: string.papi(player).toBooleanStrictOrNull() } | ||
) { | ||
|
||
override fun warn(player: Player?, requirement: String) { | ||
warning("[$requirement] '$string' (${string.papi(player)}) is not a valid boolean (accepted values: true, false)") | ||
} | ||
|
||
} |
10 changes: 9 additions & 1 deletion
10
...aft/arcanevouchers/voucher/requirements/implementations/common/variable/DoubleVariable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
package me.gabytm.minecraft.arcanevouchers.voucher.requirements.implementations.common.variable | ||
|
||
import me.gabytm.minecraft.arcanevouchers.functions.papi | ||
import me.gabytm.minecraft.arcanevouchers.functions.warning | ||
import org.bukkit.entity.Player | ||
|
||
data class DoubleVariable( | ||
private val string: String | ||
) : Variable<Double>( | ||
{ player -> string.toDoubleOrNull() ?: string.papi(player).toDoubleOrNull() } | ||
) | ||
) { | ||
|
||
override fun warn(player: Player?, requirement: String) { | ||
warning("[$requirement] '$string' (${string.papi(player)}) is not a valid Double") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters