Problems with own File Manager

Discussion in 'Spigot Plugin Development' started by Daaniel, Jul 25, 2018.

  1. This is my file manager class: https://pastebin.com/bbQjhMNB
    And this is my custom logger class: https://pastebin.com/4ejt5mB5

    But the problem is the if(File_Creator.getSettingsConfig().getString("debug") == null || File_Creator.getSettingsConfig().getBoolean("debug") == true) { because if i have that check it can't add strings to my settings.yml file and when i remove that check it has no problems with adding strings to the settings.yml
    In my console are no error. :(
    Can someone help me fix this bugg?
     
  2. Hi, first of all please remove the "Resource" tag since this is no resource. What's debug's value in the config? Furthermore I don't see any method that adds a string to the config.

    Btw. don't abuse static that much please.
     
  3. Just use

    if (config.getBoolean("debug", false))

    == true is redundant, getString() == null makes no sense and the default parameter will define a default return value if no value is available.
     
  4. I want to check if debug is enabled via == true so that the debug message only get shown when debug is enabled.
     
  5. In my mainclass is the set method: https://pastebin.com/n6EUrEZ8
     
  6. and the only way to access the class in all classes is via an static for as far as i know.
     
  7. You know that "if (debug == true)" is equal to "if (debug)" ?

    Bruh. Please take a look at Java basics. Pass an instance of the class in the constructor or create a getter that returns the class its instance.
     
  8. Sorry i didn't use that in a verry long time
     
  9. I now have if(File_Creator.getSettingsConfig().getBoolean("debug")){ but still no debug: true in my settings.yml file
     
  10. Please. This hurts so damn much in my eyes. You literally did everything wrong what you could have done wrong in a plugin.
     
  11. What? It works perfect but it has an huge problem if i try to access an file before it is loaded/created as you can see in the code.
    And i don't know how to fix it.
     
  12. :unsure: