import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class GameConfig {

    private Properties properties;

    public GameConfig(String configFilePath) {
        properties = new Properties();
        try (InputStream input = new FileInputStream(configFilePath)) {
            properties.load(input);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getProperty(String key) {
        return properties.getProperty(key);
    }

    public void injectPackage() {
        String packageName = getProperty("com.tencent.tmgp.pubgmhd");
        if (packageName != null && !packageName.isEmpty()) {
            System.out.println("Injecting into package: " + packageName);
            // 这里可以添加实际的注入逻辑
        } else {
            System.out.println("No package name specified for injection.");
        }
    }

    public void printWeaponConfig() {
        String distance = getProperty("Weapon_AUG.distance");
        String aimMode = getProperty("Weapon_AUG.aim_mode");
        String damage = getProperty("Weapon_AUG.damage");
        String fireRate = getProperty("Weapon_AUG.fire_rate");
        String recoil = getProperty("Weapon_AUG.recoil");
        String magazineSize = getProperty("Weapon_AUG.magazine_size");

        System.out.println("\nWeapon Configuration:");
        System.out.println("Distance: " + distance + "m");
        System.out.println("Aim Mode: " + aimMode);
        System.out.println("Damage: " + damage);
        System.out.println("Fire Rate: " + fireRate + "s");
        System.out.println("Recoil: " + recoil);
        System.out.println("Magazine Size: " + magazineSize);

        // 根据配置实现逻辑
        if ("head".equals(aimMode)) {
            System.out.println("Aiming at head within " + distance + "m distance.");
        } else if ("body".equals(aimMode)) {
            System.out.println("Aiming at body within " + distance + "m distance.");
        } else {
            System.out.println("Invalid aim mode.");
        }
    }

    public void printPlayerSettings() {
        String sensitivity = getProperty("PlayerSettings.sensitivity");
        String autoFire = getProperty("PlayerSettings.auto_fire");
        String aimAssist = getProperty("PlayerSettings.aim_assist");

        System.out.println("\nPlayer Settings:");
        System.out.println("Sensitivity: " + sensitivity);
        System.out.println("Auto Fire: " + autoFire);
        System.out.println("Aim Assist: " + aimAssist);
    }

    public static void main(String[] args) {
        // 加载配置文件
        GameConfig config = new GameConfig("config.ini");

        // 打印游戏配置
        System.out.println("Game Configuration:");
        System.out.println("Version: " + config.getProperty("GameConfig.version"));
        System.out.println("Description: " + config.getProperty("GameConfig.description"));

        // 注入包名逻辑
        config.injectPackage();

        // 打印武器配置
        config.printWeaponConfig();

        // 打印玩家设置
        config.printPlayerSettings();
    }
}