diff --git a/changelog.md b/changelog.md index 64058f6..66fcbe2 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,4 @@ -- Yet another lavaplayer update to fix playback issues. -- Addons' permissions are now registered in Bukkit permissions. This resolves auto-complete and goat horns not working properly. -- New config option `mono_sources` to use mono sources for playing the audio. -- `/vreload` command is now reloading the addon's config properly. -- Add [poToken](https://github.com/lavalink-devs/youtube-source?tab=readme-ov-file#using-a-potoken) support for YouTube source. -- Fixed discs commands not working properly after `/vreload`. \ No newline at end of file +- Added option to change lore burning method (`burn_lore_method` in the addon config): + - DISABLE — Disables any lore manipulations on burn/erase. + - REPLACE (default) — Replaces the whole lore with a string containing the song name on burn, and removes the lore completely on erase. + - APPEND — Adds a new line to the end of the lore on burn, and removes the last line on erase. diff --git a/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt b/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt index f7e7908..1785660 100644 --- a/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt +++ b/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt @@ -31,6 +31,24 @@ class AddonConfig { ) var addGlintToCustomDiscs = false + enum class LoreMethod { + DISABLE, + REPLACE, + APPEND + } + @ConfigField( + comment = """ + The method for creating/removing a lore on burning/erasing the discs: + + DISABLE — Disables any lore manipulations on burn/erase. + REPLACE — Replaces the whole lore with a string containing the song name on burn, and removes the lore completely on erase. + APPEND — Adds a new line to the end of the lore on burn, and removes the last line on erase. + + Default is REPLACE. + """ + ) + val burnLoreMethod = LoreMethod.REPLACE + @ConfigField( comment = """ Uses mono sources to play tracks. diff --git a/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt b/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt index a046e06..778dd58 100644 --- a/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt +++ b/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt @@ -15,12 +15,14 @@ import org.koin.core.component.inject import su.plo.slib.api.chat.component.McTextComponent import su.plo.slib.api.permission.PermissionDefault import su.plo.voice.api.server.player.VoicePlayer +import su.plo.voice.discs.AddonConfig import su.plo.voice.discs.GoatHornManager import su.plo.voice.discs.command.SubCommand import su.plo.voice.discs.item.GoatHornHelper import su.plo.voice.discs.utils.extend.asPlayer import su.plo.voice.discs.utils.extend.asVoicePlayer import su.plo.voice.discs.utils.extend.forbidGrindstone +import su.plo.voice.discs.utils.extend.isCustomDisc import su.plo.voice.discs.utils.extend.render import su.plo.voice.discs.utils.extend.sendTranslatable import su.plo.voice.discs.utils.extend.suspendSync @@ -155,7 +157,24 @@ class BurnCommand : SubCommand() { .color(NamedTextColor.GRAY) .build() - meta.lore(listOf(loreName)) + when (config.burnLoreMethod) { + AddonConfig.LoreMethod.REPLACE -> { + meta.lore(listOf(loreName)) + } + + AddonConfig.LoreMethod.APPEND -> { + val currentLore = meta.lore()?.let { + if (with(keys) { item.isCustomDisc() }) { + it.subList(0, it.size - 1) + } else { + it + } + } ?: emptyList() + meta.lore(currentLore + listOf(loreName)) + } + + AddonConfig.LoreMethod.DISABLE -> {} // do nothing + } } if (isGoatHorn) { diff --git a/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt b/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt index 26c7bf3..bc20fb3 100644 --- a/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt +++ b/core/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt @@ -6,6 +6,7 @@ import org.bukkit.inventory.ItemFlag import org.bukkit.persistence.PersistentDataType import org.koin.core.component.inject import su.plo.slib.api.permission.PermissionDefault +import su.plo.voice.discs.AddonConfig import su.plo.voice.discs.command.SubCommand import su.plo.voice.discs.item.GoatHornHelper import su.plo.voice.discs.utils.extend.allowGrindstone @@ -53,7 +54,24 @@ class EraseCommand : SubCommand() { meta.removeEnchant(Enchantment.MENDING) } - meta.lore(null) + when (config.burnLoreMethod) { + AddonConfig.LoreMethod.REPLACE -> { + meta.lore(null) + } + + AddonConfig.LoreMethod.APPEND -> { + val currentLore = meta.lore() ?: return@editMeta + if (currentLore.isEmpty()) return@editMeta + val newLore = currentLore.subList(0, currentLore.size - 1) + if (newLore.isEmpty()) { + meta.lore(null) + } else { + meta.lore(newLore) + } + } + + AddonConfig.LoreMethod.DISABLE -> {} // do nothing + } } if (item.type.name == "GOAT_HORN") { diff --git a/gradle.properties b/gradle.properties index 4865343..3b10c76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=su.plo.voice.discs -version=1.1.3 +version=1.1.4 mavenArtifactId=discs