Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.98 KB | None | 0 0
  1. public enum Property {
  2.  
  3. GUIX(PropertyType.INT, "Gui X", "4", Client.modManager.getMod(Gui.class)),
  4. GUIY(PropertyType.INT, "Gui Y", "12", Client.modManager.getMod(Gui.class)),
  5.  
  6. AUTOCLICKER_DELAY(PropertyType.INT, "AC Delay", "50", Client.modManager.getMod(AutoClicker.class)),
  7. AUTOCLICKER_RANDOMDELAY(PropertyType.INT, "AC RANDOM DELAY", "10", Client.modManager.getMod(AutoClicker.class)),
  8.  
  9.  
  10. LIVINGESP_RENDERMODE(PropertyType.MODE, "LivingESP RenderMode", "0", Client.modManager.getMod(LivingESP.class), new String[]{"Lines", "Points"}),
  11. LIVINGESP_WIDTH(PropertyType.FLOAT, "LivingESP Width", "0.02", Client.modManager.getMod(LivingESP.class), Integer.MAX_VALUE, 0.01f),
  12. LIVINGESP_SMOOTH(PropertyType.BOOLEAN, "LivingESP Smooth", "true", Client.modManager.getMod(LivingESP.class)),
  13. LIVINGESP_RED(PropertyType.FLOAT, "LivingESP Red", "0.82", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
  14. LIVINGESP_GREEN(PropertyType.FLOAT, "LivingESP Green", "0.42", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
  15. LIVINGESP_BLUE(PropertyType.FLOAT, "LivingESP Blue", "0.46", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
  16. LIVINGESP_ALPHA(PropertyType.FLOAT, "LivingESP Alpha", "0.47", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
  17.  
  18. ;
  19.  
  20. private PropertyType propertyType;
  21. private String id;
  22. private String defaultValue;
  23. private String[] modes;
  24. private float accurate;
  25. private int max;
  26. private boolean hasMax;
  27.  
  28. Property(PropertyType propertyType, String id, String defaultValue, Mod mod) {
  29. this.propertyType = propertyType;
  30. this.id = id;
  31. this.defaultValue = defaultValue;
  32. mod.settings.add(this);
  33. }
  34.  
  35. Property(PropertyType propertyType, String id, String defaultValue, Mod mod, String[] modes) {
  36. this.propertyType = propertyType;
  37. this.id = id;
  38. this.defaultValue = defaultValue;
  39. this.modes = modes;
  40. mod.settings.add(this);
  41. }
  42.  
  43. Property(PropertyType propertyType, String id, String defaultValue, Mod mod, int max) {
  44. this.propertyType = propertyType;
  45. this.id = id;
  46. this.defaultValue = defaultValue;
  47. this.max = max;
  48. hasMax = true;
  49. mod.settings.add(this);
  50. }
  51.  
  52. Property(PropertyType propertyType, String id, String defaultValue, Mod mod, int max, float accurate) {
  53. this.propertyType = propertyType;
  54. this.id = id;
  55. this.defaultValue = defaultValue;
  56. this.max = max;
  57. hasMax = true;
  58. this.accurate = accurate;
  59. mod.settings.add(this);
  60. }
  61.  
  62. public PropertyType getPropertyType() {
  63. return propertyType;
  64. }
  65.  
  66. public String getId() {
  67. return id;
  68. }
  69.  
  70. public String getDefaultValue() {
  71. return defaultValue;
  72. }
  73.  
  74. public String[] getModes() {
  75. return modes;
  76. }
  77.  
  78. public float getAccurate() {
  79. return accurate;
  80. }
  81.  
  82. public int getMax() {
  83. return max;
  84. }
  85.  
  86. public boolean isHasMax() {
  87. return hasMax;
  88. }
  89. }
  90.  
  91. public void loadSettings() {
  92. File file = Client.settingsFile;
  93. if (!file.exists()) {
  94. saveSettings();
  95. } else {
  96. try (Scanner scanner = new Scanner(file)) {
  97. while (scanner.hasNextLine()) {
  98. String line = scanner.nextLine();
  99. String splits[] = line.split(separator);
  100. properties.put(splits[0], splits[1]);
  101. }
  102. } catch (FileNotFoundException e) {
  103. e.printStackTrace();
  104. }
  105. }
  106.  
  107. }
  108.  
  109. public static void saveSettings() {
  110. File file = Client.settingsFile;
  111. try {
  112. file.createNewFile();
  113. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
  114. for (Map.Entry<String,String> entry : properties.entrySet()) {
  115. bufferedWriter.write(entry.getKey() + separator + entry.getValue());
  116. bufferedWriter.newLine();
  117. }
  118. bufferedWriter.close();
  119. } catch (IOException e) {
  120. e.printStackTrace();
  121. }
  122. }
  123.  
  124. public void setValue(Property property, Object value) {
  125. switch (property.getPropertyType()) {
  126. case BOOLEAN:
  127. properties.put(property.getId(), Boolean.toString((boolean) value));
  128. break;
  129. case INT:
  130. properties.put(property.getId(), Integer.toString((int) value));
  131. break;
  132. case FLOAT:
  133. properties.put(property.getId(), Float.toString((float) value));
  134. break;
  135. case MODE:
  136. properties.put(property.getId(), Integer.toString((int) value));
  137. break;
  138. default:
  139. throw new UnsupportedOperationException(property.getId() + "konnte nicht gesetzt werden!");
  140. }
  141. saveSettings();
  142. }
  143.  
  144. public Object getValue(Property property) {
  145. String value = properties.get(property.getId());
  146. if (value == null) {
  147. value = property.getDefaultValue();
  148. }
  149. switch (property.getPropertyType()) {
  150. case BOOLEAN:
  151. return Boolean.parseBoolean(value);
  152. case INT:
  153. return Integer.parseInt(value);
  154. case FLOAT:
  155. return Float.parseFloat(value);
  156. case MODE:
  157. return Integer.parseInt(value);
  158. default:
  159. throw new UnsupportedOperationException(property.getId() + "konnte nicht geladen werden!");
  160. }
  161. }
  162.  
  163.  
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement