use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.
the class ToggleCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("all").then(literal("on").executes(context -> {
new ArrayList<>(Modules.get().getAll()).forEach(module -> {
if (!module.isActive() && !module.name.equals("panic"))
module.toggle();
});
HUD.get().active = true;
return SINGLE_SUCCESS;
})).then(literal("off").executes(context -> {
new ArrayList<>(Modules.get().getActive()).forEach(Module::toggle);
HUD.get().active = false;
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;
})));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.
the class EnchantCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("one").then(argument("enchantment", EnchantmentArgumentType.enchantment()).then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
one(context, enchantment -> context.getArgument("level", Integer.class));
return SINGLE_SUCCESS;
}))).then(literal("max").executes(context -> {
one(context, Enchantment::getMaxLevel);
return SINGLE_SUCCESS;
}))));
builder.then(literal("all_possible").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
all(true, enchantment -> context.getArgument("level", Integer.class));
return SINGLE_SUCCESS;
}))).then(literal("max").executes(context -> {
all(true, Enchantment::getMaxLevel);
return SINGLE_SUCCESS;
})));
builder.then(literal("all").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
all(false, enchantment -> context.getArgument("level", Integer.class));
return SINGLE_SUCCESS;
}))).then(literal("max").executes(context -> {
all(false, Enchantment::getMaxLevel);
return SINGLE_SUCCESS;
})));
builder.then(literal("clear").executes(context -> {
ItemStack itemStack = tryGetItemStack();
Utils.clearEnchantments(itemStack);
syncItem();
return SINGLE_SUCCESS;
}));
builder.then(literal("remove").then(argument("enchantment", EnchantmentArgumentType.enchantment()).executes(context -> {
ItemStack itemStack = tryGetItemStack();
Utils.removeEnchantment(itemStack, context.getArgument("enchantment", Enchantment.class));
syncItem();
return SINGLE_SUCCESS;
})));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.
the class EnemiesCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("add").then(argument("enemy", EnemyArgumentType.enemy()).executes(context -> {
Enemy enemy = EnemyArgumentType.getEnemy(context, "enemy");
if (Enemies.get().add(enemy)) {
if (enemy.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
info("Added (highlight)%s(default) to enemies.", enemy.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Added to enemies.", Config.get().toastDuration.get()));
} else {
if (enemy.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
error("(highlight)%s(default) is already your enemy.", enemy.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.RED + "Already your enemy.", Config.get().toastDuration.get()));
}
return SINGLE_SUCCESS;
})));
builder.then(literal("remove").then(argument("enemy", EnemyArgumentType.enemy()).executes(context -> {
Enemy enemy = EnemyArgumentType.getEnemy(context, "enemy");
if (Enemies.get().remove(enemy)) {
if (enemy.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
info("Removed (highlight)%s(default) from enemies.", enemy.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Removed from enemies.", Config.get().toastDuration.get()));
} else {
if (enemy.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
error("(highlight)%s(default) is not your enemy.", enemy.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.RED + "Not your enemy.", Config.get().toastDuration.get()));
}
return SINGLE_SUCCESS;
})));
builder.then(literal("list").executes(context -> {
info("--- Enemies ((highlight)%s(default)) ---", Enemies.get().count());
Enemies.get().forEach(enemy -> info("(highlight)" + enemy.name));
return SINGLE_SUCCESS;
}));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.
the class NotebotCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("status").executes(ctx -> {
Notebot notebot = Modules.get().get(Notebot.class);
notebot.printStatus();
return SINGLE_SUCCESS;
}));
builder.then(literal("pause").executes(ctx -> {
Notebot notebot = Modules.get().get(Notebot.class);
notebot.pause();
return SINGLE_SUCCESS;
}));
builder.then(literal("resume").executes(ctx -> {
Notebot notebot = Modules.get().get(Notebot.class);
notebot.pause();
return SINGLE_SUCCESS;
}));
builder.then(literal("stop").executes(ctx -> {
Notebot notebot = Modules.get().get(Notebot.class);
notebot.stop();
return SINGLE_SUCCESS;
}));
builder.then(literal("play").then(argument("name", StringArgumentType.greedyString()).executes(ctx -> {
Notebot notebot = Modules.get().get(Notebot.class);
String name = ctx.getArgument("name", String.class);
if (name == null || name.equals("")) {
throw INVALID_NAME.create();
}
Path path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.txt", name));
if (!path.toFile().exists()) {
path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.nbs", name));
}
notebot.loadSong(path.toFile());
return SINGLE_SUCCESS;
})));
builder.then(literal("preview").then(argument("name", StringArgumentType.greedyString()).executes(ctx -> {
Notebot notebot = Modules.get().get(Notebot.class);
String name = ctx.getArgument("name", String.class);
if (name == null || name == "") {
throw INVALID_NAME.create();
}
Path path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.txt", name));
if (!path.toFile().exists()) {
path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.nbs", name));
}
notebot.previewSong(path.toFile());
return SINGLE_SUCCESS;
})));
builder.then(literal("record").then(literal("start").executes(ctx -> {
ticks = -1;
song.clear();
MatHax.EVENT_BUS.subscribe(this);
info("Recording started");
return SINGLE_SUCCESS;
})));
builder.then(literal("record").then(literal("cancel").executes(ctx -> {
MatHax.EVENT_BUS.unsubscribe(this);
info("Recording cancelled");
return SINGLE_SUCCESS;
})));
builder.then(literal("record").then(literal("save").then(argument("name", StringArgumentType.greedyString()).executes(ctx -> {
String name = ctx.getArgument("name", String.class);
if (name == null || name == "") {
throw INVALID_NAME.create();
}
Path path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.txt", name));
saveRecording(path);
return SINGLE_SUCCESS;
}))));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project KiwiClient by TangyKiwi.
the class Enchant method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("one").then(argument("enchantment", EnchantmentArgumentType.enchantment()).then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
one(context, enchantment -> context.getArgument("level", Integer.class));
return SINGLE_SUCCESS;
}))).then(literal("max").executes(context -> {
one(context, Enchantment::getMaxLevel);
return SINGLE_SUCCESS;
}))));
builder.then(literal("all_possible").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
all(true, enchantment -> context.getArgument("level", Integer.class));
return SINGLE_SUCCESS;
}))).then(literal("max").executes(context -> {
all(true, Enchantment::getMaxLevel);
return SINGLE_SUCCESS;
})));
builder.then(literal("all").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
all(false, enchantment -> context.getArgument("level", Integer.class));
return SINGLE_SUCCESS;
}))).then(literal("max").executes(context -> {
all(false, Enchantment::getMaxLevel);
return SINGLE_SUCCESS;
})));
builder.then(literal("clear").executes(context -> {
ItemStack itemStack = tryGetItemStack();
Utils.clearEnchantments(itemStack);
syncItem();
return SINGLE_SUCCESS;
}));
builder.then(literal("remove").then(argument("enchantment", EnchantmentArgumentType.enchantment()).executes(context -> {
ItemStack itemStack = tryGetItemStack();
Utils.removeEnchantment(itemStack, context.getArgument("enchantment", Enchantment.class));
syncItem();
return SINGLE_SUCCESS;
})));
}
Aggregations