- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
[01:48:25 ERROR]: Could not pass event PlayerJoinEvent to Listeners v1.0.0
org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.PlayerList.onPlayerJoin(PlayerList.java:272) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.PlayerList.a(PlayerList.java:156) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.LoginListener.b(LoginListener.java:109) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.LoginListener.c(LoginListener.java:41) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.NetworkManager.a(NetworkManager.java:159) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.ServerConnection.c(ServerConnection.java:82) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:800) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_211]
Caused by: java.lang.NullPointerException
at me.spoonle.listeners.join.JoinListener.onJoin(JoinListener.java:30) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_211]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
... 14 more
控制台错误消息。
package me.spoonle.listeners.join;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import me.spoonle.listeners.Main;
import me.spoonle.listeners.Utils.Utils;
public class JoinListener implements Listener {
private Main plugin;
public JoinListener(Main plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if (!p.hasPlayedBefore()) {
e.setJoinMessage(Utils.chat(plugin.getConfig().getString("FirstJoinMessage").replace("%player%", p.getName())));
} else {
e.setJoinMessage(Utils.chat(plugin.getConfig().getString("JoinMessage").replace("%player%", p.getName())));
}
}
@EventHandler
public void onQuit(PlayerQuitEvent q) {
Player p = q.getPlayer();
q.setQuitMessage(Utils.chat(plugin.getConfig().getString("QuitMessage").replace("%palyer%", p.getName())));
}
}
这是我的加入消息和退出消息代码。为什么它不能完全发挥作用?我错过了什么?我需要添加一些东西吗?我正在遵循 YouTube 上的教程,并严格按照步骤进行操作,并与他们的代码进行了三次检查,结果是相同的,所以我很困惑。
最佳答案
显然你的插件在你的 JoinListener 的第 30 列抛出了一个空指针。我猜它可能是 plugin.getConfig().getString("JoinMessage")
来自官方 Spigot 文档 1.14 文档:
FileConfiguration.getString(String path)
If the String does not exist but a default value has been specified, this will return the default value. If the String does not exist and no default value was specified, this will return null.
您的配置中似乎不存在“JoinMessage”条目。
关于java - 无法传递事件 PlayerJoinEvent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56616511/
[01:48:25 ERROR]: Could not pass event PlayerJoinEvent to Listeners v1.0.0 org.bukkit.event.EventExc
每次通过配置文件连接时,我都会收到错误。 主类: public Core plugin; @Override public void onEnable() {
当第一次加入服务器(PlayerJoinEvent)时,如何为每个玩家创建一个新的ArrayList,这样每个玩家都有一个ArrayList(用于好友列表插件)? 我想要一个ArrayList,或任何
我是一名优秀的程序员,十分优秀!