File tree 3 files changed +48
-3
lines changed
eco-api/src/main/kotlin/com/willfp/libreforge/conditions/conditions
3 files changed +48
-3
lines changed Original file line number Diff line number Diff line change 1
1
package com.willfp.libreforge.conditions.conditions
2
2
3
3
import com.willfp.eco.core.config.interfaces.JSONConfig
4
+ import com.willfp.libreforge.ConfigViolation
4
5
import com.willfp.libreforge.conditions.Condition
5
6
import com.willfp.libreforge.updateEffects
6
7
import org.bukkit.entity.Player
@@ -20,6 +21,20 @@ class ConditionInAir: Condition("in_air") {
20
21
}
21
22
22
23
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
24
39
}
25
40
}
Original file line number Diff line number Diff line change 1
1
package com.willfp.libreforge.conditions.conditions
2
2
3
3
import com.willfp.eco.core.config.interfaces.JSONConfig
4
+ import com.willfp.libreforge.ConfigViolation
4
5
import com.willfp.libreforge.conditions.Condition
5
6
import com.willfp.libreforge.updateEffects
6
7
import org.bukkit.entity.Player
@@ -24,6 +25,20 @@ class ConditionInWater: Condition("in_water") {
24
25
}
25
26
26
27
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
28
43
}
29
44
}
Original file line number Diff line number Diff line change 1
1
package com.willfp.libreforge.conditions.conditions
2
2
3
3
import com.willfp.eco.core.config.interfaces.JSONConfig
4
+ import com.willfp.libreforge.ConfigViolation
4
5
import com.willfp.libreforge.conditions.Condition
5
6
import com.willfp.libreforge.updateEffects
6
7
import org.bukkit.entity.Player
@@ -20,6 +21,20 @@ class ConditionIsSneaking: Condition("is_sneaking") {
20
21
}
21
22
22
23
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
24
39
}
25
40
}
You can’t perform that action at this time.
0 commit comments