I tried saving/reading a location from the config file with th following code: Code (Java): this.saveDefaultConfig(); World wrld = Bukkit.getServer().getWorld(this.getConfig().getString("afkWarp.world")); // Bukkit.getLogger().info("[[[[[[[World read from config is " + wrld + "]]]]]]]"); if (wrld != null) { WarpLocation.setWorld(wrld);} else { Bukkit.getLogger().info("[[[[[[[World read from config is null.]]]]]]]"); } WarpLocation.setX(this.getConfig().getDouble("afkWarp.x")); WarpLocation.setY(this.getConfig().getDouble("afkWarp.y")); WarpLocation.setZ(this.getConfig().getDouble("afkWarp.z")); WarpLocation.setYaw((float)this.getConfig().getDouble("afkWarp.yaw")); WarpLocation.setPitch((float)this.getConfig().getDouble("afkWarp.pitch")); Bukkit.getLogger().info("[[[[[[[Position of AFK warp read from the config is " + WarpLocation + "]]]]]]]"); commands.loadedFromConfig = WarpLocation; My default config.yml Code (Text): #This is the default configuration file. #Please don't change values unless you know what you are doing. afkWarp: world: world x: 0.0 y: 0.0 z: 100.0 pitch: 0.0 yaw: 0.0 For some reason, Code (Text): if (wrld != null) { WarpLocation.setWorld(wrld);} else { Bukkit.getLogger().info("[[[[[[[World read from config is null.]]]]]]]"); } gives an error. If I comment the line, the next line gives one. Please help. (Code samples appreciated) Thanks!
To save a location: FileConfiguration#set("path", Location) To fetch a location: FileConfiguration#getLocation("path")
I got these errors: Code (Text): Description Resource Path Location Type FileConfiguration cannot be resolved to a variable Main.java /AFKTP/src/me/Ma100/afktp line 40 Java Problem Syntax error on token "Invalid Character", ; expected Main.java /AFKTP/src/me/Ma100/afktp line 40 Java Problem The method getLocation(String) is undefined for the type Main Main.java /AFKTP/src/me/Ma100/afktp line 40 Java Problem
WarpLocation... Why are you using a WarpLocation class? Use Location instead. Give us the stacktrace That works too, but he can fix his system. Many IDEs have auto importing functions, like IntelliJ. They're useful if you don't know imports Well what is on line 40?
WarpLocation is my Location variable. On line 40 is : Code (Java): WarpLocation = FileConfiguration#getLocation("afkWarp.position");
Please learn basic Java. When I said FileConfiguration#whatever I didn't mean that you would have to litterally use it.. I meant that this is the method that you have to call on a FileConfiguration object that is returned by JavaPlugin#getConfig
Other developers can always tell when somebody knows a programming language well or not. You will find benefit from learning fundamentals of java before moving into spigot development. We are not here to spoon feed you answers.