Search in sources :

Example 1 with RadioSong

use of gg.projecteden.nexus.models.radio.RadioConfig.RadioSong in project Nexus by ProjectEdenGG.

the class RadioCommand method configAddSong.

@Path("config addSong <radio> <song>")
@Description("Add a song to a radio")
@Permission(Group.ADMIN)
void configAddSong(Radio radio, @Arg(type = RadioSong.class) List<RadioSong> radioSongs) {
    for (RadioSong radioSong : radioSongs) config.addSong(radio, radioSong);
    configService.save(config);
    send(PREFIX + "Added " + radioSongs.stream().map(RadioSong::getName).collect(Collectors.joining(", ")) + " to " + radio.getId());
}
Also used : RadioSong(gg.projecteden.nexus.models.radio.RadioConfig.RadioSong) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 2 with RadioSong

use of gg.projecteden.nexus.models.radio.RadioConfig.RadioSong in project Nexus by ProjectEdenGG.

the class RadioFeature method onStart.

@Override
public void onStart() {
    allSongs = new ArrayList<>();
    new Listeners();
    Tasks.async(() -> {
        File[] songs = songsDirectory.listFiles();
        if (songs != null) {
            for (File file : songs) allSongs.add(new RadioSong(file.getName(), file));
        }
        setupRadios();
        // Rejoin radios
        for (Player player : OnlinePlayers.getAll()) {
            RadioUser user = userService.get(player);
            if (user.getLastServerRadio() != null)
                RadioUtils.addPlayer(player, user.getLastServerRadio());
        }
        // Radio Particles Task
        Tasks.repeat(0, TickTime.TICK.x(5), () -> {
            for (Radio radio : getRadios()) {
                if (!radio.getType().equals(RadioType.RADIUS))
                    continue;
                if (!radio.isEnabled())
                    continue;
                if (!radio.isParticles())
                    continue;
                if (radio.getLocation() == null)
                    continue;
                new ParticleBuilder(Particle.NOTE).count(RandomUtils.randomInt(1, 3)).offset(0.25, 0.25, 0.25).location(radio.getLocation().add(0, RandomUtils.randomDouble(0.45, 0.75), 0)).spawn();
            }
        });
        // Radius Radio User Task
        RadioUserService service = new RadioUserService();
        Tasks.repeat(0, TickTime.SECOND.x(2), () -> {
            for (Radio radio : getRadios()) {
                if (!(radio.getSongPlayer() instanceof PositionSongPlayer))
                    continue;
                for (Player player : OnlinePlayers.getAll()) {
                    RadioUser user = service.get(player);
                    if (user.isMute())
                        continue;
                    if (user.getLeftRadiusRadios().contains(radio.getId()))
                        continue;
                    boolean isInRange = isInRangeOfRadiusRadio(player, radio);
                    boolean isListening = isListening(player, radio);
                    if (isInRange && !isListening) {
                        if (user.getServerRadio() != null)
                            removePlayer(player, user.getServerRadio());
                        addPlayer(player, radio);
                    } else if (!isInRange && isListening) {
                        removePlayer(player, radio);
                        if (user.getLastServerRadio() != null)
                            addPlayer(player, user.getLastServerRadio());
                    }
                }
            }
        });
    });
}
Also used : PositionSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer) RadioUtils.removePlayer(gg.projecteden.nexus.features.radio.RadioUtils.removePlayer) Player(org.bukkit.entity.Player) PositionSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer) SongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer) RadioUtils.addPlayer(gg.projecteden.nexus.features.radio.RadioUtils.addPlayer) RadioSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer) RadioUser(gg.projecteden.nexus.models.radio.RadioUser) Radio(gg.projecteden.nexus.models.radio.RadioConfig.Radio) RadioUtils.isInRangeOfRadiusRadio(gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio) File(java.io.File) RadioSong(gg.projecteden.nexus.models.radio.RadioConfig.RadioSong) ParticleBuilder(com.destroystokyo.paper.ParticleBuilder) RadioUserService(gg.projecteden.nexus.models.radio.RadioUserService)

Aggregations

RadioSong (gg.projecteden.nexus.models.radio.RadioConfig.RadioSong)2 ParticleBuilder (com.destroystokyo.paper.ParticleBuilder)1 PositionSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer)1 RadioSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer)1 SongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer)1 RadioUtils.addPlayer (gg.projecteden.nexus.features.radio.RadioUtils.addPlayer)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 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)1 Radio (gg.projecteden.nexus.models.radio.RadioConfig.Radio)1 RadioUser (gg.projecteden.nexus.models.radio.RadioUser)1 RadioUserService (gg.projecteden.nexus.models.radio.RadioUserService)1 File (java.io.File)1 Player (org.bukkit.entity.Player)1