简体   繁体   English

当我尝试在库存外部/没有物品的库存中单击时,为什么会出现错误?

[英]Why do I get an error when I try to click outside the inventory / in the inventory where there's no item

I am using Spigot 1.14 and when I try to click in the inventory or outside the inventory where there is no item I get an error. 我正在使用Spigot 1.14,当我尝试在库存中或没有物品的库存之外单击时,出现错误。

I have tried with different methods such as: 我尝试了不同的方法,例如:

e.getCurrentItem().getItemMeta().getDisplayName()
e.getCurrentItem().getItemMeta().hasDisplayName()

and some other methods but none of them seem to work. 和其他一些方法,但似乎都不起作用。

if (e.getCurrentItem().getItemMeta().getDisplayName() != null && (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eMystery Box"))) {

When I click outside the inventory or in the inventory where there is no item I get this error message: https://pastebin.com/v0wDB2gp 当我在库存外部或没有物品的库存中单击时,出现以下错误消息: https : //pastebin.com/v0wDB2gp

Saying that it could not pass the inventory click event. 说它无法通过广告资源点击事件。

From the code and the stacktrace everything I can say is that either e.getCurrentItem().getItemMeta() or e.getCurrentItem() is returning null . 从代码和stacktrace,我能说的就是e.getCurrentItem().getItemMeta()e.getCurrentItem()返回null
Stacktrace 堆栈跟踪

Could not pass event InventoryClickEvent to MysteryBox v1.0-SNAPSHOT
org.bukkit.event.EventException: null
        ...
Caused by: java.lang.NullPointerException
        at com.chefren.mysterybox.clickevent.onclick(clickevent.java:23) ~[?:?]
        ...

See also 也可以看看
What is a stack trace, and how can I use it to debug my application errors? 什么是堆栈跟踪,如何使用它来调试应用程序错误?
What is a NullPointerException, and how do I fix it? 什么是NullPointerException,我该如何解决?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM