Search in sources :

Example 1 with ModeSetting

use of net.wurstclient.settings.ModeSetting in project Wurst-MC-1.12 by Wurst-Imperium.

the class SetModeCmd method call.

@Override
public void call(String[] args) throws CmdException {
    if (args.length != 3)
        throw new CmdSyntaxError();
    // find feature
    Feature feature = null;
    String featureName = args[0];
    for (Iterator itr = wurst.navigator.iterator(); itr.hasNext(); ) {
        Feature item = (Feature) itr.next();
        if (featureName.equalsIgnoreCase(item.getName())) {
            feature = item;
            break;
        }
    }
    if (feature == null)
        throw new CmdError("A feature named \"" + featureName + "\" could not be found.");
    // find setting
    Setting setting = null;
    String settingName = args[1].replace("_", " ");
    for (Setting featureSetting : feature.getSettings()) if (featureSetting.getName().equalsIgnoreCase(settingName)) {
        setting = featureSetting;
        break;
    }
    if (setting == null)
        throw new CmdError("A setting named \"" + settingName + "\" could not be found in " + feature.getName() + ".");
    // check that setting is mode setting
    if (!(setting instanceof ModeSetting))
        throw new CmdError(feature.getName() + " " + setting.getName() + " is not a mode setting.");
    ModeSetting modeSetting = (ModeSetting) setting;
    // set mode
    String modeName = args[2].replace("_", " ");
    if (modeName.equalsIgnoreCase("next"))
        modeSetting.nextMode();
    else if (modeName.equalsIgnoreCase("prev"))
        modeSetting.prevMode();
    else {
        // find mode
        int mode = modeSetting.indexOf(modeName);
        if (mode == -1)
            throw new CmdError("A " + feature.getName() + " " + setting.getName() + " named \"" + modeName + "\" could not be found.");
        // set mode
        modeSetting.setSelected(mode);
    }
}
Also used : ModeSetting(net.wurstclient.settings.ModeSetting) Setting(net.wurstclient.settings.Setting) ModeSetting(net.wurstclient.settings.ModeSetting) Iterator(java.util.Iterator) Feature(net.wurstclient.features.Feature)

Example 2 with ModeSetting

use of net.wurstclient.settings.ModeSetting in project Wurst-MC-1.12 by Wurst-Imperium.

the class AutoBuildMod method setTemplates.

public void setTemplates(TreeMap<String, int[][]> templates) {
    // TODO: Find a better way to do this.
    getSettings().clear();
    addSetting(mode);
    addSetting(useAi);
    this.templates = templates.values().toArray(new int[templates.size()][][]);
    int selected;
    if (template != null && template.getSelected() < templates.size())
        selected = template.getSelected();
    else
        selected = 0;
    template = new ModeSetting("Template", templates.keySet().toArray(new String[templates.size()]), selected);
    addSetting(template);
}
Also used : ModeSetting(net.wurstclient.settings.ModeSetting)

Aggregations

ModeSetting (net.wurstclient.settings.ModeSetting)2 Iterator (java.util.Iterator)1 Feature (net.wurstclient.features.Feature)1 Setting (net.wurstclient.settings.Setting)1