PageRenderTime 61ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 1ms

/src/main/java/bspkrs/util/UniqueNameListGenerator.java

https://github.com/bspkrs-mods/bspkrsCore
Java | 95 lines | 75 code | 20 blank | 0 comment | 7 complexity | 47b40fa56dcb7a4685fc12f62f9ce802 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. package bspkrs.util;
  2. import net.minecraftforge.fml.common.registry.ForgeRegistries;
  3. import java.io.File;
  4. import java.io.FileWriter;
  5. import java.io.PrintWriter;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Collections;
  9. import java.util.Date;
  10. public class UniqueNameListGenerator
  11. {
  12. private static UniqueNameListGenerator instance;
  13. public static UniqueNameListGenerator instance()
  14. {
  15. if (instance == null)
  16. instance = new UniqueNameListGenerator();
  17. return instance;
  18. }
  19. public void run()
  20. {
  21. File listFile = new File(new File(CommonUtils.getConfigDir()), "UniqueNames.txt");
  22. try
  23. {
  24. ArrayList<String> blockList = new ArrayList<String>();
  25. ArrayList<String> itemList = new ArrayList<String>();
  26. for (Object obj : ForgeRegistries.BLOCKS.getKeys())
  27. blockList.add(obj.toString());
  28. for (Object obj : ForgeRegistries.ITEMS.getKeys())
  29. itemList.add(obj.toString());
  30. Collections.sort(blockList);
  31. Collections.sort(itemList);
  32. if (listFile.exists())
  33. listFile.delete();
  34. listFile.createNewFile();
  35. PrintWriter out = new PrintWriter(new FileWriter(listFile));
  36. out.println("# generated by bspkrsCore " + new SimpleDateFormat("yyyyMMdd HH:mm:ss").format(new Date()));
  37. out.println();
  38. out.println("**********************************************");
  39. out.println("* #### # ### ### # # #### *");
  40. out.println("* # # # # # # # # # # *");
  41. out.println("* #### # # # # ### ### *");
  42. out.println("* # # # # # # # # # *");
  43. out.println("* #### ##### ### #### # # #### *");
  44. out.println("**********************************************");
  45. out.println();
  46. out.println();
  47. for (String s : blockList)
  48. {
  49. out.println(s);
  50. }
  51. out.println();
  52. out.println();
  53. out.println("***************************************");
  54. out.println("* ##### ##### ##### # # #### *");
  55. out.println("* # # # ## ## # *");
  56. out.println("* # # ### # # # ### *");
  57. out.println("* # # # # # # *");
  58. out.println("* ##### # ##### # # #### *");
  59. out.println("***************************************");
  60. out.println();
  61. out.println();
  62. for (String s : itemList)
  63. {
  64. out.println(s);
  65. }
  66. out.println();
  67. out.println();
  68. out.close();
  69. }
  70. catch (Exception exception)
  71. {
  72. exception.printStackTrace();
  73. }
  74. }
  75. }