Search in sources :

Example 1 with MonoMode

use of com.xxmicloxx.NoteBlockAPI.model.playmode.MonoMode 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)

Aggregations

Song (com.xxmicloxx.NoteBlockAPI.model.Song)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 RadioSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer)1 File (java.io.File)1