Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better presets #7

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ Because we want to have a chat system that actually wOREks for us.

## Commands

| Command | Permission | Description | Aliases |
|---------------------------------------|---------------------------------|----------------------------------------------------------|----------------------------------------------------|
| `/chattore version` | `chattore.manage` | View the version of Chattore | No aliases |
| `/chattore reload` | `chattore.manage` | Reload Chattore configuration | No aliases |
| `/emoji <emoji_names>+` | `chattore.emoji` | View multiple emojis | No aliases |
| `/ac <message>` | `chattore.helpop` | Message ORE Staff | No aliases |
| `/mail mailbox` | `chattore.mail` | Manage your mailbox | `/mailbox\|/mail` |
| `/mail send <player> <message>` | `chattore.mail` | Send a mail message | No aliases |
| `/mail read <mail ID>` | `chattore.mail` | Read a mail message (Designed for usage with `/mailbox`) | No aliases |
| `/me <message>` | `chattore.me` | Have a thought in chat | No aliases |
| `/message <player> <message>` | `chattore.message` | Send a message to a player | `/m\|/pm\|/msg\|/vmsg\|/vmessage\|/whisper\|/tell` |
| `/reply <message>` | `chattore.message` | Reply to a message | `/playerprofile` |
| `/profile info <player>` | `chattore.profile` | View a player's profile | `/playerprofile` |
| `/profile about <player>` | `chattore.profile.about` | Set your about | `/playerprofile` |
| `/profile setabout <player> <about>` | `chattore.profile.about.others` | Set another player's about | `/playerprofile` |
| `/nick color <color>+` | `chattore.nick` | Set your nickname with at least one color (up to three) | No aliases |
| `/nick presets` | `chattore.nick.preset` | View available presets | No aliases |
| `/nick preset <preset>` | `chattore.nick.preset` | Apply a nickname preset | No aliases |
| `/nick nick <player> <nickname>` | `chattore.nick.others` | Set a player's nickname | No aliases |
| `/nick remove <player>` | `chattore.nick.remove` | Remove a player's nickname | No aliases |
| `/nick setgradient <player> <color>+` | `chattore.nick.setgradient` | Set a gradient for a user | No aliases |
| Command | Permission | Description | Aliases |
|------------------------------------------|---------------------------------|----------------------------------------------------------|----------------------------------------------------|
| `/chattore version` | `chattore.manage` | View the version of Chattore | No aliases |
| `/chattore reload` | `chattore.manage` | Reload Chattore configuration | No aliases |
| `/emoji <emoji_names>+` | `chattore.emoji` | View multiple emojis | No aliases |
| `/ac <message>` | `chattore.helpop` | Message ORE Staff | No aliases |
| `/mail mailbox` | `chattore.mail` | Manage your mailbox | `/mailbox\|/mail` |
| `/mail send <player> <message>` | `chattore.mail` | Send a mail message | No aliases |
| `/mail read <mail ID>` | `chattore.mail` | Read a mail message (Designed for usage with `/mailbox`) | No aliases |
| `/me <message>` | `chattore.me` | Have a thought in chat | No aliases |
| `/message <player> <message>` | `chattore.message` | Send a message to a player | `/m\|/pm\|/msg\|/vmsg\|/vmessage\|/whisper\|/tell` |
| `/reply <message>` | `chattore.message` | Reply to a message | `/playerprofile` |
| `/profile info <player>` | `chattore.profile` | View a player's profile | `/playerprofile` |
| `/profile about <player>` | `chattore.profile.about` | Set your about | `/playerprofile` |
| `/profile setabout <player> <about>` | `chattore.profile.about.others` | Set another player's about | `/playerprofile` |
| `/nick color <color>+` | `chattore.nick` | Set your nickname with at least one color (up to three) | No aliases |
| `/nick presets <pride/birdflop/players>` | `chattore.nick.preset` | View available presets | No aliases |
| `/nick preset <preset>` | `chattore.nick.preset` | Apply a nickname preset | No aliases |
| `/nick nick <player> <nickname>` | `chattore.nick.others` | Set a player's nickname | No aliases |
| `/nick remove <player>` | `chattore.nick.remove` | Remove a player's nickname | No aliases |
| `/nick setgradient <player> <color>+` | `chattore.nick.setgradient` | Set a gradient for a user | No aliases |
59 changes: 55 additions & 4 deletions src/main/kotlin/Pride.kt → src/main/kotlin/Presets.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file is based on hyfetch, and was last updated 2024-06-12
// This file adds presets. PridePresets are based on hyfetch, and were last updated 2024-06-12
// https://github.com/hykilpikonna/hyfetch/blob/7534371b05ee877cd3c4c3733b13d7c41d09c3e/hyfetch/presets.py


package chattore

fun weighted(vararg colors: Pair<String, Int>): Array<String> =
Expand Down Expand Up @@ -519,6 +520,56 @@ val prideColors = mapOf(
),
)

val pridePresets = prideColors.mapValues { (_, colors) ->
"<gradient:${colors.joinToString(':'.toString())}><username></gradient>"
}.toSortedMap()
val birdflopColors = mapOf(
"birdflop" to arrayOf(
"#084CFB",
"#ADF3FD"
),
"SimplyMC" to arrayOf (
"#084CFB",
"#ADF3FD"
),
"Rainbow" to arrayOf (
"#FF0000",
"#FF7F00",
"#FFFF00",
"#00FF00",
"#0000FF",
"#EAE4AA"
),
"Skyline" to arrayOf (
"#1488CC",
"#2B32B2"
),
"Mango" to arrayOf (
"#1488CC",
"#2B32B2"
),
"Vice City" to arrayOf (
"#1488CC",
"#2B32B2"
),
"Dawn" to arrayOf (
"#1488CC",
"#2B32B2"
),
"Rose" to arrayOf (
"#1488CC",
"#2B32B2"
),
"Firewatch" to arrayOf (
"#1488CC",
"#2B32B2"
),
)

val playerColors = mapOf(
"Waffle" to arrayOf (
"#1488CC",
"#2B32B2"
),
)

val pridePresets = prideColors.toGradientMinimessage()
val birdflopPresets = birdflopColors.toGradientMinimessage()
val playerPresets = playerColors.toGradientMinimessage()
17 changes: 13 additions & 4 deletions src/main/kotlin/commands/Nick.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,19 @@ class Nick(private val chattORE: ChattORE) : BaseCommand() {

@Subcommand("presets")
@CommandPermission("chattore.nick.preset")
@CommandCompletion("@username")
fun presets(player: Player, @Optional shownText: String?) {
@CommandCompletion("pride|birdflop|players")
fun presets(player: Player, @Optional shownText: String?, @Optional type: String?) {
val additionalPresets = when (type?.lowercase()) {
"pride" -> chattORE.config[ChattORESpec.nicknamePresets]["pride"] ?: mapOf()
"birdflop" -> chattORE.config[ChattORESpec.nicknamePresets]["birdflop"] ?: mapOf()
"players" -> chattORE.config[ChattORESpec.nicknamePresets]["players"] ?: mapOf()
else -> mapOf()
}

val combinedPresets = chattORE.config[ChattORESpec.nicknamePresets] + additionalPresets

val renderedPresets = ArrayList<Component>()
for ((presetName, preset) in chattORE.config[ChattORESpec.nicknamePresets]) {
for ((presetName, preset) in combinedPresets) {
val applyPreset: (String) -> Component = {
preset.render(mapOf(
"username" to Component.text(it)
Expand All @@ -114,7 +123,7 @@ class Nick(private val chattORE: ChattORE) : BaseCommand() {
}
renderedPresets.add(rendered)
}

val response = chattORE.config[ChattORESpec.format.chattore].render(
"Available presets: <message>".render(
Component.join(JoinConfiguration.commas(true), renderedPresets)
Expand Down
18 changes: 17 additions & 1 deletion src/main/kotlin/entity/ChattORESpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package chattore.entity

import com.uchuhimo.konf.ConfigSpec
import chattore.pridePresets
Wueffi marked this conversation as resolved.
Show resolved Hide resolved
import chattore.birdflopPresets
import chattore.playerPresets

object ChattORESpec : ConfigSpec("") {

Expand Down Expand Up @@ -45,6 +47,20 @@ object ChattORESpec : ConfigSpec("") {
val joinDiscord by optional("**<player> has joined the network**")
val leaveDiscord by optional("**<player> has left the network**")
}

fun Map<String, Array<String>>.toGradientMinimessage(): Map<String, String> {
return this.mapValues { (_, colors) ->
"<gradient:${colors.joinToString(":")}><username></gradient>"
}
}


val nicknamePresets by optional(
mapOf(
"pride" to pridePresets.toGradientMinimessage(),
"birdflop" to birdflopPresets.toGradientMinimessage(),
"players" to playerPresets.toGradientMinimessage()
)
)

val nicknamePresets by optional(pridePresets)
}