diff --git a/gradle.properties b/gradle.properties index fde083f..f9ba4f1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ lavaplayerLibVersion=1.0.8 # Version mavenGroup=su.plo.voice.discs mavenArtifactId=discs -pluginVersion=1.0.6 +pluginVersion=1.0.7 diff --git a/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt b/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt index ef2995b..c5d25a9 100644 --- a/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt +++ b/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt @@ -30,6 +30,25 @@ 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. + """ + ) + var burnLoreMethod = LoreMethod.REPLACE + @Config class DistanceConfig { @ConfigField( diff --git a/src/main/kotlin/su/plo/voice/discs/DiscsPlugin.kt b/src/main/kotlin/su/plo/voice/discs/DiscsPlugin.kt index 9737a87..a450f8f 100644 --- a/src/main/kotlin/su/plo/voice/discs/DiscsPlugin.kt +++ b/src/main/kotlin/su/plo/voice/discs/DiscsPlugin.kt @@ -29,8 +29,8 @@ import su.plo.voice.discs.utils.extend.debug @Addon( id = "pv-addon-discs", scope = AddonLoaderScope.SERVER, - version = "1.0.6", - authors = ["KPidS"] + version = "1.0.7", + authors = ["KPidS", "Apehum"] ) class DiscsPlugin : JavaPlugin() { diff --git a/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt b/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt index f3da41e..b88dde5 100644 --- a/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt +++ b/src/main/kotlin/su/plo/voice/discs/command/subcommand/BurnCommand.kt @@ -14,12 +14,14 @@ import org.bukkit.inventory.ItemStack import org.bukkit.persistence.PersistentDataType import su.plo.lib.api.server.permission.PermissionDefault import su.plo.voice.api.server.player.VoicePlayer +import su.plo.voice.discs.AddonConfig import su.plo.voice.discs.DiscsPlugin import su.plo.voice.discs.command.CommandHandler import su.plo.voice.discs.command.SubCommand import su.plo.voice.discs.utils.SchedulerUtil.suspendSync import su.plo.voice.discs.utils.extend.asPlayer import su.plo.voice.discs.utils.extend.asVoicePlayer +import su.plo.voice.discs.utils.extend.isCustomDisc import su.plo.voice.discs.utils.extend.sendTranslatable class BurnCommand(handler: CommandHandler) : SubCommand(handler) { @@ -124,7 +126,25 @@ class BurnCommand(handler: CommandHandler) : SubCommand(handler) { .color(NamedTextColor.GRAY) .build() - meta.lore(listOf(loreName)) + when (handler.plugin.addonConfig.burnLoreMethod) { + AddonConfig.LoreMethod.REPLACE -> { + meta.lore(listOf(loreName)) + } + + AddonConfig.LoreMethod.APPEND -> { + val currentLore = meta.lore()?.let { + if (item.isCustomDisc(handler.plugin)) { + it.subList(0, it.size - 1) + } else { + it + } + } ?: emptyList() + + meta.lore(currentLore + listOf(loreName)) + } + + AddonConfig.LoreMethod.DISABLE -> {} // do nothing + } } voicePlayer.instance.sendTranslatable("pv.addon.discs.success.burn", name) diff --git a/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt b/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt index e9fcbb1..155c277 100644 --- a/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt +++ b/src/main/kotlin/su/plo/voice/discs/command/subcommand/EraseCommand.kt @@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender import org.bukkit.enchantments.Enchantment import org.bukkit.inventory.ItemFlag import su.plo.lib.api.server.permission.PermissionDefault +import su.plo.voice.discs.AddonConfig import su.plo.voice.discs.command.CommandHandler import su.plo.voice.discs.command.SubCommand import su.plo.voice.discs.utils.extend.asPlayer @@ -48,7 +49,25 @@ class EraseCommand(handler: CommandHandler) : SubCommand(handler) { meta.removeEnchant(Enchantment.MENDING) } - meta.lore(null) + when (handler.plugin.addonConfig.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 + } } voicePlayer.instance.sendTranslatable("pv.addon.discs.success.erase")