Search in sources :

Example 1 with Song

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!");
            }
        }
    }
}
Also used : Song(com.xxmicloxx.NoteBlockAPI.model.Song) EntitySongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.EntitySongPlayer) File(java.io.File)

Example 2 with Song

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;
}
Also used : Path(java.nio.file.Path) Song(com.xxmicloxx.NoteBlockAPI.model.Song) Files(java.nio.file.Files) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Tasks(gg.projecteden.nexus.utils.Tasks) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) NBSDecoder(com.xxmicloxx.NoteBlockAPI.utils.NBSDecoder) ArrayList(java.util.ArrayList) Nullables.isNullOrEmpty(gg.projecteden.nexus.utils.Nullables.isNullOrEmpty) List(java.util.List) Stream(java.util.stream.Stream) Data(lombok.Data) Comparator(java.util.Comparator) Path(java.nio.file.Path) IOUtils.getPluginFolder(gg.projecteden.nexus.utils.IOUtils.getPluginFolder) CompletableFuture(java.util.concurrent.CompletableFuture) Song(com.xxmicloxx.NoteBlockAPI.model.Song)

Example 3 with Song

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");
    }
}
Also used : Song(com.xxmicloxx.NoteBlockAPI.model.Song) MonoMode(com.xxmicloxx.NoteBlockAPI.model.playmode.MonoMode) MonoStereoMode(com.xxmicloxx.NoteBlockAPI.model.playmode.MonoStereoMode) StereoMode(com.xxmicloxx.NoteBlockAPI.model.playmode.StereoMode) MonoStereoMode(com.xxmicloxx.NoteBlockAPI.model.playmode.MonoStereoMode) RadioSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer) File(java.io.File)

Example 4 with Song

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);
    }
}
Also used : PositionSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer) Song(com.xxmicloxx.NoteBlockAPI.model.Song) RadioUtils.removePlayer(gg.projecteden.nexus.features.radio.RadioUtils.removePlayer) SongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer) RadioUtils.addPlayer(gg.projecteden.nexus.features.radio.RadioUtils.addPlayer) Player(org.bukkit.entity.Player) PositionSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer) SongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer) PositionSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer) Radio(gg.projecteden.nexus.models.radio.RadioConfig.Radio) UUID(java.util.UUID) EventHandler(org.bukkit.event.EventHandler)

Example 5 with Song

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();
}
Also used : RadioSong(gg.projecteden.nexus.models.radio.RadioConfig.RadioSong) Song(com.xxmicloxx.NoteBlockAPI.model.Song) SongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer) Radio(gg.projecteden.nexus.models.radio.RadioConfig.Radio) RadioUtils.getListenedRadio(gg.projecteden.nexus.features.radio.RadioUtils.getListenedRadio) RadioUtils.isInRangeOfRadiusRadio(gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description)

Aggregations

Song (com.xxmicloxx.NoteBlockAPI.model.Song)8 RadioSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer)3 SongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer)3 File (java.io.File)3 PositionSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer)2 Radio (gg.projecteden.nexus.models.radio.RadioConfig.Radio)2 List (java.util.List)2 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)1 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 MonoMode (com.xxmicloxx.NoteBlockAPI.model.playmode.MonoMode)1 MonoStereoMode (com.xxmicloxx.NoteBlockAPI.model.playmode.MonoStereoMode)1 StereoMode (com.xxmicloxx.NoteBlockAPI.model.playmode.StereoMode)1 EntitySongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.EntitySongPlayer)1 NBSDecoder (com.xxmicloxx.NoteBlockAPI.utils.NBSDecoder)1 RadioUtils.addPlayer (gg.projecteden.nexus.features.radio.RadioUtils.addPlayer)1 RadioUtils.getListenedRadio (gg.projecteden.nexus.features.radio.RadioUtils.getListenedRadio)1 RadioUtils.isInRangeOfRadiusRadio (gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio)1 RadioUtils.removePlayer (gg.projecteden.nexus.features.radio.RadioUtils.removePlayer)1 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)1 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)1