package com.forgeessentials.api.snooper;

import java.lang.reflect.Type;

import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTException;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.config.Configuration;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import cpw.mods.fml.common.FMLCommonHandler;

/**
 * If you want your own query response, extend this file and override
 * getResponceString(DatagramPacket packet)
 *
 * @author Dries007
 */
public abstract class Response
{
    protected final MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    protected static final Gson GSON = (new GsonBuilder())
            .registerTypeHierarchyAdapter(NBTBase.class, new NBTBaseAdapter())
            .setPrettyPrinting()
            .create();
    
    public int id;
    public boolean allowed = true;

    public abstract JsonElement getResponce(JsonObject jsonElement) throws JsonParseException;

    public abstract String getName();

    public abstract void readConfig(String category, Configuration config);

    public abstract void writeConfig(String category, Configuration config);
    
    private static class NBTBaseAdapter implements JsonDeserializer<NBTBase>, JsonSerializer<NBTBase> 
    {

        @Override
        public JsonElement serialize(NBTBase src, Type typeOfSrc, JsonSerializationContext context)
        {
            return (new JsonParser()).parse(src.toString());
        }

        @Override
        public NBTBase deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
        {
            try
            {
                return JsonToNBT.func_150315_a(GSON.toJson(json));
            }
            catch (NBTException e)
            {
                e.printStackTrace();
                return null;
            }
        }
    }
}

@@ -46,33 +46,72 @@
 ort 
-java.lang.reflect.Type
+com.google.gson.*;%0Aimport cpw.mods.fml.common.FMLCommonHandler
 ;%0A
-%0A
 impo
@@ -327,439 +327,30 @@
 ort 
-com.google.gson.Gson;%0Aimport com.google.gson.GsonBuilder;%0Aimport com.google.gson.JsonDeserializationContext;%0Aimport com.google.gson.JsonDeserializer;%0Aimport com.google.gson.JsonElement;%0Aimport com.google.gson.JsonObject;%0Aimport com.google.gson.JsonParseException;%0Aimport com.google.gson.JsonParser;%0Aimport com.google.gson.JsonSerializationContext;%0Aimport com.google.gson.JsonSerializer;%0A%0Aimport cpw.mods.fml.common.FMLCommonHandler
+java.lang.reflect.Type
 ;%0A%0A/
@@ -1607,17 +1607,16 @@
 context)
- 
 throws J
@@ -1633,16 +1633,16 @@
 ception%0A
+
         
@@ -1700,31 +1700,19 @@
 urn 
-JsonToNBT.func_150315_a
+parseAsJson
 (GSO
@@ -1857,16 +1857,16 @@
 n null;%0A
-
         
@@ -1876,21 +1876,165 @@
  %7D%0A        %7D
+%0A%0A        private NBTBase parseAsJson(String string) throws NBTException%0A        %7B%0A         return JsonToNBT.func_150315_a(string)   ;%0A        %7D
 %0A    %7D%0A%7D%0A

Fix compile error