Package com.sk89q.craftbook.util.jinglenote

Examples of com.sk89q.craftbook.util.jinglenote.Playlist


    @Override
    public void load() {

        band = getLine(3);
        Playlist playlist = new Playlist(getLine(2));
        stations.put(band, playlist);
    }
View Full Code Here


    }

    @Override
    public void trigger (ChipState chip) {

        Playlist playlist = null;

        if (!stations.containsKey(band)) {
            playlist = new Playlist(getLine(2));
            stations.put(band, playlist);
        } else
            playlist = stations.get(band);

        if (chip.getInput(0) && !playlist.isPlaying())
            playlist.startPlaylist();
        else if(!chip.getInput(0) && playlist.isPlaying())
            playlist.stopPlaylist();

        chip.setOutput(0, playlist.isPlaying());
    }
View Full Code Here

        String plist = getLine(2);
        if (!getLine(3).isEmpty()) area = SearchArea.createArea(getLocation().getBlock(), getLine(3));

        if(!playlists.containsKey(getBackBlock().getLocation()))
            playlists.put(getBackBlock().getLocation(), new Playlist(plist));

        players = new HashMap<String, SearchArea>();
    }
View Full Code Here

    }

    @Override
    public void trigger (ChipState chip) {

        Playlist playlist = playlists.get(getBackBlock().getLocation());

        if(playlist == null) return; //Heh?

        if (chip.getInput(0) && !playlist.isPlaying())
            playlist.startPlaylist();
        else if(!chip.getInput(0) && playlist.isPlaying())
            playlist.stopPlaylist();

        if(chip.getInput(0)) {

            boolean hasChanged = false;

            for(Player p : Bukkit.getServer().getOnlinePlayers()) {
                if(area != null && !area.isWithinArea(p.getLocation())) {
                    if(players.containsKey(p.getName())) {
                        players.remove(p.getName());
                        hasChanged = true;
                    }
                } else if (!players.containsKey(p.getName())) {
                    players.put(p.getName(), area);
                    hasChanged = true;
                }
            }

            if(hasChanged)
                playlist.getPlaylistInterpreter().setPlayers(players);
        }

        chip.setOutput(0, playlist.isPlaying());
    }
View Full Code Here

    }

    @Override
    public void trigger (ChipState chip) {

        Playlist playlist = RadioStation.getPlaylist(band);

        if(playlist == null)
            return;

        if(chip.getInput(0)) {
            if(area.getPlayersInArea().size() != listening.size()) {

                Map<String, SearchArea> removals = new HashMap<String, SearchArea>();

                for(Entry<String, SearchArea> key : listening.entrySet()) {
                    boolean found = false;
                    for(Player p : area.getPlayersInArea()) {
                        if(p.getName().equals(key.getKey())) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) removals.put(key.getKey(), key.getValue());
                }

                if(removals.size() > 0) {
                    playlist.getPlaylistInterpreter().removePlayers(removals);
                    for(String key : removals.keySet())
                        listening.remove(key);
                }

                boolean changed = false;

                for(Player player : area.getPlayersInArea())
                    if(!listening.containsKey(player.getName())) {
                        listening.put(player.getName(), area);
                        changed = true;
                    }

                if(changed)
                    playlist.getPlaylistInterpreter().addPlayers(listening);

                CraftBookPlugin.logDebugMessage("Reset listener list! Size of: " + listening.size(), "ic-mc1277");
            }
        } else if(listening.size() > 0) {
            playlist.getPlaylistInterpreter().removePlayers(listening);
            listening.clear();

            CraftBookPlugin.logDebugMessage("Cleared listener list!", "ic-mc1277");
        }

        chip.setOutput(0, playlist.isPlaying() && !listening.isEmpty());
    }
View Full Code Here

TOP

Related Classes of com.sk89q.craftbook.util.jinglenote.Playlist

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.