Search in sources :

Example 6 with PaginationBox

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;
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) ArrayList(java.util.ArrayList) RegionPermissionModel(com.sk89q.worldguard.internal.permission.RegionPermissionModel) PaginationBox(com.sk89q.worldedit.util.formatting.component.PaginationBox)

Aggregations

PaginationBox (com.sk89q.worldedit.util.formatting.component.PaginationBox)6 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)5 Command (org.enginehub.piston.annotation.Command)5 RollbackOptimizedHistory (com.fastasyncworldedit.core.history.RollbackOptimizedHistory)2 SimpleChangeSetSummary (com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary)2 ChangeSet (com.sk89q.worldedit.history.changeset.ChangeSet)2 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)2 Countable (com.sk89q.worldedit.util.Countable)2 Location (com.sk89q.worldedit.util.Location)2 TextComponentProducer (com.sk89q.worldedit.util.formatting.component.TextComponentProducer)2 Component (com.sk89q.worldedit.util.formatting.text.Component)2 TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)2 TranslatableComponent (com.sk89q.worldedit.util.formatting.text.TranslatableComponent)2 Fawe (com.fastasyncworldedit.core.Fawe)1 FaweAPI (com.fastasyncworldedit.core.FaweAPI)1 Caption (com.fastasyncworldedit.core.configuration.Caption)1 Settings (com.fastasyncworldedit.core.configuration.Settings)1 DBHandler (com.fastasyncworldedit.core.database.DBHandler)1 RollbackDatabase (com.fastasyncworldedit.core.database.RollbackDatabase)1 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)1