use of com.sk89q.worldedit.util.formatting.component.PaginationBox in project WorldGuard by EngineHub.
the class RegionLister method call.
@Override
public Integer call() throws Exception {
Map<String, ProtectedRegion> regions = manager.getRegions();
Collection<ProtectedRegion> iterableRegions = regions.values();
if (filterByIntersecting != null) {
iterableRegions = filterByIntersecting.getIntersectingRegions(iterableRegions);
}
// Build a list of regions to show
List<RegionListEntry> entries = new ArrayList<>();
for (ProtectedRegion rg : iterableRegions) {
if (rg.getId().equals("__global__")) {
continue;
}
final RegionListEntry entry = new RegionListEntry(rg);
if (entry.matches(idFilter) && entry.matches(ownerMatcher)) {
entries.add(entry);
}
}
if (ownerMatcher == null) {
Collections.sort(entries);
}
// insert global on top
if (regions.containsKey("__global__")) {
final RegionListEntry entry = new RegionListEntry(regions.get("__global__"));
if (entry.matches(idFilter) && entry.matches(ownerMatcher)) {
entries.add(0, entry);
}
}
// unless we're matching owners, then sort by ownership
if (ownerMatcher != null) {
Collections.sort(entries);
}
RegionPermissionModel perms = sender.isPlayer() ? new RegionPermissionModel(sender) : null;
String title = ownerMatcher == null ? "Regions" : "Regions for " + ownerMatcher.getName();
String cmd = "/rg list -w \"" + world + "\"" + (playerName != null ? " -p " + playerName : "") + (nameOnly ? " -n" : "") + (filterByIntersecting != null ? " -s" : "") + (idFilter != null ? " -i " + idFilter : "") + " %page%";
PaginationBox box = new RegionListBox(title, cmd, perms, entries, world);
sender.print(box.create(page));
return page;
}
Aggregations