import org.ini4j.Ini;
import org.ini4j.Profile;

import java.io.File;
import java.io.IOException;

public class IniExample {
    public static void main(String[] args) {
        try {
            // 创建Ini对象
            Ini ini = new Ini(new File("config.ini"));

            // 读取子弹散布配置
            double defaultBulletSpread = Double.parseDouble(ini.get("Weapons", "DefaultBulletSpread"));
            double defaultBulletSpreadReduction = Double.parseDouble(ini.get("Weapons", "DefaultBulletSpreadReduction"));

            System.out.println("Default Bullet Spread: " + defaultBulletSpread);
            System.out.println("Default Bullet Spread Reduction: " + defaultBulletSpreadReduction);

            // 减少子弹散布
            double newBulletSpread = defaultBulletSpread * defaultBulletSpreadReduction;
            ini.put("Weapons", "DefaultBulletSpread", String.valueOf(newBulletSpread));

            // 保存修改
            ini.store();

            System.out.println("Bullet spread reduced to: " + newBulletSpread);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
