Help with my code - can't find issue

Status
This thread has been locked.

PurrfectMistake

¬ Owner of AetherTale.com
Premium
Feedback score
10
Posts
307
Reactions
95
Resources
0
Hey, trying to open up the pickaxeinv inventory but its throwing out errors, and the stacktrace ends.. doesn't help :/ Anyone able to help me figure out what the issue is?

Class:
Stacktrace:
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

PurrfectMistake

¬ Owner of AetherTale.com
Premium
Feedback score
10
Posts
307
Reactions
95
Resources
0
it should show in console the stacktrace and which line the code is screwing up, check where that is
nope
Code:
[11:09:35 INFO]: PurrfectMistake_ issued server command: /etshop
[11:09:36 ERROR]: Could not pass event InventoryClickEvent to MineArch-TokenEnchantGUI v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[minecraft_server.ja
r:git-Spigot-7754231-94b0980]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[minecraft_server.jar:
git-Spigot-7754231-94b0980]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:499) [minecraft_server.ja
r:git-Spigot-7754231-94b0980]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484) [minecraft_server.ja
r:git-Spigot-7754231-94b0980]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1884) [minecraft_server.jar
:git-Spigot-7754231-94b0980]
at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [minecraft_server.jar:git-S
pigot-7754231-94b0980]
at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [minecraft_server.jar:git-S
pigot-7754231-94b0980]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [minecraft_server.jar:git
-Spigot-7754231-94b0980]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_171]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_171]
at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [minecraft_server.jar:git-Spigot-775423
1-94b0980]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [minecraft_server.jar:gi
t-Spigot-7754231-94b0980]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [minecraft_server.jar:gi
t-Spigot-7754231-94b0980]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [minecraft_server.jar:gi
t-Spigot-7754231-94b0980]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [minecraft_server.jar:
git-Spigot-7754231-94b0980]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
Caused by: java.lang.NullPointerException
 

Clyde

Premium
Feedback score
44
Posts
1,574
Reactions
1,220
Resources
0
Code:
player.getOpenInventory().getTopInventory().getName();

Try that instead and add this:
Code:
if (event.getClickedInventory != null)
 

PurrfectMistake

¬ Owner of AetherTale.com
Premium
Feedback score
10
Posts
307
Reactions
95
Resources
0
Code:
player.getOpenInventory().getTopInventory().getName();

Try that instead and add this:
Code:
if (event.getClickedInventory != null)
Code:
  else if (e.getSlot() == 13)
  {
      e.setCancelled(true);
      player.openInventory(pickaxeinv(player));
      player.sendMessage(player.getOpenInventory().getTopInventory().getName());
      if (e.getClickedInventory() != null)
      {
          //do nothing
      }
  }

Same error
 

Clyde

Premium
Feedback score
44
Posts
1,574
Reactions
1,220
Resources
0
Code:
  else if (e.getSlot() == 13)
  {
      e.setCancelled(true);
      player.openInventory(pickaxeinv(player));
      player.sendMessage(player.getOpenInventory().getTopInventory().getName());
      if (e.getClickedInventory() != null)
      {
          //do nothing
      }
  }

Same error
No, check for null here

Code:
 ((e.getSlot() >= 0) &&
    (e.getInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&',name))))

That is what's probably returning null as the error doesn't show the line.
 

qIooIp

Supreme
Feedback score
3
Posts
14
Reactions
149
Resources
0
It this is happening when someone clicks outside of the actual inventory you can add this:

Code:
if(event.getSlotType() == SlotType.OUTSIDE) return;

Also you don't need so many if statements. You only need simple if-else statement and that's it.
 
Last edited:

PurrfectMistake

¬ Owner of AetherTale.com
Premium
Feedback score
10
Posts
307
Reactions
95
Resources
0
It this is happening when someone clicks outside of the actual inventory you can add this:

Code:
if(event.getSlotType() == SlotType.OUTSIDE) return;
[DOUBLEPOST=1533518706][/DOUBLEPOST]
Also you don't need so many if statements. You only need simple if-else statement and that's it.
They're clicking on an item thats in it - pickaxe

No, check for null here

Code:
 ((e.getSlot() >= 0) &&
    (e.getInventory().getTitle().equals(ChatColor.translateAlternateColorCodes('&',name))))

That is what's probably returning null as the error doesn't show the line.
same error :/
 

Aerosa

Feedback score
0
Posts
15
Reactions
5
Resources
0
Hey, trying to open up the pickaxeinv inventory but its throwing out errors, and the stacktrace ends.. doesn't help :/ Anyone able to help me figure out what the issue is?

Class:
Stacktrace:


Code:
 if (e.getClickedInventory() == null) return;  if (e.getClickedInventory().getName().equalsIgnoreCase(name)) { //   if (item == null) return; if (!item.hasItemMeta()) return;  }
Just check through clicked Inventories and the item. If what they are clicking is returning the value null, it'll return and wont give you any NPE(s)[DOUBLEPOST=1533520832][/DOUBLEPOST]Why are you also opening inventory in the inventory builder and then using the openInventory code again when command is executed?
 
Last edited:

PurrfectMistake

¬ Owner of AetherTale.com
Premium
Feedback score
10
Posts
307
Reactions
95
Resources
0
Code:
 if (e.getClickedInventory() == null) return;  if (e.getClickedInventory().getName().equalsIgnoreCase(name)) { //   if (item == null) return; if (!item.hasItemMeta()) return;  }
Just check through clicked Inventories and the item. If what they are clicking is returning the value null, it'll return and wont give you any NPE(s)[DOUBLEPOST=1533520832][/DOUBLEPOST]Why are you also opening inventory in the inventory builder and then using the openInventory code again when command is executed?
ah, good eye. I'll fix that now
 
Status
This thread has been locked.
Top