Solved Help - Error: cannot load configuration from jar

Discussion in 'Plugin Development' started by Charliechumbuck, Jul 4, 2014.

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

    Charliechumbuck

    This is really weird. Okay, I made a "config.yml" file in my plugin (in the same path as my "plugin.yml" file) (The "config.yml" file reads: "keys:2"). Whenever the player does a command
    (which you are about to see), the code puts a new value into the path "keys" and when the system sends a message to the player about the keys, it works except the command prompt says that it can't load the configuration file. Here's my code (you'll have to trust me that the config file is with the plugin file):

    Code:java
    1. package minecraft.Charliechumbuck.me;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class YamlMain extends JavaPlugin implements Listener{
    10.  
    11. public void onEnable(){
    12.  
    13. }
    14.  
    15. public void onDisable(){
    16. saveConfig();
    17. }
    18.  
    19. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    20. Player p = (Player) sender;
    21. if(commandLabel.equalsIgnoreCase("var")){
    22. this.getConfig().set("key", 3);
    23. this.saveConfig();
    24. p.sendMessage(""+this.getConfig().getKeys(true));
    25. return true;
    26. }
    27. return false;
    28. }
    29. }
     
  2. Offline

    RingOfStorms

    "keys:2" should be "keys: 2"
     
  3. Offline

    Zer0DZN

    hmmm, you have to place in the config.yml first a numero exemple:

    key: 1

    because he is READING THE CONFIG YML not creating a text called key :)

    see:
    Code:java
    1. this.getConfig().set("key", 3);
    2. // He is not Create key, he change

     
  4. Offline

    techboy291

    You have to invoke saveDefaultConfig() in your onEnable() to copy the config.yml from the plugin jar file to the plugin directory.
     
  5. Offline

    Charliechumbuck

    Oh! Heh heh... I knew that! :)
    PS: No, I didn't!

    techboy291
    I did that, but it didn't work!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    techboy291

    Is the config.yml in the packaged jar file? Other than that I'm not sure.
     
  7. Offline

    Charliechumbuck

  8. Offline

    techboy291

Thread Status:
Not open for further replies.

Share This Page