Skip to content

Commit

Permalink
v1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum authored Jul 1, 2024
2 parents b7f508b + 38f62ed commit e33d6ca
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
1.20.2
1.20.3
1.20.4
1.20.6
1.21
- name: Publish to GitHub
uses: Apehum/[email protected]
Expand Down
6 changes: 2 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
**Requires [pv-addon-lavaplayer-lib 1.0.8+](https://modrinth.com/plugin/pv-addon-lavaplayer-lib/version/1.0.8) to work**

Changelog:
- Hopper interactions support
- 1.20 discs burnable craft
- Fixed empty suggestions when using the /disc command
- Config option to disable voice distance visualization [#10](https://github.com/plasmoapp/pv-addon-discs/issues/10)
- Config option to change lore burn method
- 1.21 support
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ lavaplayerLibVersion=1.0.8
# Version
mavenGroup=su.plo.voice.discs
mavenArtifactId=discs
pluginVersion=1.0.6
pluginVersion=1.0.7
21 changes: 20 additions & 1 deletion src/main/kotlin/su/plo/voice/discs/AddonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -153,6 +172,6 @@ class AddonConfig {
)

private fun getAddonFolder(): File =
File(Bukkit.getPluginsFolder(), "pv-addon-discs")
Bukkit.getPluginManager().getPlugin("pv-addon-discs")!!.getDataFolder()
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/su/plo/voice/discs/DiscsPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import net.kyori.adventure.text.format.TextDecoration
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.Tag
import org.bukkit.enchantments.Enchantment
import org.bukkit.inventory.*
import org.bukkit.persistence.PersistentDataType
import su.plo.voice.discs.DiscsPlugin
import su.plo.voice.discs.utils.MaterialUtil

class BurnableDiscCraft(val plugin: DiscsPlugin) {

private val groupKey = NamespacedKey(plugin, "burnable_record_craft")

fun registerRecipes() = Tag.ITEMS_MUSIC_DISCS.values.forEach { record ->
fun registerRecipes() = MaterialUtil.itemMusicDiscs.forEach { record ->
createRecipe(record).let(Bukkit::addRecipe)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ class JukeboxEventListener(

@EventHandler
fun onChunkUnload(event: ChunkUnloadEvent) {
event.chunk.getTileEntities({ it.isJukebox() }, true)
val chunk = event.chunk

jobByBlock.keys
.filter { it.chunk == chunk }
.forEach {
jobByBlock.remove(it.block)?.cancel()
jobByBlock.remove(it)?.cancel()
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/su/plo/voice/discs/utils/MaterialUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package su.plo.voice.discs.utils

import org.bukkit.Material

object MaterialUtil {

val itemMusicDiscs: List<Material> =
Material.values()
.filter { it.name.startsWith("MUSIC_DISC_") }
}

0 comments on commit e33d6ca

Please sign in to comment.