Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum Property {
- GUIX(PropertyType.INT, "Gui X", "4", Client.modManager.getMod(Gui.class)),
- GUIY(PropertyType.INT, "Gui Y", "12", Client.modManager.getMod(Gui.class)),
- AUTOCLICKER_DELAY(PropertyType.INT, "AC Delay", "50", Client.modManager.getMod(AutoClicker.class)),
- AUTOCLICKER_RANDOMDELAY(PropertyType.INT, "AC RANDOM DELAY", "10", Client.modManager.getMod(AutoClicker.class)),
- LIVINGESP_RENDERMODE(PropertyType.MODE, "LivingESP RenderMode", "0", Client.modManager.getMod(LivingESP.class), new String[]{"Lines", "Points"}),
- LIVINGESP_WIDTH(PropertyType.FLOAT, "LivingESP Width", "0.02", Client.modManager.getMod(LivingESP.class), Integer.MAX_VALUE, 0.01f),
- LIVINGESP_SMOOTH(PropertyType.BOOLEAN, "LivingESP Smooth", "true", Client.modManager.getMod(LivingESP.class)),
- LIVINGESP_RED(PropertyType.FLOAT, "LivingESP Red", "0.82", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
- LIVINGESP_GREEN(PropertyType.FLOAT, "LivingESP Green", "0.42", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
- LIVINGESP_BLUE(PropertyType.FLOAT, "LivingESP Blue", "0.46", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
- LIVINGESP_ALPHA(PropertyType.FLOAT, "LivingESP Alpha", "0.47", Client.modManager.getMod(LivingESP.class), 1, 0.01f),
- ;
- private PropertyType propertyType;
- private String id;
- private String defaultValue;
- private String[] modes;
- private float accurate;
- private int max;
- private boolean hasMax;
- Property(PropertyType propertyType, String id, String defaultValue, Mod mod) {
- this.propertyType = propertyType;
- this.id = id;
- this.defaultValue = defaultValue;
- mod.settings.add(this);
- }
- Property(PropertyType propertyType, String id, String defaultValue, Mod mod, String[] modes) {
- this.propertyType = propertyType;
- this.id = id;
- this.defaultValue = defaultValue;
- this.modes = modes;
- mod.settings.add(this);
- }
- Property(PropertyType propertyType, String id, String defaultValue, Mod mod, int max) {
- this.propertyType = propertyType;
- this.id = id;
- this.defaultValue = defaultValue;
- this.max = max;
- hasMax = true;
- mod.settings.add(this);
- }
- Property(PropertyType propertyType, String id, String defaultValue, Mod mod, int max, float accurate) {
- this.propertyType = propertyType;
- this.id = id;
- this.defaultValue = defaultValue;
- this.max = max;
- hasMax = true;
- this.accurate = accurate;
- mod.settings.add(this);
- }
- public PropertyType getPropertyType() {
- return propertyType;
- }
- public String getId() {
- return id;
- }
- public String getDefaultValue() {
- return defaultValue;
- }
- public String[] getModes() {
- return modes;
- }
- public float getAccurate() {
- return accurate;
- }
- public int getMax() {
- return max;
- }
- public boolean isHasMax() {
- return hasMax;
- }
- }
- public void loadSettings() {
- File file = Client.settingsFile;
- if (!file.exists()) {
- saveSettings();
- } else {
- try (Scanner scanner = new Scanner(file)) {
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine();
- String splits[] = line.split(separator);
- properties.put(splits[0], splits[1]);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
- public static void saveSettings() {
- File file = Client.settingsFile;
- try {
- file.createNewFile();
- BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
- for (Map.Entry<String,String> entry : properties.entrySet()) {
- bufferedWriter.write(entry.getKey() + separator + entry.getValue());
- bufferedWriter.newLine();
- }
- bufferedWriter.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setValue(Property property, Object value) {
- switch (property.getPropertyType()) {
- case BOOLEAN:
- properties.put(property.getId(), Boolean.toString((boolean) value));
- break;
- case INT:
- properties.put(property.getId(), Integer.toString((int) value));
- break;
- case FLOAT:
- properties.put(property.getId(), Float.toString((float) value));
- break;
- case MODE:
- properties.put(property.getId(), Integer.toString((int) value));
- break;
- default:
- throw new UnsupportedOperationException(property.getId() + "konnte nicht gesetzt werden!");
- }
- saveSettings();
- }
- public Object getValue(Property property) {
- String value = properties.get(property.getId());
- if (value == null) {
- value = property.getDefaultValue();
- }
- switch (property.getPropertyType()) {
- case BOOLEAN:
- return Boolean.parseBoolean(value);
- case INT:
- return Integer.parseInt(value);
- case FLOAT:
- return Float.parseFloat(value);
- case MODE:
- return Integer.parseInt(value);
- default:
- throw new UnsupportedOperationException(property.getId() + "konnte nicht geladen werden!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement