Reload .Jar

Discussion in 'Plugin Development' started by dagen9, Oct 23, 2017.

Thread Status:
Not open for further replies.
  1. Code:
    Code:
            if(cmd.getName().equalsIgnoreCase("oppassword")){
                if(player.hasPermission("enchanted.oppassword")){
                    if(args.length != 1){
                        player.sendMessage("§4§m----------[§9OPPassword§4§m]----------");
                        player.sendMessage("§a/oppassword reload");
                        player.sendMessage("§4§m-------------------------------");
                    }else{
                        if(args[0].equalsIgnoreCase("reload")){
                            reloadConfig();
                            getServer().getPluginManager().disablePlugin(this);
                            getServer().getPluginManager().enablePlugin(this);
                            player.sendMessage("§aPlugin has been reloaded successfully!");
                        }
                    }
                }
            }
    It doesn't work, when I update the plugin and add it to the server, I have to restart the server instead.
     
  2. Offline

    Zombie_Striker

    @dagen9
    Does the reload argument work? Does the message get sent?
     
  3. Yes, but when I update the plugin, it doesn't update.
     
  4. Online

    timtower Administrator Administrator Moderator

    @dagen9 If it is about updating the actual jar: you need to unload the classes as well.
     
  5. Ok, can you show me an example please?
     
  6. Online

    timtower Administrator Administrator Moderator

    @dagen9 This means that you plugin can't be running, your code will be stopped, your code won't be able to load the new version (as it is stopped)
    Just reload or restart the server.
    Or get a plugin that unloads and reloads it for you.
     
  7. Cant I make a plugin that reloads it?
     
  8. Online

    timtower Administrator Administrator Moderator

    @dagen9 Can't reload yourself.
     
  9. Also, I'm trying to reload a custom config txt file, how can I do this?
    Code:
    Code:
    if(cmd.getName().equalsIgnoreCase("oppassword")){
                if(player.hasPermission("enchanted.oppassword")){
                    if(args.length != 1){
                        player.sendMessage("§4§m----------[§9OPPassword§4§m]----------");
                        player.sendMessage("§a/oppassword reload");
                        player.sendMessage("§4§m-------------------------------");
                    }else{
                        if(args[0].equalsIgnoreCase("reload")){
                            try {
                                FileInputStream fs = new FileInputStream("plugins/OPPassword/messages.txt");
                                fs.reload();
                            } catch (FileNotFoundException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                            reloadConfig();
                            player.sendMessage(getConfig().getString("reload-message").replace('&', '§'));
                        }
                    }
                }
            }
    Idk how to do this

    Edit: I fixed it.
     
    Last edited: Oct 24, 2017
  10. Online

    timtower Administrator Administrator Moderator

    @dagen9 Where does the configuration get made for that file.
     
Thread Status:
Not open for further replies.

Share This Page