Skip to content

Commit

Permalink
fix gson and adjust the deeper config
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecdcaeb committed Oct 9, 2024
1 parent f536417 commit b0ad434
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (useMirror) apply from: "mirror.gradle"
apply plugin: "net.minecraftforge.gradle.forge"
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

version = "1.7 for 1.12.2-1.8.8"
version = "1.8 for 1.12.2-1.8.8"
group = "com.ideallandframework.silent_assassin" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "redirectionor"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import net.minecraft.crash.CrashReport;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.fml.common.ICrashCallable;
import sun.awt.windows.ThemeReader;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;

/**
Expand Down Expand Up @@ -71,13 +74,13 @@ public static JsonObject encode(){

JsonArray contains = new JsonArray();
for(String element : Config.contains){
contains.add(element);
contains.add(new JsonPrimitive(element));
}
json.add("contains", contains);

JsonArray prefix = new JsonArray();
for(String element : Config.prefix){
prefix.add(element);
prefix.add(new JsonPrimitive(element));
}

json.add("prefix", prefix);
Expand Down Expand Up @@ -158,14 +161,30 @@ public static void handleCrash(CrashReport crashReport){
if (Config.generateConfigWhenCrash){
if ("ThisIsFake".equals(crashReport.getDescription())) return;
else if (Config.isBlock){
for(StackTraceElement element : crashReport.getCrashCause().getStackTrace()){
try{
Class<?> cls = Class.forName(element.getClassName(), false, Launch.classLoader);
if (cls.isEnum()){
Config.prefix.add(cls.getName());
Iterator<Throwable> iterator = new Iterator<Throwable>() {
public Throwable current = crashReport.getCrashCause();
@Override
public boolean hasNext() {
return current != null;
}

@Override
public Throwable next() {
Throwable toReturn = current;
current = toReturn.getCause();
return toReturn;
}
};
while (iterator.hasNext()){
for(StackTraceElement element : iterator.next().getStackTrace()){
try{
Class<?> cls = Class.forName(element.getClassName(), false, Launch.classLoader);
if (cls.isEnum()){
Config.prefix.add(cls.getName());
}
} catch (ClassNotFoundException ignored) {
// no ops
}
} catch (ClassNotFoundException ignored) {
// no ops
}
}
save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public RedirectionorContainer(){
metadata.modId=Redirectionor.MODID;
metadata.name="Redirectionor";
metadata.description="Redirectionor is the implementation of this concept, specifically for the Direction enum class stuff, to reduce the required memory of the game.";
metadata.version="1.7 for 1.12.2-1.8.8";
metadata.version="1.8 for 1.12.2-1.8.8";
metadata.url="https://www.curseforge.com/minecraft/mc-mods/redirectionor";
metadata.logoFile="/icon_redirectionor.png";
metadata.authorList.add("MCTeamPotato");
Expand Down

0 comments on commit b0ad434

Please sign in to comment.