diff options
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features/VisitorAlert.kt')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/features/VisitorAlert.kt | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/features/VisitorAlert.kt b/src/main/kotlin/com/dulkirfabric/features/VisitorAlert.kt new file mode 100644 index 0000000..9f75d83 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/VisitorAlert.kt @@ -0,0 +1,45 @@ +package com.dulkirfabric.features + +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.AreaChangeEvent +import com.dulkirfabric.events.HudRenderEvent +import com.dulkirfabric.events.LongUpdateEvent +import com.dulkirfabric.util.TablistUtils +import com.dulkirfabric.util.render.HudRenderUtil +import meteordevelopment.orbit.EventHandler +import net.minecraft.text.Style +import net.minecraft.text.Text +import net.minecraft.util.Formatting +import java.time.Duration + +object VisitorAlert { + + private var canAlert = true + private var prevVisitorState = "" + + @EventHandler + private fun onAreaChange(event: AreaChangeEvent) { + canAlert = true + } + + @EventHandler + private fun onLong(event: LongUpdateEvent) { + if (TablistUtils.persistentInfo.area != "Garden") return + if (TablistUtils.persistentInfo.nextVisitorTime == "Queue Full!") { + if (DulkirConfig.configOptions.persistentVisitorAlert) { + HudRenderUtil.drawTitle( + Text.literal("Max Visitors").setStyle(Style.EMPTY.withColor(Formatting.GOLD)), + Duration.ofSeconds(5) + ) + } else if (canAlert) { + HudRenderUtil.drawTitle( + Text.literal("Max Visitors").setStyle(Style.EMPTY.withColor(Formatting.GOLD)), + Duration.ofSeconds(5) + ) + canAlert = false + } + } + + prevVisitorState = TablistUtils.persistentInfo.nextVisitorTime + } +}
\ No newline at end of file |