Search in sources :

Example 6 with RegionPermissionModel

use of com.sk89q.worldguard.internal.permission.RegionPermissionModel 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

RegionPermissionModel (com.sk89q.worldguard.internal.permission.RegionPermissionModel)6 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)6 Command (com.sk89q.minecraft.util.commands.Command)4 CommandException (com.sk89q.minecraft.util.commands.CommandException)4 CommandPermissionsException (com.sk89q.minecraft.util.commands.CommandPermissionsException)4 World (com.sk89q.worldedit.world.World)4 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)4 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)4 LocalPlayer (com.sk89q.worldguard.LocalPlayer)3 Player (com.sk89q.worldedit.entity.Player)1 Location (com.sk89q.worldedit.util.Location)1 PaginationBox (com.sk89q.worldedit.util.formatting.component.PaginationBox)1 Component (com.sk89q.worldedit.util.formatting.text.Component)1 TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)1 RegionAdder (com.sk89q.worldguard.commands.task.RegionAdder)1 WorldConfiguration (com.sk89q.worldguard.config.WorldConfiguration)1 ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)1 InvalidFlagFormat (com.sk89q.worldguard.protection.flags.InvalidFlagFormat)1 RegionGroup (com.sk89q.worldguard.protection.flags.RegionGroup)1 RegionGroupFlag (com.sk89q.worldguard.protection.flags.RegionGroupFlag)1