Add timer command, recraft module & recipes
Introduce a /timer admin command with tab completion (speedhg.admin.timer) and a parseTimeToSeconds utility; add CommandSender.sendMsg extension and language strings. Add RecraftManager module that enforces a configurable recraft-nerf (reduces extra recraft points for alive players) and starts from GameManager; wire the new module into GameManager. Register mushroom-stew shapeless recipes for cocoa and cactus in plugin startup and tidy command registration. Update plugin.yml with permission/command entries and adjust imports as needed.
This commit is contained in:
@@ -4,6 +4,7 @@ import club.mcscrims.speedhg.SpeedHG
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
private val langManager get() = SpeedHG.instance.languageManager
|
||||
@@ -31,6 +32,14 @@ fun Player.sendMsg(
|
||||
this.sendMessage( component )
|
||||
}
|
||||
|
||||
fun CommandSender.sendMsg(
|
||||
key: String,
|
||||
vararg placeholders: Pair<String, String>
|
||||
) {
|
||||
val component = langManager.getDefaultComponent( key, placeholders.toMap() )
|
||||
this.sendMessage( component )
|
||||
}
|
||||
|
||||
fun Player.trans(
|
||||
key: String,
|
||||
vararg placeholders: Pair<String, String>
|
||||
@@ -70,4 +79,21 @@ fun Component.toLegacyString(): String
|
||||
}
|
||||
|
||||
val Player.getDisplayName: String
|
||||
get() = legacySerializer.serialize( this.displayName() )
|
||||
get() = legacySerializer.serialize( this.displayName() )
|
||||
|
||||
fun String.parseTimeToSeconds(): Int?
|
||||
{
|
||||
val regex = Regex( "^(\\d+)([smh]?)$", RegexOption.IGNORE_CASE )
|
||||
val match = regex.find( this.trim() ) ?: return null
|
||||
|
||||
val value = match.groupValues[ 1 ].toIntOrNull() ?: return null
|
||||
val unit = match.groupValues[ 2 ].lowercase()
|
||||
|
||||
return when( unit )
|
||||
{
|
||||
"h" -> value * 3600
|
||||
"m" -> value * 60
|
||||
"s", "" -> value
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user