From 5d1286092eac1545f819babbee27244504a212f0 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Tue, 23 Aug 2022 00:17:48 +0200 Subject: Add Config to override mob drops + some fixes (#8) * Add overrides * GTNHCoreMod custom drops integration * Update buildscript * Bump * EEC blacklist * NEI info * Loops optimization * Warn when 0% loots are detected * Detect looting drops * No * Super rare drops * Keep the same naming * Crash * Fix meta * maybe * Run at least twice * Fix stupid TF Lich boss * Comments * Fix EEC blacklist --- src/main/java/kubatech/api/utils/GSONUtils.java | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/main/java/kubatech/api/utils') diff --git a/src/main/java/kubatech/api/utils/GSONUtils.java b/src/main/java/kubatech/api/utils/GSONUtils.java index 1c0e7ec3f4..90f777000c 100644 --- a/src/main/java/kubatech/api/utils/GSONUtils.java +++ b/src/main/java/kubatech/api/utils/GSONUtils.java @@ -1,12 +1,16 @@ package kubatech.api.utils; import com.google.gson.*; +import java.io.File; import java.io.IOException; +import java.io.Reader; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTSizeTracker; import net.minecraft.nbt.NBTTagCompound; @@ -66,5 +70,32 @@ public class GSONUtils { .addSerializationExclusionStrategy(GSONStrategy) .addDeserializationExclusionStrategy(GSONStrategy) .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer) - .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer); + .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer) + .serializeNulls(); + public static final GsonBuilder GSON_BUILDER_PRETTY = new GsonBuilder() + .addSerializationExclusionStrategy(GSONStrategy) + .addDeserializationExclusionStrategy(GSONStrategy) + .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer) + .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer) + .serializeNulls() + .setPrettyPrinting(); + + public static T readFile(Gson gson, File file, Class tClass) { + if (!file.exists()) return null; + if (!file.isFile()) return null; + T t = null; + Reader reader = null; + try { + reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8); + t = gson.fromJson(reader, tClass); + } catch (Exception ignored) { + } finally { + if (reader != null) + try { + reader.close(); + } catch (Exception ignored) { + } + } + return t; + } } -- cgit