Add new command; update kit command
A new command /kitinfo has been added to provide information about kits / perks at any time. The command /kit now also works in invincibility for players without kits. Sounds when picking up items has been removed
This commit is contained in:
@@ -4,6 +4,7 @@ import club.mcscrims.speedhg.client.LunarClientManager
|
|||||||
import club.mcscrims.speedhg.combat.KnockbackListener
|
import club.mcscrims.speedhg.combat.KnockbackListener
|
||||||
import club.mcscrims.speedhg.command.HelpCommand
|
import club.mcscrims.speedhg.command.HelpCommand
|
||||||
import club.mcscrims.speedhg.command.KitCommand
|
import club.mcscrims.speedhg.command.KitCommand
|
||||||
|
import club.mcscrims.speedhg.command.KitInfoCommand
|
||||||
import club.mcscrims.speedhg.command.LeaderboardCommand
|
import club.mcscrims.speedhg.command.LeaderboardCommand
|
||||||
import club.mcscrims.speedhg.command.PerksCommand
|
import club.mcscrims.speedhg.command.PerksCommand
|
||||||
import club.mcscrims.speedhg.command.RankingCommand
|
import club.mcscrims.speedhg.command.RankingCommand
|
||||||
@@ -270,6 +271,16 @@ class SpeedHG : JavaPlugin() {
|
|||||||
tabCompleter = kitCommand
|
tabCompleter = kitCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val kitInfoCommand = KitInfoCommand()
|
||||||
|
getCommand( "kitinfo" )?.apply {
|
||||||
|
setExecutor( kitInfoCommand )
|
||||||
|
tabCompleter = kitInfoCommand
|
||||||
|
}
|
||||||
|
getCommand( "perkinfo" )?.apply {
|
||||||
|
setExecutor( kitInfoCommand )
|
||||||
|
tabCompleter = kitInfoCommand
|
||||||
|
}
|
||||||
|
|
||||||
val timerCommand = TimerCommand( this )
|
val timerCommand = TimerCommand( this )
|
||||||
getCommand( "timer" )?.apply {
|
getCommand( "timer" )?.apply {
|
||||||
setExecutor( timerCommand )
|
setExecutor( timerCommand )
|
||||||
|
|||||||
@@ -38,8 +38,13 @@ class KitCommand : CommandExecutor, TabCompleter {
|
|||||||
if ( state == GameState.ENDING )
|
if ( state == GameState.ENDING )
|
||||||
return true
|
return true
|
||||||
|
|
||||||
val ingame = state == GameState.INVINCIBILITY ||
|
val ingame = state == GameState.INGAME
|
||||||
state == GameState.INGAME
|
|
||||||
|
if ( state == GameState.INVINCIBILITY && selectedKit != null )
|
||||||
|
{
|
||||||
|
player.sendMsg( "commands.kit.alreadySelected", mapOf(), "name" to selectedKit.displayName )
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if ( ingame && !isBackup )
|
if ( ingame && !isBackup )
|
||||||
{
|
{
|
||||||
|
|||||||
117
src/main/kotlin/club/mcscrims/speedhg/command/KitInfoCommand.kt
Normal file
117
src/main/kotlin/club/mcscrims/speedhg/command/KitInfoCommand.kt
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
package club.mcscrims.speedhg.command
|
||||||
|
|
||||||
|
import club.mcscrims.speedhg.SpeedHG
|
||||||
|
import club.mcscrims.speedhg.util.sendMsg
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage
|
||||||
|
import org.bukkit.command.Command
|
||||||
|
import org.bukkit.command.CommandExecutor
|
||||||
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.command.TabCompleter
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ## KitInfoCommand
|
||||||
|
*
|
||||||
|
* Zeigt den Namen und die Beschreibung eines Kits oder Perks im Chat an.
|
||||||
|
*
|
||||||
|
* ## Verwendung
|
||||||
|
* | Command | Alias | Beschreibung |
|
||||||
|
* |---|---|---|
|
||||||
|
* | `/kitinfo <id>` | `/perkinfo <id>` | Zeigt Name + Lore des Kits/Perks |
|
||||||
|
*
|
||||||
|
* ## Lookup-Reihenfolge
|
||||||
|
* 1. Suche in `kitManager` (case-insensitive auf `kit.id`)
|
||||||
|
* 2. Falls nicht gefunden, suche in `perkManager`
|
||||||
|
* 3. Falls immer noch nicht gefunden, sende Fehlermeldung
|
||||||
|
*/
|
||||||
|
class KitInfoCommand : CommandExecutor, TabCompleter
|
||||||
|
{
|
||||||
|
|
||||||
|
private val plugin get() = SpeedHG.instance
|
||||||
|
private val mm = MiniMessage.miniMessage()
|
||||||
|
|
||||||
|
override fun onCommand(
|
||||||
|
sender: CommandSender,
|
||||||
|
command: Command,
|
||||||
|
label: String,
|
||||||
|
args: Array<out String>
|
||||||
|
): Boolean
|
||||||
|
{
|
||||||
|
val player = sender as? Player ?: run {
|
||||||
|
sender.sendMessage( "§cOnly players can execute this command." )
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( args.isEmpty() )
|
||||||
|
{
|
||||||
|
player.sendMsg( "commands.kitinfo.usage" )
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
val query = args[0].lowercase()
|
||||||
|
|
||||||
|
// ── 1. Kit-Lookup ─────────────────────────────────────────────────────
|
||||||
|
val kit = plugin.kitManager.getKit( query )
|
||||||
|
if ( kit != null )
|
||||||
|
{
|
||||||
|
sendKitInfo( player, kit.displayName, kit.lore )
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── 2. Perk-Lookup ────────────────────────────────────────────────────
|
||||||
|
val perk = plugin.perkManager.getPerk( query )
|
||||||
|
if ( perk != null )
|
||||||
|
{
|
||||||
|
sendKitInfo( player, perk.displayName, perk.lore )
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── 3. Nicht gefunden ─────────────────────────────────────────────────
|
||||||
|
player.sendMsg( "commands.kitinfo.notFound", "name" to args[0] )
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Formatierungs-Helfer ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
private fun sendKitInfo(
|
||||||
|
player: Player,
|
||||||
|
displayName: Component,
|
||||||
|
lore: List<String>
|
||||||
|
) {
|
||||||
|
val separator = mm.deserialize( plugin.languageManager.getRawMessage( player, "commands.kitinfo.separator" ) )
|
||||||
|
val header = mm.deserialize( plugin.languageManager.getRawMessage( player, "commands.kitinfo.header" ) )
|
||||||
|
|
||||||
|
player.sendMessage( separator )
|
||||||
|
player.sendMessage( header.append( displayName ) )
|
||||||
|
|
||||||
|
lore.forEach { line ->
|
||||||
|
player.sendMessage( mm.deserialize( line ) )
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage( separator )
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Tab-Completion ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
override fun onTabComplete(
|
||||||
|
sender: CommandSender,
|
||||||
|
command: Command,
|
||||||
|
label: String,
|
||||||
|
args: Array<out String>
|
||||||
|
): List<String>
|
||||||
|
{
|
||||||
|
if ( args.size != 1 )
|
||||||
|
return emptyList()
|
||||||
|
|
||||||
|
val input = args[0].lowercase()
|
||||||
|
|
||||||
|
val kitIds = plugin.kitManager.getRegisteredKits().map { it.id }
|
||||||
|
val perkIds = plugin.perkManager.getRegisteredPerks().map { it.id }
|
||||||
|
|
||||||
|
return ( kitIds + perkIds )
|
||||||
|
.filter { it.startsWith( input ) }
|
||||||
|
.sorted()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -273,14 +273,11 @@ class GameStateListener : Listener {
|
|||||||
fun onPickupItem(
|
fun onPickupItem(
|
||||||
event: PlayerAttemptPickupItemEvent
|
event: PlayerAttemptPickupItemEvent
|
||||||
) {
|
) {
|
||||||
val player = event.player
|
|
||||||
|
|
||||||
if ( gameManager.currentState == GameState.INVINCIBILITY ||
|
if ( gameManager.currentState == GameState.INVINCIBILITY ||
|
||||||
gameManager.currentState == GameState.INGAME )
|
gameManager.currentState == GameState.INGAME )
|
||||||
return
|
return
|
||||||
|
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
player.playSound( player.location, Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val swordNerf = 0.75
|
private val swordNerf = 0.75
|
||||||
|
|||||||
@@ -148,12 +148,13 @@ team:
|
|||||||
|
|
||||||
commands:
|
commands:
|
||||||
kit:
|
kit:
|
||||||
usage: '<red>Usage: /kit <kitName> <playstyle></red>'
|
usage: '<prefix><red>Usage: /kit <kitName> <playstyle></red>'
|
||||||
kitNotFound: '<red><kit> is not a registered kit!</red>'
|
kitNotFound: '<prefix><red><kit> is not a registered kit!</red>'
|
||||||
playstyleNotFound: '<red><playstyle> is not an available playstyle!</red>'
|
playstyleNotFound: '<prefix><red><playstyle> is not an available playstyle!</red>'
|
||||||
gameHasStarted: '<red>The game has already started. You cannot select a kit right now!</red>'
|
gameHasStarted: '<prefix><red>The game has already started. You cannot select a kit right now!</red>'
|
||||||
cannotPickSameKit: '<red>You cannot pick the same kit!</red>'
|
cannotPickSameKit: '<prefix><red>You cannot pick the same kit!</red>'
|
||||||
selected: '<green>You have selected <kit> as your Kit with playstyle <playstyle>!</green>'
|
alreadySelected: '<prefix><red>You have already selected <name> as a kit!</red>'
|
||||||
|
selected: '<prefix><green>You have selected <kit> as your Kit with playstyle <playstyle>!</green>'
|
||||||
leaderboard:
|
leaderboard:
|
||||||
header: '<gray>====== <gold>Leaderboard</gold> ======</gray>'
|
header: '<gray>====== <gold>Leaderboard</gold> ======</gray>'
|
||||||
empty: '<red>There are currently no stats</red>'
|
empty: '<red>There are currently no stats</red>'
|
||||||
@@ -173,6 +174,11 @@ commands:
|
|||||||
rank_usage: '<red>Usage: /ranking rank <player></red>'
|
rank_usage: '<red>Usage: /ranking rank <player></red>'
|
||||||
player_not_found: '<red>Player <name> is not online.</red>'
|
player_not_found: '<red>Player <name> is not online.</red>'
|
||||||
rank_info: '<prefix><gray>Player <white><name></white> — <rank> <gray>(<score> RR · <games> games)</gray>'
|
rank_info: '<prefix><gray>Player <white><name></white> — <rank> <gray>(<score> RR · <games> games)</gray>'
|
||||||
|
kitinfo:
|
||||||
|
usage: '<prefix><red>Usage: <white>/kitinfo <name></white></red>'
|
||||||
|
notFound: '<prefix><red>Kit/Perk <white><name></white> not found.</red>'
|
||||||
|
separator: '<dark_gray>──────────────────────</dark_gray>'
|
||||||
|
header: '<dark_gray>[</dark_gray><gold>✦</gold><dark_gray>]</dark_gray> '
|
||||||
help:
|
help:
|
||||||
message: '<gray>━━━━━ <gradient:red:gold>SpeedHG</gradient> <red>Help</red> ━━━━━</gray><newline><gray>▪</gray> <blue>Discord:</blue> discord.gg/HyZV4CdUgV<newline><gray>▪</gray> <gold>Store:</gold> https://mcscrims.club<newline><white><newline><gray>▪</gray> <yellow>/msg <player> <message></yellow><newline><gray>▪</gray> <yellow>/r <message></yellow><newline><gray>▪</gray> <yellow>/report <player></yellow><newline><gray>▪</gray> <yellow>/leaderboard</yellow><newline><gray>▪</gray> <yellow>/team <invite|accept|deny></yellow><newline><gray>━━━━━ <gradient:red:gold>SpeedHG</gradient> <red>Help</red> ━━━━━</gray>'
|
message: '<gray>━━━━━ <gradient:red:gold>SpeedHG</gradient> <red>Help</red> ━━━━━</gray><newline><gray>▪</gray> <blue>Discord:</blue> discord.gg/HyZV4CdUgV<newline><gray>▪</gray> <gold>Store:</gold> https://mcscrims.club<newline><white><newline><gray>▪</gray> <yellow>/msg <player> <message></yellow><newline><gray>▪</gray> <yellow>/r <message></yellow><newline><gray>▪</gray> <yellow>/report <player></yellow><newline><gray>▪</gray> <yellow>/leaderboard</yellow><newline><gray>▪</gray> <yellow>/team <invite|accept|deny></yellow><newline><gray>━━━━━ <gradient:red:gold>SpeedHG</gradient> <red>Help</red> ━━━━━</gray>'
|
||||||
|
|
||||||
@@ -601,6 +607,7 @@ kits:
|
|||||||
|
|
||||||
# ── BlackPanther (neue Defensive-Leap Fähigkeit aus vorherigem Fix) ─────────
|
# ── BlackPanther (neue Defensive-Leap Fähigkeit aus vorherigem Fix) ─────────
|
||||||
blackpanther:
|
blackpanther:
|
||||||
|
name: '<gradient:dark_gray:white><bold>Black Panther</bold></gradient>'
|
||||||
# Lore-Zeile für DEF aktualisieren:
|
# Lore-Zeile für DEF aktualisieren:
|
||||||
lore:
|
lore:
|
||||||
- ' '
|
- ' '
|
||||||
|
|||||||
@@ -42,3 +42,7 @@ commands:
|
|||||||
perks:
|
perks:
|
||||||
description: 'Perk-Auswahl öffnen'
|
description: 'Perk-Auswahl öffnen'
|
||||||
usage: '/perks'
|
usage: '/perks'
|
||||||
|
kitinfo:
|
||||||
|
description: 'Shows the name and description of a kit or perk'
|
||||||
|
usage: '/kitinfo <name>'
|
||||||
|
aliases: [ perkinfo ]
|
||||||
Reference in New Issue
Block a user