1package com.runehive.util;
3import com.google.gson.JsonArray;
4import com.google.gson.JsonElement;
5import com.google.gson.JsonObject;
6import com.google.gson.reflect.TypeToken;
7import com.runehive.content.WellOfGoodwill;
8import com.runehive.content.WellOfGoodwill.Contributor;
9import com.runehive.content.bot.BotUtility;
10import com.runehive.game.world.entity.mob.player.PlayerRight;
11import com.runehive.util.parser.GsonParser;
13import java.io.FileWriter;
14import java.util.HashMap;
15import java.util.Optional;
26 public static void save() {
27 Thread.startVirtualThread(() -> {
28 try (FileWriter fw =
new FileWriter(
"./data/content/game/world.json")) {
30 }
catch (
final Exception e) {
37 JsonObject
object =
new JsonObject();
46 JsonArray wogArray =
new JsonArray();
48 JsonObject contributorObj =
new JsonObject();
49 contributorObj.addProperty(
"name", contributor.
name);
50 contributorObj.addProperty(
"rank", contributor.
rank.
getCrown());
51 contributorObj.addProperty(
"amount", contributor.
contribution);
52 wogArray.add(contributorObj);
55 object.add(
"contributors", wogArray);
59 object.addProperty(
"personal-store-items-sold",
ITEMS_SOLD);
64 public static void load() {
67 protected void parse(JsonObject
object) {
74 if (
object.has(
"wog-last-contributor")) {
78 final JsonArray contributors =
object.get(
"contributors").getAsJsonArray();
79 for (JsonElement element : contributors) {
80 final JsonObject contributorObj = (JsonObject) element;
81 final String name = contributorObj.get(
"name").getAsString();
82 final Optional<PlayerRight> rank =
PlayerRight.
lookup(contributorObj.get(
"rank").getAsInt());
83 final int amount = contributorObj.get(
"amount").getAsInt();
89 ITEMS_SOLD =
object.get(
"personal-store-items-sold").getAsLong();
Handles contribution towards the well of goodwill.
static String lastContributor
The last contributor to the well.
static int CONTRIBUTION
The current contribution amount for the well.
static TreeSet< Contributor > contributors
The array list of contributors.
static void add(String name, PlayerRight rank, int amount)
Holds all the constants used by bot.
static Map< Integer, MutableNumber > BOOT_LOOT
Created by Daniel on 2017-11-05.
static JsonObject toJson()
static long PERSONAL_ITEM_WORTH
This class provides an easy to use google gson parser specifically designed for parsing JSON files.
Holds all the player right data.
static Optional< PlayerRight > lookup(int id)
static String getCrown(Player player)
Gets the crown display.
static final ThreadLocal< Gson > JSON_PRETTY_NO_NULLS
static final ThreadLocal< Gson > JSON_PRETTY_ALLOW_NULL