Solved Path just doesn't work

Discussion in 'Plugin Development' started by yPedx, Jun 23, 2017.

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

    yPedx

    I'm 100% sure I have set the correct path aswell as all the spaces in the config loaded when server started are correct.
    It acts like the path isn't there, it doesn't exist.. But it does..
    Code:
    Code:
     Removed 
    Config:
    Code:
     Removed 
    Any ideas?
    if(!this.getConfig().contains("GUIs.Page1.Slot"+a)) continue; seems to be the problem.
    No errors, except for that it can't get the name for the item from the path set, but the path does exist...
     
    Last edited: Jun 28, 2017
  2. Offline

    timtower Administrator Administrator Moderator

    @yPedx Print the keys in GUIS.Page1
     
  3. Offline

    yPedx

  4. Offline

    timtower Administrator Administrator Moderator

    @yPedx ConfigurationSection.getKeys(false)
    Print those on GUIs.Page1, see what the config thinks it contains.
     
  5. Offline

    yPedx

    @timtower
    Ugh, I've never actually used that code before :p Where to put?
     
  6. Offline

    timtower Administrator Administrator Moderator

    @yPedx Anywhere, it is just for debugging.
    Probably for your counter loop.
     
  7. Offline

    yPedx

    @timtower
    Then it just says
    Cannot make a static reference to the non-static method getKeys(boolean) from the type ConfigurationSection xD
     
  8. Offline

    Zombie_Striker

    @timtower @yPedx
    This is why # are used for non-static calls. You need to replace ConfigurationSection with the instance of the configuration section (so, use something like ...
    YOUR_CONFIG#getConfigurationSection("Path.To.Keys").getKeys(false);
    Where path.to.keys would be replaced with "GUIs.Page1")
     
  9. Offline

    yPedx

    @Zombie_Striker
    Ahh, that makes a lot more sense..
    Code:
    [00:26:32 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'pu' in plugin SB-GUI v5.0.8
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_131]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_131]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
    Caused by: java.lang.NullPointerException
            at me.developer.kriss.SB.page1(SB.java:51) ~[?:?]
            at me.developer.kriss.SB.onCommand(SB.java:466) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            ... 15 more
    Line 51 is
    Code:
    System.out.println(config.getConfigurationSection("GUIs.Page1.Slot"+a+".name").getKeys(false));
    Was that what I was supposed to type? xD Still the same config by the way.
     
  10. Offline

    Zombie_Striker

    @yPedx
    That is not how you use that line. You're supposed to use those keys in order to get a. Just to speed this along, please use the following bit of code instead:
    Code:
    for(String key : config.getConfigurationSection("GUIs.Page1").getKeys(false))
    System.out.println(key+" = "+config.get("GUIs.Page1."+key+".name"));
     
  11. Offline

    yPedx

    @Zombie_Striker
    Alright. It does print the values though..
    upload_2017-6-24_20-11-3.png
    Same config as posted earlier.
     
  12. Offline

    Horsey

    You could always just check for a value there and then use an != null
     
  13. Offline

    yPedx

Thread Status:
Not open for further replies.

Share This Page