package mc.nbt.codec; import mc.nbt.TagType; import mc.nbt.TagValue; import java.util.Map; import java.util.Objects; public class CodecRegistry { private static final CodecRegistry INSTANCE = new CodecRegistry(); private final Map> codecs; private CodecRegistry() { codecs = Map.ofEntries( Map.entry(TagType.BYTE, new ByteTagCodec()), Map.entry(TagType.SHORT, new ShortTagCodec()), Map.entry(TagType.INTEGER, new IntegerTagCodec()), Map.entry(TagType.LONG, new LongTagCodec()), Map.entry(TagType.FLOAT, new FloatTagCodec()), Map.entry(TagType.DOUBLE, new DoubleTagCodec()), Map.entry(TagType.BYTE_ARRAY, new ByteArrayTagCodec()), Map.entry(TagType.INTEGER_ARRAY, new IntegerArrayTagCodec()), Map.entry(TagType.LONG_ARRAY, new LongArrayTagCodec()), Map.entry(TagType.STRING, new StringTagCodec()), Map.entry(TagType.LIST, new ListTagCodec()), Map.entry(TagType.COMPOUND, new CompoundTagCodec()), Map.entry(TagType.END, new EndTagCodec()) ); } public Codec get(TagType tagType) { return codecs.get(Objects.requireNonNull(tagType)); } public static CodecRegistry getInstance() { return INSTANCE; } }