settings.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 boolean cmdEzModo = false;
  24. private PropertiesFile properties;
  25. String file = "vminecraft.properties";
  26. public String rules[] = null;
  27. public void loadSettings() throws IOException
  28. {
  29. File theDir = new File("vminecraft.properties");
  30. if(!theDir.exists())
  31. {
  32. String location = "vminecraft.properties";
  33. properties = new PropertiesFile("vminecraft.properties");
  34. FileWriter writer = null;
  35. try {
  36. writer = new FileWriter(location);
  37. writer.write("#This plugin is modular\r\n");
  38. writer.write("#Turn any features you don't want to false and they won't be running\r\n");
  39. writer.write("#If you edit this file and save it, then use /reload it will reload the settings\r\n");
  40. writer.write("greentext=true\r\n");
  41. writer.write("quakeColors=true\r\n");
  42. writer.write("cmdTphere=true\r\n");
  43. writer.write("cmdFabulous=true\r\n");
  44. writer.write("cmdWhoIs=true\r\n");
  45. writer.write("cmdPromote=true\r\n");
  46. writer.write("cmdDemote=true\r\n");
  47. writer.write("cmdMasstp=true\r\n");
  48. writer.write("cmdSay=true\r\n");
  49. writer.write("cmdTp=true\r\n");
  50. writer.write("cmdRules=true\r\n");
  51. writer.write("globalmessages=true\r\n");
  52. writer.write("FFF=true\r\n");
  53. writer.write("adminchat=true\r\n");
  54. writer.write("cmdEzModo=true\r\n");
  55. writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n");
  56. } catch (Exception e) {
  57. log.log(Level.SEVERE, "Exception while creating " + location, e);
  58. } finally {
  59. try {
  60. if (writer != null) {
  61. writer.close();
  62. }
  63. } catch (IOException e) {
  64. log.log(Level.SEVERE, "Exception while closing writer for " + location, e);
  65. }
  66. }
  67. } else {
  68. properties = new PropertiesFile("vminecraft.properties");
  69. properties.load();
  70. }
  71. try {
  72. adminChat = properties.getBoolean("adminchat",true);
  73. greentext = properties.getBoolean("greentext",true);
  74. FFF = properties.getBoolean("FFF",true);
  75. quakeColors = properties.getBoolean("quakeColors",true);
  76. cmdFabulous = properties.getBoolean("cmdFabulous",true);
  77. cmdPromote = properties.getBoolean("cmdPromote",true);
  78. cmdDemote = properties.getBoolean("cmdDemote",true);
  79. cmdWhoIs = properties.getBoolean("cmdWhoIs",true);
  80. cmdRules = properties.getBoolean("cmdRules",true);
  81. cmdTp = properties.getBoolean("cmdTp",true);
  82. cmdMasstp = properties.getBoolean("cmdMasstp",true);
  83. cmdTphere = properties.getBoolean("cmdTphere",true);
  84. globalmessages = properties.getBoolean("globalmessages",true);
  85. cmdSay = properties.getBoolean("cmdSay",true);
  86. cmdEzModo = properties.getBoolean("cmdEzModo",true);
  87. rules = properties.getString("rules", "").split("@");
  88. log.log(Level.INFO, "vminecraft plugin successfully loaded");
  89. }
  90. catch (Exception e)
  91. {
  92. log.log(Level.SEVERE, "vminecraft Error: ERROR LOADING PROPERTIES FILE");
  93. }
  94. }
  95. public boolean adminchat() {return adminChat;}
  96. public boolean greentext() {return greentext;}
  97. public boolean FFF() {return FFF;}
  98. public boolean quakeColors() {return quakeColors;}
  99. public boolean cmdFabulous() {return cmdFabulous;}
  100. public boolean cmdPromote() {return cmdPromote;}
  101. public boolean cmdDemote() {return cmdDemote;}
  102. public boolean cmdWhoIs() {return cmdWhoIs;}
  103. public boolean cmdTp() {return cmdTp;}
  104. public boolean cmdTphere() {return cmdTphere;}
  105. public boolean cmdSay() {return cmdSay;}
  106. public boolean cmdRules() {return cmdRules;}
  107. public boolean globalmessages() {return globalmessages;}
  108. public boolean cmdMasstp() {return cmdMasstp;}
  109. public boolean cmdEzModo() {return cmdEzModo;}
  110. public static settings getInstance() {
  111. if (instance == null) {
  112. instance = new settings();
  113. }
  114. return instance;
  115. }
  116. //Will return the rules
  117. public String[] getRules() {
  118. return rules;
  119. }
  120. }