Search in sources :

Example 1 with TextComponentProducer

use of com.sk89q.worldedit.util.formatting.component.TextComponentProducer in project FastAsyncWorldEdit by IntellectualSites.

the class SelectionCommands method select.

@Command(name = "/sel", aliases = { ";", "/desel", "/deselect" }, desc = "Choose a region selector")
// FAWE start
@CommandPermissions("worldedit.analysis.sel")
public // FAWE end
void select(Actor actor, World world, LocalSession session, @Arg(desc = "Selector to switch to", def = "") SelectorChoice selector, @Switch(name = 'd', desc = "Set default selector") boolean setDefaultSelector) throws WorldEditException {
    if (selector == null) {
        session.getRegionSelector(world).clear();
        session.dispatchCUISelection(actor);
        actor.print(Caption.of("worldedit.select.cleared"));
        return;
    }
    final RegionSelector oldSelector = session.getRegionSelector(world);
    final RegionSelector newSelector;
    switch(selector) {
        case CUBOID:
            newSelector = new CuboidRegionSelector(oldSelector);
            actor.print(Caption.of("worldedit.select.cuboid.message"));
            break;
        case EXTEND:
            newSelector = new ExtendingCuboidRegionSelector(oldSelector);
            actor.print(Caption.of("worldedit.select.extend.message"));
            break;
        case POLY:
            {
                newSelector = new Polygonal2DRegionSelector(oldSelector);
                actor.print(Caption.of("worldedit.select.poly.message"));
                Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
                limit.ifPresent(integer -> actor.print(Caption.of("worldedit.select.poly.limit-message", TextComponent.of(integer))));
                break;
            }
        case ELLIPSOID:
            newSelector = new EllipsoidRegionSelector(oldSelector);
            actor.print(Caption.of("worldedit.select.ellipsoid.message"));
            break;
        case SPHERE:
            newSelector = new SphereRegionSelector(oldSelector);
            actor.print(Caption.of("worldedit.select.sphere.message"));
            break;
        case CYL:
            newSelector = new CylinderRegionSelector(oldSelector);
            actor.print(Caption.of("worldedit.select.cyl.message"));
            break;
        case CONVEX:
        case HULL:
        case POLYHEDRON:
            {
                newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
                actor.print(Caption.of("worldedit.select.convex.message"));
                Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
                limit.ifPresent(integer -> actor.print(Caption.of("worldedit.select.convex.limit-message", TextComponent.of(integer))));
                break;
            }
        // FAWE start
        case POLYHEDRAL:
            newSelector = new PolyhedralRegionSelector(world);
            actor.print(Caption.of("fawe.selection.sel.convex.polyhedral"));
            Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
            limit.ifPresent(integer -> actor.print(Caption.of("fawe.selection.sel.max", integer)));
            actor.print(Caption.of("fawe.selection.sel.list"));
            break;
        case FUZZY:
        case MAGIC:
            Mask maskOpt = new IdMask(world);
            newSelector = new FuzzyRegionSelector(actor, world, maskOpt);
            actor.print(Caption.of("fawe.selection.sel.fuzzy"));
            actor.print(Caption.of("fawe.selection.sel.list"));
            break;
        // FAWE end
        case LIST:
        default:
            CommandListBox box = new CommandListBox("Selection modes", null, null);
            box.setHidingHelp(true);
            TextComponentProducer contents = box.getContents();
            contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
            box.appendCommand("cuboid", Caption.of("worldedit.select.cuboid.description"), "//sel cuboid");
            box.appendCommand("extend", Caption.of("worldedit.select.extend.description"), "//sel extend");
            box.appendCommand("poly", Caption.of("worldedit.select.poly.description"), "//sel poly");
            box.appendCommand("ellipsoid", Caption.of("worldedit.select.ellipsoid.description"), "//sel ellipsoid");
            box.appendCommand("sphere", Caption.of("worldedit.select.sphere.description"), "//sel sphere");
            box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl");
            box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex");
            // FAWE start
            box.appendCommand("polyhedral", Caption.of("fawe.selection.sel.polyhedral"), "//sel polyhedral");
            box.appendCommand("fuzzy[=<mask>]", Caption.of("fawe.selection.sel.fuzzy-instruction"), "//sel fuzzy[=<mask>]");
            box.setComponentsPerPage(box.getComponentsSize());
            // FAWE end
            actor.print(box.create(1));
            return;
    }
    if (setDefaultSelector) {
        RegionSelectorType found = null;
        for (RegionSelectorType type : RegionSelectorType.values()) {
            if (type.getSelectorClass() == newSelector.getClass()) {
                found = type;
                break;
            }
        }
        if (found != null) {
            session.setDefaultRegionSelector(found);
            actor.print(Caption.of("worldedit.select.default-set", TextComponent.of(found.name())));
        } else {
            throw new RuntimeException("Something unexpected happened. Please report this.");
        }
    }
    session.setRegionSelector(world, newSelector);
    session.dispatchCUISelection(actor);
}
Also used : EditSession(com.sk89q.worldedit.EditSession) ChunkStore(com.sk89q.worldedit.world.storage.ChunkStore) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Player(com.sk89q.worldedit.entity.Player) World(com.sk89q.worldedit.world.World) Caption(com.fastasyncworldedit.core.configuration.Caption) BaseItemStack(com.sk89q.worldedit.blocks.BaseItemStack) Arg(org.enginehub.piston.annotation.param.Arg) MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) ExtendingCuboidRegionSelector(com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector) Component(com.sk89q.worldedit.util.formatting.text.Component) RegionOperationException(com.sk89q.worldedit.regions.RegionOperationException) SelectionWand(com.sk89q.worldedit.command.tool.SelectionWand) CommandContainer(org.enginehub.piston.annotation.CommandContainer) TextColor(com.sk89q.worldedit.util.formatting.text.format.TextColor) NavigationWand(com.sk89q.worldedit.command.tool.NavigationWand) SelectorChoice(com.sk89q.worldedit.command.argument.SelectorChoice) Operations(com.sk89q.worldedit.function.operation.Operations) Location(com.sk89q.worldedit.util.Location) URI(java.net.URI) POSITION(com.sk89q.worldedit.command.util.Logging.LogMode.POSITION) MultiDirection(com.sk89q.worldedit.internal.annotation.MultiDirection) Polygonal2DRegionSelector(com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) BlockType(com.sk89q.worldedit.world.block.BlockType) URIClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions) Locatable(com.sk89q.worldedit.extension.platform.Locatable) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) SubtleFormat(com.sk89q.worldedit.util.formatting.component.SubtleFormat) CHUNK_SHIFTS_Y(com.sk89q.worldedit.world.storage.ChunkStore.CHUNK_SHIFTS_Y) InvalidComponentException(com.sk89q.worldedit.util.formatting.component.InvalidComponentException) ArgFlag(org.enginehub.piston.annotation.param.ArgFlag) TextComponentProducer(com.sk89q.worldedit.util.formatting.component.TextComponentProducer) CommandListBox(com.sk89q.worldedit.util.formatting.component.CommandListBox) List(java.util.List) Stream(java.util.stream.Stream) StopExecutionException(org.enginehub.piston.exception.StopExecutionException) CommandPermissionsConditionGenerator(com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator) PaginationBox(com.sk89q.worldedit.util.formatting.component.PaginationBox) ActorSelectorLimits(com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits) Optional(java.util.Optional) Countable(com.sk89q.worldedit.util.Countable) RegionSelector(com.sk89q.worldedit.regions.RegionSelector) BlockDistributionCounter(com.sk89q.worldedit.function.block.BlockDistributionCounter) CuboidRegionSelector(com.sk89q.worldedit.regions.selector.CuboidRegionSelector) ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) Switch(org.enginehub.piston.annotation.param.Switch) Logging(com.sk89q.worldedit.command.util.Logging) HoverEvent(com.sk89q.worldedit.util.formatting.text.event.HoverEvent) CHUNK_SHIFTS(com.sk89q.worldedit.world.storage.ChunkStore.CHUNK_SHIFTS) EllipsoidRegionSelector(com.sk89q.worldedit.regions.selector.EllipsoidRegionSelector) Strings(com.google.common.base.Strings) WorldEditException(com.sk89q.worldedit.WorldEditException) RegionSelectorType(com.sk89q.worldedit.regions.selector.RegionSelectorType) PolyhedralRegionSelector(com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector) ClickEvent(com.sk89q.worldedit.util.formatting.text.event.ClickEvent) CylinderRegionSelector(com.sk89q.worldedit.regions.selector.CylinderRegionSelector) WorldEdit(com.sk89q.worldedit.WorldEdit) Region(com.sk89q.worldedit.regions.Region) SphereRegionSelector(com.sk89q.worldedit.regions.selector.SphereRegionSelector) TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) ItemTypes(com.sk89q.worldedit.world.item.ItemTypes) REGION(com.sk89q.worldedit.command.util.Logging.LogMode.REGION) RegionVisitor(com.sk89q.worldedit.function.visitor.RegionVisitor) File(java.io.File) Actor(com.sk89q.worldedit.extension.platform.Actor) Direction(com.sk89q.worldedit.internal.annotation.Direction) IdMask(com.fastasyncworldedit.core.function.mask.IdMask) FuzzyRegionSelector(com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector) Command(org.enginehub.piston.annotation.Command) LocalSession(com.sk89q.worldedit.LocalSession) Mask(com.sk89q.worldedit.function.mask.Mask) BlockState(com.sk89q.worldedit.world.block.BlockState) ItemType(com.sk89q.worldedit.world.item.ItemType) CommandListBox(com.sk89q.worldedit.util.formatting.component.CommandListBox) TextComponentProducer(com.sk89q.worldedit.util.formatting.component.TextComponentProducer) Optional(java.util.Optional) Polygonal2DRegionSelector(com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector) IdMask(com.fastasyncworldedit.core.function.mask.IdMask) Mask(com.sk89q.worldedit.function.mask.Mask) CylinderRegionSelector(com.sk89q.worldedit.regions.selector.CylinderRegionSelector) ExtendingCuboidRegionSelector(com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector) CuboidRegionSelector(com.sk89q.worldedit.regions.selector.CuboidRegionSelector) ExtendingCuboidRegionSelector(com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector) EllipsoidRegionSelector(com.sk89q.worldedit.regions.selector.EllipsoidRegionSelector) FuzzyRegionSelector(com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector) ExtendingCuboidRegionSelector(com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector) Polygonal2DRegionSelector(com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) RegionSelector(com.sk89q.worldedit.regions.RegionSelector) CuboidRegionSelector(com.sk89q.worldedit.regions.selector.CuboidRegionSelector) EllipsoidRegionSelector(com.sk89q.worldedit.regions.selector.EllipsoidRegionSelector) PolyhedralRegionSelector(com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector) CylinderRegionSelector(com.sk89q.worldedit.regions.selector.CylinderRegionSelector) SphereRegionSelector(com.sk89q.worldedit.regions.selector.SphereRegionSelector) FuzzyRegionSelector(com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) IdMask(com.fastasyncworldedit.core.function.mask.IdMask) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) PolyhedralRegionSelector(com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector) SphereRegionSelector(com.sk89q.worldedit.regions.selector.SphereRegionSelector) RegionSelectorType(com.sk89q.worldedit.regions.selector.RegionSelectorType) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 2 with TextComponentProducer

use of com.sk89q.worldedit.util.formatting.component.TextComponentProducer in project FastAsyncWorldEdit by IntellectualSites.

the class SchematicCommands method list.

@Command(name = "list", aliases = { "all", "ls" }, desc = "List saved schematics", descFooter = "Note: Format is not fully verified until loading.")
@CommandPermissions("worldedit.schematic.list")
public void list(Actor actor, LocalSession session, @ArgFlag(name = 'p', desc = "Page to view.", def = "1") int page, @Switch(name = 'd', desc = "Sort by date, oldest first") boolean oldFirst, @Switch(name = 'n', desc = "Sort by date, newest first") boolean newFirst, @ArgFlag(name = 'f', desc = "Restricts by format.", def = "") String formatName, @Arg(name = "filter", desc = "Filter for schematics", def = "all") String filter, Arguments arguments) throws WorldEditException {
    if (oldFirst && newFirst) {
        throw new StopExecutionException(Caption.of("worldedit.schematic.sorting-old-new"));
    }
    // FAWE start
    String pageCommand = "/" + arguments.get();
    LocalConfiguration config = worldEdit.getConfiguration();
    File dir = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
    String schemCmd = "//schematic";
    String loadSingle = schemCmd + " load";
    String loadMulti = schemCmd + " loadall";
    String unload = schemCmd + " unload";
    String delete = schemCmd + " delete";
    String list = schemCmd + " list";
    String showCmd = schemCmd + " show";
    List<String> args = filter.isEmpty() ? Collections.emptyList() : Arrays.asList(filter.split(" "));
    URIClipboardHolder multi = as(URIClipboardHolder.class, session.getExistingClipboard());
    final boolean hasShow = false;
    // If player forgot -p argument
    boolean playerFolder = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS;
    UUID uuid = playerFolder ? actor.getUniqueId() : null;
    List<File> files = UtilityCommands.getFiles(dir, actor, args, formatName, playerFolder, oldFirst, newFirst);
    List<Map.Entry<URI, String>> entries = UtilityCommands.filesToEntry(dir, files, uuid);
    Function<URI, Boolean> isLoaded = multi == null ? f -> false : multi::contains;
    List<Component> components = UtilityCommands.entryToComponent(dir, entries, isLoaded, (name, path, type, loaded) -> {
        TextComponentProducer msg = new TextComponentProducer();
        msg.append(Caption.of("worldedit.schematic.dash.symbol"));
        if (loaded) {
            msg.append(Caption.of("worldedit.schematic.minus.symbol").clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, unload + " " + path)).hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.unload"))));
        } else {
            msg.append(Caption.of("worldedit.schematic.plus.symbol").clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, loadMulti + " " + path)).hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.clipboard"))));
        }
        if (type != UtilityCommands.URIType.DIRECTORY) {
            msg.append(Caption.of("worldedit.schematic.x.symbol").clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, delete + " " + path)).hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.delete"))));
        } else if (hasShow) {
            msg.append(Caption.of("worldedit.schematic.0.symbol").clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, showCmd + " " + path)).hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.visualize"))));
        }
        TextComponent msgElem = TextComponent.of(name);
        if (type != UtilityCommands.URIType.DIRECTORY) {
            msgElem = msgElem.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, loadSingle + " " + path));
            msgElem = msgElem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.load")));
        } else {
            msgElem = msgElem.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, list + " " + path));
            msgElem = msgElem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.list")));
        }
        msg.append(msgElem);
        if (type == UtilityCommands.URIType.FILE) {
            long filesize = 0;
            try {
                filesize = Files.size(Paths.get(dir.getAbsolutePath() + File.separator + (playerFolder ? (uuid.toString() + File.separator) : "") + path));
            } catch (IOException e) {
                e.printStackTrace();
            }
            TextComponent sizeElem = TextComponent.of(String.format(" (%.1f kb)", filesize / 1000.0), TextColor.GRAY);
            msg.append(sizeElem);
        }
        return msg.create();
    });
    long totalBytes = 0;
    File parentDir = new File(dir.getAbsolutePath() + (playerFolder ? File.separator + uuid.toString() : ""));
    try {
        List<File> toAddUp = getFiles(parentDir, null, null);
        if (toAddUp != null && toAddUp.size() != 0) {
            for (File schem : toAddUp) {
                if (schem.getName().endsWith(".schem") || schem.getName().endsWith(".schematic")) {
                    totalBytes += Files.size(Paths.get(schem.getAbsolutePath()));
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    String headerBytesElem = String.format("%.1fkb", totalBytes / 1000.0);
    if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1) {
        headerBytesElem += String.format(" / %dkb", Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT);
    }
    if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS) {
        String fullHeader = "| My Schematics: " + headerBytesElem + " |";
        PaginationBox paginationBox = PaginationBox.fromComponents(fullHeader, pageCommand, components);
        actor.print(paginationBox.create(page));
    } else {
        String fullHeader = "| Schematics: " + headerBytesElem + " |";
        PaginationBox paginationBox = PaginationBox.fromComponents(fullHeader, pageCommand, components);
        actor.print(paginationBox.create(page));
    }
// FAWE end
}
Also used : TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) TextComponentProducer(com.sk89q.worldedit.util.formatting.component.TextComponentProducer) IOException(java.io.IOException) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) URI(java.net.URI) URIClipboardHolder(com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder) StopExecutionException(org.enginehub.piston.exception.StopExecutionException) UUID(java.util.UUID) Component(com.sk89q.worldedit.util.formatting.text.Component) TranslatableComponent(com.sk89q.worldedit.util.formatting.text.TranslatableComponent) TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) PaginationBox(com.sk89q.worldedit.util.formatting.component.PaginationBox) File(java.io.File) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 3 with TextComponentProducer

use of com.sk89q.worldedit.util.formatting.component.TextComponentProducer in project FastAsyncWorldEdit by IntellectualSites.

the class HistorySubCommands method summary.

@Command(name = "info", aliases = { "summary", "summarize" }, desc = "Summarize an edit")
@CommandPermissions("worldedit.history.info")
public synchronized void summary(Player player, RollbackDatabase database, Arguments arguments, @Arg(desc = "Player uuid/name") UUID other, @Arg(desc = "edit index") Integer index) throws WorldEditException, ExecutionException, InterruptedException {
    RollbackOptimizedHistory edit = database.getEdit(other, index).get();
    if (edit == null) {
        player.print(Caption.of("fawe.worldedit.schematic.schematic.none"));
        return;
    }
    Location origin = player.getLocation();
    String name = Fawe.platform().getName(edit.getUUID());
    String cmd = edit.getCommand();
    BlockVector3 pos1 = edit.getMinimumPoint();
    BlockVector3 pos2 = edit.getMaximumPoint();
    double distanceX = Math.min(Math.abs(pos1.getX() - origin.getX()), Math.abs(pos2.getX() - origin.getX()));
    double distanceZ = Math.min(Math.abs(pos1.getZ() - origin.getZ()), Math.abs(pos2.getZ() - origin.getZ()));
    int distance = (int) Math.sqrt(distanceX * distanceX + distanceZ * distanceZ);
    BlockVector2 dirVec = BlockVector2.at(edit.getOriginX() - origin.getX(), edit.getOriginZ() - origin.getZ());
    Direction direction = Direction.findClosest(dirVec.toVector3(), Direction.Flag.ALL);
    long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
    String timeStr = MainUtil.secToTime(seconds);
    int size = edit.size();
    boolean biomes = edit.getBioFile().exists();
    boolean createdEnts = edit.getEnttFile().exists();
    boolean removedEnts = edit.getEntfFile().exists();
    boolean createdTiles = edit.getNbttFile().exists();
    boolean removedTiles = edit.getNbtfFile().exists();
    TranslatableComponent header = Caption.of("fawe.worldedit.history.find.element", name, timeStr, distance, direction.name(), cmd);
    String sizeStr = StringMan.humanReadableByteCountBin(edit.getSizeOnDisk());
    String extra = "";
    if (biomes) {
        extra += "biomes, ";
    }
    if (createdEnts) {
        extra += "+entity, ";
    }
    if (removedEnts) {
        extra += "-entity, ";
    }
    if (createdTiles) {
        extra += "+tile, ";
    }
    if (removedTiles) {
        extra += "-tile, ";
    }
    TranslatableComponent body = Caption.of("fawe.worldedit.history.find.element.more", size, edit.getMinimumPoint(), edit.getMaximumPoint(), extra.trim(), sizeStr);
    Component distr = TextComponent.of("/history distr").clickEvent(ClickEvent.suggestCommand("//history distr " + other + " " + index));
    TextComponentProducer content = new TextComponentProducer().append(header).newline().append(body).newline().append(distr);
    player.print(content.create());
}
Also used : TextComponentProducer(com.sk89q.worldedit.util.formatting.component.TextComponentProducer) BlockVector3(com.sk89q.worldedit.math.BlockVector3) BlockVector2(com.sk89q.worldedit.math.BlockVector2) Direction(com.sk89q.worldedit.util.Direction) RollbackOptimizedHistory(com.fastasyncworldedit.core.history.RollbackOptimizedHistory) TranslatableComponent(com.sk89q.worldedit.util.formatting.text.TranslatableComponent) Component(com.sk89q.worldedit.util.formatting.text.Component) TranslatableComponent(com.sk89q.worldedit.util.formatting.text.TranslatableComponent) TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) Location(com.sk89q.worldedit.util.Location) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 4 with TextComponentProducer

use of com.sk89q.worldedit.util.formatting.component.TextComponentProducer in project WorldGuard by EngineHub.

the class WorldGuardCommands method listRunningTasks.

@Command(aliases = { "running", "queue" }, desc = "List running tasks", max = 0)
@CommandPermissions("worldguard.running")
public void listRunningTasks(CommandContext args, Actor sender) throws CommandException {
    List<Task<?>> tasks = WorldGuard.getInstance().getSupervisor().getTasks();
    if (tasks.isEmpty()) {
        sender.print("There are currently no running tasks.");
    } else {
        tasks.sort(new TaskStateComparator());
        MessageBox builder = new MessageBox("Running Tasks", new TextComponentProducer());
        builder.append(TextComponent.of("Note: Some 'running' tasks may be waiting to be start.", TextColor.GRAY));
        for (Task<?> task : tasks) {
            builder.append(TextComponent.newline());
            builder.append(TextComponent.of("(" + task.getState().name() + ") ", TextColor.BLUE));
            builder.append(TextComponent.of(CommandUtils.getOwnerName(task.getOwner()) + ": ", TextColor.YELLOW));
            builder.append(TextComponent.of(task.getName(), TextColor.WHITE));
        }
        sender.print(builder.create());
    }
}
Also used : FutureForwardingTask(com.sk89q.worldedit.util.task.FutureForwardingTask) Task(com.sk89q.worldedit.util.task.Task) TaskStateComparator(com.sk89q.worldedit.util.task.TaskStateComparator) TextComponentProducer(com.sk89q.worldedit.util.formatting.component.TextComponentProducer) MessageBox(com.sk89q.worldedit.util.formatting.component.MessageBox) NestedCommand(com.sk89q.minecraft.util.commands.NestedCommand) Command(com.sk89q.minecraft.util.commands.Command) CommandPermissions(com.sk89q.minecraft.util.commands.CommandPermissions)

Aggregations

CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)3 TextComponentProducer (com.sk89q.worldedit.util.formatting.component.TextComponentProducer)3 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)2 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)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 Command (org.enginehub.piston.annotation.Command)2 Caption (com.fastasyncworldedit.core.configuration.Caption)1 IdMask (com.fastasyncworldedit.core.function.mask.IdMask)1 RollbackOptimizedHistory (com.fastasyncworldedit.core.history.RollbackOptimizedHistory)1 FuzzyRegionSelector (com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector)1 PolyhedralRegionSelector (com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector)1 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)1 Strings (com.google.common.base.Strings)1 Command (com.sk89q.minecraft.util.commands.Command)1 CommandPermissions (com.sk89q.minecraft.util.commands.CommandPermissions)1 NestedCommand (com.sk89q.minecraft.util.commands.NestedCommand)1 EditSession (com.sk89q.worldedit.EditSession)1 LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)1