Created
November 8, 2017 13:42
-
-
Save dblsaiko/d806b34659313defcd2f9980e1ba47a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import net.minecraftforge.fml.common.FMLLog; | |
| import net.minecraftforge.fml.relauncher.ReflectionHelper; | |
| import org.apache.logging.log4j.Logger; | |
| import java.lang.reflect.Field; | |
| public class Nope { | |
| /** | |
| * Make forge not spew "dangerous alternative prefix" messages in this block. | |
| */ | |
| public static void shutupForge(Runnable op) { | |
| Logger log = FMLLog.log; | |
| try { | |
| Field privateConfig = (Field) ReflectionHelper.findField(Logger.class, "privateConfig").get(log); | |
| Field intLevelF = ReflectionHelper.findField(privateConfig.getClass(), "intLevel"); | |
| int intLevel = (int) intLevelF.get(privateConfig); | |
| intLevelF.set(privateConfig, 299); // disable WARN logging | |
| try { | |
| op.run(); | |
| } finally { | |
| intLevelF.set(privateConfig, intLevel); | |
| } | |
| } catch (IllegalAccessException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment