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);
}
}
Aggregations