Spaces:
Build error
Build error
File size: 1,597 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
package net.minecraft.util.eventlog;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import com.mojang.serialization.Codec;
import com.mojang.serialization.JsonOps;
import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.io.Reader;
import javax.annotation.Nullable;
public interface JsonEventLogReader<T> extends Closeable {
static <T> JsonEventLogReader<T> create(final Codec<T> p_261600_, Reader p_261836_) {
final JsonReader jsonreader = new JsonReader(p_261836_);
jsonreader.setLenient(true);
return new JsonEventLogReader<T>() {
@Nullable
@Override
public T next() throws IOException {
try {
if (!jsonreader.hasNext()) {
return null;
} else {
JsonElement jsonelement = JsonParser.parseReader(jsonreader);
return p_261600_.parse(JsonOps.INSTANCE, jsonelement).getOrThrow(IOException::new);
}
} catch (JsonParseException jsonparseexception) {
throw new IOException(jsonparseexception);
} catch (EOFException eofexception) {
return null;
}
}
@Override
public void close() throws IOException {
jsonreader.close();
}
};
}
@Nullable
T next() throws IOException;
} |