RuneHive-Game
Loading...
Searching...
No Matches
PersonalStoreSaver.java
Go to the documentation of this file.
1
package
com.runehive.content.store;
2
3
import
com.google.gson.JsonParser;
4
import
com.runehive.content.store.impl.PersonalStore;
5
import
com.runehive.util.GsonUtils;
6
7
import
java.io.FileReader;
8
import
java.io.FileWriter;
9
import
java.nio.file.Files;
10
import
java.nio.file.Path;
11
import
java.nio.file.Paths;
12
13
public
class
PersonalStoreSaver
{
14
15
private
static
final
String
PAYMENT_PATH
=
"/def/content/game/personal_stores_payments.json"
;
16
17
public
static
void
savePayments
() {
18
Thread.startVirtualThread(() -> {
19
try
(FileWriter fw =
new
FileWriter(
"./data"
+
PAYMENT_PATH
)) {
20
fw.write(
GsonUtils
.
JSON_PRETTY_ALLOW_NULL
.get().toJson(
PersonalStore
.
SOLD_ITEMS
));
21
}
catch
(
final
Exception e) {
22
e.printStackTrace();
23
}
24
});
25
}
26
27
public
static
void
loadPayments
() {
28
Path path = Paths.get(
"data"
,
PAYMENT_PATH
);
29
30
if
(!Files.exists(path)) {
31
return
;
32
}
33
34
try
(FileReader reader =
new
FileReader(path.toFile())) {
35
JsonParser parser =
new
JsonParser();
36
//PersonalStore.SOLD_ITEMS = new GsonBuilder().create().fromJson(parser.parse(reader), type);
37
}
catch
(Exception e) {
38
e.printStackTrace();
39
}
40
}
41
}
com.runehive.content.store.PersonalStoreSaver
Definition
PersonalStoreSaver.java:13
com.runehive.content.store.PersonalStoreSaver.loadPayments
static void loadPayments()
Definition
PersonalStoreSaver.java:27
com.runehive.content.store.PersonalStoreSaver.savePayments
static void savePayments()
Definition
PersonalStoreSaver.java:17
com.runehive.content.store.PersonalStoreSaver.PAYMENT_PATH
static final String PAYMENT_PATH
Definition
PersonalStoreSaver.java:15
com.runehive.content.store.impl.PersonalStore
Definition
PersonalStore.java:22
com.runehive.content.store.impl.PersonalStore.SOLD_ITEMS
static Map< String, Long > SOLD_ITEMS
A mapping of a player name with the amount of coins waiting for him.
Definition
PersonalStore.java:28
com.runehive.util.GsonUtils
Definition
GsonUtils.java:8
com.runehive.util.GsonUtils.JSON_PRETTY_ALLOW_NULL
static final ThreadLocal< Gson > JSON_PRETTY_ALLOW_NULL
Definition
GsonUtils.java:14