Search in sources :

Example 1 with MultiPagedMessage

use of biz.princeps.lib.chat.MultiPagedMessage in project LandLord by SpatiumPrinceps.

the class ListLands method onListLands.

public void onListLands(Player sender, LPlayer target, int page) {
    List<ProtectedRegion> lands = new ArrayList<>(plugin.getWgHandler().getRegions(target.getUuid()));
    if (lands.size() > 0) {
        String mode = plugin.getConfig().getString("CommandSettings.ListLands.mode");
        if (mode.equals("gui")) {
            MultiPagedGUI landGui = new MultiPagedGUI(sender, 5, plugin.getLangManager().getRawString("Commands.ListLands.header").replace("%player%", target.getName()));
            lands.forEach(land -> landGui.addIcon(new Icon(new ItemStack(Material.GRASS)).setName(land.getId())));
            landGui.setIcon(52, new Icon(new ItemStack(Material.BEACON)).setName(lm.getRawString("Commands.ListLands.manageAll")).addClickAction((p, ic2) -> {
                ManageGUIAll manageGUIAll = new ManageGUIAll(sender, landGui, plugin.getWgHandler().getRegionsAsOL(target.getUuid()));
                manageGUIAll.display();
            }));
            landGui.display();
        } else {
            // Chat based system
            List<String> formatted = new ArrayList<>();
            String segment = lm.getRawString("Commands.ListLands.chat.segment");
            lands.forEach(land -> {
                OwnedLand ol = plugin.getLand(land);
                formatted.add(segment.replace("%landname%", ol.getName()).replace("%members%", ol.printMembers()));
            });
            String prev = lm.getRawString("Commands.ListLands.chat.previous");
            String next = lm.getRawString("Commands.ListLands.chat.next");
            MultiPagedMessage message = new MultiPagedMessage("/land list", plugin.getLangManager().getRawString("Commands.ListLands.header").replace("%player%", target.getName()), plugin.getConfig().getInt("CommandSettings.ListLands.landsPerPage"), formatted, prev, next, page);
            sender.spigot().sendMessage(message.create());
        }
    } else {
        sender.sendMessage(plugin.getLangManager().getString("Commands.ListLands.noLands"));
    }
}
Also used : MultiPagedGUI(biz.princeps.lib.gui.MultiPagedGUI) LandlordCommand(biz.princeps.landlord.commands.LandlordCommand) ManageGUIAll(biz.princeps.landlord.guis.ManageGUIAll) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) LPlayer(biz.princeps.landlord.persistent.LPlayer) OwnedLand(biz.princeps.landlord.util.OwnedLand) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) List(java.util.List) MultiPagedMessage(biz.princeps.lib.chat.MultiPagedMessage) Icon(biz.princeps.lib.gui.simple.Icon) Material(org.bukkit.Material) ManageGUIAll(biz.princeps.landlord.guis.ManageGUIAll) MultiPagedGUI(biz.princeps.lib.gui.MultiPagedGUI) OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) ArrayList(java.util.ArrayList) Icon(biz.princeps.lib.gui.simple.Icon) MultiPagedMessage(biz.princeps.lib.chat.MultiPagedMessage) ItemStack(org.bukkit.inventory.ItemStack)

Example 2 with MultiPagedMessage

use of biz.princeps.lib.chat.MultiPagedMessage 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)

Aggregations

MultiPagedMessage (biz.princeps.lib.chat.MultiPagedMessage)2 LandlordCommand (biz.princeps.landlord.commands.LandlordCommand)1 ManageGUIAll (biz.princeps.landlord.guis.ManageGUIAll)1 LangManager (biz.princeps.landlord.manager.LangManager)1 LPlayer (biz.princeps.landlord.persistent.LPlayer)1 OwnedLand (biz.princeps.landlord.util.OwnedLand)1 MultiPagedGUI (biz.princeps.lib.gui.MultiPagedGUI)1 Icon (biz.princeps.lib.gui.simple.Icon)1 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Material (org.bukkit.Material)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 Player (org.bukkit.entity.Player)1 ItemStack (org.bukkit.inventory.ItemStack)1