use of com.sk89q.worldedit.util.SideEffect 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));
}
}
use of com.sk89q.worldedit.util.SideEffect in project FastAsyncWorldEdit by IntellectualSites.
the class SideEffectBox method getComponent.
@Override
public Component getComponent(int number) {
SideEffect effect = getSideEffects().get(number);
SideEffect.State state = this.sideEffectSet.getState(effect);
TextComponent.Builder builder = TextComponent.builder();
builder = builder.append(Caption.of(effect.getDisplayName(), TextColor.YELLOW).hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of(effect.getDescription()))));
for (SideEffect.State uiState : SHOWN_VALUES) {
builder = builder.append(TextComponent.space());
builder = builder.append(Caption.of(uiState.getDisplayName(), uiState == state ? TextColor.WHITE : TextColor.GRAY).clickEvent(ClickEvent.runCommand("//perf -h " + effect.name().toLowerCase(Locale.US) + " " + uiState.name().toLowerCase(Locale.US))).hoverEvent(HoverEvent.showText(uiState == state ? Caption.of("worldedit.sideeffect.box.current") : Caption.of("worldedit.sideeffect.box.change-to", Caption.of(uiState.getDisplayName())))));
}
return builder.build();
}
Aggregations