diff --git a/changelog.md b/changelog.md index 31ebe8c..646a292 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,2 @@ -- Update to Plasmo Voice 2.1.0. This version is not compatible with PV 2.0.x. -- Experimental goat horn support. Disabled by default. Set `goat_horn.enabled` to `true` to enable. For now horns are burned same as the discs using `/disc burn` command, but it'll be changed later. -- HTTP proxy support. \ No newline at end of file +- Fix `/disc burn` produces broken goat horns in 1.20.1. This fix will not repair broken horns, so you need to do it manually by using command: `/item replace entity @p weapon.mainhand with minecraft:goat_horn{instrument:"empty"}`. +- Disallow burning custom goat horn with tracks exceeding the maximum duration defined in the config. \ No newline at end of file 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 93064fd..a046e06 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,6 +15,7 @@ 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.GoatHornManager import su.plo.voice.discs.command.SubCommand import su.plo.voice.discs.item.GoatHornHelper import su.plo.voice.discs.utils.extend.asPlayer @@ -28,7 +29,8 @@ import su.plo.voice.discs.utils.extend.toPlainText class BurnCommand : SubCommand() { private val plugin: JavaPlugin by inject() - private val goatHornHelper: GoatHornHelper by inject() + private val hornHelper: GoatHornHelper by inject() + private val hornManager: GoatHornManager by inject() override val name = "burn" @@ -113,6 +115,13 @@ class BurnCommand : SubCommand() { val isGoatHorn = item.type.name == "GOAT_HORN" + if (isGoatHorn && !hornManager.canPlay(track)) { + voicePlayer.instance.sendTranslatable( + "pv.addon.discs.error.horn_too_long", config.goatHorn.maxDurationSeconds + ) + return@launch + } + plugin.suspendSync(player.location) { item.editMeta { meta -> meta.addItemFlags(*ItemFlag.values()) @@ -129,7 +138,7 @@ class BurnCommand : SubCommand() { } if (isGoatHorn) { - goatHornHelper.getInstrument(item) + hornHelper.getInstrument(item) .takeIf { it.isNotEmpty() } ?.let { meta.persistentDataContainer.set( @@ -150,7 +159,7 @@ class BurnCommand : SubCommand() { } if (isGoatHorn) { - goatHornHelper.setEmptyInstrument(item) + hornHelper.setEmptyInstrument(item) } voicePlayer.instance.sendTranslatable("pv.addon.discs.success.burn", name) diff --git a/gradle.properties b/gradle.properties index 61f9393..b2a0cf6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=su.plo.voice.discs -version=1.1.0 +version=1.1.1 mavenArtifactId=discs diff --git a/v1_19_4/src/main/kotlin/su/plo/voice/discs/v1_19_4/GoatHornHelperImpl.kt b/v1_19_4/src/main/kotlin/su/plo/voice/discs/v1_19_4/GoatHornHelperImpl.kt index 3efc5c5..86850ac 100644 --- a/v1_19_4/src/main/kotlin/su/plo/voice/discs/v1_19_4/GoatHornHelperImpl.kt +++ b/v1_19_4/src/main/kotlin/su/plo/voice/discs/v1_19_4/GoatHornHelperImpl.kt @@ -17,7 +17,7 @@ class GoatHornHelperImpl : GoatHornHelper { val compoundTag = ReflectionProxies.itemStack.getOrCreateTag(mcItem) - ReflectionProxies.compoundTag.putString(compoundTag, "instrument", "") + ReflectionProxies.compoundTag.putString(compoundTag, "instrument", "empty") } override fun getInstrument(item: ItemStack): String {