Bukkit NoteBlockAPI 1.2.5(MC1.8+)

Play .nbs files as noteblock sounds

  1. koca2000 submitted a new resource:

    NoteBlockAPI - Play .nbs files as noteblock sounds

    Read more about this resource...
     
  2. Amazing thanks so much for updating this!
     
  3. Awesome but why am I getting this when using it with icJukebox
    Code (Text):
    Could not pass event InventoryClickEvent to icJukeBox v1.6.1
    org.bukkit.event.EventException
        at us.Myles.PWP.TransparentListeners.PerWorldPluginLoader$1.execute(PerWorldPluginLoader.java:122) ~[?:?]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-7d15d07-c194444]
        at us.Myles.PWP.TransparentListeners.PWPRegisteredListener.callEvent(PWPRegisteredListener.java:30) [PerWorldPlugins.jar:?]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-7d15d07-c194444]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java:1802) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.PacketPlayInWindowClick.a(SourceFile:33) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.PacketPlayInWindowClick.a(SourceFile:10) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-7d15d07-c194444]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_73]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_73]
        at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:716) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:400) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:655) [spigot.jar:git-Spigot-7d15d07-c194444]
        at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-7d15d07-c194444]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_73]
    Caused by: java.lang.NoSuchFieldError: CLICK
        at com.statiocraft.jukebox.events.evtInventoryClick.runEvent(evtInventoryClick.java:64) ~[?:?]
        at com.statiocraft.jukebox.events.EventManager.onInventoryClick(EventManager.java:27) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_73]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_73]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_73]
        at us.Myles.PWP.TransparentListeners.PerWorldPluginLoader$1.execute(PerWorldPluginLoader.java:120) ~[?:?]
        ... 16 more
    [21:11:30 WARN]: Exception in thread "Thread-21"
    [21:11:30 WARN]: java.lang.NoSuchFieldError: NOTE_PIANO
    [21:11:30 WARN]:     at com.statiocraft.xxmicloxx.NoteBlockAPI.Instrument.getInstrument(Instrument.java:10)
    [21:11:30 WARN]:     at com.statiocraft.xxmicloxx.NoteBlockAPI.RadioSongPlayer.playTick(RadioSongPlayer.java:21)
    [21:11:30 WARN]:     at com.statiocraft.xxmicloxx.NoteBlockAPI.SongPlayer$1.run(SongPlayer.java:108)
    [21:11:30 WARN]:     at java.lang.Thread.run(Thread.java:745)
    >
     
     
  4. icJukeBox 1.6+ is no longer depending on this plugin. They propably included NoteBlockAPI into their plugin. This error is in this version of NoteBlockAPI fixed. You can try to downgrade to icJukeBox 1.5.
     
  5. is it support 1.8
     
  6. Version for 1.8 go to original thread.
     
  7. It would be great if you added Maven support.
     
  8. Good idea, look at resource description.
     
  9. I want to do something when a song ends, but I am having trouble getting "Player" from "SongPlayer". I have tried

    Code (Text):
    @EventHandler
    public void musicStopped(SongEndEvent event){
        Player player = (Player) event.getSongPlayer();
        player.sendMessage(Messages.songEnded());
    }
    But this gives me an error telling me SongPlayer can't be cast to Player. What should I do?

    [16:37:11 ERROR]: Could not pass event SongEndEvent to Ublisk v1.0.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at com.xxmicloxx.NoteBlockAPI.SongPlayer$1.run(SongPlayer.java:94) [NoteBlockAPI.jar:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
    Caused by: java.lang.ClassCastException: com.xxmicloxx.NoteBlockAPI.RadioSongPlayer cannot be cast to org.bukkit.entity.Player
    at com.robinmc.ublisk.listeners.SongEnd.musicStopped(SongEnd.java:14) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_92]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_92]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_92]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_92]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    ... 5 more
    [16:38:38 ERROR]: Could not pass event SongEndEvent to Ublisk v1.0.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    at com.xxmicloxx.NoteBlockAPI.SongPlayer$1.run(SongPlayer.java:94) [NoteBlockAPI.jar:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
    Caused by: java.lang.ClassCastException: com.xxmicloxx.NoteBlockAPI.RadioSongPlayer cannot be cast to org.bukkit.entity.Player
    at com.robinmc.ublisk.listeners.SongEnd.musicStopped(SongEnd.java:14) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_92]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_92]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_92]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_92]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.9.2.jar:git-Spigot-e6f93f4-935f18b]
    ... 5 more
     
  10. SongPlayer is class that controls playing song. Use this:
    Code (Text):
    @EventHandler
    public void musicStopped(SongEndEvent event){
        for (String playername : event.getSongPlayer().getPlayerList())
            Player player = getServer().getOnlinePlayer(playername);
            player.sendMessage(Messages.songEnded());
        }
    }
    You can also surround getOnlinePlayer function by try/catch block for case that player have allready disconnected.
     
  11. Thanks a bunch, you're a lifesafer :) (I needed this for my server, which is all custom coded)
     
  12. Hello,
    I'm having an EOFException when trying to NBSDecoder.parse any file.
    Code (Text):
    [19:43:49 WARN]: java.io.EOFException
    [19:43:49 WARN]:     at java.io.DataInputStream.readByte(DataInputStream.java:267)
    [19:43:49 WARN]:     at com.xxmicloxx.NoteBlockAPI.NBSDecoder.readString(NBSDecoder.java:104)
    [19:43:49 WARN]:     at com.xxmicloxx.NoteBlockAPI.NBSDecoder.parse(NBSDecoder.java:27)
    [19:43:49 WARN]:     at com.xxmicloxx.NoteBlockAPI.NBSDecoder.parse(NBSDecoder.java:10)
    [19:43:49 WARN]:     at be.isach.ultracosmetics.UltraCosmetics.onEnable(UltraCosmetics.java:525)
    [19:43:49 WARN]:     at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:292)
    [19:43:49 WARN]:     at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340)
    [19:43:49 WARN]:     at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405)
    [19:43:49 WARN]:     at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugin(CraftServer.java:362)
    [19:43:49 WARN]:     at org.bukkit.craftbukkit.v1_10_R1.CraftServer.enablePlugins(CraftServer.java:322)
    [19:43:49 WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.t(MinecraftServer.java:416)
    [19:43:49 WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.l(MinecraftServer.java:381)
    [19:43:49 WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.a(MinecraftServer.java:336)
    [19:43:49 WARN]:     at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:270)
    [19:43:49 WARN]:     at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:539)
    [19:43:49 WARN]:     at java.lang.Thread.run(Thread.java:745)
    Using repositery: https://jitpack.io
    Dependency: compile 'com.github.koca2000:NoteBlockAPI:-SNAPSHOT'
     
  13. What type is file you use? Can you send me it?
     
  14. It's simply Song song = NBSDecoder.parse(new File(UltraCosmetics.getInstance().getDataFolder(), "songs/NyanCat.nbs");
    (Yes, the file exists)
     
  15. This is my working code:
    Code (Text):
    import java.io.File;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    import com.xxmicloxx.NoteBlockAPI.NBSDecoder;
    import com.xxmicloxx.NoteBlockAPI.RadioSongPlayer;
    import com.xxmicloxx.NoteBlockAPI.Song;
    import com.xxmicloxx.NoteBlockAPI.SongPlayer;

    public class Main extends JavaPlugin{
        Song s;
        SongPlayer sp;
        public void onEnable(){
            s = NBSDecoder.parse(new File(getDataFolder(), "songs/NyanCat.nbs"));
            sp = new RadioSongPlayer(s);
        }
     
        public void onDisable(){
            sp.destroy();
         
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String label,
                String[] args) {
            if (sender instanceof Player){
                if (cmd.getName().equalsIgnoreCase("snplay")) {
                    playSong((Player)sender);
                }
            }
         
            return true;
        }
     
        private void playSong(Player player){
            sp.addPlayer(player);
            sp.setPlaying(true);
            player.sendMessage("Playing song");
        }
     
    }

    Is it possible that your sound file is interrupted?
     
  16. I don't know, as it works when I test the file manually in icJuekbox for example. I might be copying it from resources folder to the plugin's folder wrongly, or something like that.

    Thanks for your help.
     
  17. Okay so, I kinda isolated the problem:

    if ((!songsFolder.exists()) || (songsFolder.listFiles().length <= 0)) {
    super.saveResource("songs/GetLucky.nbs", true);
    super.saveResource("songs/NyanCat.nbs", true);
    }

    Those lines which should just save the songs using the Bukkit's methods copy them, but I can't tuse them they generate EOF exceptions.
    I have no idea of how to save a resource properly, would you maybe know?
     

Share This Page