import com.alibaba.fastjson.JSON;
import java.util.Map;

public class WeaponBulletConfig {
    private Map<String, Map<String, AxisParam>> configData;

    public static class AxisParam {
        private double X;
        private double Y;
        private double Z;

        public AxisParam() {}

        public AxisParam(double X, double Y, double Z) {
            this.X = X;
            this.Y = Y;
            this.Z = Z;
        }

        public double getX() { return X; }
        public double getY() { return Y; }
        public double getZ() { return Z; }

        public void setX(double X) { this.X = X; }
        public void setY(double Y) { this.Y = Y; }
        public void setZ(double Z) { this.Z = Z; }
    }

    public Map<String, Map<String, AxisParam>> getConfigData() {
        return configData;
    }

    public void setConfigData(Map<String, Map<String, AxisParam>> configData) {
        this.configData = configData;
    }

    public static WeaponBulletConfig loadFromJson(String jsonStr) {
        if (jsonStr == null || jsonStr.trim().isEmpty()) {
            throw new IllegalArgumentException("");
        }
        return JSON.parseObject(jsonStr, WeaponBulletConfig.class);
    }

    public AxisParam getParamByPathAndName(String configPath, String paramName) {
        if (configData == null || configPath == null || paramName == null) {
            return null;
        }
        Map<String, AxisParam> pathParams = configData.get(configPath);
        if (pathParams == null) {
            return null;
        }
        return pathParams.get(paramName);
    }

    public static void main(String[] args) {
        String configJson = "{" +
                "\"/Script/Engine.Game.Weapon.BulletParameters.Axis\":{\"Axis@Player.Character.Hold.Weapon.Fire.Shoot.FlyingBullet.AimOffset\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.Weapon.BulletParameters.556mm\":{\"HorizontalAxis@Player.Character.Hold556mmWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.Weapon.BulletParameters.762mm\":{\"HorizontalAxis@Player.Character.Hold762mmWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.Weapon.BulletParameters.9mm\":{\"HorizontalAxis@Player.Character.Hold9mmWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.Weapon.BulletParameters.57mm\":{\"HorizontalAxis@Player.Character.Hold57mmWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.ExcellentWeapon.BulletParameters.556mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition556mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.BlackHawkWeapon.BulletParameters.556mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition556mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.XuanYuanWeapon.BulletParameters.556mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition556mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.IronClawWeapon.BulletParameters.556mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition556mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.ExcellentWeapon.BulletParameters.57mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition57mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.BlackHawkWeapon.BulletParameters.57mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition57mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.IronClawWeapon.BulletParameters.57mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition57mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.XuanYuanWeapon.BulletParameters.57mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition57mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}," +
                "\"/Script/Engine.MetroEscape.ExcellentWeapon.BulletParameters.762mm.Competition\":{\"HorizontalAxis@Player.Character.HoldCompetition762mmBulletWeapon.Fire.FlyingBullet.Axis\":{\"X\":-5.0,\"Y\":3.0,\"Z\":0.0}}" +
                "}";

        WeaponBulletConfig config = WeaponBulletConfig.loadFromJson(configJson);
    }
}