SHARE
TWEET

Restore preferIPv4Stack value on Forge 1.8

EnderAlice Dec 5th, 2014 (edited) 184 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Mod.EventHandler
  2. public void forgePreInitialization(FMLPreInitializationEvent event)
  3. {
  4.         String preferIPv4Stack = System.getProperty("java.net.preferIPv4Stack");
  5.         if((preferIPv4Stack != null) && (preferIPv4Stack.equals("true")))
  6.         {
  7.                 System.err.println("WARNING: `java.net.preferIPv4Stack' was true. Check for original JVM arguments...");
  8.                 System.setProperty("java.net.preferIPv4Stack", "false");
  9.  
  10.                 RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
  11.                 List<String> arguments = runtimeMxBean.getInputArguments();
  12.                 for(String arg : arguments)
  13.                 {
  14.                         int at = arg.indexOf("-Djava.net.preferIPv4Stack=");
  15.                         if(at >= 0)
  16.                         {
  17.                                 System.setProperty("java.net.preferIPv4Stack", arg.substring(at + 27));
  18.                                 break;
  19.                         }
  20.                 }
  21.  
  22.                 System.err.println("Restored original `java.net.preferIPv4Stack'. Goodluck!");
  23.         }
  24. }
RAW Paste Data
Top