Search in sources :

Example 1 with Mod

use of net.wurstclient.features.Mod in project Wurst-MC-1.12 by Wurst-Imperium.

the class TCmd method call.

@Override
public void call(String[] args) throws CmdException {
    int mode = -1;
    if (args.length == 1)
        mode = 0;
    else if (args.length == 2 && args[1].equalsIgnoreCase("on"))
        mode = 1;
    else if (args.length == 2 && args[1].equalsIgnoreCase("off"))
        mode = 2;
    else
        throw new CmdSyntaxError();
    Mod mod = wurst.mods.getModByName(args[0]);
    if (mod == null)
        throw new CmdError("Could not find mod \"" + args[0] + "\".");
    if (mode == 0)
        mod.toggle();
    else if (mode == 1 && !mod.isEnabled())
        mod.setEnabled(true);
    else if (mode == 2 && mod.isEnabled())
        mod.setEnabled(false);
}
Also used : Mod(net.wurstclient.features.Mod)

Example 2 with Mod

use of net.wurstclient.features.Mod in project Wurst-MC-1.12 by Wurst-Imperium.

the class KeybindProcessor method onKeyPress.

public void onKeyPress() {
    if (!WurstClient.INSTANCE.isEnabled())
        return;
    int keyCode = Keyboard.getEventKey();
    if (keyCode == 0 || !Keyboard.getEventKeyState())
        return;
    String keyName = Keyboard.getKeyName(keyCode);
    KeyPressEvent event = new KeyPressEvent(keyCode, keyName);
    WurstClient.INSTANCE.events.fire(event);
    String commands = keybinds.getCommands(keyName);
    if (commands == null)
        return;
    commands = commands.replace(";", "�").replace("��", ";");
    for (String command : commands.split("�")) {
        command = command.trim();
        if (command.startsWith("."))
            cmdProcessor.runCommand(command.substring(1));
        else if (command.contains(" "))
            cmdProcessor.runCommand(command);
        else {
            Mod mod = mods.getModByName(command);
            if (mod != null)
                mod.toggle();
            else
                cmdProcessor.runCommand(command);
        }
    }
}
Also used : Mod(net.wurstclient.features.Mod) KeyPressEvent(net.wurstclient.events.KeyPressListener.KeyPressEvent)

Example 3 with Mod

use of net.wurstclient.features.Mod in project Wurst-MC-1.12 by Wurst-Imperium.

the class NavigatorFeatureScreen method onResize.

@Override
protected void onResize() {
    buttonDatas.clear();
    // primary button
    String primaryAction = feature.getPrimaryAction();
    boolean hasPrimaryAction = !primaryAction.isEmpty();
    boolean hasHelp = !feature.getHelpPage().isEmpty();
    if (hasPrimaryAction) {
        primaryButton = new GuiButton(0, width / 2 - 151, height - 65, hasHelp ? 149 : 302, 18, primaryAction);
        buttonList.add(primaryButton);
    }
    // help button
    if (hasHelp)
        buttonList.add(new GuiButton(1, width / 2 + (hasPrimaryAction ? 2 : -151), height - 65, hasPrimaryAction ? 149 : 302, 20, "Help"));
    // type
    text = "Type: " + feature.getType();
    // category
    if (feature.getCategory() != null)
        text += ", Category: " + feature.getCategory().getName();
    // description
    String description = feature.getDescription();
    if (!description.isEmpty())
        text += "\n\nDescription:\n" + description;
    // area
    Rectangle area = new Rectangle(middleX - 154, 60, 308, height - 103);
    // settings
    ArrayList<Setting> settings = feature.getSettings();
    if (!settings.isEmpty()) {
        text += "\n\nSettings:";
        window.setY(Fonts.segoe15.getStringHeight(text) + 2);
        sliders.clear();
        checkboxes.clear();
        for (int i = 0; i < Math.ceil(window.getInnerHeight() / 9.0); i++) text += "\n";
        for (Setting setting : settings) if (setting.getComponent() == null)
            setting.addToFeatureScreen(this);
    }
    // keybinds
    ArrayList<PossibleKeybind> possibleKeybinds = feature.getPossibleKeybinds();
    if (!possibleKeybinds.isEmpty()) {
        // heading
        text += "\n\nKeybinds:";
        // add keybind button
        ButtonData addKeybindButton = new ButtonData(area.x + area.width - 16, area.y + Fonts.segoe15.getStringHeight(text) - 7, 12, 8, "+", 0x00ff00) {

            @Override
            public void press() {
                // add keybind
                mc.displayGuiScreen(new NavigatorNewKeybindScreen(possibleKeybinds, NavigatorFeatureScreen.this));
            }
        };
        buttonDatas.add(addKeybindButton);
        // keybind list
        HashMap<String, String> possibleKeybindsMap = new HashMap<>();
        for (PossibleKeybind possibleKeybind : possibleKeybinds) possibleKeybindsMap.put(possibleKeybind.getCommand(), possibleKeybind.getDescription());
        TreeMap<String, PossibleKeybind> existingKeybinds = new TreeMap<>();
        boolean noKeybindsSet = true;
        for (int i = 0; i < WurstClient.INSTANCE.getKeybinds().size(); i++) {
            Keybind keybind = WurstClient.INSTANCE.getKeybinds().get(i);
            String commands = keybind.getCommands();
            commands = commands.replace(";", "�").replace("��", ";");
            for (String command : commands.split("�")) {
                command = command.trim();
                String keybindDescription = possibleKeybindsMap.get(command);
                if (keybindDescription != null) {
                    if (noKeybindsSet)
                        noKeybindsSet = false;
                    text += "\n" + keybind.getKey() + ": " + keybindDescription;
                    existingKeybinds.put(keybind.getKey(), new PossibleKeybind(command, keybindDescription));
                } else if (feature instanceof Mod && command.equalsIgnoreCase(feature.getName())) {
                    if (noKeybindsSet)
                        noKeybindsSet = false;
                    text += "\n" + keybind.getKey() + ": " + "Toggle " + feature.getName();
                    existingKeybinds.put(keybind.getKey(), new PossibleKeybind(command, "Toggle " + feature.getName()));
                }
            }
        }
        if (noKeybindsSet)
            text += "\nNone";
        else {
            // remove keybind button
            buttonDatas.add(new ButtonData(addKeybindButton.x, addKeybindButton.y, addKeybindButton.width, addKeybindButton.height, "-", 0xff0000) {

                @Override
                public void press() {
                    // remove keybind
                    mc.displayGuiScreen(new NavigatorRemoveKeybindScreen(existingKeybinds, NavigatorFeatureScreen.this));
                }
            });
            addKeybindButton.x -= 16;
        }
    }
    // see also
    Feature[] seeAlso = feature.getSeeAlso();
    if (seeAlso.length != 0) {
        text += "\n\nSee also:";
        for (Feature seeAlsoFeature : seeAlso) {
            int y = 60 + getTextHeight() + 2;
            String name = seeAlsoFeature.getName();
            text += "\n- " + name;
            buttonDatas.add(new ButtonData(middleX - 148, y, Fonts.segoe15.getStringWidth(name) + 1, 8, "", 0x404040) {

                @Override
                public void press() {
                    mc.displayGuiScreen(new NavigatorFeatureScreen(seeAlsoFeature, parent));
                }
            });
        }
    }
    // text height
    setContentHeight(Fonts.segoe15.getStringHeight(text));
}
Also used : PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind) Mod(net.wurstclient.features.Mod) HashMap(java.util.HashMap) Setting(net.wurstclient.settings.Setting) SliderSetting(net.wurstclient.settings.SliderSetting) CheckboxSetting(net.wurstclient.settings.CheckboxSetting) Rectangle(java.awt.Rectangle) TreeMap(java.util.TreeMap) NavigatorNewKeybindScreen(net.wurstclient.keybinds.NavigatorNewKeybindScreen) Feature(net.wurstclient.features.Feature) NavigatorRemoveKeybindScreen(net.wurstclient.keybinds.NavigatorRemoveKeybindScreen) GuiButton(net.minecraft.client.gui.GuiButton) Keybind(net.wurstclient.keybinds.KeybindList.Keybind) PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind)

Example 4 with Mod

use of net.wurstclient.features.Mod in project Wurst-MC-1.12 by Wurst-Imperium.

the class ModsConfig method saveToJson.

@Override
protected JsonElement saveToJson() {
    JsonObject json = new JsonObject();
    JsonObject jsonMod = new JsonObject();
    jsonMod.addProperty("enabled", true);
    for (Mod mod : WurstClient.INSTANCE.mods.getAllMods()) if (mod.isEnabled() && mod.isStateSaved())
        json.add(mod.getName(), jsonMod);
    return json;
}
Also used : Mod(net.wurstclient.features.Mod) JsonObject(com.google.gson.JsonObject)

Example 5 with Mod

use of net.wurstclient.features.Mod in project Wurst-MC-1.12 by Wurst-Imperium.

the class FeaturesCmd method call.

@Override
public void call(String[] args) throws CmdException {
    if (args.length != 0)
        throw new CmdSyntaxError();
    ChatUtils.message("> All features: " + wurst.navigator.countAllFeatures());
    ChatUtils.message("> Mods: " + wurst.mods.countMods());
    ChatUtils.message("> Commands: " + wurst.commands.countCommands());
    ChatUtils.message("> Special features: " + wurst.special.countFeatures());
    int settings = 0, bypasses = 0;
    for (Mod mod : wurst.mods.getAllMods()) {
        settings += mod.getSettings().size();
        if (mod.getClass().getAnnotation(Mod.Bypasses.class).mineplex())
            bypasses++;
    }
    ChatUtils.message("> NoCheat bypasses (mods only): " + bypasses);
    for (Cmd cmd : wurst.commands.getAllCommands()) settings += cmd.getSettings().size();
    for (Spf spf : wurst.special.getAllFeatures()) settings += spf.getSettings().size();
    ChatUtils.message("> Settings: " + settings);
}
Also used : Mod(net.wurstclient.features.Mod) Spf(net.wurstclient.features.Spf) Cmd(net.wurstclient.features.Cmd)

Aggregations

Mod (net.wurstclient.features.Mod)6 JsonObject (com.google.gson.JsonObject)2 JsonElement (com.google.gson.JsonElement)1 Rectangle (java.awt.Rectangle)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 GuiButton (net.minecraft.client.gui.GuiButton)1 KeyPressEvent (net.wurstclient.events.KeyPressListener.KeyPressEvent)1 Cmd (net.wurstclient.features.Cmd)1 Feature (net.wurstclient.features.Feature)1 Spf (net.wurstclient.features.Spf)1 Keybind (net.wurstclient.keybinds.KeybindList.Keybind)1 NavigatorNewKeybindScreen (net.wurstclient.keybinds.NavigatorNewKeybindScreen)1 NavigatorRemoveKeybindScreen (net.wurstclient.keybinds.NavigatorRemoveKeybindScreen)1 PossibleKeybind (net.wurstclient.keybinds.PossibleKeybind)1 CheckboxSetting (net.wurstclient.settings.CheckboxSetting)1 Setting (net.wurstclient.settings.Setting)1 SliderSetting (net.wurstclient.settings.SliderSetting)1