我有兩個類「主要」的命令和更多的事件和「事件」,現在 我想讓事件「PlayerdeathEvent」傳送我到一個點,從點的座標保存在一個配置現在我測試:Java(Bukkit)如何訪問Config與此?
我在事件類使它
public void lbbkampfrespawn() { FileConfiguration cfg = this.getConfig(); { String world = cfg.getString("LBBsetkampfrespawn1.world"); double x = cfg.getDouble("LBBsetkampfrespawn1.x"); double y = cfg.getDouble("LBBsetkampfrespawn1.y"); double z = cfg.getDouble("LBBsetkampfrespawn1.z"); double yaw = cfg.getDouble("LBBsetkampfrespawn1.yaw"); double pitch = cfg.getDouble("LBBsetkampfrespawn1.pitch"); Location loc = new Location(Bukkit.getWorld(world), x, y, z); loc.setYaw((float) yaw); loc.setPitch((float) pitch); p1.teleport(loc); } { String world = cfg.getString("LBBsetkampfrespawn2.world"); double x = cfg.getDouble("LBBsetkampfrespawn2.x"); double y = cfg.getDouble("LBBsetkampfrespawn2.y"); double z = cfg.getDouble("LBBsetkampfrespawn2.z"); double yaw = cfg.getDouble("LBBsetkampfrespawn2.yaw"); double pitch = cfg.getDouble("LBBsetkampfrespawn2.pitch"); Location loc = new Location(Bukkit.getWorld(world), x, y, z); loc.setYaw((float) yaw); loc.setPitch((float) pitch); p2.teleport(loc); } } }
問題: 的不知道關於"getConfig()"
日食說我crathe方法getConfig()
i相靜態
public static void lbbkampfrespawn() { FileConfiguration cfg = this.getConfig(); { String world = cfg.getString("LBBsetkampfrespawn1.world"); double x = cfg.getDouble("LBBsetkampfrespawn1.x"); double y = cfg.getDouble("LBBsetkampfrespawn1.y"); double z = cfg.getDouble("LBBsetkampfrespawn1.z"); double yaw = cfg.getDouble("LBBsetkampfrespawn1.yaw"); double pitch = cfg.getDouble("LBBsetkampfrespawn1.pitch"); Location loc = new Location(Bukkit.getWorld(world), x, y, z); loc.setYaw((float) yaw); loc.setPitch((float) pitch); p1.teleport(loc); } { String world = cfg.getString("LBBsetkampfrespawn2.world"); double x = cfg.getDouble("LBBsetkampfrespawn2.x"); double y = cfg.getDouble("LBBsetkampfrespawn2.y"); double z = cfg.getDouble("LBBsetkampfrespawn2.z"); double yaw = cfg.getDouble("LBBsetkampfrespawn2.yaw"); double pitch = cfg.getDouble("LBBsetkampfrespawn2.pitch"); Location loc = new Location(Bukkit.getWorld(world), x, y, z); loc.setYaw((float) yaw); loc.setPitch((float) pitch); p2.teleport(loc); } }
問題使它在主類:我不能USET此。在靜態
我必須做的感謝您的幫助!
當你需要更多的鱈魚,請發送什麼。
謝謝。 Sry基因的拼寫