use of com.xxmicloxx.NoteBlockAPI.model.Song in project TrollV4 by DxsSucuk.
the class PlayMusic method play.
/**
* Plays Musik(.nbs) with NoteBlocks.
*
* @param p the player that should hear the song.
* @param PATH the full file path.
* @since 4.4.4
*/
public static void play(Player p, String PATH) {
if (new File(PATH).exists()) {
Song song = NBSDecoder.parse(new File(PATH));
EntitySongPlayer esp = new EntitySongPlayer(song);
esp.setEntity(p);
esp.setDistance(16);
esp.addPlayer(p);
esp.setPlaying(true);
} else {
if (!new File("plugins/TrollV4/rick.nbs").exists()) {
Main.logger.info("Downloading Rick.nbs!");
Main.download("https://cdn.azura.best/download/trollv4/uni/rick.nbs", "plugins/TrollV4/rick.nbs");
if (new File("plugins/TrollV4/rick.nbs").exists()) {
Main.logger.info("Downloaded Rick.nbs!");
} else {
Main.logger.info("Couldnt download Rick.nbs!");
}
} else if (!new File("plugins/TrollV4/giorno.nbs").exists()) {
Main.logger.info("Downloading Giorno.nbs!");
Main.download("https://cdn.azura.best/download/trollv4/uni/giorno.nbs", "plugins/TrollV4/giorno.nbs");
if (new File("plugins/TrollV4/giorno.nbs").exists()) {
Main.logger.info("Downloaded Giorno.nbs!");
} else {
Main.logger.info("Couldnt download Giorno.nbs!");
}
}
}
}
use of com.xxmicloxx.NoteBlockAPI.model.Song in project Nexus by ProjectEdenGG.
the class JukeboxSong method reload.
public static CompletableFuture<Void> reload() {
final CompletableFuture<Void> future = new CompletableFuture<>();
Tasks.async(() -> {
SONGS.clear();
try (Stream<Path> paths = Files.walk(getPluginFolder("jukebox").toPath())) {
paths.forEach(path -> {
String fileName = path.getFileName().toString();
if (!fileName.contains(".nbs"))
return;
fileName = fileName.replace(".nbs", "");
Function<String, String> formatter = string -> string.replaceAll("_", " ").trim();
final String[] split = fileName.split("=", 2);
final String author = split.length > 1 ? formatter.apply(split[0]) : null;
final String title = split.length > 1 ? formatter.apply(split[1]) : formatter.apply(split[0]);
final Song song = NBSDecoder.parse(path.toFile());
SONGS.add(new JukeboxSong(author, title, song));
});
} catch (Exception ex) {
ex.printStackTrace();
}
SONGS.sort(Comparator.comparing(JukeboxSong::getName));
future.complete(null);
});
return future;
}
use of com.xxmicloxx.NoteBlockAPI.model.Song in project JoinMusic by T0biii.
the class Music method playSong.
private static void playSong(Player player, Main plugin) {
try {
File songFile;
if (plugin.getConfig().getBoolean("options.music.random")) {
songFile = SelectRandomFileFromFolder(plugin);
} else {
songFile = new File(plugin.getDataFolder() + "/" + plugin.getConfig().getString("music"));
}
Song s = NBSDecoder.parse(songFile);
final RadioSongPlayer sp = new RadioSongPlayer(s);
sp.addPlayer(player);
sp.setPlaying(true);
int volume = plugin.getConfig().getInt("options.music.Volume");
if (volume >= 0 && volume <= 100) {
sp.setVolume((byte) volume);
} else {
plugin.log.warning(plugin.cprefix + "ERROR: Volume must be between 0-100 (Your Value: " + volume + ")");
}
if (plugin.getConfig().getBoolean("options.music.10Octave")) {
sp.setEnable10Octave(true);
}
String mode = plugin.getConfig().getString("options.music.Mode");
if (mode.equalsIgnoreCase("MonoMode")) {
sp.setChannelMode(new MonoMode());
} else if (mode.equalsIgnoreCase("MonoStereoMode")) {
sp.setChannelMode(new MonoStereoMode());
} else if (mode.equalsIgnoreCase("StereoMode")) {
sp.setChannelMode(new StereoMode());
} else {
sp.setChannelMode(new MonoMode());
}
playingSong.put(player.getUniqueId(), sp);
String playingMessage = plugin.getConfig().getString("messages.playing");
playingMessage = replacePlaceholders(player, playingMessage);
if (!playingMessage.isEmpty() && plugin.getConfig().getBoolean("options.printSongTitel")) {
player.sendMessage(plugin.prefix + playingMessage.replaceAll("&", "ยง"));
}
} catch (IllegalArgumentException e) {
System.err.println(plugin.cprefix + "No sounds detected");
}
}
use of com.xxmicloxx.NoteBlockAPI.model.Song in project Nexus by ProjectEdenGG.
the class Listeners method onSongNext.
@EventHandler
public void onSongNext(SongNextEvent event) {
SongPlayer songPlayer = event.getSongPlayer();
Song song = songPlayer.getSong();
Set<UUID> UUIDList = songPlayer.getPlayerUUIDs();
for (UUID uuid : UUIDList) {
Player player = Bukkit.getPlayer(uuid);
if (player == null || !player.isOnline())
continue;
if (songPlayer instanceof PositionSongPlayer) {
Radio radio = RadioUtils.getRadio(songPlayer);
if (radio != null) {
if (RadioUtils.isInRangeOfRadiusRadio(player, radio))
RadioUtils.actionBar(player, song, true);
}
} else
RadioUtils.actionBar(player, song, true);
}
}
use of com.xxmicloxx.NoteBlockAPI.model.Song in project Nexus by ProjectEdenGG.
the class RadioCommand method songInfo.
@Path("info")
@Description("Shows info about the radio you are listening to")
void songInfo() {
Radio radio = RadioUtils.getListenedRadio(player(), true);
if (radio == null)
error("You are not listening to a radio!");
SongPlayer songPlayer = radio.getSongPlayer();
Song song = songPlayer.getSong();
send(PREFIX + "Radio Info:");
send("&3Radio: &e" + StringUtils.camelCase(radio.getId()));
List<String> list = RadioUtils.getPlaylistHover(radio);
send(json("&3Songs: &e[" + list.size() + "]").hover(list).loreize(false));
send("&3Playing: &e" + song.getTitle() + " &3by &e" + song.getAuthor() + " &3(" + getSongPercent(songPlayer) + "%)");
line();
}
Aggregations