settings.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //This doesn't do anything yet, eventually you will be able to toggle features by writing true or false in vminecraft-config.txt
  2. //This is high up on my priority list
  3. import java.io.*;
  4. import java.util.*;
  5. import java.util.logging.Level;
  6. import java.util.logging.Logger;
  7. import net.minecraft.server.MinecraftServer;
  8. public class settings {
  9. private final static Object syncLock = new Object();
  10. protected static final Logger log = Logger.getLogger("Minecraft");
  11. private static volatile settings instance;
  12. static boolean toggle = true;
  13. private boolean adminChat = false;
  14. private boolean greentext = false;
  15. private boolean FFF = false;
  16. private boolean quakeColors = false;
  17. private boolean cmdFabulous = false;
  18. private boolean cmdPromote = false;
  19. private boolean cmdDemote = false;
  20. private boolean cmdWhoIs = false;
  21. private PropertiesFile properties;
  22. String file = "vminecraft.properties";
  23. //Unfinished was interrupted in the middle of making this shit, where we can triggle toggles in a text file for commands
  24. //example return true for greentext=true in vminecraft.properties file would disable that code
  25. public void loadSettings()
  26. {
  27. try{
  28. Scanner scanner = new Scanner(new File(file));
  29. while (scanner.hasNextLine()) {
  30. String line = scanner.nextLine();
  31. if( line.startsWith("#") || line.equals(""))
  32. {
  33. continue;
  34. }
  35. String[] split = line.split("=");
  36. if(split[0].equalsIgnoreCase("adminchat"))
  37. {
  38. if(split[1].equalsIgnoreCase("true"))
  39. {
  40. adminChat = true;
  41. }
  42. else adminChat = false;
  43. }
  44. if(split[0].equalsIgnoreCase("Greentext"))
  45. {
  46. if(split[1].equalsIgnoreCase("true"))
  47. {
  48. greentext = true;
  49. }
  50. else greentext = false;
  51. }
  52. if(split[0].equalsIgnoreCase("FFF"))
  53. {
  54. if(split[1].equalsIgnoreCase("true"))
  55. {
  56. FFF = true;
  57. }
  58. else FFF = false;
  59. }
  60. if(split[0].equalsIgnoreCase("QuakeColors"))
  61. {
  62. if(split[1].equalsIgnoreCase("true"))
  63. {
  64. quakeColors = true;
  65. }
  66. else quakeColors = false;
  67. }
  68. if(split[0].equalsIgnoreCase("cmdFabulous"))
  69. {
  70. if(split[1].equalsIgnoreCase("true"))
  71. {
  72. cmdFabulous = true;
  73. }
  74. else cmdFabulous = false;
  75. }
  76. if(split[0].equalsIgnoreCase("cmdPromote"))
  77. {
  78. if(split[1].equalsIgnoreCase("true"))
  79. {
  80. cmdPromote = true;
  81. }
  82. else cmdPromote = false;
  83. }
  84. if(split[0].equalsIgnoreCase("cmdDemote"))
  85. {
  86. if(split[1].equalsIgnoreCase("true"))
  87. {
  88. cmdDemote = true;
  89. }
  90. else cmdDemote = false;
  91. }
  92. if(split[0].equalsIgnoreCase("cmdWhoIs"))
  93. {
  94. if(split[1].equalsIgnoreCase("true"))
  95. {
  96. cmdWhoIs = true;
  97. }
  98. else cmdWhoIs = false;
  99. }
  100. }
  101. scanner.close();
  102. }
  103. catch (Exception e) {log.log(Level.SEVERE, "Oh shi-: "+ e.getMessage() );}
  104. }
  105. public boolean adminchat() {return adminChat;}
  106. public boolean greentext() {return greentext;}
  107. public boolean FFF() {return FFF;}
  108. public boolean quakeColors() {return quakeColors;}
  109. public boolean cmdFabulous() {return cmdFabulous;}
  110. public boolean cmdPromote() {return cmdPromote;}
  111. public boolean cmdDemote() {return cmdDemote;}
  112. public boolean cmdWhoIs() {return cmdWhoIs;}
  113. public static settings getInstance() {
  114. if (instance == null) {
  115. instance = new settings();
  116. }
  117. return instance;
  118. }
  119. }