Plugin not working and no errors?

Discussion in 'Spigot Plugin Development' started by ZevoGaems, May 6, 2017.

  1. I am a little confused on the

    if(!getconfigsection == null) {
    cancel
    }

    can you please elaborate.
     
  2. or well

    if you do (value== null) then it will only run the code in the block if the value is null. However if you do (value != null), then it will only run the code in the block if the value isn't null.

    so you can do if(getconfigsection != null) kick because banned
     
  3. Do I change getconfigsection or do I leave it as getconfigsection?
     
  4. Figure it out. Didn't I tell you to learn Java like 4 posts ago (2 days ago)?
     
  5. WAS

    WAS

    Why aren't you just using a basic create configuration method?

    Code (Java):
      private void createConfig() {
         try {
           if (!(getDataFolder().exists())) {
             getDataFolder().mkdirs();
           }
           File file = new File(getDataFolder(), "config.yml");
           if (!(file.exists())) {
             getLogger().info("Generating configuration...");
             saveDefaultConfig();
           } else {
             getLogger().info("Loading configuration...");
             // Could assign your getConfig() method to a private global var here if you wanted.
           }
         } catch (Exception e) {
           e.printStackTrace();
         }
       }
    Code (Java):
    @Override
    public void onEnable() {
        createConfig();
    }
     
    #45 WAS, May 8, 2017
    Last edited: May 8, 2017
  6. change it to getConfig().getConfigurationSection(), I was just using getconfigsection as pseudo code. I do highly suggest you learn Java.
     
  7. WAS

    WAS

    May want to also add MemorySection#getConfigurationSection(String path) takes a path.
     
    • Agree Agree x 1
  8. You could just use #isConfigurationSection instead ;p
     
    • Agree Agree x 1
  9. Oh yeah, that'd be a better alternative

    if(isConfigurationSection("the key") //yep, their banned
     
  10. Don't have this, it copy's the config in your plugin, then replaces the one in the plugins folder. That means you will remove everything saved when the plugin reloads. if i'm, wrong someone let me know