/nbsLib

Lightweight library for playing .nbs-files

Primary LanguageJavaMIT LicenseMIT

nbsLib

nbsLib is a lightweight library for playing .nbs-files.

This library serves a reformatted and clean code-base inspired by xxmicloxx's NoteBlockAPI. Unlike the NoteBlockAPI by xxmicloxx only 1.16.* is fully supported. Since this library is only using the bukkit-api, it may also work with other versions. (I think 1.12+)

The support of multiple versions is not intended and will not be pursued!

Important: Please do not contact xxmicloxx for errors occurring with this library!

Examples:

Playing a song to specific players or whole server (e.g. server-radio):

final Song song = Song.createFromFile(new File("songFile.nbs"));
final SimpleSongPlayer songPlayer = new SimpleSongPlayer(song);
// If you're not adding specific players, song will be played for everybody.
        
songPlayer.addListeningPlayer(UUID.randomUUID()); // Replace with uuid of player to be added.
songPlayer.play();

Playing a song to players within a certain range:

final Location centerLocation = new Location(Bukkit.getWorld("world"), 0, 100, 0);
final Song song = Song.createFromFile(new File("songFile.nbs"));
final PositionedSongPlayer songPlayer = new PositionedSongPlayer(centerLocation, song);
songPlayer.setDistance(10); // Radius in blocks

// If your not adding specific players, song will be played for everybody.
songPlayer.addListeningPlayer(UUID.randomUUID()); // Replace with uuid of player to be added.
songPlayer.play();

Add own event-adapter:

final PositionedSongPlayer songPlayer = new PositionedSongPlayer(new Location(Bukkit.getWorld("world"), 0, 100, 0),
        Song.createFromFile(new File("songFile.nbs")));

songPlayer.addEventAdapter(new PositionedSongPlayerEventAdapter() {  
    @Override
    public void onEnd() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onPlay(Song song) {

    }

    @Override
    public void onPlayerAdded(Player player) {

    }

    @Override
    public void onPlayerRemoved(Player player) {

    }

    @Override
    public void onPlayerEnteredRange(Player player) {

    }

    @Override
    public void onPlayerLeftRange(Player player) {

    }
});
songPlayer.play();