Fixed all issues with F chest, and a massive increase in performance due to /f chest only serializing / deserializing on startup/shutdown instead of realtime.

This commit is contained in:
ProSavage
2018-09-09 12:40:45 -05:00
parent 9795d3c158
commit 4ad062dddb
7 changed files with 74 additions and 50 deletions

View File

@@ -0,0 +1,29 @@
package com.massivecraft.factions.util;
import com.google.gson.*;
import org.bukkit.inventory.Inventory;
import java.lang.reflect.Type;
public class InventoryTypeAdapter implements JsonSerializer<Inventory>, JsonDeserializer<Inventory> {
@Override
public JsonElement serialize(Inventory inventory, Type type, JsonSerializationContext jsonSerializationContext) {
JsonObject object = new JsonObject();
object.add("contents", new JsonPrimitive(InventoryUtil.toBase64(inventory)));
return object;
}
@Override
public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
JsonObject object = jsonElement.getAsJsonObject();
return InventoryUtil.fromBase64(object.get("contents").getAsString());
}
}