Open inventory

Discussion in 'Plugin Help/Development/Requests' started by DaanSander, Feb 27, 2015.

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

    DaanSander

    Hello i am trying to make a plugin so when i do a command it opens a inventory but it doesnt seems to work
    sorry for bad english

    code:
    Code:
    if(cmd.getName().equalsIgnoreCase("bonuschest") && sender instanceof Player) {
                Player p = (Player) sender;
                Menu.show(p);
            }
    menu show method class:
    Code:
    public static void show(Player p ) {
            p.openInventory(shop);
        }
     
  2. Offline

    _Filip

    What is the problem?
     
  3. Offline

    DaanSander

    @_Filip it wont open the menu

    stacktrace:
    Code:
    [16:43:44 INFO]: The_Unkown_User issued server command: /bonuschest
    [16:43:44 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'bonu
    schest' in plugin HMCEssentials v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spi
    got-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:14
    1) ~[spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServe
    r.java:645) ~[spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:1115) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java
    :950) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :26) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :53) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spi
    got-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [
    ?:1.8.0_31]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_31]
            at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:6
    83) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:3
    16) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:6
    23) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java
    :526) [spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_31]
    Caused by: java.lang.NullPointerException
            at org.bukkit.craftbukkit.v1_8_R1.entity.CraftHumanEntity.openInventory(
    CraftHumanEntity.java:176) ~[spigot-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-089
    9683]
            at me.daansander.hmcessentials.Menu.show(Menu.java:105) ~[?:?]
            at me.daansander.hmcessentials.cmds.TreasureGUI.AlgemeneCMDS.onCommand(A
    lgemeneCMDS.java:64) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spi
    got-1.8-R0.1-SNAPSHOT.jar:git-Spigot-13716d9-0899683]
            ... 14 more
    >
     
    Last edited: Feb 27, 2015
  4. Offline

    Ruptur

    @DaanSander

    Code:
    [LIST=1]
    [*]org.bukkit.command.CommandException: Unhandled exception executing command 'bonu
    [*]schest' in plugin HMCEssentials v1.0
    [/LIST]
    
    This means you tried to do something that could throw an exception without trying to handle it.

    Code:
    at me.daansander.hmcessentials.Menu.show(Menu.java:105) ~[?:?]
    
    On line 105 in your 'Menu' class you have the problem
     
  5. Moved to Bukkit Alternates
     
  6. Offline

    DaanSander

    on line 105 is only this:
    public HashMap<String, Integer> numbers = new HashMap<String, Integer>();

    in eclipse the method worked fine but inteliJ not
     
  7. Offline

    Ruptur

    @DaanSander

    I dont know how to help you, it works fine on inteliJ for me
    Did you import HashMaps?
     
  8. Offline

    DaanSander

    yes but now i have multiple errors now when i try to register the events inside it says:
    Error:(87, 62) java: constructor Menu in class me.daansander.hmcessentials.Menu cannot be applied to given types;
    required: me.daansander.hmcessentials.HMCEssentials
    found: no arguments
    reason: actual and formal argument lists differ in length
     
Thread Status:
Not open for further replies.

Share This Page