use of com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer in project PlayMoreSounds by Epicnicity322.
the class NBSSongPlayer method play.
/**
* Plays a nbs inside 'Note Block Songs' folder using NoteBlockAPI.
*
* @param player The player to play the song.
* @param nbsName The name of the nbs song.
*/
public static void play(@NotNull Player player, @NotNull String nbsName) {
if (songs.containsKey(nbsName)) {
String key = player.getUniqueId() + ";" + nbsName;
if (playingSongs.containsKey(key)) {
RadioSongPlayer songPlayer = playingSongs.get(key);
songPlayer.setPlaying(false);
playingSongs.remove(key);
}
RadioSongPlayer songPlayer = new RadioSongPlayer(songs.get(nbsName));
songPlayer.addPlayer(player);
songPlayer.setPlaying(true);
playingSongs.put(key, songPlayer);
} else {
throw new IllegalArgumentException(nbsName + " is not a valid note block song.");
}
}
use of com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer in project PlayMoreSounds by Epicnicity322.
the class NBSSongPlayer method stop.
/**
* Stops a note block song inside 'Note Block Songs' folder from playing using NoteBlockAPI.
*
* @param player The player the song is playing.
* @param nbsName The song name or null to stop all songs playing for this player.
*/
public static void stop(@NotNull Player player, @Nullable String nbsName) {
if (nbsName == null) {
playingSongs.keySet().removeIf(key -> {
if (key.startsWith(player.getUniqueId() + ";")) {
RadioSongPlayer songPlayer = playingSongs.get(key);
songPlayer.setPlaying(false);
return true;
} else {
return false;
}
});
} else if (songs.containsKey(nbsName)) {
String key = player.getUniqueId() + ";" + nbsName;
if (playingSongs.containsKey(key)) {
RadioSongPlayer songPlayer = playingSongs.get(key);
songPlayer.setPlaying(false);
playingSongs.remove(key);
}
}
}
use of com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer in project Nexus by ProjectEdenGG.
the class JukeboxUser method preview.
public void preview(JukeboxSong jukeboxSong) {
cancel();
final Song song = jukeboxSong.getSong();
final RadioSongPlayer songPlayer = new RadioSongPlayer(song);
songPlayer.addPlayer(getOnlinePlayer());
songPlayer.setStereo(true);
songPlayer.setPlaying(true);
songPlayer.setCategory(SoundCategory.RECORDS);
this.songPlayer = songPlayer;
}
use of com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer in project Nexus by ProjectEdenGG.
the class RadioFeature method createSongPlayer.
public static void createSongPlayer(Radio radio, Playlist playlist) {
playlist = RadioUtils.shufflePlaylist(playlist);
if (radio.getType().equals(RadioType.RADIUS)) {
Location location = radio.getLocation();
int radius = radio.getRadius();
PositionSongPlayer positionSongPlayer = new PositionSongPlayer(playlist);
positionSongPlayer.setTargetLocation(location);
positionSongPlayer.setDistance(radius);
setRadioDefaults(positionSongPlayer);
radio.setSongPlayer(positionSongPlayer);
} else {
RadioSongPlayer radioSongPlayer = new RadioSongPlayer(playlist);
setRadioDefaults(radioSongPlayer);
radio.setSongPlayer(radioSongPlayer);
}
}
Aggregations