@@ -43,13 +43,15 @@ public class ConfigAPI {
4343 * @param nameStyle Style of config's fields names
4444 * @param commentStyle Style of config's comments
4545 * @param automaticColorStrings Automatic translate '&' based colors
46+ * @param dir The config's directory.
4647 * @param plugin Instance of your plugin
4748 * @see NameStyle
4849 * @see CommentStyle
4950 * @return Instance of {@param clazz} ready to use methods
5051 */
5152 public static <T extends Config > T init (Class <T > clazz , NameStyle nameStyle , CommentStyle commentStyle ,
52- boolean automaticColorStrings , JavaPlugin plugin ) {
53+ boolean automaticColorStrings , File dir , JavaPlugin plugin ){
54+
5355 ConfigAPI .plugin = plugin ;
5456 ConfigName configName = clazz .getAnnotation (ConfigName .class );
5557 if (configName == null ) {
@@ -60,7 +62,7 @@ public static <T extends Config> T init(Class<T> clazz, NameStyle nameStyle, Com
6062 String configComment = configCommentAnnotation == null ? null : configCommentAnnotation .value ();
6163
6264 String name = configName .value () + (configName .value ().endsWith (".yml" ) ? "" : ".yml" );
63- File file = new File (plugin . getDataFolder () , name );
65+ File file = new File (dir , name );
6466
6567 BukkitConfiguration rawConfiguration = new BukkitConfiguration (file , nameStyle , commentStyle , automaticColorStrings , configComment );
6668 rawConfigurations .put (name , rawConfiguration );
@@ -72,6 +74,24 @@ public static <T extends Config> T init(Class<T> clazz, NameStyle nameStyle, Com
7274 return configuration ;
7375 }
7476
77+ /**
78+ * Initializes instance of Config
79+ * @param clazz Class of your Config interface
80+ * @param nameStyle Style of config's fields names
81+ * @param commentStyle Style of config's comments
82+ * @param automaticColorStrings Automatic translate '&' based colors
83+ * @param plugin Instance of your plugin
84+ * @see NameStyle
85+ * @see CommentStyle
86+ * @return Instance of {@param clazz} ready to use methods
87+ */
88+ public static <T extends Config > T init (Class <T > clazz , NameStyle nameStyle , CommentStyle commentStyle ,
89+ boolean automaticColorStrings , JavaPlugin plugin ) {
90+ return init (clazz , nameStyle , commentStyle , automaticColorStrings , plugin .getDataFolder (), plugin );
91+ }
92+
93+
94+
7595 /**
7696 * Initializes instance of Config with default values
7797 * (CAMEL_CASE as NameStyle, ABOVE_CONTENT as CommentStyle, enabled automatic translation of '&' based colors)
@@ -83,6 +103,18 @@ public static <T extends Config> T init(Class<T> clazz, JavaPlugin plugin) {
83103 return init (clazz , NameStyle .CAMEL_CASE , CommentStyle .ABOVE_CONTENT , true , plugin );
84104 }
85105
106+ /**
107+ * Initializes instance of Config with default values
108+ * (CAMEL_CASE as NameStyle, ABOVE_CONTENT as CommentStyle, enabled automatic translation of '&' based colors)
109+ * @param clazz Class of your Config interface
110+ * @param dir The config's directory.
111+ * @param plugin Instance of your plugin
112+ * @return Instance of {@param clazz} ready to use methods
113+ */
114+ public static <T extends Config > T init (Class <T > clazz , File dir , JavaPlugin plugin ) {
115+ return init (clazz , NameStyle .CAMEL_CASE , CommentStyle .ABOVE_CONTENT , true , dir , plugin );
116+ }
117+
86118 /**
87119 * Allows to get BukkitConfiguration object for config. It allows to access Bukkit's YamlConfiguration raw methods
88120 * @param name Name of your config
0 commit comments