gpt4 book ai didi

java - IllegalArgumentException:在scheduleSyncDelayedTask方法中插件不能为null

转载 作者:行者123 更新时间:2023-12-02 02:27:44 26 4
gpt4 key购买 nike

每当插件尝试运行此延迟的任务时,我都会收到“ IllegalArgumentException:插件不能为空”错误:

  Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, 
new Runnable() {
public void run() {
b.setType(Material.COAL_ORE);
}
}, 500L);


错误:

29.07 00:22:24 [Server] ERROR Could not pass event BlockBreakEvent to Core v1.0.0
29.07 00:22:24 [Server] INFO org.bukkit.event.EventException
29.07 00:22:24 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerInteractManager.breakBlock(PlayerInteractManager.java:286) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerInteractManager.a(PlayerInteractManager.java:215) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:637) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInBlockDig.a(SourceFile:40) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInBlockDig.a(SourceFile:10) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]
29.07 00:22:24 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
29.07 00:22:24 [Server] INFO Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
29.07 00:22:24 [Server] INFO at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.validate(CraftScheduler.java:397) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:123) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:119) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.scheduleSyncDelayedTask(CraftScheduler.java:102) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
29.07 00:22:24 [Server] INFO at me.quib.rpgcore.EventsClass.onBlockBreak(EventsClass.java:720) ~[?:?]
29.07 00:22:24 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
29.07 00:22:24 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
29.07 00:22:24 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]


720行是:

Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {


我不知道为什么插件为空?

我在课程开始时就有了一个实现方法:

Main plugin;

public void initEventsClass(Main plugin) {
this.plugin = plugin;
}


这是我在Main类开始时的代码:

    InventoryClass icp = new InventoryClass();
EventsClass ecp = new EventsClass();


private static Main instance;
public static Main getInstance() {
return instance;
}

@Override
public void onEnable() {
instance = this;
icp.initInventoryClass(this);
ecp.initEventsClass(this);
getLogger().info("Quib's RPG Core Enabled");
getServer().getPluginManager().registerEvents(this, this);
getServer().getPluginManager().registerEvents(new EventsClass(), this);
getConfig().options().copyDefaults(true);
}

最佳答案

我没有使用适当的构造函数

public void initEventsClass(Main plugin) {




public void EventsClass(Main plugin) {


解决了这个问题!

关于java - IllegalArgumentException:在scheduleSyncDelayedTask方法中插件不能为null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57245686/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com