Solved Why command no work?

Discussion in 'Spigot Plugin Development' started by JanTuck, Jun 13, 2018.

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

    Supporter

    My comand nu wark, wen i try two use it.

    Code (Java):

    [code=Java]public class me.jantuck.spawnershop.commands.SpawnerShopCommand implements org.bukkit.command.CommandExecutor,org.bukkit.event.Listener {
      public me.jantuck.spawnershop.commands.SpawnerShopCommand();
        Code:
           0: aload_0
           1: invokespecial #1                  // Method java/lang/Object."<init>":()V
           4: aload_0
           5: new           #2                  // class java/util/concurrent/atomic/AtomicReference
           8: dup
           9: invokespecial #3                  // Method java/util/concurrent/atomic/AtomicReference."<init>":()V
          12: putfield      #4                  // Field spawnerGui:Ljava/util/concurrent/atomic/AtomicReference;
          15: aload_0
          16: aload_0
          17: invokedynamic #5,  0              // InvokeDynamic #0:getInventory:(Lme/jantuck/spawnershop/commands/SpawnerShopCommand;)Lorg/bukkit/inventory/InventoryHolder;
          22: putfield      #6                  // Field inventoryHolder:Lorg/bukkit/inventory/InventoryHolder;
          25: return

      public boolean onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[]);
        Code:
           0: aload_1
           1: instanceof    #7                  // class org/bukkit/entity/Player
           4: ifeq          14
           7: aload_1
           8: checkcast     #7                  // class org/bukkit/entity/Player
          11: goto          15
          14: aconst_null
          15: astore        5
          17: aload         5
          19: ifnonnull     24
          22: iconst_1
          23: ireturn
          24: aload         5
          26: ldc           #8                  // String spawnershop.menu
          28: invokeinterface #9,  2            // InterfaceMethod org/bukkit/entity/Player.hasPermission:(Ljava/lang/String;)Z
          33: ifne          38
          36: iconst_1
          37: ireturn
          38: aload         5
          40: aload_0
          41: invokevirtual #10                 // Method getSpawnerGui:()Lorg/bukkit/inventory/Inventory;
          44: invokeinterface #11,  2           // InterfaceMethod org/bukkit/entity/Player.openInventory:(Lorg/bukkit/inventory/Inventory;)Lorg/bukkit/inventory/InventoryView;
          49: pop
          50: iconst_1
          51: ireturn

      public void onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent);
        Code:
           0: aload_1
           1: invokevirtual #63                 // Method org/bukkit/event/inventory/InventoryClickEvent.getInventory:()Lorg/bukkit/inventory/Inventory;
           4: invokeinterface #64,  1           // InterfaceMethod org/bukkit/inventory/Inventory.getHolder:()Lorg/bukkit/inventory/InventoryHolder;
           9: aload_0
          10: getfield      #6                  // Field inventoryHolder:Lorg/bukkit/inventory/InventoryHolder;
          13: if_acmpeq     17
          16: return
          17: aload_1
          18: iconst_1
          19: invokevirtual #65                 // Method org/bukkit/event/inventory/InventoryClickEvent.setCancelled:(Z)V
          22: aload_1
          23: invokevirtual #66                 // Method org/bukkit/event/inventory/InventoryClickEvent.getCurrentItem:()Lorg/bukkit/inventory/ItemStack;
          26: ifnull        339
          29: aload_1
          30: invokevirtual #66                 // Method org/bukkit/event/inventory/InventoryClickEvent.getCurrentItem:()Lorg/bukkit/inventory/ItemStack;
          33: invokevirtual #67                 // Method org/bukkit/inventory/ItemStack.getType:()Lorg/bukkit/Material;
          36: getstatic     #33                 // Field org/bukkit/Material.MONSTER_EGG:Lorg/bukkit/Material;
          39: if_acmpne     339
          42: new           #68                 // class me/jantuck/spawnershop/utils/itemnbtapi/NBTItem
          45: dup
          46: aload_1
          47: invokevirtual #66                 // Method org/bukkit/event/inventory/InventoryClickEvent.getCurrentItem:()Lorg/bukkit/inventory/ItemStack;
          50: invokespecial #69                 // Method me/jantuck/spawnershop/utils/itemnbtapi/NBTItem."<init>":(Lorg/bukkit/inventory/ItemStack;)V
          53: astore_2
          54: aload_2
          55: ldc           #70                 // String EGG_SPAWNER.OUR
          57: invokevirtual #71                 // Method me/jantuck/spawnershop/utils/itemnbtapi/NBTItem.hasKey:(Ljava/lang/String;)Ljava/lang/Boolean;
          60: invokevirtual #72                 // Method java/lang/Boolean.booleanValue:()Z
          63: ifeq          339
          66: aload_1
          67: invokevirtual #66                 // Method org/bukkit/event/inventory/InventoryClickEvent.getCurrentItem:()Lorg/bukkit/inventory/ItemStack;
          70: invokevirtual #58                 // Method org/bukkit/inventory/ItemStack.getItemMeta:()Lorg/bukkit/inventory/meta/ItemMeta;
          73: checkcast     #59                 // class org/bukkit/inventory/meta/SpawnEggMeta
          76: invokeinterface #60,  1           // InterfaceMethod org/bukkit/inventory/meta/SpawnEggMeta.getSpawnedType:()Lorg/bukkit/entity/EntityType;
          81: astore_3
          82: getstatic     #73                 // Field java/lang/System.out:Ljava/io/PrintStream;
          85: aload_3
          86: invokevirtual #74                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
          89: aload_0
          90: getfield      #12                 // Field spawnerShop:Lme/jantuck/spawnershop/SpawnerShop;
          93: aload_3
          94: invokevirtual #29                 // Method me/jantuck/spawnershop/SpawnerShop.isEnabled:(Lorg/bukkit/entity/EntityType;)Z
          97: ifne          101
         100: return
         101: aload_1
         102: invokevirtual #75                 // Method org/bukkit/event/inventory/InventoryClickEvent.getWhoClicked:()Lorg/bukkit/entity/HumanEntity;
         105: checkcast     #7                  // class org/bukkit/entity/Player
         108: astore        4
         110: aload_0
         111: getfield      #12                 // Field spawnerShop:Lme/jantuck/spawnershop/SpawnerShop;
         114: aload_3
         115: invokevirtual #52                 // Method me/jantuck/spawnershop/SpawnerShop.getPrice:(Lorg/bukkit/entity/EntityType;)I
         118: istore        5
         120: new           #76                 // class me/jantuck/spawnershop/events/SpawnerPurchaseEvent
         123: dup
         124: aload         4
         126: getstatic     #77                 // Field me/jantuck/spawnershop/events/SpawnerEvent$How.OTHER:Lme/jantuck/spawnershop/events/SpawnerEvent$How;
         129: iconst_1
         130: aload_3
         131: invokespecial #78                 // Method me/jantuck/spawnershop/events/SpawnerPurchaseEvent."<init>":(Lorg/bukkit/entity/Player;Lme/jantuck/spawnershop/events/SpawnerEvent$How;ILorg/bukkit/entity/EntityType;)V
         134: astore        6
         136: invokestatic  #79                 // Method org/bukkit/Bukkit.getPluginManager:()Lorg/bukkit/plugin/PluginManager;
         139: aload         6
         141: invokeinterface #80,  2           // InterfaceMethod org/bukkit/plugin/PluginManager.callEvent:(Lorg/bukkit/event/Event;)V
         146: aload         6
         148: invokevirtual #81                 // Method me/jantuck/spawnershop/events/SpawnerPurchaseEvent.isCancelled:()Z
         151: ifeq          155
         154: return
         155: aload_0
         156: getfield      #12                 // Field spawnerShop:Lme/jantuck/spawnershop/SpawnerShop;
         159: invokevirtual #82                 // Method me/jantuck/spawnershop/SpawnerShop.getEcon:()Lnet/milkbowl/vault/economy/Economy;
         162: aload         4
         164: iload         5
         166: i2d
         167: invokeinterface #83,  4           // InterfaceMethod net/milkbowl/vault/economy/Economy.withdrawPlayer:(Lorg/bukkit/OfflinePlayer;D)Lnet/milkbowl/vault/economy/EconomyResponse;
         172: astore        7
         174: aload         7
         176: invokevirtual #84                 // Method net/milkbowl/vault/economy/EconomyResponse.transactionSuccess:()Z
         179: ifeq          303
         182: aload         4
         184: aload_0
         185: getfield      #12                 // Field spawnerShop:Lme/jantuck/spawnershop/SpawnerShop;
         188: invokevirtual #50                 // Method me/jantuck/spawnershop/SpawnerShop.getSignListener:()Lme/jantuck/spawnershop/listener/SignListener;
         191: invokevirtual #85                 // Method me/jantuck/spawnershop/listener/SignListener.getBuyMessage:()Ljava/lang/String;
         194: ldc           #86                 // String %type%
         196: aload_3
         197: invokevirtual #87                 // Method org/bukkit/entity/EntityType.name:()Ljava/lang/String;
         200: ldc           #88                 // String _
         202: ldc           #89                 // String
         204: invokevirtual #90                 // Method java/lang/String.replace:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
         207: invokestatic  #91                 // Method org/apache/commons/lang/WordUtils.capitalizeFully:(Ljava/lang/String;)Ljava/lang/String;
         210: invokestatic  #92                 // Method org/apache/commons/lang/StringUtils.replace:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
         213: ldc           #93                 // String %amount%
         215: iconst_1
         216: invokestatic  #94                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
         219: invokestatic  #92                 // Method org/apache/commons/lang/StringUtils.replace:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
         222: ldc           #95                 // String %money%
         224: new           #39                 // class java/lang/StringBuilder
         227: dup
         228: invokespecial #40                 // Method java/lang/StringBuilder."<init>":()V
         231: aload_0
         232: getfield      #12                 // Field spawnerShop:Lme/jantuck/spawnershop/SpawnerShop;
         235: invokevirtual #50                 // Method me/jantuck/spawnershop/SpawnerShop.getSignListener:()Lme/jantuck/spawnershop/listener/SignListener;
         238: invokevirtual #51                 // Method me/jantuck/spawnershop/listener/SignListener.getMoneyPrefix:()Ljava/lang/String;
         241: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
         244: iload         5
         246: invokevirtual #41                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
         249: invokevirtual #44                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
         252: invokestatic  #92                 // Method org/apache/commons/lang/StringUtils.replace:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
         255: invokeinterface #96,  2           // InterfaceMethod org/bukkit/entity/Player.sendMessage:(Ljava/lang/String;)V
         260: aload         4
         262: invokeinterface #97,  1           // InterfaceMethod org/bukkit/entity/Player.getInventory:()Lorg/bukkit/inventory/PlayerInventory;
         267: iconst_1
         268: anewarray     #61                 // class org/bukkit/inventory/ItemStack
         271: dup
         272: iconst_0
         273: aload_0
         274: getfield      #12                 // Field spawnerShop:Lme/jantuck/spawnershop/SpawnerShop;
         277: invokevirtual #13                 // Method me/jantuck/spawnershop/SpawnerShop.getEntityTypes:()Lme/jantuck/spawnershop/shop/EntityTypes;
         280: aload_3
         281: invokevirtual #31                 // Method me/jantuck/spawnershop/shop/EntityTypes.getSpawnerType:(Lorg/bukkit/entity/EntityType;)Lorg/bukkit/inventory/ItemStack;
         284: aastore
         285: invokeinterface #98,  2           // InterfaceMethod org/bukkit/inventory/PlayerInventory.addItem:([Lorg/bukkit/inventory/ItemStack;)Ljava/util/HashMap;
         290: aload         4
         292: invokedynamic #99,  0             // InvokeDynamic #2:accept:(Lorg/bukkit/entity/Player;)Ljava/util/function/BiConsumer;
         297: invokevirtual #100                // Method java/util/HashMap.forEach:(Ljava/util/function/BiConsumer;)V
         300: goto          339
         303: aload         4
         305: aload_0
         306: getfield      #12                 // Field spawnerShop:Lme/jantuck/spawnershop/SpawnerShop;
         309: invokevirtual #50                 // Method me/jantuck/spawnershop/SpawnerShop.getSignListener:()Lme/jantuck/spawnershop/listener/SignListener;
         312: invokevirtual #101                // Method me/jantuck/spawnershop/listener/SignListener.getNotEnoughMoneyMessage:()Ljava/lang/String;
         315: ldc           #86                 // String %type%
         317: aload_3
         318: invokevirtual #87                 // Method org/bukkit/entity/EntityType.name:()Ljava/lang/String;
         321: ldc           #88                 // String _
         323: ldc           #89                 // String
         325: invokevirtual #90                 // Method java/lang/String.replace:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
         328: invokestatic  #91                 // Method org/apache/commons/lang/WordUtils.capitalizeFully:(Ljava/lang/String;)Ljava/lang/String;
         331: invokestatic  #92                 // Method org/apache/commons/lang/StringUtils.replace:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
         334: invokeinterface #96,  2           // InterfaceMethod org/bukkit/entity/Player.sendMessage:(Ljava/lang/String;)V
         339: return

      public org.bukkit.inventory.Inventory getSpawnerGui();
        Code:
           0: aload_0
           1: getfield      #4                  // Field spawnerGui:Ljava/util/concurrent/atomic/AtomicReference;
           4: invokevirtual #102                // Method java/util/concurrent/atomic/AtomicReference.get:()Ljava/lang/Object;
           7: astore_1
           8: aload_1
           9: ifnonnull     69
          12: aload_0
          13: getfield      #4                  // Field spawnerGui:Ljava/util/concurrent/atomic/AtomicReference;
          16: dup
          17: astore_2
          18: monitorenter
          19: aload_0
          20: getfield      #4                  // Field spawnerGui:Ljava/util/concurrent/atomic/AtomicReference;
          23: invokevirtual #102                // Method java/util/concurrent/atomic/AtomicReference.get:()Ljava/lang/Object;
          26: astore_1
          27: aload_1
          28: ifnonnull     57
          31: aload_0
          32: invokespecial #103                // Method populateInventory:()Lorg/bukkit/inventory/Inventory;
          35: astore_3
          36: aload_3
          37: ifnonnull     47
          40: aload_0
          41: getfield      #4                  // Field spawnerGui:Ljava/util/concurrent/atomic/AtomicReference;
          44: goto          48
          47: aload_3
          48: astore_1
          49: aload_0
          50: getfield      #4                  // Field spawnerGui:Ljava/util/concurrent/atomic/AtomicReference;
          53: aload_1
          54: invokevirtual #104                // Method java/util/concurrent/atomic/AtomicReference.set:(Ljava/lang/Object;)V
          57: aload_2
          58: monitorexit
          59: goto          69
          62: astore        4
          64: aload_2
          65: monitorexit
          66: aload         4
          68: athrow
          69: aload_1
          70: aload_0
          71: getfield      #4                  // Field spawnerGui:Ljava/util/concurrent/atomic/AtomicReference;
          74: if_acmpne     81
          77: aconst_null
          78: goto          82
          81: aload_1
          82: checkcast     #105                // class org/bukkit/inventory/Inventory
          85: areturn
        Exception table:
           from    to  target type
              19    59    62   any
              62    66    62   any
    }
    [/code]

    Error:
    Code (Text):
    [21:40:56 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'spawnershop' in plugin SpawnerShop v1.0-SNAPSHOT
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:151) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:685) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1472) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1277) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [PaperSpigot-1.12.2.jar:git-Paper-1386]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [PaperSpigot-1.12.2.jar:git-Paper-1386]
        at java.lang.Thread.run(Thread.java:844) [?:?]
    Caused by: java.lang.Exception
        at org.bukkit.craftbukkit.v1_12_R1.entity.CraftHumanEntity.openInventory(CraftHumanEntity.java:186) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        at me.jantuck.spawnershop.commands.SpawnerShopCommand.onCommand(SpawnerShopCommand.java:49) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[PaperSpigot-1.12.2.jar:git-Paper-1386]
        ... 15 more
     
    • Funny Funny x 2
    • Optimistic Optimistic x 2
    • Creative Creative x 1
  2. nani tf is this
     
    • Funny Funny x 4
  3. this is java !!!!
     
    • Like Like x 2
    • Optimistic Optimistic x 2
  4. Tested this myself with an older version of spigot, there is absolutely nothing wrong with your code and you should send a bug report to them immediately. I'm surprised spigot even allowed a release with such an obviously game-breaking problem, shame on them.
     
  5. electronicboy

    IRC Staff

    You are literally everything wrong with this website.
     
    • Funny Funny x 3
    • Creative Creative x 2
    • Agree Agree x 1
    • Friendly Friendly x 1
  6. You are attempting to pop a value from the front of your list, however the list is empty so you actually retrieve a null value.
     
  7. JanTuck

    Supporter

    How to fix?
     
  8. Insert "ifnull 51" on line 50
     
  9. JanTuck

    Supporter

    What lol
    [​IMG]
     
    • Winner Winner x 1
    • Useful Useful x 1
Thread Status:
Not open for further replies.