Why will this scheduler not work?

Discussion in 'Plugin Development' started by Excalibur, Jul 21, 2014.

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

    Excalibur

    Arena.java
    Code:
    public ArcherArena main;
     
    public void countdownTwo() {
    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, new Runnable() {
    public void run() {
    Bukkit.broadcastMessage("hey");
    }
     
    }, 0, 20);
    }
    
    ArcherArena.java (Main class)
    Code:
    public void startGame(Player player) {
    Arena gameArena = new Arena();
    gameArena.countdownTwo();
     
    }
    
     
  2. I don't know, so i would put in debug code so you know where it is going wrong :)
     
  3. Offline

    ZodiacTheories

    Excalibur

    Do you initialize the main variable
     
  4. Offline

    SkyleTyler1337

    at the end
    Code:
     0, 20);
    needs to be
    Code:
    0L,  20L);
     
  5. Offline

    fireblast709

    SkyleTyler1337 no difference there. Integers would be a subset of longs, thus an integer would work fine in a long field

    Excalibur any errors?
     
  6. Offline

    negative_codezZ

    Excalibur, try making that 0 at the end a 20 too. Also, use the method runTaskTimer instead.
     
  7. Offline

    Excalibur

    [13:50:37] [Server thread/INFO]: Admin issued server command: /start
    [13:50:37] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'start' in plugin ArcherArena v1
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:956) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    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.9-R0.1-10-g8688bd4-b3092jnks]
    at org.bukkit.craftbukkit.v1_7_R3.scheduler.CraftScheduler.validate(CraftScheduler.java:391) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at org.bukkit.craftbukkit.v1_7_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:120) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at org.bukkit.craftbukkit.v1_7_R3.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:116) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    at com.stevepavlin.Arena.countdownTwo(Arena.java:71) ~[?:?]
    at com.stevepavlin.ArcherArena.startGame(ArcherArena.java:31) ~[?:?]
    at com.stevepavlin.ArcherArena.onCommand(ArcherArena.java:46) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    ... 13 more
     
  8. Offline

    Zupsub

    Please read your stacktrace fully next time.
     
  9. Offline

    stormneo7

    Code:java
    1. public ArcherArena main;
    2. // In Other Words
    3. public ArcherArena main = null;

    You didn't define it.
    To change that, you could make the 'main' object static. Then on your onEnable() statement, do [Arena.main = this;]
     
  10. Offline

    fireblast709

    stormneo7 eew static. Rather teach him how to use a constructor
    Excalibur
    Code:java
    1. private final Main main;
    2.  
    3. public OtherClass(Main main)
    4. {
    5. this.main = main;
    6. }
    from the main class
    Code:java
    1. new OtherClass(this);
     
  11. Offline

    1Rogue

  12. Offline

    stormneo7

    Didn't know you could edit a final object.


    I know you shouldn't use static methods.
    I'm just saying, doing what he did, that's how you'd define it.
     
  13. Offline

    fireblast709

    stormneo7 I didn't edit a final variable, I assigned a plugin reference to it as initial initialisation ;). Assigning final variables in constructors is pretty normal (as long as you don't try to assign it twice)
     
  14. Offline

    Excalibur

    I know how to use a constructor, just wasn't thinking about passing the plugin object into it, thanks for that its fixed now.
     
Thread Status:
Not open for further replies.

Share This Page