捕获异常“playerinteractevent”并检查位置是否存在| | | minecraft插件插口bukkit

syqv5f0l  于 2021-08-20  发布在  Java
关注(0)|答案(1)|浏览(351)

我有个问题。我有一个minecraft服务器插件,我正在尝试使用其中不存在的。
我得到以下错误:
无法将event playerinteractevent传递给 org.bukkit.event.eventexception:null位于org.bukkit.plugin.java.javapluginloader$1.execute(javapluginloader.java:319)~[spiget-1.16.3.jar:git-spiget-57bbdd8-b8dd5ec]位于org.bukkit.plugin.registeredlistener.callevent(registeredlistener.java:70)~[spiget-1.16.3.jar:git-spiget-57bbdd8-b8dd5ec]firevent(simplepluginmanager.java:589)~[spiget-1.16.3.jar:git-spiget-57bbdd8-b8dd5ec]位于org.bukkit.plugin.simplepluginmanager.callevent(simplepluginmanager.java:576)~[spiget-1.16.3.jar:git-spiget-57bbdd8-b8dd5ec]org.bukkit.craftbukkit.v1_16_r2.event.crafteventfactory.callplayerinteractevent(crafteventfactory.java:483)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在org.bukkit.craftbukkit.v1_r2.event.crafteventfactory.callplayerinteractevent(crafteventfactory.java:450)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]net.minecraft.server.v1_16_r2.playerinteractmanager.a(playerconnection.java:148)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在net.minecraft.server.v1_16_r2.playerconnection.a(playerconnection.java:1219)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在net.minecraft.server.r2.v1_16_.packet.player40(源文件:playdig)net.minecraft.server.v1_16_r2.packetplayinblockdig.a(源文件:10)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在net.minecraft.server.v1_16_r2.playerconnectionutils.lambda$0(playerconnectionutils.java:19)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b5ec]net.minecraft.server.v1_16_r2.ticktask.run(源文件:18)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在net.minecraft.server.v1_16_r2.iasynctaskhandler.executetask(源文件:144)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在net.minecraft.server.v1_16_r2.iasynctaskhandlerentrant.executetask(源文件:23)net.minecraft.server.v1_16_r2.iasynctaskhandler.executeext(源文件:118)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]net.minecraft.server.v1_16_r2.minecraftserver.ba(minecraftserver.java:941)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]net.minecraft.server.v1_16_r2.minecraftserver.executenext(minecraftserver.java:934)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在net.minecraft.server.v1_16_r2.iasynctaskhandler.waittasks(源文件:127)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]在net.minecraftr.server.v1_16_r2.minecraftserver.sleepftick(minecraftserver.918)net.minecraft.server.v1_16_r2.minecraftserver.w(minecraftserver.java:850)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]at net.minecraft.server.v1_16_r2.minecraftserver.lambda$0(minecraftserver.java:164)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8ec]at.minecraftserver.v1_r2.java:164;.java线程[?:?]原因:java.lang.nullpointerexception:无法调用“org.bukkit.location.getblockz()”,因为“this.secondlocation”在.playerinteracteventlistener.onplayeruse(playerinteracteventlistener.java:128)~[?:?]在jdk.internal.reflect.nativemethodaccessorimpl.invoke0(本机方法)~[?:?]在jdk.internal.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:64)~[?:?]在jdk.internal.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)~[?:?]在java.lang.reflect.method.invoke(method.java:564)~[?:?]在org.bukkit.plugin.java.javapluginloader$1.execute(javapluginloader.java:315)~[spigot-1.16.3.jar:git-spigot-57bbdd8-b8dd5ec]。。。还有21个
是否有插口的例外情况列表?
在这种情况下,我应该使用try-and-catch捕获哪个异常?
有人能提出其他方法来检查给定位置是否存在吗?

jfewjypa

jfewjypa1#

您是否尝试过验证位置是否为空?

if (location != null){
   // Do your thing
}

相关问题