Solved Annoying exception bug

Discussion in 'Plugin Development' started by cfil360, Apr 25, 2014.

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

    cfil360

    There is nothing structurally wrong with the code, and no errors occur, but this message is very annoying in my console. Thanks for the help.

    Code:java
    1. public void setup(Plugin p) {
    2. this.p = p;
    3.  
    4. try{
    5. //copy all the files within plugin in the directory "plugins/YOUR_PLUGIN/"
    6. //files will be overwritten
    7. p.saveResource("arenas.yml", false);
    8. p.saveResource("config.yml", false);
    9. p.saveResource("signs.yml", false);
    10. p.saveResource("chests.yml", false);
    11. } catch (Exception e){}
    12.  
    13. arenaFile = new File(p.getDataFolder(), "arenas.yml");
    14. configFile = new File(p.getDataFolder(), "config.yml");
    15. signFile = new File(p.getDataFolder(), "signs.yml");
    16. chestFile = new File(p.getDataFolder(), "chests.yml");
    17.  
    18.  
    19. //files are certainly created now, so you won't have to check, whether or not they exist.
    20. arenas = YamlConfiguration.loadConfiguration(arenaFile);
    21. config = YamlConfiguration.loadConfiguration(configFile);
    22. signs = YamlConfiguration.loadConfiguration(signFile);
    23. chests = YamlConfiguration.loadConfiguration(chestFile);
    24.  
    25. if(SettingsManager.getInstance().config.getBoolean("Economy.Enabled")) {
    26. if (!setupEconomy() ) {
    27. getPlugin().getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getPlugin().getDescription().getName()));
    28. getPlugin().getServer().getPluginManager().disablePlugin(getPlugin());
    29. return;
    30. }
    31. }
    32. }
    33.  
    34. public void saveArenas() {
    35. try { arenas.save(arenaFile); }
    36. catch (Exception e) { }
    37. }
    38.  
    39. public void saveConfig() {
    40. try { config.save(configFile);}
    41. catch (Exception e) { }
    42. }
    43.  
    44. public void saveSigns() {
    45. try { signs.save(signFile); }
    46. catch (Exception e) { }
    47. }
    48.  
    49. public void saveChests() {
    50. try { chests.save(chestFile); }
    51. catch (Exception e) { }
    52. }


    Here is the errors
    Code:
        [23:32:27 INFO]: [HungerGames] Enabling HungerGames v1.0.0
    [23:32:27 WARN]: [HungerGames] Could not save arenas.yml to plugins\HungerGames\
    arenas.yml because arenas.yml already exists.
    [23:32:27 WARN]: [HungerGames] Could not save config.yml to plugins\HungerGames\
    config.yml because config.yml already exists.
    [23:32:27 WARN]: [HungerGames] Could not save signs.yml to plugins\HungerGames\s
    igns.yml because signs.yml already exists.
    [23:32:27 WARN]: [HungerGames] Could not save chests.yml to plugins\HungerGames\
    chests.yml because chests.yml already exists.
     
  2. Offline

    WinX64

    The second parameter of saveReources specifies if the file will be overwritten if it already exists. You can simply change it to true or check if that file already exists before saving it.
     
    cfil360 likes this.
  3. Offline

    cfil360

    Ok I will try checking to see if the file exists. Thanks WinX64
     
Thread Status:
Not open for further replies.

Share This Page