Reloading the config?

Discussion in 'Plugin Development' started by thehutch, Nov 13, 2011.

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

    thehutch

    Ok so i'm having trouble reloading my config so that it updates my plugin. Basically at the moment it kinda works however, it works by reloading the server then using the reload command which obviously isn't how it is meant to be. Here is my code and just ask if you don't understand what parts of it mean :D
    PHP:
            if (args[0].equalsIgnoreCase("reload") && args.length == 1) {

                        if (!
    cs.hasPermission("iskin.reload")) {
                            
    cs.sendMessage(ChatColor.RED "You do not have permission");
                            return 
    false;
                        }
                            
    plugin.reloadConfig();
                            
    plugin.saveConfig();
                            for(
    Player p plugin.getServer().getOnlinePlayers()) {
                                
    plugin.updatePlayerSkin(p.getName());
                            }
                            
    plugin.updateGroupSkin();
                            
    cs.sendMessage(ChatColor.GREEN "Reload complete");
                            return 
    true;
                        }
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    This is a name conflict with the built in reload command, call your something else to avoid trouble.
     
  3. Offline

    thehutch

    No its not read again thats arg[0] one which is reload :p therefore command is /iskin reload
     
  4. Offline

    Sagacious_Zed Bukkit Docs

  5. Offline

    thehutch

    @Sagacious_Zed I'm not sure I understand could you give me an example of how this would work?
    EDIT: nvm I got it to work finally thank you :D taken me ages to figure this out thank you thank you thank you :p
     
  6. Offline

    Sagacious_Zed Bukkit Docs

    @thehutch
    Sigh....
    Assuming in your main class you have something like this
    Code:
    FileConfiguration config;
    ...
    public void onEnable {
    ...
    config = getConfig()
    ...
    }
    ...
    
    Either don't do this and replace every instance of the variable "config" with the method call "getConfig()" in your code.
    OR
    add a "plugin.config = getConfig()" after "plugin.reloadConfig()" as bad fix.
    OR
    in any methods you use config instantiate and assign config inside that method with something like
    Code:
    FileConfiguration config = plugin.getConfig()
    or if the method is in your main class
    Code:
    FileConfiguration config = getConfig()
     
  7. Offline

    thehutch

    @Sagacious_Zed well thank you but I got it to work but add this to the tutorial for added help for people :D
     
Thread Status:
Not open for further replies.

Share This Page