Search in sources :

Example 1 with Radio

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

the class RadioHeads method onClickRadio.

@EventHandler
public void onClickRadio(PlayerInteractEvent event) {
    if (BearFair21.isNotAtBearFair(event))
        return;
    if (WorldGuardEditCommand.canWorldGuardEdit(event.getPlayer()))
        return;
    Block block = event.getClickedBlock();
    if (isNullOrAir(block) || !block.getType().equals(Material.PLAYER_HEAD))
        return;
    Location radioHeadLoc = new Location(BearFair21.getWorld(), 16, 119, -19);
    ItemStack item = ItemUtils.getItem(block);
    // item.equals(Nexus.getHeadAPI().getItemHead("17150"))
    if (item.equals(ItemUtils.getItem(radioHeadLoc.getBlock()))) {
        event.setCancelled(true);
        RadioUserService userService = new RadioUserService();
        RadioUser radioUser = userService.get(event.getPlayer());
        Radio radio = radioUser.getServerRadio();
        if (radioUser.getVolume() == 100) {
            radioUser.setVolume((byte) 25);
            userService.save(radioUser);
        }
        if (radio == null || !radio.getId().equalsIgnoreCase("bearfair"))
            PlayerUtils.runCommand(event.getPlayer(), "radio join bearfair");
        else if (radio.getId().equalsIgnoreCase("bearfair"))
            PlayerUtils.runCommand(event.getPlayer(), "radio leave");
    }
}
Also used : RadioUser(gg.projecteden.nexus.models.radio.RadioUser) Block(org.bukkit.block.Block) Radio(gg.projecteden.nexus.models.radio.RadioConfig.Radio) ItemStack(org.bukkit.inventory.ItemStack) RadioUserService(gg.projecteden.nexus.models.radio.RadioUserService) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Radio

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

the class RadioCommand method leaveRadio.

@Path("leave")
@Description("Leave the listened radio")
void leaveRadio() {
    Radio radio = getListenedRadio(player(), true);
    if (radio == null)
        return;
    removePlayer(player(), radio);
    if (radio.getType().equals(RadioType.RADIUS))
        user.getLeftRadiusRadios().add(radio.getId());
    else
        user.setLastServerRadioId(null);
    if (user.getLastServerRadio() != null)
        addPlayer(player(), user.getLastServerRadio());
    userService.save(user);
}
Also used : 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)

Example 3 with Radio

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

the class RadioFeature method setupRadios.

private void setupRadios() {
    RadioConfigService configService = new RadioConfigService();
    RadioConfig radioConfig = configService.get0();
    for (Radio radio : radioConfig.getRadios()) {
        if (!radio.isEnabled())
            continue;
        Playlist playlist = radio.getPlaylist();
        if (playlist == null || playlist.getSongList().size() <= 0) {
            Nexus.severe(radio.getId() + " radio playlist is empty!");
            continue;
        }
        createSongPlayer(radio, playlist);
    }
    configService.save(radioConfig);
}
Also used : Playlist(com.xxmicloxx.NoteBlockAPI.model.Playlist) RadioConfigService(gg.projecteden.nexus.models.radio.RadioConfigService) RadioConfig(gg.projecteden.nexus.models.radio.RadioConfig) Radio(gg.projecteden.nexus.models.radio.RadioConfig.Radio) RadioUtils.isInRangeOfRadiusRadio(gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio)

Example 4 with Radio

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

the class RadioFeature method onStop.

@Override
public void onStop() {
    RadioConfigService configService = new RadioConfigService();
    RadioConfig radioConfig = configService.get0();
    RadioUserService userService = new RadioUserService();
    RadioUser user;
    for (Radio radio : radioConfig.getRadios()) {
        if (radio.getSongPlayer() != null) {
            SongPlayer songPlayer = radio.getSongPlayer();
            for (UUID uuid : songPlayer.getPlayerUUIDs()) {
                user = userService.get(uuid);
                user.setServerRadioId(radio.getId());
                userService.save(user);
            }
            removeSongPlayer(radio.getSongPlayer());
        }
    }
    configService.save(radioConfig);
}
Also used : RadioConfigService(gg.projecteden.nexus.models.radio.RadioConfigService) PositionSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer) SongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer) RadioSongPlayer(com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer) RadioUser(gg.projecteden.nexus.models.radio.RadioUser) RadioConfig(gg.projecteden.nexus.models.radio.RadioConfig) Radio(gg.projecteden.nexus.models.radio.RadioConfig.Radio) RadioUtils.isInRangeOfRadiusRadio(gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio) UUID(java.util.UUID) RadioUserService(gg.projecteden.nexus.models.radio.RadioUserService)

Example 5 with Radio

use of gg.projecteden.nexus.models.radio.RadioConfig.Radio 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)

Aggregations

Radio (gg.projecteden.nexus.models.radio.RadioConfig.Radio)10 RadioUtils.isInRangeOfRadiusRadio (gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio)6 SongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer)5 PositionSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer)4 RadioUser (gg.projecteden.nexus.models.radio.RadioUser)4 RadioUserService (gg.projecteden.nexus.models.radio.RadioUserService)4 EventHandler (org.bukkit.event.EventHandler)4 RadioUtils.addPlayer (gg.projecteden.nexus.features.radio.RadioUtils.addPlayer)3 RadioUtils.getListenedRadio (gg.projecteden.nexus.features.radio.RadioUtils.getListenedRadio)3 RadioUtils.removePlayer (gg.projecteden.nexus.features.radio.RadioUtils.removePlayer)3 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)3 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)3 Player (org.bukkit.entity.Player)3 Song (com.xxmicloxx.NoteBlockAPI.model.Song)2 RadioSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer)2 RadioConfig (gg.projecteden.nexus.models.radio.RadioConfig)2 RadioSong (gg.projecteden.nexus.models.radio.RadioConfig.RadioSong)2 RadioConfigService (gg.projecteden.nexus.models.radio.RadioConfigService)2 UUID (java.util.UUID)2 ParticleBuilder (com.destroystokyo.paper.ParticleBuilder)1