private Preferences prefs;

public AimSettings() {
    prefs = Preferences.userRoot().node(NODE_PATH);
    loadDefaultSettings();
}

private void loadDefaultSettings() {
    if (prefs.get(AIM_SPEED, null) == null) {
        prefs.putInt(AIM_SPEED, 1);
        prefs.putFloat(SCOPE_SENSITIVITY, 1.0f);
        prefs.putFloat(ADS_MULTIPLIER, 0.85f);
        prefs.putFloat(X_FACTOR, 1.0f);
        prefs.putInt(SMOOTHING, 2);
        prefs.putInt(ACCELERATION, 0);
        prefs.putFloat(DEADZONE, 0.05f);
        prefs.putFloat(MAX_SPEED, 10.0f);
        prefs.putFloat(MIN_SPEED, 0.5f);
        prefs.putInt(PROFILE, 1);
        prefs.putInt(CUSTOM_CURVE, 0);
        prefs.putFloat(CURVE_EXPONENT, 1.8f);
        prefs.putInt(TOGGLE_ADS, 0);
        prefs.putInt(HOLD_ADS, 1);
        prefs.putInt(KEYBIND, 1);
        prefs.putInt(SCOPE_KEY, 2);
        prefs.putInt(ALT_SENSITIVITY, 0);
        prefs.putFloat(ALT_MULTIPLIER, 0.75f);
        prefs.putInt(WEAPON_SPECIFIC, 0);
        prefs.putFloat(SNIPER_MULTIPLIER, 0.65f);
        prefs.putFloat(AR_MULTIPLIER, 0.85f);
        prefs.putFloat(SMG_MULTIPLIER, 1.0f);
        prefs.putFloat(PISTOL_MULTIPLIER, 1.1f);
    }
}

public float calculateScopeSpeed(float baseSensitivity, int weaponType) {
    float multiplier = prefs.getFloat(ADS_MULTIPLIER, 0.85f);
    
    if (prefs.getInt(WEAPON_SPECIFIC, 0) == 1) {
        switch (weaponType) {
            case 1: multiplier = prefs.getFloat(SNIPER_MULTIPLIER, 0.65f); break;
            case 2: multiplier = prefs.getFloat(AR_MULTIPLIER, 0.85f); break;
            case 3: multiplier = prefs.getFloat(SMG_MULTIPLIER, 1.0f); break;
            case 4: multiplier = prefs.getFloat(PISTOL_MULTIPLIER, 1.1f); break;
        }
    }
    
    return baseSensitivity * multiplier;
}

public void updateSetting(String key, float value) {
    prefs.putFloat(key, value);
}

public void updateSetting(String key, int value) {
    prefs.putInt(key, value);
}

public float getFloatSetting(String key) {
    return prefs.getFloat(key, 0f);
}

public int getIntSetting(String key) {
    return prefs.getInt(key, 0);
}

public void resetToDefaults() {
    try {
        prefs.removeNode();
        prefs = Preferences.userRoot().node(NODE_PATH);
        loadDefaultSettings();
    } catch (Exception e) {}
}