Config: language.yml cannot find certain strings.

Discussion in 'Spigot Plugin Development' started by Bladian, May 17, 2015.

  1. I currently have my config like this:

    Code (Text):
    gui-chest-name: "&e&lMOUNTS"
    current-mounts-chest-name: "&e&lMOUNTS"
    rental-mounts-chest-name: "&e&lRENTAL MOUNTS"
    advertisement-chest-name: "&e&lADVERTISEMENTS AND SALES"

    gui:
      mounts-item: "&e&lMounts"
      rent-mount-item: "&e&lRent-A-Mount"
      advertisement: "&4&lAdvertisements and Sales"
      exit: "&4&lExit"

    mounts:
      chicken: Chicken
      cow: Cow
      pig: Pig
      sheep: Sheep
      zombie: Zombie
      creeper: Creeper
      spider: Spider
      skeleton: Skeleton
      enderman: Enderman

    buying:
      check: "&4&lAre you sure you want to buy his item?"
      yes: "&a&lYES"
      no: "&4&lNO"
    All of the above work, except when I try to use the buying.

    Code (Text):
     Inventory inventory = Bukkit.createInventory(p, 54, Configs.getLanguageConfig().getString("buying.check").replace("&", "§"));

            ItemStack yes = createItem(Material.EMERALD, 1, (byte) 0, Configs.getLanguageConfig().getString("buying.yes").replace("&", "§"), null);
            ItemStack no = createItem(Material.REDSTONE, 1, (byte) 0, Configs.getLanguageConfig().getString("buying.no").replace("&", "§"), null);
    All it does is return me with this error, but I'm not sure why it doesn't work.

    Code (Text):
    [20:07:59 ERROR]: Could not pass event InventoryClickEvent to Mounts v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot.jar:git-Spigot-dbe012b-61ef214]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-dbe012b-61ef214]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:1618) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.PacketPlayInWindowClick.a(SourceFile:31) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.PacketPlayInWindowClick.a(SourceFile:9) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [?:1.6.0_65]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [?:1.6.0_65]
        at java.util.concurrent.FutureTask.run(FutureTask.java:138) [?:1.6.0_65]
        at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:710) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-dbe012b-61ef214]
        at java.lang.Thread.run(Thread.java:695) [?:1.6.0_65]
    Caused by: java.lang.NullPointerException
        at me.mounts.core.Inventories.createChestCheck(Inventories.java:165) ~[?:?]
        at me.mounts.core.Events.onHeadClick(Events.java:192) ~[?:?]
        at me.mounts.core.Events.onClickMounts(Events.java:64) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot.jar:git-Spigot-dbe012b-61ef214]
        ... 16 more
     
    Any ideas on how I could fix this? All the other strings work except the buying.check and etc.

    The null pointer is caused by the buying.check not returning anything.
     
  2. is 'Configs' null?
     
  3. Continuing this,
    Make sure you get the instance of your Configs class inaide your code chunck.

    Configs c;

    @EventHandler
    public void brainFart(SomeEvent e){
    c = new Configs();
    c.somethingSomething();
    //more code
    }

    Sorry for not putting it in code tags I'm on mobile.
     
  4. Everything works except that specific buying section. Otherwise everything else works?