Search in sources :

Example 1 with ToastSystem

use of mathax.client.utils.render.ToastSystem in project Client by MatHax.

the class Modules method onBinding.

private boolean onBinding(boolean isKey, int value) {
    if (moduleToBind != null && moduleToBind.keybind.canBindTo(isKey, value)) {
        if (value != GLFW.GLFW_KEY_ESCAPE) {
            moduleToBind.keybind.set(isKey, value);
            ChatUtils.info("KeyBinds", "Module (highlight)%s (default)bound to (highlight)%s(default).", moduleToBind.title, moduleToBind.keybind);
            mc.getToastManager().add(new ToastSystem(moduleToBind.icon, moduleToBind.category.color, moduleToBind.title, null, Formatting.GRAY + "Bound to " + Formatting.WHITE + moduleToBind.keybind + Formatting.GRAY + ".", Config.get().toastDuration.get()));
        }
        MatHax.EVENT_BUS.post(ModuleBindChangedEvent.get(moduleToBind));
        moduleToBind = null;
        return true;
    }
    return false;
}
Also used : ToastSystem(mathax.client.utils.render.ToastSystem)

Example 2 with ToastSystem

use of mathax.client.utils.render.ToastSystem 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;
    }));
}
Also used : Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) Collection(java.util.Collection) CompletableFuture(java.util.concurrent.CompletableFuture) Items(net.minecraft.item.Items) Enemies(mathax.client.systems.enemies.Enemies) ArgumentType(com.mojang.brigadier.arguments.ArgumentType) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Config(mathax.client.systems.config.Config) Enemy(mathax.client.systems.enemies.Enemy) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Formatting(net.minecraft.util.Formatting) List(java.util.List) CommandSource.suggestMatching(net.minecraft.command.CommandSource.suggestMatching) Command(mathax.client.systems.commands.Command) StringReader(com.mojang.brigadier.StringReader) ToastSystem(mathax.client.utils.render.ToastSystem) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) Enemy(mathax.client.systems.enemies.Enemy) ToastSystem(mathax.client.utils.render.ToastSystem)

Example 3 with ToastSystem

use of mathax.client.utils.render.ToastSystem 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;
    }));
}
Also used : Suggestions(com.mojang.brigadier.suggestion.Suggestions) Friends(mathax.client.systems.friends.Friends) CommandContext(com.mojang.brigadier.context.CommandContext) Collection(java.util.Collection) CompletableFuture(java.util.concurrent.CompletableFuture) Items(net.minecraft.item.Items) ArgumentType(com.mojang.brigadier.arguments.ArgumentType) Friend(mathax.client.systems.friends.Friend) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Config(mathax.client.systems.config.Config) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Formatting(net.minecraft.util.Formatting) List(java.util.List) CommandSource.suggestMatching(net.minecraft.command.CommandSource.suggestMatching) Command(mathax.client.systems.commands.Command) StringReader(com.mojang.brigadier.StringReader) ToastSystem(mathax.client.utils.render.ToastSystem) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) Friend(mathax.client.systems.friends.Friend) ToastSystem(mathax.client.utils.render.ToastSystem)

Aggregations

ToastSystem (mathax.client.utils.render.ToastSystem)3 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)2 StringReader (com.mojang.brigadier.StringReader)2 ArgumentType (com.mojang.brigadier.arguments.ArgumentType)2 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)2 CommandContext (com.mojang.brigadier.context.CommandContext)2 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)2 Suggestions (com.mojang.brigadier.suggestion.Suggestions)2 SuggestionsBuilder (com.mojang.brigadier.suggestion.SuggestionsBuilder)2 Collection (java.util.Collection)2 List (java.util.List)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Collectors (java.util.stream.Collectors)2 Command (mathax.client.systems.commands.Command)2 Config (mathax.client.systems.config.Config)2 CommandSource (net.minecraft.command.CommandSource)2 CommandSource.suggestMatching (net.minecraft.command.CommandSource.suggestMatching)2 Items (net.minecraft.item.Items)2 Formatting (net.minecraft.util.Formatting)2 Enemies (mathax.client.systems.enemies.Enemies)1