-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.java
52 lines (44 loc) · 1.42 KB
/
Config.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Config {
public static String amountOfItem;
public static Long interval;
public static String notificationPrice;
public static String json;
public static String itemurl;
public static double price;
public static String getAmountOfItem() {
return amountOfItem;
}
public static Long getInterval() {
return interval;
}
public static String getNotificationPrice() {
return notificationPrice;
}
public static String getItemURL() {
return itemurl;
}
public static void parseConfig() {
JSONParser parser = new JSONParser();
Scanner s = null;
try {
s = new Scanner(new File("./config.json"));
json = s.nextLine();
s.close();
JSONObject obj = (JSONObject) parser.parse(json);
amountOfItem = (String) obj.get("amountofitem");
interval = (Long) obj.get("interval");
notificationPrice = (String) obj.get("notificationprice");
itemurl = (String) obj.get("itemurl");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}
}