Solved Read prefix from config

Discussion in 'Plugin Development' started by Mauzuk, Jul 18, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Mauzuk

    Hi, I need help.
    I need to read the prefix entered by the user from the config.

    I tried this code:
    Code:
    public FileConfiguration cfg = this.getLang();
    public String prefix = cfg.getString("JoinMessage.prefix");
    
    But I'm still getting an error in the console after turning it on.
    Code:
    Caused by: java.lang.NullPointerException
        at me.Mauzuk.JoinMessage.Main.<init>(Main.java:15) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_261]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_261]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_261]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_261]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_261]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.16.1.jar:git-Spigot-0287a20-7560f5f]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.16.1.jar:git-Spigot-0287a20-7560f5f]
        ... 24 more
     
  2. Offline

    djbomber36

    can i see your full code and the config file?
     
Thread Status:
Not open for further replies.

Share This Page