How to reload plugin (.jar)?

Discussion in 'Plugin Development' started by Staartvin, Apr 10, 2012.

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


    Hello everyone (once again),

    I need to reload (.jar) my plugin with the command /fjh reload.
    This is what I have right now:

                    else if (strings[0].equalsIgnoreCase("reload")) {
                            if(player.hasPermission("fjh.admin")) {
                                player.sendMessage(ChatColor.AQUA + "[First Join Help] Plugin reloaded!");
                                System.out.print("[FIRST JOIN HELP] " + cs.getName().toUpperCase() + " HAS RELOADED FJH!");
                                  return true;

    But, it doesn't work..
    I get this error when i'm trying to perform it:

    18:32:38 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'fjh'
    in plugin FirstJoinHelp v1.0
            at org.bukkit.command.PluginCommand.execute(
            at org.bukkit.command.SimpleCommandMap.dispatch(
            at org.bukkit.craftbukkit.CraftServer.dispatchCommand(
            at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.
            at net.minecraft.server.NetServerHandler.a(
            at net.minecraft.server.Packet3Chat.handle(
            at net.minecraft.server.NetworkManager.b(
            at net.minecraft.server.NetServerHandler.a(
            at net.minecraft.server.NetworkListenThread.a(
            at net.minecraft.server.MinecraftServer.w(
    Caused by: java.lang.NullPointerException
            at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManag
            at me.staartvin.FirstJoinHelp.FirstJoinHelp.onCommand(
            at org.bukkit.command.PluginCommand.execute(
            ... 12 more

    Could you guys help me?
  2. Did you checked if 'plugin' isn't null?
  3. Offline


            public static JavaPlugin plugin;
  4. That still doesn't answer my question, did you checked if it's null?
  5. Offline


    How can I check it?
  6. Code:
    if(plugin == null)
      System.out.println("Yes, it is.");
  7. Offline


    Yes it is.
    So how should I change that?
  8. at some point you need to set a variable to it.
  9. Offline


    Is there a way that I can reload my plugin without 'plugin'? I can't figure how to declare 'plugin' correctly..
  10. you'll need a reference to your main class otherwise not.
  11. Offline

    Father Of Time

    Ouch... Unable to perform null checks, no understanding of class casting... With all due respect, I think you need to pick yourself up an "introduction to java" book...

    To answer your question:

        YouPluginName plugin = Bukkit.getServer().getPluginManager().getPlugin("YourPluginName");
    I wrote this freehand in notepad, but basically you want to get your plugin from bukkit, then take that plugin and call the Reload function within it, which will force your plug-in to reload (I think, I've never done it).
  12. Offline


    I'm familiar with Java (not at it's greatest) , but not with Bukkit.
    Of course I know what null means and such, but I'm kind of shy towards Bukkit. They have a lot of new stuff I need to learn.

    Thank you for the help anyway, I fixed it myself. :)
    I still have one question closed before this thread can be closed, which is:

    How to make default line in the config like this:

    # This is a comment line

  13. Code:
    getConfig().options().header("This is a comment");
    You can only add a header comment, not a comment inside the lines (you could using a pre-done file as a resource but the comments will be lost after reload anyway).
  14. Offline


    Ok, that's dissapointing then... Thanks for the help!
  15. Offline

    Father Of Time

    If the code is in he main class I think you can simply do this inside your onCommand function when the command is executed:

    But this will only work within the your plug-ins main class, as it extends the JavaPlugin class.

    Edit: Opps, a little late on this one... A phone call came in at work half way through typing this. Oh well, glad to see you resolved your issue.

    Take care!
    Benlewis9000 likes this.
  16. Offline


    Thank you :)
Thread Status:
Not open for further replies.

Share This Page