diff --git a/src/main/java/net/aoba/macros/Macro.java b/src/main/java/net/aoba/macros/Macro.java index 876c999..a7282da 100644 --- a/src/main/java/net/aoba/macros/Macro.java +++ b/src/main/java/net/aoba/macros/Macro.java @@ -20,34 +20,35 @@ public class Macro { private String name; private String filePath; private LinkedList events; - + public Macro(File file) { this.name = file.getName(); this.filePath = file.getPath(); this.events = new LinkedList(); try { DataInputStream in = new DataInputStream(new FileInputStream(filePath)); - + String className = null; - while((className = in.readUTF()) != null) { + while ((className = in.readUTF()) != null) { // Read Macros - // TODO: I HATTEE writing stuff out in plaintext, but I also hate files that cant be modified externally. - // I can't think of a way to make these macros something that can be easily modified in Notepad without - // making a giant file. If possible, any chance we can write into xml format??? + // TODO: I HATTEE writing stuff out in plaintext, but I also hate files that + // cant be modified externally. + // I can't think of a way to make these macros something that can be easily + // modified in Notepad without + // making a giant file. If possible, any chance we can write into xml format??? MacroEvent event = null; - System.out.println(className); - if(className.equals(KeyClickMacroEvent.class.getName())) { + if (className.equals(KeyClickMacroEvent.class.getName())) { event = new KeyClickMacroEvent(); - }else if (className.equals(MouseClickMacroEvent.class.getName())) { + } else if (className.equals(MouseClickMacroEvent.class.getName())) { event = new MouseClickMacroEvent(); - }else if (className.equals(MouseMoveMacroEvent.class.getName())) { + } else if (className.equals(MouseMoveMacroEvent.class.getName())) { event = new MouseMoveMacroEvent(); - }else if (className.equals(MouseScrollMacroEvent.class.getName())) { + } else if (className.equals(MouseScrollMacroEvent.class.getName())) { event = new MouseScrollMacroEvent(); - }else - System.out.println("could nto find"); - - if(event != null) { + } else + System.out.println("Could not find Macro type."); + + if (event != null) { event.read(in); events.add(event); } @@ -57,43 +58,44 @@ public Macro(File file) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); - }finally { + } finally { // Read all of the data. } } - + public Macro(LinkedList events) { this.events = events; } - + public String getName() { return name; } - + public String getFilePath() { return filePath; } - - public LinkedList getEvents(){ + + public LinkedList getEvents() { return events; } - + public void setName(String name) { this.name = name; MinecraftClient MC = MinecraftClient.getInstance(); - this.filePath = MC.runDirectory + File.separator + "aoba" + File.separator + "macros" + File.separator + name + ".macro"; + this.filePath = MC.runDirectory + File.separator + "aoba" + File.separator + "macros" + File.separator + name + + ".macro"; } - + public void save() { try { File macroFile = new File(filePath); - if (!macroFile.exists() && !macroFile.createNewFile()) { - throw new IOException("Failed to create config file: " + macroFile.getAbsolutePath()); - } + if (!macroFile.exists() && !macroFile.createNewFile()) { + throw new IOException("Failed to create config file: " + macroFile.getAbsolutePath()); + } DataOutputStream out = new DataOutputStream(new FileOutputStream(macroFile)); MacroEvent event = events.poll(); - while(event != null) { + while (event != null) { event.write(out); event = events.poll(); } diff --git a/src/main/java/net/aoba/settings/SettingManager.java b/src/main/java/net/aoba/settings/SettingManager.java index 31262b9..1e70904 100644 --- a/src/main/java/net/aoba/settings/SettingManager.java +++ b/src/main/java/net/aoba/settings/SettingManager.java @@ -100,7 +100,9 @@ public static void refreshSettingFiles() { if (files != null) { for (File file : files) { - configNames.add(file.getName().replace(".ttf", "")); + String name = file.getName().replace(".xml", ""); + if (!name.equals("globals")) + configNames.add(name); } } }