12
12
public class Config {
13
13
public static File configFile = new File (Loader .instance ().getConfigDir (), "hytools.cfg" );
14
14
15
+ //returns if config is not the current version
15
16
public static Boolean isNotCurrentVersion () throws IOException {
16
17
BufferedReader brTest = new BufferedReader (new FileReader (configFile ));
17
18
String text = brTest .readLine ();
@@ -20,11 +21,9 @@ public static Boolean isNotCurrentVersion() throws IOException {
20
21
if (!text .contains (Reference .VERSION )) return true ;
21
22
return false ;
22
23
}
23
-
24
+
25
+ //example: getValueFromConfig("api-key") returns "thisIsTheApiKey"
24
26
public static String getValueFromConfig (String value ) {
25
- //example:
26
- //getValueFromConfig("api-key") returns qergijoiwequjfboqwiuefnweiofnwe
27
-
28
27
String data = null ;
29
28
try {
30
29
BufferedReader file = new BufferedReader (new FileReader (configFile ));
@@ -47,11 +46,9 @@ public static String getValueFromConfig(String value) {
47
46
48
47
return data ;
49
48
}
50
-
49
+
50
+ //example: setValueFromConfig("api-key", "thisIsTheApiKey")
51
51
public static void setValueFromConfig (String value , String data ) {
52
- //example:
53
- //setValueFromConfig("api-key", "qergijoiwequjfboqwiuefnweiofnwe")
54
-
55
52
try {
56
53
// input the (modified) file content to the StringBuffer "input"
57
54
BufferedReader file = new BufferedReader (new FileReader (configFile ));
@@ -75,16 +72,16 @@ public static void setValueFromConfig(String value, String data) {
75
72
Hytools .log .info ("Problem writing file." );
76
73
}
77
74
}
78
-
75
+
76
+ //delete the config file
79
77
public static void delete () {
80
- //deletes the config file
81
- if (configFile .delete ()) {
78
+ if (configFile .delete ())
82
79
Hytools .log .info ("Config file has been succesfully deleted." );
83
- } else {
80
+ else
84
81
Hytools .log .info ("Error! Config file couldn't be deleted!" );
85
- }
86
82
}
87
83
84
+ //create a config file
88
85
public static void create () {
89
86
try {
90
87
if (configFile .createNewFile ()) {
@@ -128,7 +125,7 @@ public static void create() {
128
125
}
129
126
}
130
127
131
- // premade methods to do the ones above automatically
128
+ // hypixel api key
132
129
public static String getStoredAPIKey () {
133
130
return getValueFromConfig ("api-key" );
134
131
}
@@ -137,6 +134,7 @@ public static void setStoredAPIKey(String key) {
137
134
setValueFromConfig ("api-key" , key );
138
135
}
139
136
137
+ // party guess
140
138
public static Boolean getPartyGuess () {
141
139
String str = getValueFromConfig ("party-guess_toggled" );
142
140
if (str .equals ("true" )) {
@@ -150,6 +148,7 @@ public static void setPartyGuess(Boolean bool) {
150
148
setValueFromConfig ("party-guess_toggled" , String .valueOf (bool ));
151
149
}
152
150
151
+ // party guess friend
153
152
public static Boolean getPartyGuessFriend () {
154
153
String str = getValueFromConfig ("party-guess-friendmsg_toggled" );
155
154
if (str .equals ("true" )) {
@@ -158,44 +157,44 @@ public static Boolean getPartyGuessFriend() {
158
157
return false ;
159
158
}
160
159
}
161
-
160
+
162
161
public static void setPartyGuessFriend (Boolean bool ) {
163
162
setValueFromConfig ("party-guess-friendmsg_toggled" , String .valueOf (bool ));
164
163
}
165
164
165
+ // party guess guild
166
166
public static Boolean getPartyGuessGuild () {
167
167
String str = getValueFromConfig ("party-guess-guildcheck_toggled" );
168
- if (str .equals ("true" )) {
168
+ if (str .equals ("true" ))
169
169
return true ;
170
- } else {
170
+ else
171
171
return false ;
172
- }
173
172
}
174
173
175
174
public static void setPartyGuessGuild (Boolean bool ) {
176
175
setValueFromConfig ("party-guess-guildcheck_toggled" , String .valueOf (bool ));
177
176
}
178
-
177
+
178
+ // nick alert
179
179
public static Boolean getNickAlert () {
180
180
String str = getValueFromConfig ("nick-alert_toggled" );
181
- if (str .equals ("true" )) {
181
+ if (str .equals ("true" ))
182
182
return true ;
183
- } else {
183
+ else
184
184
return false ;
185
- }
186
185
}
187
186
188
187
public static void setNickAlert (Boolean bool ) {
189
188
setValueFromConfig ("nick-alert_toggled" , String .valueOf (bool ));
190
189
}
191
190
191
+ // nick alert hypixel api
192
192
public static Boolean getNickAlertHypixelAPI () {
193
193
String str = getValueFromConfig ("nick-alert-hypixel-api_toggled" );
194
- if (str .equals ("true" )) {
194
+ if (str .equals ("true" ))
195
195
return true ;
196
- } else {
196
+ else
197
197
return false ;
198
- }
199
198
}
200
199
201
200
public static void setNickAlertHypixelAPI (Boolean bool ) {
0 commit comments