@@ -0,0 +1,2127 @@
+package info.u_team.u_team_core.data;%0A%0Aimport java.io.*;%0Aimport java.nio.file.*;%0Aimport java.util.Objects;%0A%0Aimport org.apache.logging.log4j.*;%0A%0Aimport com.google.gson.*;%0Aimport com.google.gson.internal.Streams;%0Aimport com.google.gson.stream.JsonWriter;%0A%0Aimport net.minecraft.data.*;%0A%0Apublic abstract class CommonProvider implements IDataProvider %7B%0A%09%0A%09protected static final Logger LOGGER = LogManager.getLogger(%22DataGenerator%22);%0A%09protected static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();%0A%09%0A%09protected final Marker marker;%0A%09%0A%09private final String name;%0A%09protected final DataGenerator generator;%0A%09protected final Path path;%0A%09%0A%09public CommonProvider(String name, DataGenerator generator) %7B%0A%09%09this.generator = generator;%0A%09%09this.name = name;%0A%09%09this.path = resolvePath(generator.getOutputFolder());%0A%09%09marker = MarkerManager.getMarker(name);%0A%09%7D%0A%09%0A%09protected abstract Path resolvePath(Path outputFolder);%0A%09%0A%09protected Path resolveAssets(Path outputFolder, String modid) %7B%0A%09%09return outputFolder.resolve(%22assets%22).resolve(modid);%0A%09%7D%0A%09%0A%09protected Path resolveData(Path outputFolder, String modid) %7B%0A%09%09return outputFolder.resolve(%22data%22).resolve(modid);%0A%09%7D%0A%09%0A%09@Override%0A%09public String getName() %7B%0A%09%09return name;%0A%09%7D%0A%09%0A%09protected void write(DirectoryCache cache, JsonElement element, Path path) throws IOException %7B%0A%09%09final StringWriter writer = new StringWriter();%0A%09%09try %7B%0A%09%09%09final JsonWriter jsonWriter = GSON.newJsonWriter(Streams.writerForAppendable(writer));%0A%09%09%09jsonWriter.setIndent(%22%09%22); // Use tab instead of two spaces%0A%09%09%09GSON.toJson(element, jsonWriter);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09throw new JsonIOException(e);%0A%09%09%7D%0A%09%09write(cache, writer.toString(), path);%0A%09%7D%0A%09%0A%09protected void write(DirectoryCache cache, String string, Path path) throws IOException %7B%0A%09%09final String hash = HASH_FUNCTION.hashUnencodedChars(string).toString();%0A%09%09if (!Objects.equals(cache.getPreviousHash(path), hash) %7C%7C !Files.exists(path)) %7B%0A%09%09%09Files.createDirectories(path.getParent());%0A%09%09%09try (final BufferedWriter writer = Files.newBufferedWriter(path)) %7B%0A%09%09%09%09writer.write(string);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09cache.func_208316_a(path, hash);%0A%09%7D%0A%7D%0A

Add common provider with some basic utility features