Search code examples
javabukkit

bukkit plugin.yml external var


i have started 1 day ago with scripting java and i am working with bukkit.

my question is how i can get&set values( variables ) into a external file (plugin.yml) ?

like this

plugin.yml

commandforx: ABC

main.java

if(cmd.getName().equalsIgnoreCase( *commandforx* )) ......

so my target is to get the var commandforx from plugin.yml to main.java

and heres my second question how i can save coordinates?

also set&get the coordinates over the plugin.yml...

thanks ahead


Solution

  • Don't store variables in plugin.yml. Instead you can use the FileConfiguration API that is in the Bukkit API by default! Here is a great tutorial on doing this: https://forums.bukkit.org/threads/tut-bukkits-new-fileconfiguration-api-create-a-yaml-configuration.42775/

    Or alternatively, you can just read and write from a defined file (Tutorials on this are everywhere online) and parse the input. This is more difficult then using the FileConfiguration API, but it's still very simple and gives you more control over the file (I always use this method).