From 63aad1d2f855f3794d393f2964df50c1da92f209 Mon Sep 17 00:00:00 2001 From: overdyn Date: Wed, 11 Nov 2026 19:10:21 +0100 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BB=D0=B5=D0=B9=D1=81=D1=85=D0=BE?= =?UTF-8?q?=D0=BB=D0=B4=D0=B5=D1=80=20%pnclans=5Fclan%=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=B8=D0=B2=D0=B0=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B5;?= =?UTF-8?q?=20=D0=BB=D1=91=D0=B3=D0=BA=D0=B8=D0=B9=20jar:=20Kotlin,=20Gson?= =?UTF-8?q?=20=D0=B8=20Adventure=20=D0=BD=D0=B5=20=D0=B2=D1=88=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D1=8E=D1=82=D1=81=D1=8F;=20=D1=81=D1=81=D1=8B=D0=BB?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- RELEASE_1.2.0.md | 2 +- RELEASE_1.2.1.md | 2 +- build.gradle.kts | 17 ++++++++--- .../pnclans/impl/config/Settings.kt | 15 ++++++++++ .../impl/placeholder/PlaceholderFormat.kt | 10 +++++++ .../impl/placeholder/PnClansPlaceholders.kt | 7 +++-- .../pnclans/impl/util/PluginBanner.kt | 2 +- src/main/resources/plugin.yml | 6 ++++ .../impl/placeholder/PlaceholderFormatTest.kt | 28 +++++++++++++++++++ 10 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormat.kt create mode 100644 src/test/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormatTest.kt diff --git a/README.md b/README.md index c7ce0e4..61286b2 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ pnLibrary проверяет GitHub сразу и каждые 30 минут, с - Релиз компилируется против Paper API `1.21.11` и проверяется на Paper `1.21.11` с Java `21` и `25`. - Код не использует API ниже Paper `1.18` без необходимости, поэтому Paper `1.18` и новее остаётся поддерживаемым диапазоном при запуске на соответствующей Java. - Paper `1.16.5`–`1.17.1` работает в режиме best effort; корректная работа всех функций на этих версиях не гарантируется. -- Если возникнет проблема совместимости, приложите лог запуска и версию Paper в теме форума нашего [Discord-сервера](https://discord.gg/jqRFJC6WDM). +- Если возникнет проблема совместимости, приложите лог запуска и версию Paper в теме форума нашего [Discord-сервера](https://discord.gg/wYgprUUMhm). ## Команды diff --git a/RELEASE_1.2.0.md b/RELEASE_1.2.0.md index 66fb825..2486f46 100644 --- a/RELEASE_1.2.0.md +++ b/RELEASE_1.2.0.md @@ -6,7 +6,7 @@ pnClans v1.2.0 — Pink Alliance: квесты и клановые битвы Версия расширяет клановые квесты, добавляет организованные битвы на аренах и вводит подробную статистику участников. Новые интерфейсы оформлены в общей стилистике pnClans и объясняют цели, прогресс, награды, условия боя и доступные действия. -После знакомства с обновлением присоединитесь к Discord: https://discord.gg/jqRFJC6WDM. Оставьте в канале «Отзывы» общий отзыв, сообщение о баге или ошибке либо идею для развития плагина. +После знакомства с обновлением присоединитесь к Discord: https://discord.gg/wYgprUUMhm. Оставьте в канале «Отзывы» общий отзыв, сообщение о баге или ошибке либо идею для развития плагина. ## Для игроков diff --git a/RELEASE_1.2.1.md b/RELEASE_1.2.1.md index 01cc4c9..5251c80 100644 --- a/RELEASE_1.2.1.md +++ b/RELEASE_1.2.1.md @@ -6,7 +6,7 @@ Главная задача обновления — убрать опасные сценарии частичных покупок и потерянных наград, сделать битвы понятными и управляемыми через полноценный Battle Lobby, отделить официальный боевой MMR от обычного PvP и перенести новые изменяемые параметры и сообщения в конфигурацию. -После знакомства с обновлением присоединитесь к Discord: https://discord.gg/jqRFJC6WDM. В канале «Отзывы» можно оставить общий отзыв, сообщить о баге или предложить идею для следующей версии. +После знакомства с обновлением присоединитесь к Discord: https://discord.gg/wYgprUUMhm. В канале «Отзывы» можно оставить общий отзыв, сообщить о баге или предложить идею для следующей версии. ## Для игроков diff --git a/build.gradle.kts b/build.gradle.kts index 0f133cb..04b6daa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,10 +33,15 @@ dependencies { testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.12.2") compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT") - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("com.charleskorn.kaml:kaml:0.67.0") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.xerial:sqlite-jdbc:3.46.0.0") + compileOnly("org.jetbrains.kotlin:kotlin-stdlib:2.4.20-Beta2") + testImplementation("org.jetbrains.kotlin:kotlin-stdlib:2.4.20-Beta2") + // Downloaded by the server from plugin.yml `libraries`, so they stay out of the jar (SQLite alone carries ~14 MB of natives). + compileOnly("com.charleskorn.kaml:kaml:0.67.0") + compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + compileOnly("org.xerial:sqlite-jdbc:3.46.0.0") + testImplementation("com.charleskorn.kaml:kaml:0.67.0") + testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + testImplementation("org.xerial:sqlite-jdbc:3.46.0.0") // The shared runtime plugin is installed by the pnLibrary bootstrap shaded into the jar; only its API is needed to compile. implementation("io.github.pnfolder:pnlibrary-bootstrap-bukkit:$pnLibraryVersion") compileOnly("io.github.pnfolder:pnlibrary-api:$pnLibraryVersion") @@ -62,6 +67,10 @@ kotlin { tasks { shadowJar { archiveFileName.set("pnClans-${project.version}-paper-mc1.21.11-java${javaTarget}.jar") + // Gson ships with every Bukkit-based server. + exclude("com/google/gson/**") + // The README targets Paper, which already ships Adventure. + exclude("net/kyori/**") // PacketEvents must be isolated when bundled to avoid conflicts with // another plugin's embedded or standalone PacketEvents installation. relocate("com.github.retrooper", "ua.inventorytype.pnclans.libs") diff --git a/src/main/kotlin/ua/inventorytype/pnclans/impl/config/Settings.kt b/src/main/kotlin/ua/inventorytype/pnclans/impl/config/Settings.kt index 226f97c..9d76e1d 100644 --- a/src/main/kotlin/ua/inventorytype/pnclans/impl/config/Settings.kt +++ b/src/main/kotlin/ua/inventorytype/pnclans/impl/config/Settings.kt @@ -117,9 +117,24 @@ data class ModuleConfig( val pvp: Boolean = true ) +@Serializable +data class PlaceholderConfig( + @YamlComment("Вид %pnclans_clan% и %pnclans_name%, когда игрок в клане. {clan} — название клана. Поддерживаются &- и HEX-цвета.") + val clanFormat: String = "{clan}", + @YamlComment("Что показывают %pnclans_clan% и %pnclans_name%, когда игрок не в клане.") + val noClan: String = "Нет", + @YamlComment("Вид %pnclans_tag%, когда игрок в клане. {clan} — название клана.") + val tagFormat: String = "&8[&6{clan}&8]", + @YamlComment("Что показывает %pnclans_tag%, когда игрок не в клане. Пусто — ничего не показывать.") + val noTag: String = "" +) + /** Global configuration settings for pnClans. */ @Serializable class Settings { + @YamlComment("Вид плейсхолдеров %pnclans_clan%, %pnclans_name% и %pnclans_tag%.") + val placeholder: PlaceholderConfig = PlaceholderConfig() + @YamlComment("Настройки кланового чата.") val clanChat: ClanChatConfig = ClanChatConfig() diff --git a/src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormat.kt b/src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormat.kt new file mode 100644 index 0000000..55a6234 --- /dev/null +++ b/src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormat.kt @@ -0,0 +1,10 @@ +package ua.inventorytype.pnclans.impl.placeholder + +import ua.inventorytype.pnclans.impl.util.ColorUtil + +/** Строит значение плейсхолдера из шаблона конфига. */ +internal object PlaceholderFormat { + /** Красит шаблон и только потом подставляет название клана, чтобы `&` в названии не стал цветом. */ + fun render(template: String, clanName: String?): String = + ColorUtil.color(template).replace("{clan}", clanName.orEmpty()) +} diff --git a/src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PnClansPlaceholders.kt b/src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PnClansPlaceholders.kt index 014d4d8..97bfdb0 100644 --- a/src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PnClansPlaceholders.kt +++ b/src/main/kotlin/ua/inventorytype/pnclans/impl/placeholder/PnClansPlaceholders.kt @@ -18,10 +18,13 @@ class PnClansPlaceholders(private val plugin: BukkitPlugin) { if (playerId == null) return "" val bukkitPlayer = Bukkit.getPlayer(playerId) ?: return "" val clan = plugin.clanService.getClanUser(bukkitPlayer) + val formats = plugin.configService.settings.placeholder return when (key) { - "clan", "name" -> clan?.name ?: "Нет" - "tag" -> if (clan != null) "§8[§6${clan.name}§8]" else "" + "clan", "name" -> PlaceholderFormat.render( + if (clan != null) formats.clanFormat else formats.noClan, clan?.name) + "tag" -> PlaceholderFormat.render( + if (clan != null) formats.tagFormat else formats.noTag, clan?.name) "role" -> { if (clan == null) "Нет" else { diff --git a/src/main/kotlin/ua/inventorytype/pnclans/impl/util/PluginBanner.kt b/src/main/kotlin/ua/inventorytype/pnclans/impl/util/PluginBanner.kt index 431fa21..fee7943 100644 --- a/src/main/kotlin/ua/inventorytype/pnclans/impl/util/PluginBanner.kt +++ b/src/main/kotlin/ua/inventorytype/pnclans/impl/util/PluginBanner.kt @@ -91,7 +91,7 @@ object PluginBanner { logRaw(formatBoxLine("EA9FD✦ ИДЕИ И ПРЕДЛОЖЕНИЯ")) logRaw(formatBoxLine("&#ffffffНужен новый плагин или хотите что-то изменить, добавить либо убрать?")) logRaw(formatBoxLine("&#ffffffСоздайте тему на форуме или напишите в чат Discord.")) - logRaw(formatBoxLine("EA9FDhttps://discord.gg/jqRFJC6WDM")) + logRaw(formatBoxLine("EA9FDhttps://discord.gg/wYgprUUMhm")) logRaw(bottomBorder) logRaw("") } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9b2e955..52973e8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -11,6 +11,12 @@ softdepend: - PlaceholderAPI - PlayerPoints +libraries: + - org.jetbrains.kotlin:kotlin-stdlib:2.4.20-Beta2 + - org.xerial:sqlite-jdbc:3.46.0.0 + - com.charleskorn.kaml:kaml-jvm:0.67.0 + - org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3 + commands: clan: description: Main pnClans command diff --git a/src/test/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormatTest.kt b/src/test/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormatTest.kt new file mode 100644 index 0000000..44c8ac6 --- /dev/null +++ b/src/test/kotlin/ua/inventorytype/pnclans/impl/placeholder/PlaceholderFormatTest.kt @@ -0,0 +1,28 @@ +package ua.inventorytype.pnclans.impl.placeholder + +import ua.inventorytype.pnclans.impl.config.PlaceholderConfig +import kotlin.test.Test +import kotlin.test.assertEquals + +class PlaceholderFormatTest { + private val defaults = PlaceholderConfig() + + @Test + fun `defaults keep the old output`() { + assertEquals("Wolves", PlaceholderFormat.render(defaults.clanFormat, "Wolves")) + assertEquals("Нет", PlaceholderFormat.render(defaults.noClan, null)) + assertEquals("§8[§6Wolves§8]", PlaceholderFormat.render(defaults.tagFormat, "Wolves")) + assertEquals("", PlaceholderFormat.render(defaults.noTag, null)) + } + + @Test + fun `custom style and hex colours`() { + assertEquals("§7[§6Wolves§7]", PlaceholderFormat.render("&7[&6{clan}&7]", "Wolves")) + assertEquals("§x§F§F§0§0§0§0Нет клана", PlaceholderFormat.render("&#FF0000Нет клана", null)) + } + + @Test + fun `ampersand in a clan name is not a colour`() { + assertEquals("§6A&cB", PlaceholderFormat.render("&6{clan}", "A&cB")) + } +}