[英]Why do I get an error when I try to click outside the inventory / in the inventory where there's no item
我正在使用Spigot 1.14,当我尝试在库存中或没有物品的库存之外单击时,出现错误。
我尝试了不同的方法,例如:
e.getCurrentItem().getItemMeta().getDisplayName()
e.getCurrentItem().getItemMeta().hasDisplayName()
和其他一些方法,但似乎都不起作用。
if (e.getCurrentItem().getItemMeta().getDisplayName() != null && (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§eMystery Box"))) {
当我在库存外部或没有物品的库存中单击时,出现以下错误消息: https : //pastebin.com/v0wDB2gp
说它无法通过广告资源点击事件。
从代码和stacktrace,我能说的就是e.getCurrentItem().getItemMeta()
或e.getCurrentItem()
返回null
。
堆栈跟踪
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) ~[?:?]
...
也可以看看
什么是堆栈跟踪,如何使用它来调试应用程序错误?
什么是NullPointerException,我该如何解决?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.