Search in sources :

Example 11 with Feature

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

the class SetSliderCmd 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 slider setting
    if (!(setting instanceof SliderSetting))
        throw new CmdError(feature.getName() + " " + setting.getName() + " is not a slider setting.");
    SliderSetting sliderSetting = (SliderSetting) setting;
    // set value
    String valueName = args[2];
    if (valueName.equalsIgnoreCase("more"))
        sliderSetting.increaseValue();
    else if (valueName.equalsIgnoreCase("less"))
        sliderSetting.decreaseValue();
    else {
        // parse value
        if (!MiscUtils.isDouble(valueName))
            throw new CmdSyntaxError("Value must be a number.");
        double value = Double.parseDouble(valueName);
        // set value
        sliderSetting.setValue(value);
    }
}
Also used : SliderSetting(net.wurstclient.settings.SliderSetting) Setting(net.wurstclient.settings.Setting) Iterator(java.util.Iterator) SliderSetting(net.wurstclient.settings.SliderSetting) Feature(net.wurstclient.features.Feature)

Aggregations

Feature (net.wurstclient.features.Feature)11 Setting (net.wurstclient.settings.Setting)6 Iterator (java.util.Iterator)4 HashMap (java.util.HashMap)3 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 Rectangle (java.awt.Rectangle)2 ArrayList (java.util.ArrayList)2 ScaledResolution (net.minecraft.client.gui.ScaledResolution)2 WurstClient (net.wurstclient.WurstClient)2 CheckboxSetting (net.wurstclient.settings.CheckboxSetting)2 SliderSetting (net.wurstclient.settings.SliderSetting)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1