Search in sources :

Example 1 with LangManager

use of biz.princeps.landlord.manager.LangManager 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)

Example 2 with LangManager

use of biz.princeps.landlord.manager.LangManager in project LandLord by SpatiumPrinceps.

the class Landlord method onEnable.

@Override
public void onEnable() {
    // Dependency stuff
    if (getWorldGuard() == null) {
        getLogger().warning("WorldGuard not found! Please ensure you have the correct version of WorldGuard in order to use LandLord");
        getPluginLoader().disablePlugin(this);
        return;
    } else
        wgHandler = new WorldGuardHandler(getWorldGuard());
    if (getVault() == null) {
        getLogger().warning("Vault not found! Not all features of landlord are working.");
    } else
        vaultHandler = new VaultHandler(getVault());
    if (!getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
        getLogger().warning("ProtocolLib not found! Please ensure you have the correct version of ProtocolLib in order to use LandLord");
        getPluginLoader().disablePlugin(this);
        return;
    }
    instance = this;
    PrincepsLib.setPluginInstance(this);
    checkWorldNames();
    saveDefaultConfig();
    ConfigUtil.handleConfigUpdate(this.getDataFolder() + "/config.yml", "/config.yml");
    saveDefaultConfig();
    langManager = new LangManager(this, getConfig().getString("Language", "en"));
    databaseAPI = new DatabaseAPI(DatabaseType.valueOf(getConfig().getString("DatabaseType")), getConfig(), new Requests(), "biz.princeps.landlord.persistent");
    handleDatabase();
    manageCommands();
    manageListeners();
    managePlaceholders();
    manageItems();
    lPlayerManager = new LPlayerManager(databaseAPI);
    lPlayerManager.onStartup();
    mapManager = new MapManager();
    ScoreboardLib.setPluginInstance(this);
    costManager = new CostManager();
    executorService = Executors.newCachedThreadPool();
    // Retrieve the LPlayer objects for all online players (in case of reload)
    Bukkit.getOnlinePlayers().forEach(p -> {
        List<Object> lPlayer = this.getDatabaseAPI().retrieveObjects(LPlayer.class, new Conditions.Builder().addCondition("uuid", p.getUniqueId().toString()).create());
        LPlayer lp;
        if (lPlayer.size() > 0)
            lp = (LPlayer) lPlayer.get(0);
        else
            lp = new LPlayer(p.getUniqueId());
        this.getPlayerManager().add(p.getUniqueId(), lp);
    });
    if (getConfig().getBoolean("EnableMetrics")) {
        Metrics metrics = new Metrics(this);
    // TODO maybe add some interesting statistics
    }
}
Also used : LPlayerManager(biz.princeps.landlord.manager.LPlayerManager) LangManager(biz.princeps.landlord.manager.LangManager) WorldGuardHandler(biz.princeps.landlord.handler.WorldGuardHandler) VaultHandler(biz.princeps.landlord.handler.VaultHandler) DatabaseAPI(biz.princeps.lib.storage.DatabaseAPI) Requests(biz.princeps.landlord.persistent.Requests) Conditions(biz.princeps.lib.storage.requests.Conditions) LPlayer(biz.princeps.landlord.persistent.LPlayer) Metrics(biz.princeps.landlord.util.Metrics) CostManager(biz.princeps.landlord.manager.CostManager) MapManager(biz.princeps.landlord.manager.map.MapManager)

Example 3 with LangManager

use of biz.princeps.landlord.manager.LangManager in project LandLord by SpatiumPrinceps.

the class Landlordbase method onCommand.

@Override
public void onCommand(Properties properties, Arguments arguments) {
    if (properties.isConsole())
        return;
    LangManager lm = Landlord.getInstance().getLangManager();
    List<String> playersList = lm.getStringList("Commands.Help.players");
    List<String> adminList = lm.getStringList("Commands.Help.admins");
    int perSite = Landlord.getInstance().getConfig().getInt("HelpCommandPerSite");
    String[] argsN = new String[1];
    if (arguments.get().length == 1) {
        argsN[0] = (arguments.get()[0] == null ? "0" : arguments.get()[0]);
    }
    List<String> toDisplay = new ArrayList<>();
    if (properties.getPlayer().hasPermission("landlord.admin.help"))
        toDisplay.addAll(adminList);
    toDisplay.addAll(playersList);
    // System.out.println(toDisplay.size());
    MultiPagedMessage msg = new MultiPagedMessage.Builder().setElements(toDisplay).setPerSite(perSite).setHeaderString(lm.getRawString("Commands.Help.header")).setNextString(lm.getRawString("Commands.Help.next")).setPreviousString(lm.getRawString("Commands.Help.previous")).setCommand("ll help", argsN).build();
    properties.getPlayer().spigot().sendMessage(msg.create());
}
Also used : LangManager(biz.princeps.landlord.manager.LangManager) MultiPagedMessage(biz.princeps.lib.chat.MultiPagedMessage)

Example 4 with LangManager

use of biz.princeps.landlord.manager.LangManager in project LandLord by SpatiumPrinceps.

the class LandMap method buildMap.

private String[] buildMap(Player p) {
    final int radius = 3;
    String[][] mapBoard = getMapDir(getPlayerDirection(p));
    String[] mapRows = new String[mapBoard.length + 3];
    if (!currChunk.equals(mapViewer.getLocation().getChunk())) {
        updateMap();
    }
    Map<Chunk, OwnedLand> nearby = plugin.getWgHandler().getNearbyLands(p.getLocation(), radius, radius);
    for (int z = 0; z < mapBoard.length; z++) {
        StringBuilder row = new StringBuilder();
        for (int x = 0; x < mapBoard[z].length; x++) {
            int xx = x - radius;
            int zz = z - radius;
            OwnedLand land = nearby.get(p.getWorld().getChunkAt(xx + p.getLocation().getChunk().getX(), zz + p.getLocation().getChunk().getZ()));
            String currSpot = mapBoard[z][x];
            if (land != null) {
                if (land.getWGLand().getOwners().getUniqueIds().contains(p.getUniqueId())) {
                    currSpot = ChatColor.GREEN + currSpot;
                } else if (land.getWGLand().getMembers().getUniqueIds().contains(p.getUniqueId())) {
                    currSpot = ChatColor.YELLOW + currSpot;
                } else {
                    currSpot = ChatColor.RED + currSpot;
                }
            } else {
                if (currSpot.equals("∞") || currSpot.equals("\u2062")) {
                    currSpot = ChatColor.RESET + currSpot;
                } else {
                    currSpot = ChatColor.GRAY + currSpot;
                }
            }
            row.append(currSpot);
        }
        mapRows[z] = row.toString();
    }
    LangManager messages = plugin.getLangManager();
    final String yours = messages.getRawString("Commands.LandMap.yours");
    final String friends = messages.getRawString("Commands.LandMap.friends");
    final String others = messages.getRawString("Commands.LandMap.others");
    if (yours.length() <= 25) {
        mapRows[mapRows.length - 3] = ChatColor.GREEN + "█- " + yours;
    } else {
        mapRows[mapRows.length - 3] = ChatColor.GREEN + "█- " + yours.substring(0, 25);
    }
    if (friends.length() <= 25) {
        mapRows[mapRows.length - 2] = ChatColor.YELLOW + "█- " + friends;
    } else {
        mapRows[mapRows.length - 2] = ChatColor.YELLOW + "█- " + friends.substring(0, 25);
    }
    if (others.length() <= 25) {
        mapRows[mapRows.length - 1] = ChatColor.RED + "█- " + others;
    } else {
        mapRows[mapRows.length - 1] = ChatColor.RED + "█- " + others.substring(0, 25);
    }
    return mapRows;
}
Also used : LangManager(biz.princeps.landlord.manager.LangManager) OwnedLand(biz.princeps.landlord.util.OwnedLand) Chunk(org.bukkit.Chunk)

Aggregations

LangManager (biz.princeps.landlord.manager.LangManager)4 VaultHandler (biz.princeps.landlord.handler.VaultHandler)1 WorldGuardHandler (biz.princeps.landlord.handler.WorldGuardHandler)1 CostManager (biz.princeps.landlord.manager.CostManager)1 LPlayerManager (biz.princeps.landlord.manager.LPlayerManager)1 MapManager (biz.princeps.landlord.manager.map.MapManager)1 LPlayer (biz.princeps.landlord.persistent.LPlayer)1 Requests (biz.princeps.landlord.persistent.Requests)1 Metrics (biz.princeps.landlord.util.Metrics)1 OwnedLand (biz.princeps.landlord.util.OwnedLand)1 MultiPagedMessage (biz.princeps.lib.chat.MultiPagedMessage)1 DatabaseAPI (biz.princeps.lib.storage.DatabaseAPI)1 Conditions (biz.princeps.lib.storage.requests.Conditions)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 Chunk (org.bukkit.Chunk)1 Player (org.bukkit.entity.Player)1