diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-23 00:17:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 00:17:48 +0200 |
commit | 5d1286092eac1545f819babbee27244504a212f0 (patch) | |
tree | a377af43657e1959a5a088a5e48dde0c2c2b9b22 /src/main/java/kubatech/api/utils | |
parent | c31a00ff0259c6f1a2c8098aacb3afc14384aa4b (diff) | |
download | GT5-Unofficial-5d1286092eac1545f819babbee27244504a212f0.tar.gz GT5-Unofficial-5d1286092eac1545f819babbee27244504a212f0.tar.bz2 GT5-Unofficial-5d1286092eac1545f819babbee27244504a212f0.zip |
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
Diffstat (limited to 'src/main/java/kubatech/api/utils')
-rw-r--r-- | src/main/java/kubatech/api/utils/GSONUtils.java | 33 |
1 files changed, 32 insertions, 1 deletions
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> T readFile(Gson gson, File file, Class<T> 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; + } } |