Search in sources :

Example 1 with Module

use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.

the class ModuleListCommand method getComponent.

public static ITextComponent getComponent() {
    AbstractTextComponent component = new SimpleComponent("Modules: ");
    component.setWrap(true);
    List<Module> moduleList = Managers.MODULES.getRegistered().stream().sorted(Comparator.comparing(Displayable::getDisplayName)).collect(Collectors.toList());
    for (int i = 0; i < moduleList.size(); i++) {
        Module module = moduleList.get(i);
        if (module != null) {
            int finalI = i;
            ITextComponent sibling = new SuppliedComponent(() -> (module.isEnabled() ? TextColor.GREEN : TextColor.RED) + module.getName() + (finalI == moduleList.size() - 1 ? "" : ", ")).setWrap(true);
            Style style = new Style().setHoverEvent(ChatComponentUtil.setOffset(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(module.getData().getDescription())))).setClickEvent(new SmartClickEvent(ClickEvent.Action.RUN_COMMAND) {

                @Override
                public String getValue() {
                    return Commands.getPrefix() + "toggle " + module.getName();
                }
            });
            ((IStyle) style).setSuppliedInsertion(() -> Commands.getPrefix() + module.getName());
            ((IStyle) style).setMiddleClickEvent(new SmartClickEvent(ClickEvent.Action.RUN_COMMAND) {

                @Override
                public String getValue() {
                    return Commands.getPrefix() + module.getName();
                }
            });
            sibling.setStyle(style);
            component.appendSibling(sibling);
        }
    }
    return component;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) Displayable(me.earth.earthhack.api.util.interfaces.Displayable) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) AbstractTextComponent(me.earth.earthhack.impl.gui.chat.AbstractTextComponent) SuppliedComponent(me.earth.earthhack.impl.gui.chat.components.SuppliedComponent) TextComponentString(net.minecraft.util.text.TextComponentString) SmartClickEvent(me.earth.earthhack.impl.gui.chat.clickevents.SmartClickEvent) IStyle(me.earth.earthhack.impl.core.ducks.util.IStyle) SimpleComponent(me.earth.earthhack.impl.gui.chat.components.SimpleComponent) Style(net.minecraft.util.text.Style) IStyle(me.earth.earthhack.impl.core.ducks.util.IStyle) Module(me.earth.earthhack.api.module.Module)

Example 2 with Module

use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.

the class ToggleCommand method execute.

@Override
public void execute(String[] args) {
    if (args.length > 1) {
        Module module = Managers.MODULES.getObject(args[1]);
        if (module != null) {
            int times = 1;
            if (args.length > 2) {
                try {
                    times = Integer.parseInt(args[2]);
                } catch (NumberFormatException ignored) {
                    ChatUtil.sendMessage("<ToggleCommand> " + TextColor.RED + args[2] + " is not a valid number.");
                    return;
                }
            }
            String color = module.isEnabled() && times % 2 == 0 || !module.isEnabled() && times % 2 != 0 ? TextColor.GREEN : TextColor.RED;
            Managers.CHAT.sendDeleteMessage(color + "Toggling " + TextColor.WHITE + TextColor.BOLD + module.getDisplayName() + color + (times > 1 ? " " + times + "x." : "."), module.getName(), ChatIDs.MODULE);
            int finalTimes = times;
            Scheduler.getInstance().schedule(() -> {
                for (int i = 0; i < finalTimes; i++) {
                    module.toggle();
                }
            });
        } else {
            ChatUtil.sendMessage("<ToggleCommand> " + TextColor.RED + "Couldn't find " + args[1] + ".");
        }
        return;
    }
    ChatUtil.sendMessage("<ToggleCommand> " + TextColor.RED + "Usage is: " + this.getFullUsage());
}
Also used : Module(me.earth.earthhack.api.module.Module)

Example 3 with Module

use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.

the class HSettingCommand method execute.

@Override
public void execute(String[] args) {
    if (args.length > 2) {
        Module module = Managers.MODULES.getObject(args[1]);
        if (module != null) {
            Setting<?> setting = module.getSetting(args[2]);
            if (setting != null) {
                if (args.length == 3) {
                    String command = getCommand(setting, module);
                    Scheduler.getInstance().schedule(() -> mc.displayGuiScreen(new GuiChat(command)));
                } else {
                    update(setting, module, args, false);
                }
            }
        }
    }
}
Also used : GuiChat(net.minecraft.client.gui.GuiChat) Module(me.earth.earthhack.api.module.Module)

Example 4 with Module

use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.

the class HModulesCommand method execute.

@Override
public void execute(String[] args) {
    if (args.length > 1) {
        String name = args[1];
        Module module = Managers.MODULES.getObject(name);
        if (module != null) {
            if (Mouse.isButtonDown(1)) {
                mc.displayGuiScreen(new GuiChat(Commands.getPrefix() + module.getName() + " "));
            } else {
                module.toggle();
            }
        } else {
            ChatUtil.sendMessage(TextColor.RED + "An error occurred.");
        }
    }
}
Also used : GuiChat(net.minecraft.client.gui.GuiChat) Module(me.earth.earthhack.api.module.Module)

Example 5 with Module

use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.

the class PresetCommand method getPossibleInputs.

@Override
public PossibleInputs getPossibleInputs(String[] args) {
    if (args.length > 2) {
        if (args.length == 3) {
            Module module = Managers.MODULES.getObject(args[1]);
            if (module == null) {
                return PossibleInputs.empty();
            }
            ModuleData<?> data = module.getData();
            if (data == null) {
                return PossibleInputs.empty();
            }
            ModulePreset<?> preset = CommandUtil.getNameableStartingWith(args[2], data.getPresets());
            if (preset != null) {
                return new PossibleInputs(TextUtil.substring(preset.getName(), args[2].length()), "");
            }
        }
        return PossibleInputs.empty();
    }
    return super.getPossibleInputs(args);
}
Also used : PossibleInputs(me.earth.earthhack.api.command.PossibleInputs) Module(me.earth.earthhack.api.module.Module)

Aggregations

Module (me.earth.earthhack.api.module.Module)21 PossibleInputs (me.earth.earthhack.api.command.PossibleInputs)4 Setting (me.earth.earthhack.api.setting.Setting)4 Map (java.util.Map)3 Managers (me.earth.earthhack.impl.managers.Managers)3 CustomCommandModule (me.earth.earthhack.impl.util.helpers.command.CustomCommandModule)3 JsonElement (com.google.gson.JsonElement)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BooleanSetting (me.earth.earthhack.api.setting.settings.BooleanSetting)2 YesNoNonPausing (me.earth.earthhack.impl.commands.gui.YesNoNonPausing)2 ModuleUtil (me.earth.earthhack.impl.util.client.ModuleUtil)2 TextColor (me.earth.earthhack.impl.util.text.TextColor)2 GuiChat (net.minecraft.client.gui.GuiChat)2 GuiScreen (net.minecraft.client.gui.GuiScreen)2 ScaledResolution (net.minecraft.client.gui.ScaledResolution)2 JsonObject (com.google.gson.JsonObject)1 ChatFormatting (com.mojang.realmsclient.gui.ChatFormatting)1 java.awt (java.awt)1 InputStreamReader (java.io.InputStreamReader)1