Delayed task trouble.

Discussion in 'Plugin Development' started by Blabba, Aug 15, 2012.

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

    Blabba

    I am new to bukkit plugin making (and quite new to java). I am trying to add a delayed task but I get an error with it. I think the problem is the "plugin" argument. I dont know what to put there. In my main class "MiniGames" I have this which I dont remember putting there but I tried to put it as the argument.

    I just dont know what I am meant to put there.

    Public static MiniGames plugin;

    Code:
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(MiniGames.plugin, new Runnable() {
     
                      public void run() {
                          Game.isSettingUp = false;
                          Bukkit.getServer().broadcastMessage(ChatColor.RED +"[Server] "+ ChatColor.DARK_GREEN + "The Team Deathmatch is starting!");
                      }
                    }, 200L);
     
  2. Offline

    Jogy34

    In your main class you should have it extend 'JavaPlugin'. the plugin argument is looking for a class that extends JavaPlugin so your best bet would be to put an instance of your main class in there. If you are creating the task in your main class then you can just put 'this' otherwise you either have to send and instance of you main class into any other classes in the constructor or you could do something like this:
    Code:
    public static YourMainClass plugin;
     
    //in onEnable
    plugin = this;
     
    //you call it by doing this from another class:
    YouMainClass.plugin;
     
  3. Offline

    toothplck1

    You could also do getServer().getPluginManager().getPlugin("YourPlugin")
     
  4. Offline

    Blabba

    Thanks for the help guys, I just needed to add to on enable:
    plugin = this;
     
Thread Status:
Not open for further replies.

Share This Page