Advertisement
Creepinson

Untitled

Apr 6th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1.  
  2. @Override
  3. public Void call() {
  4.  
  5. if (FMLLaunchHandler.side().isClient()) {
  6. // Configuration
  7. File file = new File("config");
  8. file.mkdirs();
  9. config = new ModConfig(file.getAbsolutePath(), "memcheck.cfg");
  10.  
  11. if (!config.hasKey("utils", "recommended_memory"))
  12. config.writeConfig("utils", "recommended_memory", 2048);
  13.  
  14. if (!config.hasKey("utils", "memory_check_enabled"))
  15. config.writeConfig("utils", "memory_check_enabled", false);
  16. long maxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;
  17. System.out.println("Memory allocated in MB: " + maxMemory);
  18. System.out.println("Recommended modpack memory: " + getConfig().getInt("utils", "recommended_memory"));
  19. if (maxMemory < getConfig().getInt("utils", "recommended_memory") && getConfig().getBoolean("utils", "memory_check_enabled")) {
  20. // Make sure it is the client so that the gui can be called without crashing the server.
  21. /* MemoryCheckWorker thread = new MemoryCheckWorker(Thread.currentThread(), maxMemory);
  22. thread.start();*/
  23. Thread previousThread = Thread.currentThread();
  24. Checker downloadMonitor = new Checker();
  25. downloadMonitor.makeDialog("The modpack developer recommends " + getConfig().
  26. getInt("utils", "recommended_memory") + " memory, but you are using " + maxMemory + " MB.").setVisible(true);
  27. downloadMonitor.setVisible(true);
  28. downloadMonitor.confirmButton.addActionListener(b -> {
  29. downloadMonitor.requestClose();
  30. });
  31. }
  32. }
  33. return null;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement