Simple BukkitRunnable not sure what I am doing wrong

Discussion in 'Spigot Plugin Development' started by Strict, Nov 9, 2018.

Thread Status:
Not open for further replies.
  1. Code (Text):

    public void onEnable() {

            BukkitTask task = new BukkitRunnable() {

                @Override
                public void run() {
                    System.out.println("Hello");
                }
            }.runTaskTimer(this, 20 * 1, 20 * 1);
    }
     
    Just a test example, basically I thought this is supposed to repeat "Hello" every second in the console? Nothing happens for some reason

    Everything else with the plugin works, just this block of code seems to not run

    Any help is appreciated
     
  2. ThomasRW

    Supporter

    Try using the plugin logger?
    That literally is the only thing that I can think of without seeing what “everything else” is.
     
  3. Code (Java):
      public void onEnable()
      {
          Bukkit.getConsoleSender().sendMessage("§c H");
          Bukkit.getConsoleSender().sendMessage("§6 E");
          Bukkit.getConsoleSender().sendMessage("§a L");
          Bukkit.getConsoleSender().sendMessage("§2 L");
          Bukkit.getConsoleSender().sendMessage("§9 O");
      }
    @Strict
    I am not sure if your goal is to spam console. But if you need multiple messages you can use this code above ^
     
    #3 SoSparkly, Nov 9, 2018
    Last edited: Nov 9, 2018
    • Optimistic Optimistic x 1
  4. Yeah me too, no idea what the issue is. I'll try with logger

    result ->

    So I added a Sys. out .println above the code and that was output properly... Just not the task

    Code (Text):

            System.out.println("READING!");
            BukkitTask task = new BukkitRunnable() {

                [USER=32110]@Override[/USER]
                public void run() {
                    plugin.getLogger().info("WORKING");
                }
            }.runTaskTimer(this, 20 * 1, 20 * 1);
     
    IT doesn't repeat WORKING, only prints out 'READING' once.
     
  5. I am not sure if it would work (Never tried), possibly a for loop running console messages, instead of bukkitrunnable
     
  6. This is silly. He's trying to make a Runnable not spam the same message, simply trying to test functionality.

    OT: Is it possible that on startup BukkitRunnables fuck up? Try a normal Runnable
     

  7. Ok sorry. So System.out.println("Hello"); it is.

    Code (Java):
         public void onEnable()
      {
    new BukkitRunnable() {
                int seconds = 5;
                @Override
                public void run() {
                    seconds--;
                    System.out.println("Hello");
                    if(seconds == 0) cancel();
                }
            }.runTaskTimer(this, 0L, 20L);
    }
    This will repeat "Hello"
     
    • Agree Agree x 1
  8. That works on my 1.12 version but I cannot seem to get this to work on 1.8.8
     

  9. Glad it at least works. Um I don't really work with 1.8, so maybe @Kozs Any ideas?
     
  10. Full code? It may allow us to better understand your situation.
     
Thread Status:
Not open for further replies.