[Solved] Playing No-MC-Sounds from Resource-Pack

Discussion in 'Spigot Plugin Development' started by Zeryther, Jun 5, 2015.

  1. Zeryther

    Supporter

    Hey guys!

    I was bored and explored the .minecraft Directory as I saw the "server-resource-packs" Folder. As I am quite active on the Hypixel server, there were the Resourcepacks from Hypixel like the Warlords and the Turbo Kart Racers RP. While exploring the Warlords RP i saw the soundfiles which weren't minecraftsounds that just got replaced. They had custom names like "victory.ogg" and "ctf/friendlyflagtaken.ogg". So how do you play them from a plugin? The bukkit API just allows you to play a sound from the org.bukkit.Sound Enum ( https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html ). I thought of using NMS Code for that. That should work because with the /playsound Command you can provide the path to the soundfile. As I don't want to execute commands everytime I wanted to know how to play those sounds.

    ~ Zeryther
     
  2. ask the devs. I know at least one of them is quite active on this forums.
    The simple answer is magic.
     
  3. player.playSound(location, "soundName", volume, pitch);
     
    • Like Like x 1
    • Useful Useful x 1
  4. Yay, magic!

    Yes just play them by name- and if you're rolling your own RP, you'll need to make a sounds.json for them to be playable.
     
    • Useful Useful x 2
  5. Zeryther

    Supporter

    Thank you!