RuneHive-Game
Loading...
Searching...
No Matches
PersonalStoreSaver.java
Go to the documentation of this file.
1package com.runehive.content.store;
2
3import com.google.gson.JsonParser;
4import com.runehive.content.store.impl.PersonalStore;
5import com.runehive.util.GsonUtils;
6
7import java.io.FileReader;
8import java.io.FileWriter;
9import java.nio.file.Files;
10import java.nio.file.Path;
11import java.nio.file.Paths;
12
13public 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)) {
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}
static Map< String, Long > SOLD_ITEMS
A mapping of a player name with the amount of coins waiting for him.
static final ThreadLocal< Gson > JSON_PRETTY_ALLOW_NULL