use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project meteor-client by MeteorDevelopment.
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 meteor-client by MeteorDevelopment.
the class FriendsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("add").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
Friend friend = FriendArgumentType.getFriend(context, "friend");
if (Friends.get().add(friend))
info("Added (highlight)%s (default)to friends.", friend.name);
else
error("That person is already your friend.");
return SINGLE_SUCCESS;
})));
builder.then(literal("remove").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
Friend friend = FriendArgumentType.getFriend(context, "friend");
if (Friends.get().remove(friend))
info("Removed (highlight)%s (default)from friends.", friend.name);
else
error("That person is not your friend.");
return SINGLE_SUCCESS;
})));
builder.then(literal("list").executes(context -> {
info("--- Friends ((highlight)%s(default)) ---", Friends.get().count());
Friends.get().forEach(friend -> ChatUtils.info("(highlight)" + friend.name));
return SINGLE_SUCCESS;
}));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.
the class LocateCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("buried_treasure").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a treasure map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Buried Treasure located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("lodestone").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.COMPASS) {
error("You need to hold a lodestone compass");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
if (tag == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
NbtCompound nbt1 = tag.getCompound("LodestonePos");
if (nbt1 == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(nbt1.getDouble("X"), nbt1.getDouble("Y"), nbt1.getDouble("Z"));
BaseText text = new LiteralText("Lodestone located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("mansion").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a woodland explorer map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Mansion located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("stronghold").executes(s -> {
FindItemResult eye = InvUtils.findInHotbar(Items.ENDER_EYE);
if (eye.found()) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
firstStart = null;
firstEnd = null;
secondStart = null;
secondEnd = null;
MatHax.EVENT_BUS.subscribe(this);
info("Please throw the first Eye of Ender");
} else {
Vec3d coords = findByBlockList(strongholdBlocks);
if (coords == null) {
error("No stronghold found nearby. You can use (highlight)Ender Eyes(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Stronghold located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("nether_fortress").executes(s -> {
Vec3d coords = findByBlockList(netherFortressBlocks);
if (coords == null) {
error("No nether fortress found.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Fortress located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("monument").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() == Items.FILLED_MAP) {
NbtCompound tag = stack.getNbt();
if (tag != null) {
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 != null) {
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT != null) {
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}
}
}
}
Vec3d coords = findByBlockList(monumentBlocks);
if (coords == null) {
error("No monument found. You can try using a (highlight)Ocean explorer map(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("cancel").executes(s -> {
cancel();
return SINGLE_SUCCESS;
}));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.
the class FriendsCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("add").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
Friend friend = FriendArgumentType.getFriend(context, "friend");
if (Friends.get().add(friend)) {
if (friend.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
info("Added (highlight)%s(default) to friends.", friend.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Added to friends.", Config.get().toastDuration.get()));
} else {
if (friend.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
error("(highlight)%s(default) is already your friend.", friend.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.RED + "Already your friend.", Config.get().toastDuration.get()));
}
return SINGLE_SUCCESS;
})));
builder.then(literal("remove").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
Friend friend = FriendArgumentType.getFriend(context, "friend");
if (Friends.get().remove(friend)) {
if (friend.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
info("Removed (highlight)%s(default) from friends.", friend.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Removed from friends.", Config.get().toastDuration.get()));
} else {
if (friend.name.equals(mc.getSession().getUsername()))
return SINGLE_SUCCESS;
if (Config.get().chatFeedback.get())
error("(highlight)%s(default) is not your friend.", friend.name);
if (Config.get().toastFeedback.get())
mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.RED + "Not your friend.", Config.get().toastDuration.get()));
}
return SINGLE_SUCCESS;
})));
builder.then(literal("list").executes(context -> {
info("--- Friends ((highlight)%s(default)) ---", Friends.get().count());
Friends.get().forEach(friend -> info("(highlight)" + friend.name));
return SINGLE_SUCCESS;
}));
}
use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.
the class NbtCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("add").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtCompound tag = CompoundNbtTagArgumentType.getNbt(s, "nbt_data");
NbtCompound source = stack.getOrCreateNbt();
if (tag != null) {
source.copyFrom(tag);
setStack(stack);
} else {
error("Some of the NBT data could not be found, try using: " + Config.get().prefix + "nbt set {nbt}");
}
}
return SINGLE_SUCCESS;
})));
builder.then(literal("set").then(argument("nbt_data", CompoundNbtTagArgumentType.nbtTag()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtCompound tag = s.getArgument("nbt_data", NbtCompound.class);
stack.setNbt(tag);
setStack(stack);
}
return SINGLE_SUCCESS;
})));
builder.then(literal("remove").then(argument("nbt_path", NbtPathArgumentType.nbtPath()).executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
NbtPathArgumentType.NbtPath path = s.getArgument("nbt_path", NbtPathArgumentType.NbtPath.class);
path.remove(stack.getNbt());
}
return SINGLE_SUCCESS;
})));
builder.then(literal("get").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack == null) {
error("You must hold an item in your main hand.");
} else {
NbtCompound tag = stack.getNbt();
String nbt = tag == null ? "{}" : tag.asString();
BaseText copyButton = new LiteralText("NBT");
copyButton.setStyle(copyButton.getStyle().withFormatting(Formatting.UNDERLINE).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, this.toString("copy"))).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Copy the NBT data to your clipboard."))));
BaseText text = new LiteralText("");
text.append(copyButton);
text.append(new LiteralText(": " + nbt));
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("copy").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack == null) {
error("You must hold an item in your main hand.");
} else {
NbtCompound tag = stack.getOrCreateNbt();
mc.keyboard.setClipboard(tag.toString());
BaseText nbt = new LiteralText("NBT");
nbt.setStyle(nbt.getStyle().withFormatting(Formatting.UNDERLINE).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(tag.toString()))));
BaseText text = new LiteralText("");
text.append(nbt);
text.append(new LiteralText(" data copied!"));
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("count").then(argument("count", IntegerArgumentType.integer(-127, 127)).executes(context -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (validBasic(stack)) {
int count = IntegerArgumentType.getInteger(context, "count");
stack.setCount(count);
setStack(stack);
info("Set mainhand stack count to %s.", count);
}
return SINGLE_SUCCESS;
})));
}
Aggregations