Search in sources :

Example 1 with SideEffectSet

use of com.sk89q.worldedit.util.SideEffectSet in project FastAsyncWorldEdit by IntellectualSites.

the class GeneralCommands method perf.

@Command(name = "/perf", desc = "Toggle side effects for performance", descFooter = "Note that this command is GOING to change in the future." + " Do not depend on the exact format of this command yet.")
@CommandPermissions("worldedit.perf")
void perf(Actor actor, LocalSession session, @Arg(desc = "The side effect", def = "") SideEffect sideEffect, @Arg(desc = "The new side effect state", def = "") SideEffect.State newState, @Switch(name = 'h', desc = "Show the info box") boolean showInfoBox) throws WorldEditException {
    if (sideEffect != null) {
        SideEffect.State currentState = session.getSideEffectSet().getState(sideEffect);
        if (newState != null && newState == currentState) {
            if (!showInfoBox) {
                actor.print(Caption.of("worldedit.perf.sideeffect.already-set", TranslatableComponent.of(sideEffect.getDisplayName()), TranslatableComponent.of(newState.getDisplayName())));
            }
            return;
        }
        if (newState != null) {
            session.setSideEffectSet(session.getSideEffectSet().with(sideEffect, newState));
            if (!showInfoBox) {
                actor.print(Caption.of("worldedit.perf.sideeffect.set", TranslatableComponent.of(sideEffect.getDisplayName()), TranslatableComponent.of(newState.getDisplayName())));
            }
        } else {
            actor.print(Caption.of("worldedit.perf.sideeffect.get", TranslatableComponent.of(sideEffect.getDisplayName()), TranslatableComponent.of(currentState.getDisplayName())));
        }
    } else if (newState != null) {
        SideEffectSet applier = session.getSideEffectSet();
        for (SideEffect sideEffectEntry : SideEffect.values()) {
            applier = applier.with(sideEffectEntry, newState);
        }
        session.setSideEffectSet(applier);
        if (!showInfoBox) {
            actor.print(Caption.of("worldedit.perf.sideeffect.set-all", TranslatableComponent.of(newState.getDisplayName())));
        }
    }
    if (sideEffect == null || showInfoBox) {
        SideEffectBox sideEffectBox = new SideEffectBox(session.getSideEffectSet());
        actor.print(sideEffectBox.create(1));
    }
}
Also used : SideEffectSet(com.sk89q.worldedit.util.SideEffectSet) SideEffectBox(com.sk89q.worldedit.util.formatting.component.SideEffectBox) SideEffect(com.sk89q.worldedit.util.SideEffect) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 SideEffect (com.sk89q.worldedit.util.SideEffect)1 SideEffectSet (com.sk89q.worldedit.util.SideEffectSet)1 SideEffectBox (com.sk89q.worldedit.util.formatting.component.SideEffectBox)1 Command (org.enginehub.piston.annotation.Command)1