Configuration

Discussion in 'Plugin Development' started by MaTaMoR_, May 19, 2015.

Thread Status:
Not open for further replies.
  1. Hi, i made a configuration using a enum but i was wondering if it is efficient or it just sucks

    I really like this type of config beucase i can really easy acces it from any class, also i made a similar system for messages.yml

    ¿ What do you think guys ? :
    Show Spoiler

    Code:
    public enum Config {
     
        TAG_DURATION(10, "tagDuration");
    
        private final Object message;
        private final String path;
        private static FileConfiguration config;
    
        private Config(Object message, String path) {
            this.message = message;
            this.path = path;
        }
    
        public Object getDefault() {
            return this.message;
        }
    
        public String getPath() {
            return "Configuration." + this.path;
        }
    
        public Object getValue() {
            return config.get(getPath());
        }
     
        public String getString() {
            return config.getString(getPath());
        }
     
        public int getInt() {
            return config.getInt(getPath());
        }
     
        public boolean getBoolean() {
            return config.getBoolean(getPath());
        }
    
        public List<String> getList() {
            return config.getStringList(getPath());
        }
     
        public static void setConfig(FileConfiguration config) {
            Config.config = config;
        }
    }
    
     
Thread Status:
Not open for further replies.

Share This Page