Issues with reloading plugin?

Discussion in 'Plugin Development' started by kittenchunks, Sep 23, 2012.

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

    kittenchunks

    So my plugin works fine, everything is perfect, op overrides commands, but when i reload the plugin nothing happens no errors, no chat feedback, nothing. Heres the code, its supposed to say "reloading..." here is my code

    Code:
      public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
      {
        Player p = null;
        if ((sender instanceof Player)) {
          p = (Player)sender;
        }
        if (command.getName().equals("WhosOnline")) {
          if (args.length == 0) {
            p.sendMessage(ChatColor.GREEN + "By kittenchunks  :D.");
          }
          if ((args.length == 1) && (
            (args[0].equals("reload")) || (args[0].equals("-reload")))) {
            if (sender.hasPermission("WhosOnline.reload")) {
              logger.info(desc.getName() + " reloading.");
              pm.disablePlugin(this);
              pm.enablePlugin(this);
              return true;
            }
            p.sendMessage("You don't have permission to do that! :[");
          }
     
        }

    Any help ? Thanks
     
  2. Offline

    gregthegeek

    I don't think you can reload a plugin from itself. Bukkit has the built in commands for that. A reload command within your plugin should reload a config, external file, or something similar to that.
     
  3. Offline

    CubieX

    Bukkit has a built in "reloadConfig()" method which will re-read the config file from disk.
    All other reset actions have to be done within your own coding. (like reloading custom files or re-initializing fields or variables...)
     
    kittenchunks likes this.
  4. Offline

    MrFigg

    Why not just call your plugins onDisable() and onEnable() methods? Assuming you were handling cleanup correctly in the first place I don't think that will break anything.

    P.S. I just woke up so I could be forgetting some blatantly obvious reason you shouldn't be doing this. But I think it would be fine.
     
  5. Offline

    HON95

    I would try reenabling it one tick later, using the scheduler.

    EDIT: However, then it would remove the task, wouldn't it...
     
Thread Status:
Not open for further replies.

Share This Page