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:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user