Solved Config returning null

Discussion in 'Plugin Development' started by girardcome, Jun 10, 2019.

  1. Offline

    girardcome

    Hello, i'm using ChatColor translateAlternateColorCodes on a message in a config file and when i want to display this message i obtain this error:

    Code:
    [12:23:31] [Server thread/ERROR]: nullorg.bukkit.command.CommandException: Unhandled exception executing command 'kits' in plugin HungerGames v1.0at 
    org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:645) ~[spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_192]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_192]at 
    net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:683) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at java.lang.Thread.run(Thread.java:813) [?:1.8.0_192]Caused by: java.lang.NullPointerExceptionat 
    org.bukkit.ChatColor.translateAlternateColorCodes(ChatColor.java:210) ~[spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]
    at fr.rachid.mcpvp.commands.Kits.onCommand(Kits.java:36) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigotmc-1.8-R0.1.jar:git-Spigot-59b08be-0899683]... 14 more
    The line is Kits.java:36 :
    PHP:
    p.sendMessage(ChatColor.translateAlternateColorCodes('&'plugin.message("Messages""error""kit_error_syntax")));
    The "plugin.message" method is:
    PHP:
    public String message(String stringString string2String string3) {

            return 
    plugin.getMessagesConfig().getString(string "." string2 "." string3);
        }
    MessageConfig is a custom message config..

    My messages.yml btw:
    Code:
    Messages:
      error:
        kit_error_syntax: '&cTo choose a kit do /kit <kitName>'
    Thank you in advance.
     
    Last edited: Jun 10, 2019
  2. Online

    KarimAKL

    @girardcome Does the file exist in the plugin's folder?
     
  3. Offline

    girardcome

    Yes
     
  4. Offline

    Kars

    plugin.getMessageConfig is returning null, calling .getString on it is causing the exception.

    Debug getMessageConfig or show it here.
     
  5. Offline

    FrostDeveloper

    @girardcome
    Has your message config been loaded? Perhaps in the getMessageConfig() method? Or in the method that created the file?
     

Share This Page