Search in sources :

Example 1 with SimpleScoreboard

use of me.tigerhix.lib.scoreboard.type.SimpleScoreboard in project LandLord by SpatiumPrinceps.

the class LandMap method displayMap.

/**
 * core method for actually displaying the Map
 *
 * @param p the player, who asked for a map
 * @return a reference to the scoreboard
 */
private SimpleScoreboard displayMap(Player p) {
    Scoreboard board = ScoreboardLib.createScoreboard(p).setHandler(new ScoreboardHandler() {

        LangManager messages = plugin.getLangManager();

        @Override
        public String getTitle(Player p) {
            return messages.getRawString("Commands.LandMap.header");
        }

        @Override
        public List<Entry> getEntries(Player player) {
            if (!currDir.equals(getPlayerDirection(mapViewer)) || !currChunk.equals(mapViewer.getLocation().getChunk())) {
                currDir = getPlayerDirection(mapViewer);
            }
            EntryBuilder eb = new EntryBuilder();
            String[] mapData = buildMap(p);
            for (String aMapData : mapData) {
                // Not sure what this part does. It works without lol
                /*if (mapData[i].length() < 21) {
                        for (int f = 0; f < (21 - mapData[i].length()); f++) {
                            mapData[i] += ChatColor.RESET;
                        }
                    }*/
                eb.next(aMapData);
            }
            return eb.build();
        }
    }).setUpdateInterval(plugin.getConfig().getLong("Map.refreshRate", 10));
    SimpleScoreboard simpleScoreboard = (SimpleScoreboard) board;
    simpleScoreboard.activate();
    this.scoreboard = simpleScoreboard;
    return simpleScoreboard;
}
Also used : Player(org.bukkit.entity.Player) Entry(me.tigerhix.lib.scoreboard.type.Entry) ScoreboardHandler(me.tigerhix.lib.scoreboard.type.ScoreboardHandler) LangManager(biz.princeps.landlord.manager.LangManager) SimpleScoreboard(me.tigerhix.lib.scoreboard.type.SimpleScoreboard) Scoreboard(me.tigerhix.lib.scoreboard.type.Scoreboard) EntryBuilder(me.tigerhix.lib.scoreboard.common.EntryBuilder) SimpleScoreboard(me.tigerhix.lib.scoreboard.type.SimpleScoreboard)

Aggregations

LangManager (biz.princeps.landlord.manager.LangManager)1 EntryBuilder (me.tigerhix.lib.scoreboard.common.EntryBuilder)1 Entry (me.tigerhix.lib.scoreboard.type.Entry)1 Scoreboard (me.tigerhix.lib.scoreboard.type.Scoreboard)1 ScoreboardHandler (me.tigerhix.lib.scoreboard.type.ScoreboardHandler)1 SimpleScoreboard (me.tigerhix.lib.scoreboard.type.SimpleScoreboard)1 Player (org.bukkit.entity.Player)1