我使用的是Spigot 1.14,当我尝试单击库存中或无物品的库存外部时,出现错误。
我尝试了不同的方法,例如:
private void PlaceAt(double radian, FrameworkElement element)
{
double cx = 100 + 50.0 / 2; // Left start position of red circle + radius of it.
double cy = 100 + 50.0 / 2; // Top start position of red circle + radius of it.
double x = cx + r * Math.Cos(radian) + element.Width / 2.0;
double y = cy - r * Math.Sin(radian) + element.Height / 2.0;
Canvas.SetLeft(element, x);
Canvas.SetTop(element, y);
canvas.Children.Add(element);
}
和其他一些方法,但是似乎都不起作用。
e.getCurrentItem().getItemMeta().getDisplayName()
e.getCurrentItem().getItemMeta().hasDisplayName()
当我在库存外部或没有物品的库存中单击时,出现以下错误消息:https://pastebin.com/v0wDB2gp
说它无法通过广告资源点击事件。
答案 0 :(得分:0)
从代码和堆栈跟踪中,我只能说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) ~[?:?]
...
另请参见
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?