I'm getting a stack trace that I don't understand when I am using this. Code:java Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { settings.getData().set(p.getUniqueId().toString() + "kits." + ".junkie", false); } }, (60 * 2) * 20); Here's the stack trace Code: Could not pass event PlayerInteractEvent to Main v6.1 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.craftbukkit.v1_7_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:195) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.PlayerInteractManager.interact(PlayerInteractManager.java:374) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.PlayerConnection.a(PlayerConnection.java:628) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.PacketPlayInBlockPlace.a(SourceFile:60) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.PacketPlayInBlockPlace.handle(SourceFile:9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.NetworkManager.a(NetworkManager.java:147) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.MinecraftServer.v(MinecraftServer.java:657) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.DedicatedServer.v(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.MinecraftServer.u(MinecraftServer.java:548) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.MinecraftServer.run(MinecraftServer.java:459) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at net.minecraft.server.v1_7_R2.ThreadServerApplication.run(SourceFile:618) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] Caused by: java.lang.IllegalArgumentException: Plugin cannot be null at org.apache.commons.lang.Validate.notNull(Validate.java:203) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.craftbukkit.v1_7_R2.scheduler.CraftScheduler.validate(CraftScheduler.java:391) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.craftbukkit.v1_7_R2.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:120) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.craftbukkit.v1_7_R2.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:116) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at org.bukkit.craftbukkit.v1_7_R2.scheduler.CraftScheduler.scheduleSyncDelayedTask(CraftScheduler.java:100) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] at kits.KitSigns.onPlayerInteract5(KitSigns.java:296) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-11-g08fad7a-b3036jnks] ... 15 more [22:34:18] [Server thread/INFO]: [Main] Disabling Main v6.1
This may not be the main class, so it may not necessarily be this. But it does need to be initialized, so +1 to that aspect.
When you wrote : that would imply that this is the main plugin class, or plugin is a static variable, which would be a subpar design choice.
Barnyard_Owl, coasterman10, MooshViolet So do I just make a instance of the plugin in the main class?
King_Amun_Ra Whichever the plugin variable is needs to be initialized to your main class that extends JavaPlugin. If this code is in your main class, then just replace "plugin" with "this". If not, then you need to pass your plugin via a constructor.
coasterman10 I did and this is still happening Code: public void KitSigns(main instance) { plugin = instance; }
That's not a constructor, so it isn't being executed. This is what the code should be for it to be called as a constructor: Code:java public KitSigns(main instance) { plugin = instance;}
coasterman10 Now I'm getting errors in my registering for events Code: Bukkit.getServer().getPluginManager().registerEvents(new KitSigns(), this); private final KitSigns kitSigns = new KitSigns(); Both have errors EDIT by Moderator: merged posts, please use the edit button instead of double posting.
King_Amun_Ra Because you specified in your constructor for the class for your Main class instance. So put this in the constructor.
The constructor takes an argument: Code:java public KitSigns(main instance) You need to pass this argument. You should know this, it is basic Java. What are the errors?
@coastman10 it just saids undefined for KitSigns and for the registering. I have the constructor working he just said add this to it and never said anything else.
King_Amun_Ra When Gater12 said put this in the constructor, he was referring to the keyword "this", which is used to reference to the current object you have (i.e. the instance of your class that extends JavaPlugin)
King_Amun_Ra Is the class actually called KitSigns, and if so, is it in the same package as your main class? Did you forget to import it perhaps?
coasterman10 Yes it is called KitSigns and no it is not in the same package I'll move it. And where would I add this? I've never really used this before sorry for not knowing to much about this. I moved it and no problems solve
If it's not in the same package, that's fine. You just need to import it, which your IDE may offer as an automatic suggestion
coasterman10 Yes I have to correct imports coasterman10 thanks for the help I really don't know what I'm doing here never had to do this before sorry for being kinda nooby about this EDIT by Moderator: merged posts, please use the edit button instead of double posting.