RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
PersonalStoreSaver.java
1package com.osroyale.content.store;
2
3import com.google.gson.JsonParser;
4import com.osroyale.content.store.impl.PersonalStore;
5import com.osroyale.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
36
37public class PersonalStoreSaver {
38
39 private static final String PAYMENT_PATH = "/def/content/game/personal_stores_payments.json";
40
41 public static void savePayments() {
42 Thread.startVirtualThread(() -> {
43 try (FileWriter fw = new FileWriter("./data" + PAYMENT_PATH)) {
44 fw.write(GsonUtils.JSON_PRETTY_ALLOW_NULL.get().toJson(PersonalStore.SOLD_ITEMS));
45 } catch (final Exception e) {
46 e.printStackTrace();
47 }
48 });
49 }
50
51 public static void loadPayments() {
52 Path path = Paths.get("data", PAYMENT_PATH);
53
54 if (!Files.exists(path)) {
55 return;
56 }
57
58 try (FileReader reader = new FileReader(path.toFile())) {
59 JsonParser parser = new JsonParser();
60 //PersonalStore.SOLD_ITEMS = new GsonBuilder().create().fromJson(parser.parse(reader), type);
61 } catch (Exception e) {
62 e.printStackTrace();
63 }
64 }
65}