Hey, Usually I don't need help developing but I can't get my plugin to start up and I am getting a strange error I have never seen before and nothing I do fixes it. Below is the error and below it is my main class(just the parts that count): Code: 2013-06-17 19:44:40 [SEVERE] Error occurred while enabling DerpCommands v1.0 (Is it up to date?) org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register task while disabled at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.validate(CraftScheduler.java:394) at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:120) at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:116) at me.itidez.plugins.derpcommands.Derpcommands.init(Derpcommands.java:32) at me.itidez.plugins.derpcommands.Derpcommands.onEnable(Derpcommands.java:23) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381) at org.bukkit.craftbukkit.v1_5_R2.CraftServer.loadPlugin(CraftServer.java:282) at org.bukkit.craftbukkit.v1_5_R2.CraftServer.enablePlugins(CraftServer.java:264) at net.minecraft.server.v1_5_R2.MinecraftServer.j(MinecraftServer.java:301) at net.minecraft.server.v1_5_R2.MinecraftServer.e(MinecraftServer.java:280) at net.minecraft.server.v1_5_R2.MinecraftServer.a(MinecraftServer.java:240) at net.minecraft.server.v1_5_R2.DedicatedServer.init(DedicatedServer.java:150) at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java:379) at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:573) Code:java public class Derpcommands extends JavaPlugin { public Economy economy; public Effects effect; @Override public void onDisable() { // TODO: Place any custom disable code here. } @Override public void onEnable() { init(); } private void init() { setupEconomy(); getCommand("protect").setExecutor(new ProtectCommand(this)); getCommand("market").setExecutor(new MarketCommand()); //getCommand("chat").setExecutor(new ChatCommand(this)); effect = new Effects(); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { @Override public void run() { showStaff(); } }, 20l, 100l); TwitchManager tm = new TwitchManager(this); setupEvents(); } private void setupEvents() { getServer().getPluginManager().registerEvents(new PlayerListener(this), this); getServer().getPluginManager().registerEvents(new SignListener(this), this); getServer().getPluginManager().registerEvents(new TwitchListener(this), this); } private boolean setupEconomy() { if (getServer().getPluginManager().getPlugin("Vault") == null) { getServer().getPluginManager().disablePlugin(this); return false; } RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class); if (rsp == null) { getServer().getPluginManager().disablePlugin(this); return false; } economy = rsp.getProvider(); return economy != null; }
Yes, I have the most recent version as the dependency and the plugin. MCForger this plugin is a few months old, I have never had this issue on it, nor any other plugin before. Do you know what could cause this? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
iTidez No but if you want me to make this plugin work for you give me a basic outline (Explain what it will do) and I will write the code for you and post it here.
MCForger The plugin is literally everything that I was too lazy to package in its own plugin. Perhaps I will try updating the cbukkit source its reading from. Haven't tried that yet.
The error occurs because the plugin is trying to maintain a scheduler task, when suddenly it gets disabled. I suggest doing what MCForger said. But instead of putting it in the onDisable method, put it in the code where you disable the plugin, or right before, actually. I don't know if this works, but it's worth a try
I had this a while ago, when for the 'plugin' parameter I was using 'new MainClass()', but then using a constructor and using 'plugin' as the parameter fixed it. Though that was in a separate listener class, not in the main :c I don't think I explained what I meant very well: Code: private Gibby plugin; public ExplosionListener(Gibby gibby) { this.plugin = gibby; } (you probably know that anyway though )
I'm pretty sure it has something to do with you setupEcpnomy() method. You set this plugin to disabled, if Vault is not detected or no service-provider for Economy is registered. But after disabling it, your init() method goes on and starts registering a task, which will fail because the plugin has been disabled. Try to run the plugin without setting up your economy and see if that fixes it. It should. If so, make sure to abort your init() method (return if youre Economy setup fails.