Solved Something simple, Forgot how to fix......

Discussion in 'Plugin Development' started by ASHninja1997, Nov 16, 2013.

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

    ASHninja1997

    Basically I am trying to register a task using the "aSyncRepeatingTask" method and the problem is that when ever Bukkit goes to use the RepeatingTask it says the plugin is not enabled. In a nut-shell I need someone to look at my plugin.yml and my onEnable to make sure all class's are being fully enabled. Also when the plugin is loaded onto the console screen it broadcast's that each class has been enabled, sooooo......yah. If you need any further details please ask.
    onEnable
    Code:java
    1.  
    2. public static Snipecraft plugin;
    3. static public Counters plugin2 = new Counters(plugin);
    4. static public ItemSelector plugin3 = new ItemSelector(plugin);
    5. static public EventsEP plugin4 = new EventsEP(plugin2);
    6. static public Events plugin5 = new Events(plugin);
    7.  
    8. @Override
    9. public void onEnable(){
    10. getServer().getPluginManager().registerEvents(this, this);
    11. getServer().getPluginManager().registerEvents(new Counters(this), this);
    12. getServer().getPluginManager().registerEvents(new ItemSelector(this), this);
    13. getServer().getPluginManager().registerEvents(new EventsEP(plugin2), this);
    14. getServer().getPluginManager().registerEvents(new Events(this), this);
    15. plugin2.setEnabled(true);
    16. plugin3.setEnabled(true);
    17. plugin4.setEnabled(true);
    18. plugin5.setEnabled(true);
    19. Bukkit.getConsoleSender().sendMessage(
    20. ChatColor.GREEN + "[SnipeCraft] SnipeCraft has been Enabled!");
    21. }

    plugin.yml
    Code:
    name: SnipeCraft
    author: ASHninja1997
    package: com.ASHninja1997.snipecraft.Snipecraft
    main: com.ASHninja1997.snipecraft.Snipecraft
    version: 3.0
     
  2. Offline

    TeeePeee

    You... But... Huh?

    You shouldn't have a 5-in-1 plugin... Make Counters, ItemSelector, EventsEP and Events not extend JavaPlugin (or Plugin) and instead implement Listener...

    You should only have one class extend JavaPlugin - your main class.
     
  3. Offline

    ASHninja1997

    My main class Snipecraft is my only class that extands Javaplugin my other class's (the minor ones) extend Snipecraft or Counters and implements Listener.
     
  4. Offline

    TeeePeee

    ASHninja1997
    By extending Snipecraft, they're extending JavaPlugin. Don't make them extend Snipecraft. And remember to tag me if you want me to reply.
     
  5. Offline

    ASHninja1997

    TeeePeee
    I am not having any trouble in my other classes I am having trouble in my main one.
    This is what is am trying to tell you.
    Code:
    Caused by: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register task while disabled
    Its error occurred on this line
    Code:java
    1. Bukkit.getScheduler().scheduleAsyncDelayedTask(this, new Runnable(){

    The plug-in loads fine and tells me so when it is enabled - but there might be something wrong with the onEnable.
    Something I might have forgotten to put in for fix.

    EDIT: wait I think I might know the problem.4
     
  6. Offline

    JRL1004

    ASHninja1997 It's a fairly self explanatory error.. You have a plugin (which could be any class that directly/indirectly extends JavaPlugin) attempting to register a task. Avoid having more than one class extend JavaPlugin and do not have any classes extend a it.
     
  7. Offline

    TeeePeee

    ASHninja1997
    I've told you the problem, so has JRL1004. DO NOT HAVE MULTIPLE CLASSES THAT EXTEND JAVAPLUGIN, either directly or indirectly.

    Here is your main class:
    Code:java
    1. public class Snipecraft extends JavaPlugin implements Listener {
    2. public static Snipecraft plugin;
    3.  
    4. @Override
    5. public void onEnable() {
    6. plugin = this;
    7. getServer().getPluginManager().registerEvents(this, this);
    8. getServer().getPluginManager().registerEvents(new Counters(this), this);
    9. getServer().getPluginManager().registerEvents(new ItemSelector(this), this);
    10. getServer().getPluginManager().registerEvents(new EventsEP(plugin2), this);
    11. getServer().getPluginManager().registerEvents(new Events(this), this);
    12. getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
    13. public void run() {
    14. System.out.println("I will never, never, never extend JavaPlugin more than once in a plugin.");
    15. }
    16. }, 20L);
    17. Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[SnipeCraft] SnipeCraft has been enabled!");
    18. }
    19. }

    NOTHING ELSE SHOULD EXTEND SNIPECRAFT OR JAVAPLUGIN. Just don't do it. Instead,
    Code:java
    1. public class Counters implements Listener

    Code:java
    1. public class ItemSelector implements Listener

    Code:java
    1. public class EventsEP implements Listener

    Code:java
    1. public class Events implements Listener
     
  8. Offline

    FatAussieFatBoy

    ASHninja1997
    Please change this thread to [SOLVED]
    TeeePeee and JRL1004 have given you the Answer to your Question.
     
  9. Offline

    ASHninja1997

    FatAussieFatBoy JRL1004 TeeePeee
    I said "EDIT: I think I solved the problem...." I am not new to bukkit I just forgot a simple task that I have now solved.
    Thanks for your help though.
     
Thread Status:
Not open for further replies.

Share This Page