Search in sources :

Example 1 with RadioUser

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

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

the class RadioCommand method configSetType.

@Path("config setId <radio> <id>")
@Permission(Group.ADMIN)
void configSetType(Radio radio, String id) {
    String oldId = radio.getId();
    radio.setId(id);
    configService.save(config);
    String newId = radio.getId();
    userService.clearCache();
    List<RadioUser> radioUsers = userService.getAll();
    for (RadioUser user : radioUsers) {
        if (user.getServerRadioId() != null && user.getServerRadioId().equalsIgnoreCase(oldId))
            user.setServerRadioId(newId);
        if (user.getLastServerRadioId() != null && user.getLastServerRadioId().equalsIgnoreCase(oldId))
            user.setLastServerRadioId(newId);
        if (user.getLeftRadiusRadios() != null && user.getLeftRadiusRadios().contains(oldId)) {
            user.getLeftRadiusRadios().remove(oldId);
            user.getLeftRadiusRadios().add(newId);
        }
        userService.save(user);
    }
    send(PREFIX + "Id set to " + radio.getId());
}
Also used : RadioUser(gg.projecteden.nexus.models.radio.RadioUser) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 3 with RadioUser

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

the class RadioCommand method debugUser.

@Path("debugUser <player>")
@Permission(Group.ADMIN)
void debugUser(OfflinePlayer player) {
    RadioUser user = userService.get(player);
    send(PREFIX + "&3User Debug: ");
    send("&3Player: &e" + user.getNickname());
    send("&3Is Mute: &e" + user.isMute());
    send("&3ServerRadioId: &e" + user.getServerRadioId());
    send("&3LastServerRadioId: &e" + user.getLastServerRadioId());
    send("&3LeftRadiusRadios: &e" + user.getLeftRadiusRadios());
    line();
}
Also used : RadioUser(gg.projecteden.nexus.models.radio.RadioUser) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 4 with RadioUser

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

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

the class Listeners method onPlayerJoin.

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
    RadioUserService userService = new RadioUserService();
    RadioUser user = userService.get(event.getPlayer());
    Radio radio = user.getLastServerRadio();
    if (radio != null)
        addPlayer(user.getOnlinePlayer(), radio);
    user.getLeftRadiusRadios().clear();
}
Also used : RadioUser(gg.projecteden.nexus.models.radio.RadioUser) Radio(gg.projecteden.nexus.models.radio.RadioConfig.Radio) RadioUserService(gg.projecteden.nexus.models.radio.RadioUserService) EventHandler(org.bukkit.event.EventHandler)

Aggregations

RadioUser (gg.projecteden.nexus.models.radio.RadioUser)6 Radio (gg.projecteden.nexus.models.radio.RadioConfig.Radio)4 RadioUserService (gg.projecteden.nexus.models.radio.RadioUserService)4 PositionSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer)2 RadioSongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer)2 SongPlayer (com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer)2 RadioUtils.isInRangeOfRadiusRadio (gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio)2 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)2 EventHandler (org.bukkit.event.EventHandler)2 ParticleBuilder (com.destroystokyo.paper.ParticleBuilder)1 RadioUtils.addPlayer (gg.projecteden.nexus.features.radio.RadioUtils.addPlayer)1 RadioUtils.removePlayer (gg.projecteden.nexus.features.radio.RadioUtils.removePlayer)1 RadioConfig (gg.projecteden.nexus.models.radio.RadioConfig)1 RadioSong (gg.projecteden.nexus.models.radio.RadioConfig.RadioSong)1 RadioConfigService (gg.projecteden.nexus.models.radio.RadioConfigService)1 File (java.io.File)1 UUID (java.util.UUID)1 Location (org.bukkit.Location)1 Block (org.bukkit.block.Block)1