Skip to content

Commit

Permalink
Added false options to in_air, in_water, and is_sneaking
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Nov 22, 2021
1 parent 7cb76f9 commit d6bfc52
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.willfp.libreforge.conditions.conditions

import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.libreforge.ConfigViolation
import com.willfp.libreforge.conditions.Condition
import com.willfp.libreforge.updateEffects
import org.bukkit.entity.Player
Expand All @@ -20,6 +21,20 @@ class ConditionInAir: Condition("in_air") {
}

override fun isConditionMet(player: Player, config: JSONConfig): Boolean {
return player.location.block.isEmpty
return player.location.block.isEmpty == config.getBool("in_air")
}

override fun validateConfig(config: JSONConfig): List<ConfigViolation> {
val violations = mutableListOf<ConfigViolation>()

config.getBoolOrNull("in_air")
?: violations.add(
ConfigViolation(
"in_air",
"You must specify if the player must be in air on on land!"
)
)

return violations
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.willfp.libreforge.conditions.conditions

import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.libreforge.ConfigViolation
import com.willfp.libreforge.conditions.Condition
import com.willfp.libreforge.updateEffects
import org.bukkit.entity.Player
Expand All @@ -24,6 +25,20 @@ class ConditionInWater: Condition("in_water") {
}

override fun isConditionMet(player: Player, config: JSONConfig): Boolean {
return player.isInWater
return player.isInWater == config.getBool("in_water")
}

override fun validateConfig(config: JSONConfig): List<ConfigViolation> {
val violations = mutableListOf<ConfigViolation>()

config.getBoolOrNull("in_water")
?: violations.add(
ConfigViolation(
"in_water",
"You must specify if the player must be in water or not!"
)
)

return violations
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.willfp.libreforge.conditions.conditions

import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.libreforge.ConfigViolation
import com.willfp.libreforge.conditions.Condition
import com.willfp.libreforge.updateEffects
import org.bukkit.entity.Player
Expand All @@ -20,6 +21,20 @@ class ConditionIsSneaking: Condition("is_sneaking") {
}

override fun isConditionMet(player: Player, config: JSONConfig): Boolean {
return player.isSprinting
return player.isSneaking == config.getBool("is_sneaking")
}

override fun validateConfig(config: JSONConfig): List<ConfigViolation> {
val violations = mutableListOf<ConfigViolation>()

config.getBoolOrNull("is_sneaking")
?: violations.add(
ConfigViolation(
"is_sneaking",
"You must specify if the player must be sneaking or standing!"
)
)

return violations
}
}

0 comments on commit d6bfc52

Please sign in to comment.