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:
@@ -16,6 +16,7 @@ import club.mcscrims.speedhg.disaster.DisasterManager
|
||||
import club.mcscrims.speedhg.game.GameManager
|
||||
import club.mcscrims.speedhg.game.PodiumManager
|
||||
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.gui.listener.MenuListener
|
||||
import club.mcscrims.speedhg.kit.KitManager
|
||||
@@ -120,6 +121,9 @@ class SpeedHG : JavaPlugin() {
|
||||
lateinit var tablistManager: TablistManager
|
||||
private set
|
||||
|
||||
lateinit var lobbyAnnouncer: LobbyAnnouncer
|
||||
private set
|
||||
|
||||
override fun onLoad()
|
||||
{
|
||||
instance = this
|
||||
@@ -190,6 +194,9 @@ class SpeedHG : JavaPlugin() {
|
||||
disasterManager = DisasterManager( this )
|
||||
disasterManager.start()
|
||||
|
||||
lobbyAnnouncer = LobbyAnnouncer( this )
|
||||
lobbyAnnouncer.start()
|
||||
|
||||
registerKits()
|
||||
registerPerks()
|
||||
registerCommands()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
#
|
||||
|
||||
game:
|
||||
beta: true
|
||||
min-players: 2
|
||||
lobby-time: 60
|
||||
invincibility-time: 60
|
||||
@@ -27,7 +28,7 @@ lunarclient:
|
||||
variantName: 'SpeedHG - Solo'
|
||||
|
||||
teams:
|
||||
enabled: true
|
||||
enabled: false
|
||||
max-size: 2
|
||||
|
||||
recraftNerf:
|
||||
|
||||
Reference in New Issue
Block a user