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));
}
}
Aggregations