Skip to content

Commit d6bfc52

Browse files
committed
Added false options to in_air, in_water, and is_sneaking
1 parent 7cb76f9 commit d6bfc52

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

eco-api/src/main/kotlin/com/willfp/libreforge/conditions/conditions/ConditionInAir.kt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.willfp.libreforge.conditions.conditions
22

33
import com.willfp.eco.core.config.interfaces.JSONConfig
4+
import com.willfp.libreforge.ConfigViolation
45
import com.willfp.libreforge.conditions.Condition
56
import com.willfp.libreforge.updateEffects
67
import org.bukkit.entity.Player
@@ -20,6 +21,20 @@ class ConditionInAir: Condition("in_air") {
2021
}
2122

2223
override fun isConditionMet(player: Player, config: JSONConfig): Boolean {
23-
return player.location.block.isEmpty
24+
return player.location.block.isEmpty == config.getBool("in_air")
25+
}
26+
27+
override fun validateConfig(config: JSONConfig): List<ConfigViolation> {
28+
val violations = mutableListOf<ConfigViolation>()
29+
30+
config.getBoolOrNull("in_air")
31+
?: violations.add(
32+
ConfigViolation(
33+
"in_air",
34+
"You must specify if the player must be in air on on land!"
35+
)
36+
)
37+
38+
return violations
2439
}
2540
}

eco-api/src/main/kotlin/com/willfp/libreforge/conditions/conditions/ConditionInWater.kt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.willfp.libreforge.conditions.conditions
22

33
import com.willfp.eco.core.config.interfaces.JSONConfig
4+
import com.willfp.libreforge.ConfigViolation
45
import com.willfp.libreforge.conditions.Condition
56
import com.willfp.libreforge.updateEffects
67
import org.bukkit.entity.Player
@@ -24,6 +25,20 @@ class ConditionInWater: Condition("in_water") {
2425
}
2526

2627
override fun isConditionMet(player: Player, config: JSONConfig): Boolean {
27-
return player.isInWater
28+
return player.isInWater == config.getBool("in_water")
29+
}
30+
31+
override fun validateConfig(config: JSONConfig): List<ConfigViolation> {
32+
val violations = mutableListOf<ConfigViolation>()
33+
34+
config.getBoolOrNull("in_water")
35+
?: violations.add(
36+
ConfigViolation(
37+
"in_water",
38+
"You must specify if the player must be in water or not!"
39+
)
40+
)
41+
42+
return violations
2843
}
2944
}

eco-api/src/main/kotlin/com/willfp/libreforge/conditions/conditions/ConditionIsSneaking.kt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.willfp.libreforge.conditions.conditions
22

33
import com.willfp.eco.core.config.interfaces.JSONConfig
4+
import com.willfp.libreforge.ConfigViolation
45
import com.willfp.libreforge.conditions.Condition
56
import com.willfp.libreforge.updateEffects
67
import org.bukkit.entity.Player
@@ -20,6 +21,20 @@ class ConditionIsSneaking: Condition("is_sneaking") {
2021
}
2122

2223
override fun isConditionMet(player: Player, config: JSONConfig): Boolean {
23-
return player.isSprinting
24+
return player.isSneaking == config.getBool("is_sneaking")
25+
}
26+
27+
override fun validateConfig(config: JSONConfig): List<ConfigViolation> {
28+
val violations = mutableListOf<ConfigViolation>()
29+
30+
config.getBoolOrNull("is_sneaking")
31+
?: violations.add(
32+
ConfigViolation(
33+
"is_sneaking",
34+
"You must specify if the player must be sneaking or standing!"
35+
)
36+
)
37+
38+
return violations
2439
}
2540
}

0 commit comments

Comments
 (0)