Add ranking, feast guards and i18n updates
Use Rank info in leaderboard display (adds playerrank, passes numeric score) and adjust message placeholders. Add prefix placeholder injection in LanguageManager. Introduce max-radius-teleport config and use it for player teleport on join. Restore broadcasting of player quit messages on disconnect. Enforce no-iron crafting before feast (deny craft, notify player & play sound) and cancel entity spawns until feast starts. Update config.yml with max-radius-teleport and refresh en_US language strings (add no_iron_before_feast and translate/update several GUI/perk entries).
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package club.mcscrims.speedhg.command
|
||||
|
||||
import club.mcscrims.speedhg.SpeedHG
|
||||
import club.mcscrims.speedhg.ranking.Rank
|
||||
import club.mcscrims.speedhg.util.sendMsg
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
@@ -39,9 +40,12 @@ class LeaderboardCommand : CommandExecutor {
|
||||
val rank = ( index + 1 ).toString()
|
||||
|
||||
val playerName = stats.name
|
||||
val score = stats.scrimScore.toString()
|
||||
val score = stats.scrimScore
|
||||
|
||||
player.sendMsg( "commands.leaderboard.line", "rank" to rank, "name" to playerName, "score" to score )
|
||||
val rankFromPlayer = Rank.fromPlayer( score, stats.wins + stats.losses )
|
||||
val playerRank = "${rankFromPlayer.tag} ${rankFromPlayer.subTierRoman( score )}"
|
||||
|
||||
player.sendMsg( "commands.leaderboard.line", "playerrank" to playerRank, "rank" to rank, "name" to playerName, "score" to score.toString() )
|
||||
}
|
||||
|
||||
// 3. Footer senden
|
||||
|
||||
@@ -131,8 +131,10 @@ class LanguageManager(
|
||||
placeholders: Map<String, String>
|
||||
): Component
|
||||
{
|
||||
val prefixRaw = getDefaultRawMessage( "default.prefix" )
|
||||
val prefixTag = Placeholder.parsed( "prefix", prefixRaw )
|
||||
val raw = languages[ defaultLanguage ]?.strings?.get( key ) ?: "<red>Missing Key: $key</red>"
|
||||
val tags = placeholders.map { (k, v) -> Placeholder.parsed( k, v ) }
|
||||
val tags = placeholders.map { (k, v) -> Placeholder.parsed( k, v ) }.plus( prefixTag )
|
||||
return miniMessage.deserialize( raw, *tags.toTypedArray() )
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class GameManager(
|
||||
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)
|
||||
private val maxRadiusTeleport = plugin.config.getDouble("game.max-radius-teleport", 50.0)
|
||||
|
||||
val feastManager = FeastManager( plugin )
|
||||
val pitManager = PitManager( plugin )
|
||||
@@ -199,7 +200,7 @@ class GameManager(
|
||||
player.activePotionEffects.forEach { player.removePotionEffect( it.type ) }
|
||||
player.addPotionEffects(listOf( speedEffect, hasteEffect ))
|
||||
|
||||
teleportRandomly( player, world, startBorder / 2 )
|
||||
teleportRandomly( player, world, maxRadiusTeleport )
|
||||
|
||||
plugin.kitManager.applyKit( player ) // verteilt Items + ruft onAssign + passive.onActivate
|
||||
plugin.perkManager.applyPerks( player )
|
||||
|
||||
@@ -48,10 +48,6 @@ class ConnectListener : Listener {
|
||||
val player = event.player
|
||||
event.quitMessage( null )
|
||||
|
||||
if ( plugin.gameManager.currentState == GameState.INGAME ||
|
||||
plugin.gameManager.currentState == GameState.INVINCIBILITY )
|
||||
return
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach { p ->
|
||||
p.sendMsg( "game.quit", "name" to player.name )
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.bukkit.event.block.BlockPlaceEvent
|
||||
import org.bukkit.event.block.LeavesDecayEvent
|
||||
import org.bukkit.event.enchantment.EnchantItemEvent
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
import org.bukkit.event.entity.EntitySpawnEvent
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent
|
||||
import org.bukkit.event.entity.ItemDespawnEvent
|
||||
import org.bukkit.event.inventory.*
|
||||
@@ -326,7 +327,13 @@ class GameStateListener : Listener {
|
||||
if (!item.type.name.contains( "iron", true ))
|
||||
return
|
||||
|
||||
// TODO: add before feast check and deny item crafting
|
||||
if ( !feastStarted )
|
||||
{
|
||||
event.result = Event.Result.DENY
|
||||
player.sendMsg( "no_iron_before_feast" )
|
||||
player.playSound( player.location, Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f )
|
||||
return
|
||||
}
|
||||
|
||||
if ( item.type.maxDurability > 0 )
|
||||
{
|
||||
@@ -335,4 +342,12 @@ class GameStateListener : Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onEntitySpawn(
|
||||
event: EntitySpawnEvent
|
||||
) {
|
||||
if ( feastStarted ) return
|
||||
event.isCancelled = true
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user