请问Bukkit开发里面这个vector老是读不到正确的数值是什么情况啊,
getVectorFromConfig()方法老是读取不到正确数值
public void loadRegions() {
ConfigurationSection section = regionConfig.getConfigurationSection("regions");
if (section != null) {
for (String regionName : section.getKeys(false)) {
String owner = section.getString(regionName + ".owner");
Vector firstPoint = getVectorFromConfig(section, regionName, "firstPoint");
Vector secondPoint = getVectorFromConfig(section, regionName, "secondPoint");
System.out.println("Loaded region: " + regionName + ", owner: " + owner);
System.out.println(String.format("First Point: %.2f, %.2f, %.2f", firstPoint.getX(), firstPoint.getY(), firstPoint.getZ()));
System.out.println(String.format("Second Point: %.2f, %.2f, %.2f", secondPoint.getX(), secondPoint.getY(), secondPoint.getZ()));
Region region = new Region(owner, regionName, firstPoint, secondPoint);
regions.put(regionName, region);
}
} else {
System.out.println("没有找到 regions 配置部分!");
}
}
// 从配置中读取一个向量
public Vector getVectorFromConfig(ConfigurationSection section, String regionName, String pointName) {
// 构造配置路径
String basePath = "regions." + regionName + "." + pointName;
System.out.println("Loading vector from path: " + basePath);
// 获取坐标
double x = section.getDouble(basePath + ".x"); // 设置默认值为 0.0
double y = section.getDouble(basePath + ".y");
double z = section.getDouble(basePath + ".z");
// 输出坐标
System.out.println("x: " + x + ", y: " + y + ", z: " + z);
// 返回坐标向量
return new Vector(x, y, z);
}
为什么控制台读出来的数和我的老是不一样,文件的owner和领地名称它能读到,说明文件和路径没问题,就是这个坐标读取有问题,哪位有经验的能帮忙看看
控制台输出:
[17:29:25] [Server thread/INFO]: [Residence] Enabling Residence v1.0_Alpha
[17:29:25] [Server thread/INFO]: [Residence] Starting Residence...
[17:29:25] [Server thread/INFO]: Loading vector from path: regions.666.firstPoint
[17:29:25] [Server thread/INFO]: x: 0.0, y: 0.0, z: 0.0
[17:29:25] [Server thread/INFO]: Loading vector from path: regions.666.secondPoint
[17:29:25] [Server thread/INFO]: x: 0.0, y: 0.0, z: 0.0
[17:29:25] [Server thread/INFO]: Loaded region: 666, owner: qianhe520
[17:29:25] [Server thread/INFO]: First Point: 0.00, 0.00, 0.00
[17:29:25] [Server thread/INFO]: Second Point: 0.00, 0.00, 0.00
[17:29:25] [Server thread/INFO]: [Residence] Regions loaded successfully.
[17:29:25] [Server thread/INFO]: [Residence] Residence plugin enabled.
我的文件
regions:
666:
owner: qianhe520
firstPoint:
x: 1.0
y: 2.0
z: 3.0
secondPoint:
x: 4.0
y: 5.0
z: 6.0