Strange Error

Discussion in 'Plugin Development' started by iTidez, Jun 17, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    iTidez

    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
    1.  
    2. public class Derpcommands extends JavaPlugin {
    3. public Economy economy;
    4. public Effects effect;
    5.  
    6. @Override
    7. public void onDisable() {
    8. // TODO: Place any custom disable code here.
    9. }
    10.  
    11. @Override
    12. public void onEnable() {
    13. init();
    14. }
    15.  
    16. private void init() {
    17. setupEconomy();
    18. getCommand("protect").setExecutor(new ProtectCommand(this));
    19. getCommand("market").setExecutor(new MarketCommand());
    20. //getCommand("chat").setExecutor(new ChatCommand(this));
    21. effect = new Effects();
    22. getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    23. @Override
    24. public void run() {
    25. showStaff();
    26. }
    27. }, 20l, 100l);
    28. TwitchManager tm = new TwitchManager(this);
    29. setupEvents();
    30. }
    31.  
    32. private void setupEvents() {
    33. getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
    34. getServer().getPluginManager().registerEvents(new SignListener(this), this);
    35. getServer().getPluginManager().registerEvents(new TwitchListener(this), this);
    36. }
    37.  
    38. private boolean setupEconomy() {
    39. if (getServer().getPluginManager().getPlugin("Vault") == null) {
    40. getServer().getPluginManager().disablePlugin(this);
    41. return false;
    42. }
    43. RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    44. if (rsp == null) {
    45. getServer().getPluginManager().disablePlugin(this);
    46. return false;
    47. }
    48. economy = rsp.getProvider();
    49. return economy != null;
    50. }
     
  2. Offline

    MCForger

    iTidez
    On disable getServer().getSchedular().cancelTasks(Your plugin);
    Put that on disable
     
  3. Offline

    iTidez

    Same error. No change.
     
  4. Offline

    MCForger

    iTidez
    Is vault on the server when this error occurs?
     
  5. Offline

    iTidez

    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.
     
    Last edited by a moderator: Jun 2, 2016
  6. Offline

    MCForger

    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.
     
  7. Offline

    iTidez

    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.
     
  8. Offline

    Rocoty

    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
     
  9. Offline

    iTidez

    Rocoty I'll try that as soon as I can get on to my development computer
     
  10. Offline

    the_merciless

    Your calling setUpEvents after you call a repeating task, you should call it first.
     
  11. Offline

    iTidez

    the_merciless
    I had no idea that it was a requirement to do that... Ill touch it up now ^_^ thanks!
     
  12. Offline

    the_merciless

    Saying that im not entirely sure that will make a difference, still give it a shot.
     
  13. Offline

    Chinwe

    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 :oops:)
     
  14. Offline

    minoneer

    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.
     
Thread Status:
Not open for further replies.

Share This Page