Bukkit Runnables and Properly Shutting Down

Discussion in 'Plugin Development' started by Orcane, Apr 11, 2017.

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

    Orcane

    I'm relatively new to Java, so excuse my ignorance.

    I have found using BukkitRunnables is must easier than BukkitSchedulers. But when I use them, I get the seemingly common error "This plugin is not properly shutting down its async tasks when it is being reloaded. This may cause conflicts with the newly loaded version of the plugin" from many of the other plugins on the server, when I reload the server.

    I'm not really sure what causes this, whether it be because I'm not assigning taskIDs or something. And I can't seem to find any problems that are a result of this, but it's the knowing that kills me.

    Code:
    package askyra.clans;
    
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    
    public final class Main extends JavaPlugin {
    
        @Override
        public void onEnable() {
            new ExampleListener(this);
        }
    }
    
    class ExampleListener implements Listener {
    
        private final Main plugin;
    
        public ExampleListener(Main plugin) {
            this.plugin = plugin;
            this.plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
    
        @EventHandler
        public void onJoin(PlayerJoinEvent event) {
            new BukkitRunnable() {
    
                @Override
                public void run() {
                    plugin.getServer().broadcastMessage("Welcome to Bukkit! Remember to read the documentation!");
                }
    
            }.runTaskLater(this.plugin, 20);
        }
    
    }
    I literally copied this code right from Bukkit's "Scheduler Programming" page, yet it still casts this error. Any ideas?

    Code:
    [09:08:10 ERROR]: Nag author: 'cereal' of 'Vault' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'iiSnipez' of 'CombatLog' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'SydMontague' of 'ImageMaps' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'Minecrell <" target="_blank" class="externalLink ProxyLink" data-proxy-href="https://github.com/Minecrell>" rel="nofollow">https://github.com/Minecrell>' of 'ServerListPlus' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'Minecrell <" target="_blank" class="externalLink ProxyLink" data-proxy-href="https://github.com/Minecrell>" rel="nofollow">https://github.com/Minecrell>' of 'ServerListPlus' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'cereal' of 'Vault' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'dmulloy2' of 'ProtocolLib' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'SydMontague' of 'ImageMaps' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'iiSnipez' of 'CombatLog' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'AnjoCaido' of 'GroupManager' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'swifteh' of 'GAListener' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    [09:08:10 ERROR]: Nag author: 'Minecrell <" target="_blank" class="externalLink ProxyLink" data-proxy-href="https://github.com/Minecrell>" rel="nofollow">https://github.com/Minecrell>' of 'ServerListPlus' about the following: This plugin is not properly shutting down its async tasks when it is being reloaded.  This may cause conflicts with the newly loaded version of the plugin
    
    Thanks,
    ~ Orcane
     
    Last edited: Apr 11, 2017
  2. Online

    timtower Administrator Administrator Moderator

    @Orcane So you say that when you don't start that runnable then everything works without errors?

    And please make the onJoin use a PlayerJoinEvent or rename the method ;)
     
  3. Offline

    Orcane

    Oh, Actually I missed out a rather important piece of information, I only get these errors when I reload the server, and all the code works fine, even with the runnable, yes.

    (And I fixed the "OnJoin" method xD)
     
  4. Online

    timtower Administrator Administrator Moderator

    @Orcane Your name is not in that list.
    When you comment out the code that is responsible for your runnable and the names don't change: then ignore it, not something you should fix.

    But: restart, don't reload.
     
  5. Offline

    Orcane

    "When you comment out the code that is responsible for your runnable and the names don't change: then ignore it" I don't think I quite understand what you mean by that.

    "But: restart, don't reload." Everyone keeps telling me that, but convenienceee
     
  6. Online

    timtower Administrator Administrator Moderator

    @Orcane Make sure that your plugin won't start a runnable anymore.
    Check if the list changes: if not: don't worry.

    And no, it is high likely that your plugin won't be able to update as it should as Bukkit is still accessing the old jar
     
  7. Offline

    Orcane

    Sorry, What list are we talking about?
     
  8. Online

    timtower Administrator Administrator Moderator

    The list that you posted as error.
    The one with the "Nag author: "
     
  9. Offline

    Orcane

    Alright, every time I reload the server, the list of plugins that have the "Nag author:" is different though. This is bad then? And you said, "Make sure that your plugin won't start a runnable anymore." Why is that?

    Thanks for your help btw, it is appreciated :)
     
  10. Online

    timtower Administrator Administrator Moderator

    @Orcane Then a lot of developers need to fix their runnables (me included)

    And to confirm or deny that your plugin was causing all those issues.
    Just ignore it if your name is not in that list. Not your issue.
     
    Orcane likes this.
  11. Offline

    Orcane

    Ahh, That's good to know, Thank you a lot for your help!
     
Thread Status:
Not open for further replies.

Share This Page