Skip to content

Commit

Permalink
fix: bonfire-cooldown system
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jul 31, 2024
1 parent c6defee commit 3de5b15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=1.11
idofrontVersion=0.24.14
idofrontVersion=0.24.15
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
gearyPaper = "0.30.3"
blocky = "0.10.1"
gearyPaper = "0.30.10-dev.3"
blocky = "0.10.3-dev.2"

[libraries]
geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import com.mineinabyss.bonfire.extensions.canBreakBonfire
import com.mineinabyss.bonfire.extensions.isBonfire
import com.mineinabyss.bonfire.extensions.removeOldBonfire
import com.mineinabyss.bonfire.extensions.updateBonfireState
import com.mineinabyss.geary.actions.ActionGroupContext
import com.mineinabyss.geary.actions.execute
import com.mineinabyss.geary.helpers.with
import com.mineinabyss.geary.papermc.bridge.cooldowns.Cooldowns
import com.mineinabyss.geary.papermc.bridge.cooldowns.StartCooldown
import com.mineinabyss.geary.papermc.datastore.decode
import com.mineinabyss.geary.papermc.datastore.encode
import com.mineinabyss.geary.papermc.datastore.encodeComponentsTo
import com.mineinabyss.geary.papermc.datastore.remove
import com.mineinabyss.geary.papermc.features.general.cooldown.Cooldown
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull
import com.mineinabyss.geary.serialization.setPersisting
Expand All @@ -38,7 +41,7 @@ import kotlin.math.abs
import kotlin.time.Duration.Companion.seconds

class BonfireListener : Listener {
val cooldown = Cooldown(length = bonfire.config.bonfireInteractCooldown)
private val cooldown = StartCooldown(length = bonfire.config.bonfireInteractCooldown, display = null, "bonfire:interaction_cooldown")

private fun currentTime() = LocalDateTime.now().toInstant(ZoneOffset.UTC).epochSecond

Expand Down Expand Up @@ -95,11 +98,12 @@ class BonfireListener : Listener {

val gearyPlayer = player.toGeary()
val gearyBonfire = baseEntity.toGearyOrNull() ?: return
if (!Cooldown.isComplete(gearyPlayer, gearyBonfire)) {

if (!Cooldowns.isComplete(gearyPlayer, "bonfire:interaction_cooldown")) {
isCancelled = true
return
}
Cooldown.start(gearyPlayer, gearyBonfire, cooldown)
cooldown.execute(ActionGroupContext(gearyPlayer))

gearyBonfire.with { bonfireData: Bonfire ->
when (player.uniqueId) {
Expand Down

0 comments on commit 3de5b15

Please sign in to comment.