Minecraft Scheduler - Countdown funktioniert nicht?
Guten Tag. Ich habe ein Simplen Countdown programmiert, der allerdings Fehlermeldungen ausspuckt sobald ich den Command ausführe:
Sourcecode:
public class CMD_test implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase("test")) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
int countdown = 10;
@Override
public void run() {
if(countdown > 0) {
Bukkit.broadcastMessage("§cCountdown: §b" + countdown);
} else {
Bukkit.broadcastMessage("§c§lBoooomm!");
}
countdown--;
}
}, 0, 20);
}
return false;
}
}
2 Antworten
Hier die Fehlermeldung:
[12:59:17 INFO]: StonerSociety issued server command: /test
[12:59:17 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin ACCG v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_231]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_231]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.validate(CraftScheduler.java:397) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:123) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:119) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at me.flugzahn.commands.CMD_test.onCommand(CMD_test.java:15) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
... 15 more
Nutzer, der sehr aktiv auf gutefrage ist
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
heißt
Main.getPlugin()
gibt
null
zurück
Danke dir. Ich habe vergessen in der Main Klasse
plugin = this;
zu setzen.