diff --git a/src/main/java/me/Navoei/customdiscsplugin/HopperManager.java b/src/main/java/me/Navoei/customdiscsplugin/HopperManager.java index f895817..7703ec7 100644 --- a/src/main/java/me/Navoei/customdiscsplugin/HopperManager.java +++ b/src/main/java/me/Navoei/customdiscsplugin/HopperManager.java @@ -4,6 +4,7 @@ import me.Navoei.customdiscsplugin.language.Lang; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -41,18 +42,13 @@ public class HopperManager implements Listener { Component songNameComponent = Objects.requireNonNull(event.getItem().getItemMeta().lore()).get(0).asComponent(); String songName = PlainTextComponentSerializer.plainText().serialize(songNameComponent); - String content = Lang.NOW_PLAYING.toString().replace("%song_name%", songName); - - TextComponent customActionBarSongPlaying = Component.text() - .content(content) - .color(NamedTextColor.GOLD) - .build(); + Component customActionBarSongPlaying = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NOW_PLAYING.toString().replace("%song_name%", songName)); String soundFileName = event.getItem().getItemMeta().getPersistentDataContainer().get(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING); Path soundFilePath = Path.of(customDiscs.getDataFolder().getPath(), "musicdata", soundFileName); assert VoicePlugin.voicechatServerApi != null; - playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, event.getDestination().getLocation().getBlock(), customActionBarSongPlaying.asComponent()); + playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, event.getDestination().getLocation().getBlock(), customActionBarSongPlaying); } diff --git a/src/main/java/me/Navoei/customdiscsplugin/command/SubCommands/DownloadCommand.java b/src/main/java/me/Navoei/customdiscsplugin/command/SubCommands/DownloadCommand.java index 23b9c4b..0ab64f9 100644 --- a/src/main/java/me/Navoei/customdiscsplugin/command/SubCommands/DownloadCommand.java +++ b/src/main/java/me/Navoei/customdiscsplugin/command/SubCommands/DownloadCommand.java @@ -47,7 +47,7 @@ public class DownloadCommand extends SubCommand { } if (args.length!=3) { - Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_ARGUMENTS.toString().replace("%command_syntax", getSyntax())); + Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_ARGUMENTS.toString().replace("%command_syntax%", getSyntax())); player.sendMessage(textComponent); return; } diff --git a/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java b/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java index ebbad8a..de49e8f 100644 --- a/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java +++ b/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java @@ -8,6 +8,7 @@ import me.Navoei.customdiscsplugin.language.Lang; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -54,15 +55,10 @@ public class JukeBox implements Listener{ Component songNameComponent = Objects.requireNonNull(event.getItem().getItemMeta().lore()).get(0).asComponent(); String songName = PlainTextComponentSerializer.plainText().serialize(songNameComponent); - String content = Lang.NOW_PLAYING.toString().replace("%song_name%", songName); - - TextComponent customActionBarSongPlaying = Component.text() - .content(content) - .color(NamedTextColor.GOLD) - .build(); + Component customActionBarSongPlaying = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NOW_PLAYING.toString().replace("%song_name%", songName)); assert VoicePlugin.voicechatServerApi != null; - playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, block, customActionBarSongPlaying.asComponent()); + playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, block, customActionBarSongPlaying); } else { player.sendMessage(ChatColor.RED + "Sound file not found."); event.setCancelled(true); diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml index 1db8453..e71e1a7 100644 --- a/src/main/resources/lang.yml +++ b/src/main/resources/lang.yml @@ -1,16 +1,16 @@ prefix: "&8[&6CustomDiscs&8]&r" -no-permission: "&rYou do not have permission to execute this command." -invalid-filename: "&rThis is an invalid filename!" -no-disc-name-provided: "&rYou must provide a name for your disc." -invalid-format: "&rFile must be in wav, flac, or mp3 format!" -file-not-found: "&rFile not found!" -invalid-arguments: "&rInvalid arguments. &7(&a%command_syntax%&7)" -not-holding-disc: "&rYou must hold a disc in your main hand." +no-permission: "&cYou do not have permission to execute this command." +invalid-filename: "&cThis is an invalid filename!" +no-disc-name-provided: "&cYou must provide a name for your disc." +invalid-format: "&cFile must be in wav, flac, or mp3 format!" +file-not-found: "&cFile not found!" +invalid-arguments: "&cInvalid arguments. &7(&a%command_syntax%&7)" +not-holding-disc: "&cYou must hold a disc in your main hand." create-filename: "&7Your filename is: &a\"%filename%\"." create-custom-name: "&7Your custom name is: &a\"%custom_name%\"." downloading-file: "&7Downloading file..." -file-too-large: "&rThe file is larger than %max_download_size%MB." +file-too-large: "&cThe file is larger than %max_download_size%MB." successful-download: "&aFile successfully downloaded to &7%file_path%&a." create-disc: "&aCreate a disc by doing &7/cd create %filename% \"Custom Lore\"&a." -download-error: "&rAn error has occurred while downloading." +download-error: "&cAn error has occurred while downloading." now-playing: "&6Now playing: %song_name%"