@@ -43,13 +43,15 @@ public class ConfigAPI {
43
43
* @param nameStyle Style of config's fields names
44
44
* @param commentStyle Style of config's comments
45
45
* @param automaticColorStrings Automatic translate '&' based colors
46
+ * @param dir The config's directory.
46
47
* @param plugin Instance of your plugin
47
48
* @see NameStyle
48
49
* @see CommentStyle
49
50
* @return Instance of {@param clazz} ready to use methods
50
51
*/
51
52
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
+
53
55
ConfigAPI .plugin = plugin ;
54
56
ConfigName configName = clazz .getAnnotation (ConfigName .class );
55
57
if (configName == null ) {
@@ -60,7 +62,7 @@ public static <T extends Config> T init(Class<T> clazz, NameStyle nameStyle, Com
60
62
String configComment = configCommentAnnotation == null ? null : configCommentAnnotation .value ();
61
63
62
64
String name = configName .value () + (configName .value ().endsWith (".yml" ) ? "" : ".yml" );
63
- File file = new File (plugin . getDataFolder () , name );
65
+ File file = new File (dir , name );
64
66
65
67
BukkitConfiguration rawConfiguration = new BukkitConfiguration (file , nameStyle , commentStyle , automaticColorStrings , configComment );
66
68
rawConfigurations .put (name , rawConfiguration );
@@ -72,6 +74,24 @@ public static <T extends Config> T init(Class<T> clazz, NameStyle nameStyle, Com
72
74
return configuration ;
73
75
}
74
76
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
+
75
95
/**
76
96
* Initializes instance of Config with default values
77
97
* (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) {
83
103
return init (clazz , NameStyle .CAMEL_CASE , CommentStyle .ABOVE_CONTENT , true , plugin );
84
104
}
85
105
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
+
86
118
/**
87
119
* Allows to get BukkitConfiguration object for config. It allows to access Bukkit's YamlConfiguration raw methods
88
120
* @param name Name of your config
0 commit comments