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