opening a custom inventory getting error

Discussion in 'Plugin Development' started by djdeath1, Jun 8, 2014.

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

    djdeath1

    Hello,

    I have been coding a custom inventory plugin that i have been having issues bringing the inventory up in-ingame.... I have also debug'ed the code to find the error and its the setting of the custom inventory...

    heres the code:

    It should be obvious that i have a variable : private static Plugin plugin; at the top of my code

    Code:
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
         
            if (event.getClickedBlock() == null) return;
            Player player = event.getPlayer();
            Block block = event.getClickedBlock();
         
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if (block.getType() == Material.SIGN || block.getType() == Material.WALL_SIGN) {
                    Sign sign = (Sign) block.getState();
                    if (sign.getLine(0).equalsIgnoreCase(ChatColor.GREEN + "[csell]")) {
                        csell = plugin.getServer().createInventory(player, 9, "Chest Sell");
                        player.openInventory(csell);
                    }
                    return;
                     
                }
                return;
            }
            return;
        }
    Error happens at the
    csell = plugin.getServer().createInventory(player, 9, "Chest Sell");
     
  2. Offline

    Mrawesomecookie

  3. Offline

    djdeath1

    @Mrawesomecookie
    Code:
    [17:22:28] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to ChestSell v0.1
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.craftbukkit.v1_7_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:216) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PlayerInteractManager.interact(PlayerInteractManager.java:374) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:629) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInBlockPlace.a(SourceFile:60) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInBlockPlace.handle(SourceFile:9) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    Caused by: java.lang.NullPointerException
        at org.djcraft.djdeath1.chestsell.ChestSellListener.onPlayerInteract(ChestSellListener.java:69) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_60]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_60]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_60]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        ... 15 more
    [17:23:28]
    I had added Debug messages for each if statement and i got it to successfully pass through the

    if (sign.getLine(0).equalsIgnoreCase(ChatColor.GREEN + "[csell]")) {
    csell = plugin.getServer().createInventory(player, 9, "Chest Sell");
    player.openInventory(csell);
    }

    I added p.sendmessage after this if statement and it passed it but then i added a sendmessage after the csell = statement and it wouldn't pass that send message

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  4. Offline

    es359



    Use
    Code:java
    1. Bukkit.getServer().createInventory(null, 9, "Your inventory");
     
  5. Offline

    djdeath1

    worked thank you so much es359
     
    es359 likes this.
Thread Status:
Not open for further replies.

Share This Page