Skip to content

Commit

Permalink
added all argument to .toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
arlomcwalter committed Jan 8, 2022
1 parent dd5f88a commit c8984b3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,4 @@ public List<Command> getAll() {
public <T extends Command> T get(Class<T> klass) {
return (T) commandInstances.get(klass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.systems.commands.arguments.ModuleArgumentType;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import net.minecraft.command.CommandSource;

import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
Expand All @@ -22,23 +23,48 @@ public ToggleCommand() {

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("module", ModuleArgumentType.module())
builder
.then(literal("all")
.executes(context -> {
for (Module module : Modules.get().getAll()) module.toggle();
return SINGLE_SUCCESS;
})
.then(literal("on")
.executes(context -> {
for (Module module : Modules.get().getAll()) {
if (!module.isActive()) module.toggle();
}
return SINGLE_SUCCESS;
})
)
.then(literal("off")
.executes(context -> {
for (Module module : Modules.get().getActive()) {
module.toggle();
}
return SINGLE_SUCCESS;
})
)
)
.then(argument("module", ModuleArgumentType.module())
.executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
m.toggle();
return SINGLE_SUCCESS;
}).then(literal("on")
.executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
if (!m.isActive()) m.toggle();
return SINGLE_SUCCESS;
})).then(literal("off")
.executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
if (m.isActive()) m.toggle();
return SINGLE_SUCCESS;
})
})
.then(literal("on")
.executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
if (!m.isActive()) m.toggle();
return SINGLE_SUCCESS;
}))
.then(literal("off")
.executes(context -> {
Module m = ModuleArgumentType.getModule(context, "module");
if (m.isActive()) m.toggle();
return SINGLE_SUCCESS;
})
)
);
);
}
}

0 comments on commit c8984b3

Please sign in to comment.