Add Feast, Pit modules and Discord webhook
Introduce two new game modules (FeastManager and PitManager) to handle timed endgame events: announcements, world edits, loot generation, teleportation and escape-prevention logic. Add DiscordWebhookManager to send asynchronous webhook messages (embeds/text) and wire it into SpeedHG and GameManager to broadcast game start/end events. Integrate managers into the game loop and reset lifecycle (startGame), add config entries for Discord, and add corresponding language strings. Also include small tweaks (killer XP reward, minor formatting) and updated resource files.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package club.mcscrims.speedhg.game
|
||||
|
||||
import club.mcscrims.speedhg.SpeedHG
|
||||
import club.mcscrims.speedhg.game.modules.FeastManager
|
||||
import club.mcscrims.speedhg.game.modules.PitManager
|
||||
import club.mcscrims.speedhg.util.sendMsg
|
||||
import club.mcscrims.speedhg.util.trans
|
||||
import net.kyori.adventure.title.Title
|
||||
@@ -34,13 +36,15 @@ class GameManager(
|
||||
private var gameTask: BukkitTask? = null
|
||||
|
||||
// Einstellungen aus Config (gecached für Performance)
|
||||
private val minPlayers = plugin.config.getInt("game.min-players", 2)
|
||||
private val lobbyTime = plugin.config.getInt("game.lobby-time", 60)
|
||||
private val minPlayers = plugin.config.getInt("game.min-players", 2)
|
||||
private val lobbyTime = plugin.config.getInt("game.lobby-time", 60)
|
||||
private val invincibilityTime = plugin.config.getInt("game.invincibility-time", 60)
|
||||
private val startBorder = plugin.config.getDouble("game.border-start", 300.0)
|
||||
private val endBorder = plugin.config.getDouble("game.border-end", 20.0)
|
||||
// Zeit in Sekunden, bis Border komplett klein ist (z.B. 10 Min)
|
||||
private val borderShrinkTime = plugin.config.getLong("game.border-shrink-time", 600)
|
||||
private val startBorder = plugin.config.getDouble("game.border-start", 300.0)
|
||||
private val endBorder = plugin.config.getDouble("game.border-end", 20.0)
|
||||
private val borderShrinkTime = plugin.config.getLong("game.border-shrink-time", 600)
|
||||
|
||||
val feastManager = FeastManager( plugin )
|
||||
val pitManager = PitManager( plugin )
|
||||
|
||||
init {
|
||||
plugin.server.pluginManager.registerEvents( this, plugin )
|
||||
@@ -120,6 +124,9 @@ class GameManager(
|
||||
timer++
|
||||
updateCompass()
|
||||
checkWin()
|
||||
|
||||
feastManager.onTick( timer )
|
||||
pitManager.onTick( timer )
|
||||
}
|
||||
|
||||
GameState.ENDING ->
|
||||
@@ -140,6 +147,9 @@ class GameManager(
|
||||
|
||||
private fun startGame()
|
||||
{
|
||||
feastManager.reset()
|
||||
pitManager.reset()
|
||||
|
||||
setGameState( GameState.INVINCIBILITY )
|
||||
timer = invincibilityTime
|
||||
|
||||
@@ -194,6 +204,12 @@ class GameManager(
|
||||
Bukkit.getOnlinePlayers().forEach { player ->
|
||||
player.sendMsg( "game.invincibility-start", "time" to invincibilityTime.toString() )
|
||||
}
|
||||
|
||||
plugin.discordWebhookManager.broadcastEmbed(
|
||||
title = "🎮 Spiel gestartet!",
|
||||
description = "Eine neue Runde SpeedHG mit **${Bukkit.getOnlinePlayers().size}** Spielern hat begonnen!",
|
||||
colorHex = 0x55FF55 // Grün
|
||||
)
|
||||
}
|
||||
|
||||
private fun startFighting()
|
||||
@@ -231,6 +247,7 @@ class GameManager(
|
||||
|
||||
if ( killer != null )
|
||||
{
|
||||
killer.exp += 0.5f
|
||||
plugin.statsManager.addKill( killer.uniqueId )
|
||||
plugin.statsManager.adjustScrimScore( killer.uniqueId, +15 ) // Elo-Gewinn
|
||||
}
|
||||
@@ -267,6 +284,8 @@ class GameManager(
|
||||
setGameState( GameState.ENDING )
|
||||
timer = 15
|
||||
|
||||
pitManager.reset()
|
||||
|
||||
val winnerUUID = alivePlayers.firstOrNull()
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach { p ->
|
||||
@@ -286,6 +305,12 @@ class GameManager(
|
||||
))
|
||||
p.sendMsg( "game.win-chat", "winner" to winnerName )
|
||||
}
|
||||
|
||||
plugin.discordWebhookManager.broadcastEmbed(
|
||||
title = "🏆 Spiel beendet!",
|
||||
description = "**$winnerName** hat das Spiel gewonnen! GG!",
|
||||
colorHex = 0xFFAA00 // Gold
|
||||
)
|
||||
}
|
||||
|
||||
// --- Helfer Methoden ---
|
||||
|
||||
Reference in New Issue
Block a user