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");
}
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations