Add LobbyAnnouncer with beta broadcasts

Introduce a LobbyAnnouncer module that periodically broadcasts a MiniMessage announcement during the LOBBY state. The new class (game/modules/LobbyAnnouncer.kt) schedules broadcasts every 30 seconds when the new config flag game.beta is true and provides start/stop lifecycle methods. Integrate the announcer into the main plugin (SpeedHG.kt) by adding a lobbyAnnouncer field and starting it during initialization. Also update config.yml to add game.beta: true and change teams.enabled from true to false.
This commit is contained in:
TDSTOS
2026-04-12 05:13:50 +02:00
parent 5a828a3993
commit c986c4b593
3 changed files with 63 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ import club.mcscrims.speedhg.disaster.DisasterManager
import club.mcscrims.speedhg.game.GameManager import club.mcscrims.speedhg.game.GameManager
import club.mcscrims.speedhg.game.PodiumManager import club.mcscrims.speedhg.game.PodiumManager
import club.mcscrims.speedhg.game.modules.AntiRunningManager import club.mcscrims.speedhg.game.modules.AntiRunningManager
import club.mcscrims.speedhg.game.modules.LobbyAnnouncer
import club.mcscrims.speedhg.game.modules.LobbyItemManager import club.mcscrims.speedhg.game.modules.LobbyItemManager
import club.mcscrims.speedhg.gui.listener.MenuListener import club.mcscrims.speedhg.gui.listener.MenuListener
import club.mcscrims.speedhg.kit.KitManager import club.mcscrims.speedhg.kit.KitManager
@@ -120,6 +121,9 @@ class SpeedHG : JavaPlugin() {
lateinit var tablistManager: TablistManager lateinit var tablistManager: TablistManager
private set private set
lateinit var lobbyAnnouncer: LobbyAnnouncer
private set
override fun onLoad() override fun onLoad()
{ {
instance = this instance = this
@@ -190,6 +194,9 @@ class SpeedHG : JavaPlugin() {
disasterManager = DisasterManager( this ) disasterManager = DisasterManager( this )
disasterManager.start() disasterManager.start()
lobbyAnnouncer = LobbyAnnouncer( this )
lobbyAnnouncer.start()
registerKits() registerKits()
registerPerks() registerPerks()
registerCommands() registerCommands()

View File

@@ -0,0 +1,54 @@
package club.mcscrims.speedhg.game.modules
import club.mcscrims.speedhg.SpeedHG
import club.mcscrims.speedhg.game.GameState
import net.kyori.adventure.text.minimessage.MiniMessage
import org.bukkit.Bukkit
import org.bukkit.scheduler.BukkitTask
/**
* Sendet periodische Informationen während der Lobby-Phase
*/
class LobbyAnnouncer(
private val plugin: SpeedHG
) {
private val mm = MiniMessage.miniMessage()
private var task: BukkitTask? = null
companion object {
private const val INTERVAL_TICKS = 30 * 20L
}
/**
* Startet den Timer für die Lobby-Ankündigungen.
*/
fun start()
{
if (!plugin.config.getBoolean( "game.beta" ))
return
task = Bukkit.getScheduler().runTaskTimer( plugin, { ->
if ( plugin.gameManager.currentState != GameState.LOBBY )
return@runTaskTimer
val message = mm.deserialize(
"\n<gray>[<gradient:gold:yellow><bold>BETA</bold></gradient>]</gray> " +
"<yellow>SpeedHG is currently in Beta! Your feedback is extremely helpful for us.</yellow>\n" +
"<gray>Please share your ideas and suggestions in the <blue>#ideas</blue> forum on our Discord!</gray>\n"
)
Bukkit.broadcast( message )
}, INTERVAL_TICKS, INTERVAL_TICKS )
}
/**
* Stoppt den Timer (z.B. beim Server-Shutdown).
*/
fun stop()
{
task?.cancel()
task = null
}
}

View File

@@ -4,6 +4,7 @@
# #
game: game:
beta: true
min-players: 2 min-players: 2
lobby-time: 60 lobby-time: 60
invincibility-time: 60 invincibility-time: 60
@@ -27,7 +28,7 @@ lunarclient:
variantName: 'SpeedHG - Solo' variantName: 'SpeedHG - Solo'
teams: teams:
enabled: true enabled: false
max-size: 2 max-size: 2
recraftNerf: recraftNerf: