package valandur.webapi.json.serializers.events;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.spongepowered.api.event.cause.Cause;

import java.io.IOException;
import java.util.Map;

public class CauseSerializer extends StdSerializer<Cause> {

    public CauseSerializer() {
        this(null);
    }

    public CauseSerializer(Class<Cause> t) {
        super(t);
    }

    @Override
    public void serialize(Cause value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeStartObject();

        for (Map.Entry<String, Object> entry : value.getNamedCauses().entrySet()) {
            if (entry.getValue().getClass().getName().startsWith("net.minecraft.server"))
                gen.writeStringField(entry.getKey(), entry.getValue().getClass().getName());
            else
                gen.writeObjectField(entry.getKey(), entry.getValue());
        }

        gen.writeEndObject();
    }
}

@@ -288,16 +288,67 @@
 eption;%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A
 import j
@@ -361,16 +361,16 @@
 il.Map;%0A
-
 %0Apublic 
@@ -423,16 +423,265 @@
 use%3E %7B%0A%0A
+    private static List%3CString%3E blockedCauseClasses;%0A    static %7B%0A        List%3CString%3E classes = new ArrayList%3C%3E();%0A%0A        classes.add(%22net.minecraft.server%22);%0A        classes.add(%22valandur.webapi%22);%0A%0A        blockedCauseClasses = classes;%0A    %7D%0A%0A
     publ
@@ -1055,16 +1055,59 @@
     if (
+blockedCauseClasses.stream().anyMatch(c -%3E 
 entry.ge
@@ -1147,38 +1147,18 @@
 rtsWith(
-%22net.minecraft.server%22
+c)
 ))%0A     

Fix cmd hook not working for commands run via Web-API