Custom Configuration File isn't loading in.

Discussion in 'Plugin Development' started by OTF Catastrophe, Jun 28, 2016.

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

    OTF Catastrophe

    Well I've been searching Google a lot trying to find solutions for why my Custom Configuration File wont load in. My code: (I know its pretty bad code for the plugin, I'm simply taking over the plugin, most of it isn't my original code. It was the authors that asked me to take over.)


    Code:
        File arenasFile;
                   FileConfiguration Arena= YamlConfiguration.loadConfiguration(new File(getDataFolder(), "arenas.yml"));
    
        public void configCreator(Main plugin)
        {
          
            this.plugin = plugin;
          
        }
    
        public void onEnable()
        {
          
            getServer().getPluginManager().registerEvents(this, this);
            FileManager.getInstance().setup(this);
          
            if (config.getBoolean("Vault", true))
            {
              
                if (!setupEconomy())
                {
                  
                    this.logger.severe(String.format("[%s] - Disabled due to no Vault dependency found!", new Object[] {getDescription().getName()}));
                  
                    getServer().getPluginManager().disablePlugin(this);
                  
                    return;
                  
                }
              
                setEnabled(Boolean.TRUE.booleanValue());
              
            }
          
            System.out.println("SheepcraftParkour has been enabled! Thank you for using Sheepcraft! (Created by: Sheepcraft & Apathy)");
          
            arenas = (ArrayList)getConfig().getStringList("Arenas");
      
            this.saveDefaultConfig();
          
            config.options().copyDefaults(true);
          
        }
    
        public static Plugin getPluginInstance()
        {
          
            return instance;
          
        }
    
        private boolean setupEconomy()
        {
          
            if (getServer().getPluginManager().getPlugin("Vault") == null)
            {
              
                return false;
              
            }
          
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
          
            if (rsp == null)
            {
              
                return false;
              
            }
          
            econ = (Economy)rsp.getProvider();
            return econ != null;
          
        }
    
        public void onDisable()
        {
          
            System.out.print("Thank you for using SheepcrafParkour! Have a good day!");
          
        }
      
        public void setup(Plugin pl)
        {
          
            if (!pl.getDataFolder().exists())
            {
              
                try
                {
                  
                    pl.getDataFolder().createNewFile();
                  
                }
              
                catch (IOException e)
                {
                  
                    Bukkit.getServer().getLogger().severe("SheepcraftParkour could not create config file!");
                  
                }
              
            }
          
            if (!arenasFile.exists())
            {
              
                try
                {
                  
                    arenasFile.createNewFile();
                  
                }
              
                catch (IOException e)
                {
                  
                    Bukkit.getServer().getLogger().severe("SheepcraftParkour could not create arenas file!");
                  
                }
              
            }
          
            Arena = YamlConfiguration.loadConfiguration(arenasFile);
          
        }
      
    This is the entire onEnable and onDisable process. I've checked out a few videos and also tons and tons of bukkit and spigot forums on how to load it in and I've even looked at the bukkit wiki for the Configuration API Reference to see what I'm doing wrong and I just can't seem to get it working. Am I missing something extremely obvious?

    Path: /plugins/SheepcraftParkour/arenas.yml
    arenas.yml file:

    Code:
    # DO NOT TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING!
    Arenas:
    Pretty simple config file for the arenas. I'd also like to mention I'm trying to get the internal arenas.yml file to load in. One last thing before I end off, please try to refrain from telling me whats wrong with my code UNLESS its going to help fix my issue. I don't want to sound rude but I'd rather fix my issue than be told the random tidbits of what's wrong with my code that doesn't matter.

    Thank you for taking the time to read!
     
  2. Offline

    bwfcwalshy Retired Staff

    What ever happened to the classic true..
    Also why are you enabling the plugin while the plugin is being enabled?!?!?!?
     
  3. Offline

    OTF Catastrophe

    Well like I stated, not my original code. I'm not here to fix his old code just to add what's needed.

    And I also asked please don't comment if you weren't going to help solve the problem

    @timtower I saw you recently attempted helping MrGeneralIQ with the same issue. Could you possibly tell me what're wrong? I updated the code a little bit so it looks like this now:

    Code:
        File arenasFile = new File(getDataFolder(), "arenas.yml");
        FileConfiguration Arena = YamlConfiguration.loadConfiguration(getResource("arenas.yml"));
      
        public void configCreator(Main plugin)
        {
          
            this.plugin = plugin;
          
        }
    
        public void onEnable()
        {
          
            getServer().getPluginManager().registerEvents(this, this);
            FileManager.getInstance().setup(this);
          
            if (config.getBoolean("Vault", true))
            {
              
                if (!setupEconomy())
                {
                  
                    this.logger.severe(String.format("[%s] - Disabled due to no Vault dependency found!", new Object[] {getDescription().getName()}));
                  
                    getServer().getPluginManager().disablePlugin(this);
                  
                    return;
                  
                }
    
            }
          
            System.out.println("SheepcraftParkour has been enabled! Thank you for using Sheepcraft! (Created by: Sheepcraft & Apathy)");
          
            arenas = (ArrayList)getConfig().getStringList("Arenas");
      
            this.saveDefaultConfig();
          
            config.options().copyDefaults(true);
          
        }
    
        public static Plugin getPluginInstance()
        {
          
            return instance;
          
        }
    
        private boolean setupEconomy()
        {
          
            if (getServer().getPluginManager().getPlugin("Vault") == null)
            {
              
                return false;
              
            }
          
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
          
            if (rsp == null)
            {
              
                return false;
              
            }
          
            econ = (Economy)rsp.getProvider();
            return econ != null;
          
        }
    
        public void onDisable()
        {
          
            System.out.print("Thank you for using SheepcrafParkour! Have a good day!");
          
        }
      
        public void setup(Plugin pl)
        {
          
            if (!arenasFile.exists())
            {
              
                try
                {
                  
                    arenasFile.createNewFile();
                  
                }
              
                catch (IOException e)
                {
                  
                    Bukkit.getServer().getLogger().severe("SheepcraftParkour could not create arenas file!");
                  
                    e.printStackTrace();
                  
                }
              
            }
          
            Arena = YamlConfiguration.loadConfiguration(arenasFile);
          
        }
    Can you please tell me what I'm doing wrong? I would also like to mention I'm not getting any stack trace errors. I checked to make sure all the basics were right and even tried deleting the plugin folder and reloading the plugin to get a new data folder. Nothing's working for me.
     
    Last edited: Jun 29, 2016
  4. Offline

    OTF Catastrophe

    Bump, still need an answer :p
     
  5. Offline

    OTF Catastrophe

Thread Status:
Not open for further replies.

Share This Page