settings.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import java.io.FileWriter;
  2. import java.io.IOException;
  3. import java.util.logging.Level;
  4. import java.util.logging.Logger;
  5. public class settings {
  6. private final static Object syncLock = new Object();
  7. protected static final Logger log = Logger.getLogger("Minecraft");
  8. private static volatile settings instance;
  9. static boolean toggle = true;
  10. private boolean adminChat = false;
  11. private boolean greentext = false;
  12. private boolean FFF = false;
  13. private boolean quakeColors = false;
  14. private boolean cmdFabulous = false;
  15. private boolean cmdPromote = false;
  16. private boolean cmdDemote = false;
  17. private boolean cmdWhoIs = false;
  18. private boolean cmdRules = false;
  19. private boolean cmdMasstp = false;
  20. private boolean cmdTp = false;
  21. private boolean cmdTphere = false;
  22. private boolean globalmessages = false;
  23. private boolean cmdSay = false;
  24. private PropertiesFile properties;
  25. String file = "vminecraft.properties";
  26. public String rules[] = null;
  27. public void loadSettings()
  28. {
  29. if(properties == null)
  30. {
  31. String location = "vminecraft.properties";
  32. properties = new PropertiesFile("vminecraft.properties");
  33. FileWriter writer = null;
  34. try {
  35. writer = new FileWriter(location);
  36. writer.write("#This plugin is modular\r\n");
  37. writer.write("#Turn any features you don't want to false and they won't be running\r\n");
  38. writer.write("#If you edit this file and save it, then use /reload it will reload the settings\r\n");
  39. writer.write("greentext=true\r\n");
  40. writer.write("quakeColors=true\r\n");
  41. writer.write("cmdTphere=true\r\n");
  42. writer.write("cmdFabulous=true\r\n");
  43. writer.write("cmdWhoIs=true\r\n");
  44. writer.write("cmdPromote=true\r\n");
  45. writer.write("cmdDemote=true\r\n");
  46. writer.write("cmdMasstp=true\r\n");
  47. writer.write("cmdSay=true\r\n");
  48. writer.write("cmdTp=true\r\n");
  49. writer.write("cmdRules=true\r\n");
  50. writer.write("globalmessages=true\r\n");
  51. writer.write("FFF=true\r\n");
  52. writer.write("adminchat=true\r\n");
  53. writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n");
  54. } catch (Exception e) {
  55. log.log(Level.SEVERE, "Exception while creating " + location, e);
  56. } finally {
  57. try {
  58. if (writer != null) {
  59. writer.close();
  60. }
  61. } catch (IOException e) {
  62. log.log(Level.SEVERE, "Exception while closing writer for " + location, e);
  63. }
  64. }
  65. } else {
  66. properties.load();
  67. }
  68. try {
  69. adminChat = properties.getBoolean("adminchat",true);
  70. greentext = properties.getBoolean("greentext",true);
  71. FFF = properties.getBoolean("FFF",true);
  72. quakeColors = properties.getBoolean("quakeColors",true);
  73. cmdFabulous = properties.getBoolean("cmdFabulous",true);
  74. cmdPromote = properties.getBoolean("cmdPromote",true);
  75. cmdDemote = properties.getBoolean("cmdDemote",true);
  76. cmdWhoIs = properties.getBoolean("cmdWhoIs",true);
  77. cmdRules = properties.getBoolean("cmdRules",true);
  78. cmdTp = properties.getBoolean("cmdTp",true);
  79. cmdMasstp = properties.getBoolean("cmdMasstp",true);
  80. cmdTphere = properties.getBoolean("cmdTphere",true);
  81. globalmessages = properties.getBoolean("globalmessages",true);
  82. cmdSay = properties.getBoolean("cmdSay",true);
  83. rules = properties.getString("rules", "").split("@");
  84. id.a.log(Level.INFO, "vminecraft plugin successfully loaded");
  85. }
  86. catch (Exception e)
  87. {
  88. log.log(Level.SEVERE, "vminecraft Error: ERROR LOADING PROPERTIES FILE");
  89. }
  90. }
  91. public boolean adminchat() {return adminChat;}
  92. public boolean greentext() {return greentext;}
  93. public boolean FFF() {return FFF;}
  94. public boolean quakeColors() {return quakeColors;}
  95. public boolean cmdFabulous() {return cmdFabulous;}
  96. public boolean cmdPromote() {return cmdPromote;}
  97. public boolean cmdDemote() {return cmdDemote;}
  98. public boolean cmdWhoIs() {return cmdWhoIs;}
  99. public boolean cmdTp() {return cmdTp;}
  100. public boolean cmdTphere() {return cmdTphere;}
  101. public boolean cmdSay() {return cmdSay;}
  102. public boolean cmdRules() {return cmdRules;}
  103. public boolean globalmessages() {return globalmessages;}
  104. public boolean cmdMasstp() {return cmdMasstp;}
  105. public static settings getInstance() {
  106. if (instance == null) {
  107. instance = new settings();
  108. }
  109. return instance;
  110. }
  111. //Will return the rules
  112. public String[] getRules() {
  113. return rules;
  114. }
  115. }