Solved CreateInventory help

Discussion in 'Plugin Development' started by mehboss, Sep 16, 2016.

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

    mehboss

    How do I make it so that for the create inventory size string to get the size number from the config, I did what the code shown below and it says something is wrong with it.

    Code:
            String size = Bukkit.getPluginManager().getPlugin("WarpGUI").getConfig().getString("size");
            inv = Bukkit.getServer().createInventory(null, size, "Warps");
     
  2. Offline

    Jakeeeee

    Well first off, size is a string and I'm 100% sure the second parameter requires an internet. Also we can guess you error without stacktrace, the full code to the class.
     
  3. Offline

    mehboss

    @Jakeeeee
    Example please? :)
     
  4. Offline

    Zombie_Striker

    1. The plugin can be null
    2. The string at path "size" can be null
    3. size can be an integer that is not a multiple of nine.
    One of these is your issue. Without the actual error message, we will not be able to know what your actual issue is.
     
  5. Offline

    mehboss

    @Zombie_Striker
    @Jakeeeee
    I don't actually think you know what I mean, I want the size of that inventory configurable from the config. Here is the error it gives as to why it is underlined as an error.

    Code:
    The method createInventory(InventoryHolder, InventoryType, String) in the type Server is not applicable for the arguments (null, String, String)
     
    Last edited: Sep 16, 2016
  6. Offline

    Zombie_Striker

    @mehboss
    Your issue is that the middle variable is supposed to be an Integer, and you are providing a string. Use Integer.parseInt(size) for the middle value.
     
  7. Offline

    mehboss

    @Zombie_Striker
    So like this?
    Code:
        public Menu(Plugin p, String cratename, String infoname, String mobname, String shopname, String rstain1name, String name) {
            String size = Bukkit.getPluginManager().getPlugin("WarpGUI").getConfig().getString("size");
            inv = Bukkit.getServer().createInventory(null, Integer.parseInt(size), "Warps");
    @Zombie_Striker
    Console gives errors when trying to enable it, here they are.
    Code:
    [05:39:21 INFO]: [WarpGUI] Enabling WarpGUI v1.0
    [05:39:21 ERROR]: Error occurred while enabling WarpGUI v1.0 (Is it up to date?)
    java.lang.ArrayIndexOutOfBoundsException: 12
            at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom$MinecraftInventory.setItem(CraftInventoryCustom.java:104) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory.setItem(CraftInventory.java:79) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at me.mehboss.warpgui.Menu.infoItem(Menu.java:80) ~[?:?]
            at me.mehboss.warpgui.Menu.<init>(Menu.java:28) ~[?:?]
            at me.mehboss.warpgui.WarpGUI.onEnable(WarpGUI.java:19) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [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(Executors.java:511) [?:1.8.0_72]
            at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_72]
            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(Thread.java:745) [?:1.8.0_72]
    EDIT:

    Okay, it works I am just a moron and I may have just put the wrong inventory size, it was too small for my items in it. :)
     
    Last edited: Sep 16, 2016
Thread Status:
Not open for further replies.

Share This Page