saveResource Spam

Discussion in 'Spigot Plugin Development' started by WAS, Apr 17, 2017.

  1. WAS


    Not sure why saveResource even complains at you when it specifically gives you a boolean to handle it, but why am I getting a file exists error when the code should only be running if the file doesn't exist?

    Code (Java):
        String effectsPath = Bukkit.getPluginManager().getPlugin("BlastRadius").getDataFolder().getAbsolutePath() + File.separator + "effects" + File.separator;
        File defaultEffect = new File(effectsPath + File.separator + "effects" + File.separator + "default.yml");
         if ( ! ( defaultEffect.exists() ) ) {
           // Fires regardless if file exists or not...
           Bukkit.getServer().getPluginManager().getPlugin("BlastRadius").saveResource("effects/default.yml", false);
    Code (Text):
    Could not save default.yml to plugins\BlastRadius\effects\default.yml because default.yml already exists.
    Seriously though. I specify false. Do not overwrite. That doesn't mean bitch at me because it exists. Because I know it will, and the reason the flag is false to not overwrite... It's like a catch 22 lol I mean the functionality would seem perfectly acceptable if a boolean wasn't provided.
    #1 WAS, Apr 17, 2017
    Last edited: Apr 17, 2017
  2. You are adding /effects/ to the file path twice. Because of this it thinks that the file doesn't exist so it saves it.

    Also, just a question, why do people hate this message so much? Imo it provides debug/verbose info so I like it
  3. WAS


    Holy-fresh-eyes Batman! I didn't even notice that. Looked over that all like probably 30 times.

    And I hate it because the methods implementation is contrary to it. If I didn't add a flag, than it would make perfect sense. But adding a flag is a indication the user expects a outcome. For example, I put false because it only want to save it once and let user modification, but it is required so if it doesn't exist it must be generated.
  4. The smallest things are the hardest to find, happens to me all the time too :(
  5. WAS


    Seriously. I had a "^" instead of "&" for a chat translation and couldn't figure it out for almost an hour earlier but felt too embarrassed as I knew it was something stupid as there was nothing "big" amiss. Also updated my last post.
  6. That's a fair point, never thought about that.
    That must have sucked :D
    • Like Like x 1