settings.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import java.io.*;
  2. import java.util.logging.Level;
  3. import java.util.logging.Logger;
  4. public class settings {
  5. private final static Object syncLock = new Object();
  6. protected static final Logger log = Logger.getLogger("Minecraft");
  7. private static volatile settings instance;
  8. static boolean toggle = true;
  9. private boolean adminChat = false;
  10. private boolean greentext = false;
  11. private boolean FFF = false;
  12. private boolean quakeColors = false;
  13. private boolean cmdFabulous = false;
  14. private boolean cmdPromote = false;
  15. private boolean cmdDemote = false;
  16. private boolean cmdWhoIs = false;
  17. private boolean cmdRules = false;
  18. private boolean cmdMasstp = false;
  19. private boolean cmdTp = false;
  20. private boolean cmdTphere = false;
  21. private boolean globalmessages = false;
  22. private boolean cmdSay = false;
  23. private PropertiesFile properties;
  24. String file = "vminecraft.properties";
  25. public String rules[] = null;
  26. public void loadSettings()
  27. {
  28. File theDir = new File("vminecraft.properties");
  29. if(!theDir.exists())
  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 = new PropertiesFile("vminecraft.properties");
  67. properties.load();
  68. }
  69. try {
  70. adminChat = properties.getBoolean("adminchat",true);
  71. greentext = properties.getBoolean("greentext",true);
  72. FFF = properties.getBoolean("FFF",true);
  73. quakeColors = properties.getBoolean("quakeColors",true);
  74. cmdFabulous = properties.getBoolean("cmdFabulous",true);
  75. cmdPromote = properties.getBoolean("cmdPromote",true);
  76. cmdDemote = properties.getBoolean("cmdDemote",true);
  77. cmdWhoIs = properties.getBoolean("cmdWhoIs",true);
  78. cmdRules = properties.getBoolean("cmdRules",true);
  79. cmdTp = properties.getBoolean("cmdTp",true);
  80. cmdMasstp = properties.getBoolean("cmdMasstp",true);
  81. cmdTphere = properties.getBoolean("cmdTphere",true);
  82. globalmessages = properties.getBoolean("globalmessages",true);
  83. cmdSay = properties.getBoolean("cmdSay",true);
  84. rules = properties.getString("rules", "").split("@");
  85. log.log(Level.INFO, "vminecraft plugin successfully loaded");
  86. }
  87. catch (Exception e)
  88. {
  89. log.log(Level.SEVERE, "vminecraft Error: ERROR LOADING PROPERTIES FILE");
  90. }
  91. }
  92. public boolean adminchat() {return adminChat;}
  93. public boolean greentext() {return greentext;}
  94. public boolean FFF() {return FFF;}
  95. public boolean quakeColors() {return quakeColors;}
  96. public boolean cmdFabulous() {return cmdFabulous;}
  97. public boolean cmdPromote() {return cmdPromote;}
  98. public boolean cmdDemote() {return cmdDemote;}
  99. public boolean cmdWhoIs() {return cmdWhoIs;}
  100. public boolean cmdTp() {return cmdTp;}
  101. public boolean cmdTphere() {return cmdTphere;}
  102. public boolean cmdSay() {return cmdSay;}
  103. public boolean cmdRules() {return cmdRules;}
  104. public boolean globalmessages() {return globalmessages;}
  105. public boolean cmdMasstp() {return cmdMasstp;}
  106. public static settings getInstance() {
  107. if (instance == null) {
  108. instance = new settings();
  109. }
  110. return instance;
  111. }
  112. //Will return the rules
  113. public String[] getRules() {
  114. return rules;
  115. }
  116. }