src/main/java/de/dosmike/sponge/megamenus/api/state/StateObject.java
public static StateObject fromJson(JsonObject object) {
        StateObject result = new StateObject();
        object.entrySet().forEach(e->{
            int i = e.getKey().indexOf(':');
            if (i<1) throw new RuntimeException("Could not deserialize State from Json, not type information");
            String type = e.getKey().substring(0, i);
            String name = e.getKey().substring(i+1).toLowerCase();
            if (type.equals("b")) {
                result.set(name, e.getValue().getAsByte());
            } else if (type.equals("t")) {
                result.set(name, e.getValue().getAsBoolean());
            } else if (type.equals("s")) {
                result.set(name, e.getValue().getAsShort());
            } else if (type.equals("i")) {
                result.set(name, e.getValue().getAsInt());
            } else if (type.equals("l")) {
                result.set(name, e.getValue().getAsLong());
            } else if (type.equals("f")) {
                result.set(name, e.getValue().getAsFloat());
            } else if (type.equals("d")) {
                result.set(name, e.getValue().getAsDouble());
            } else if (type.equals("BI")) {
                result.set(name, e.getValue().getAsBigInteger());
            } else if (type.equals("BD")) {
                result.set(name, e.getValue().getAsBigDecimal());
            } else if (type.equals("S")) {
                result.set(name, e.getValue().getAsString());
            } else if (type.equals("O")) {
                try {
                    byte[] buffer = Base64.getDecoder().decode(e.getValue().getAsString());
                    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
                    ObjectInputStream ois = new ObjectInputStream(bais);
                    result.set(name, (Serializable) ois.readObject());
                } catch (Exception exception) {
                    throw new RuntimeException("Could not deserialize State from Json, Object corrupted", exception);
                }
            }
        });
        return result;
    }
/**
     * Create a new StateObject from Json
     * @return the restored StateObject
     */
Create a new StateObject from Json
@return the restored StateObject
Create a new StateObject from Json @return the restored StateObject
public static StateObject fromJson(JsonObject object) {
        StateObject result = new StateObject();
        object.entrySet().forEach(e->{
            int i = e.getKey().indexOf(':');
            if (i<1) throw new RuntimeException("Could not deserialize State from Json, not type information");
            String type = e.getKey().substring(0, i);
            String name = e.getKey().substring(i+1).toLowerCase();
            if (type.equals("b")) {
                result.set(name, e.getValue().getAsByte());
            } else if (type.equals("t")) {
                result.set(name, e.getValue().getAsBoolean());
            } else if (type.equals("s")) {
                result.set(name, e.getValue().getAsShort());
            } else if (type.equals("i")) {
                result.set(name, e.getValue().getAsInt());
            } else if (type.equals("l")) {
                result.set(name, e.getValue().getAsLong());
            } else if (type.equals("f")) {
                result.set(name, e.getValue().getAsFloat());
            } else if (type.equals("d")) {
                result.set(name, e.getValue().getAsDouble());
            } else if (type.equals("BI")) {
                result.set(name, e.getValue().getAsBigInteger());
            } else if (type.equals("BD")) {
                result.set(name, e.getValue().getAsBigDecimal());
            } else if (type.equals("S")) {
                result.set(name, e.getValue().getAsString());
            } else if (type.equals("O")) {
                try {
                    byte[] buffer = Base64.getDecoder().decode(e.getValue().getAsString());
                    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
                    ObjectInputStream ois = new ObjectInputStream(bais);
                    result.set(name, (Serializable) ois.readObject());
                } catch (Exception exception) {
                    throw new RuntimeException("Could not deserialize State from Json, Object corrupted", exception);
                }
            }
        });
        return result;
    }
public static StateObject fromJson ( JsonObject object ) { StateObject result = new StateObject ( ) ; object . entrySet ( ) . forEach ( e -> { int i = e . getKey ( ) . indexOf ( ':' ) ; if ( i < 1 ) throw new RuntimeException ( "Could not deserialize State from Json, not type information" ) ; String type = e . getKey ( ) . substring ( 0 , i ) ; String name = e . getKey ( ) . substring ( i + 1 ) . toLowerCase ( ) ; if ( type . equals ( "b" ) ) { result . set ( name , e . getValue ( ) . getAsByte ( ) ) ; } else if ( type . equals ( "t" ) ) { result . set ( name , e . getValue ( ) . getAsBoolean ( ) ) ; } else if ( type . equals ( "s" ) ) { result . set ( name , e . getValue ( ) . getAsShort ( ) ) ; } else if ( type . equals ( "i" ) ) { result . set ( name , e . getValue ( ) . getAsInt ( ) ) ; } else if ( type . equals ( "l" ) ) { result . set ( name , e . getValue ( ) . getAsLong ( ) ) ; } else if ( type . equals ( "f" ) ) { result . set ( name , e . getValue ( ) . getAsFloat ( ) ) ; } else if ( type . equals ( "d" ) ) { result . set ( name , e . getValue ( ) . getAsDouble ( ) ) ; } else if ( type . equals ( "BI" ) ) { result . set ( name , e . getValue ( ) . getAsBigInteger ( ) ) ; } else if ( type . equals ( "BD" ) ) { result . set ( name , e . getValue ( ) . getAsBigDecimal ( ) ) ; } else if ( type . equals ( "S" ) ) { result . set ( name , e . getValue ( ) . getAsString ( ) ) ; } else if ( type . equals ( "O" ) ) { try { byte [ ] buffer = Base64 . getDecoder ( ) . decode ( e . getValue ( ) . getAsString ( ) ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( buffer ) ; ObjectInputStream ois = new ObjectInputStream ( bais ) ; result . set ( name , ( Serializable ) ois . readObject ( ) ) ; } catch ( Exception exception ) { throw new RuntimeException ( "Could not deserialize State from Json, Object corrupted" , exception ) ; } } } ) ; return result ; }
Create a new StateObject from Json
 @return the restored StateObject
Create a new StateObject from Json @return the restored StateObject