Advertisement
Keridos

Untitled

May 28th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.36 KB | None | 0 0
  1.  public static void readInKeybinds() {
  2.         try {
  3.             File file = new File(Loader.instance().getConfigDir(), "powersuits-keybinds.cfg");
  4.             if (!file.exists()) {
  5.                 MuseLogger.logError("No powersuits keybind file found.");
  6.                 return;
  7.             }
  8.             BufferedReader reader = new BufferedReader(new FileReader(file));
  9.             ClickableKeybinding workingKeybinding[] = new ClickableKeybinding[100];
  10.             int i = 0;
  11.             while (reader.ready()) {
  12.                 String line = reader.readLine();
  13.                 if (line.contains(":")) {
  14.                     int j = 0;
  15.                     String[] exploded = line.split(":");
  16.                     int id = Integer.parseInt(exploded[0]);
  17.                     boolean replicate = false;
  18.                     MusePoint2D position = new MusePoint2D(Double.parseDouble(exploded[1]), Double.parseDouble(exploded[2]));
  19.                     for (ClickableKeybinding keybinding : getInstance().keybindings) {
  20.                         if (keybinding.getKeyBinding().keyCode==id) {
  21.                             replicate = true;
  22.                         }
  23.                     }
  24.                     while (j<=i) {
  25.                         if (workingKeybinding[j] != null) {
  26.                             if (workingKeybinding[j].getKeyBinding().keyCode == id) {
  27.                                 replicate = true;
  28.                             }
  29.                         }
  30.                         j++;
  31.                     }
  32.                     if (!replicate) {
  33.                         boolean free = !KeyBinding.hash.containsItem(id);
  34.                         workingKeybinding[i] = new ClickableKeybinding(new KeyBinding(Keyboard.getKeyName(id), id), position, free);
  35.                         getInstance().keybindings.add(workingKeybinding[i]);
  36.                     } else {
  37.                         workingKeybinding[i] = null;
  38.                     }
  39.                     i++;
  40.                 } else if (line.contains("~") && workingKeybinding[i] != null) {
  41.                     String[] exploded = line.split("~");
  42.                     MusePoint2D position = new MusePoint2D(Double.parseDouble(exploded[1]), Double.parseDouble(exploded[2]));
  43.                     IPowerModule module = ModuleManager.getModule(exploded[0]);
  44.                     if (module != null) {
  45.                         ClickableModule cmodule = new ClickableModule(module, position);
  46.                         workingKeybinding[i].bindModule(cmodule);
  47.                     }
  48.  
  49.                 }
  50.                 }
  51.             reader.close();
  52.         } catch (Exception e) {
  53.             MuseLogger.logError("Problem reading in keyconfig :(");
  54.             e.printStackTrace();
  55.         }
  56.     }
  57.  
  58.  
  59.  
  60.  public static void readInKeybinds() {
  61.         try {
  62.             File file = new File(Loader.instance().getConfigDir(), "powersuits-keybinds.cfg");
  63.             if (!file.exists()) {
  64.                 MuseLogger.logError("No powersuits keybind file found.");
  65.                 return;
  66.             }
  67.             BufferedReader reader = new BufferedReader(new FileReader(file));
  68.             ClickableKeybinding workingKeybinding = null;
  69.             while (reader.ready()) {
  70.                 String line = reader.readLine();
  71.                 if (line.contains(":")) {
  72.                     String[] exploded = line.split(":");
  73.                     int id = Integer.parseInt(exploded[0]);
  74.                     if (!KeyBinding.hash.containsItem(id)) {
  75.                         MusePoint2D position = new MusePoint2D(Double.parseDouble(exploded[1]), Double.parseDouble(exploded[2]));
  76.                         boolean free = !KeyBinding.hash.containsItem(id);
  77.                         workingKeybinding = new ClickableKeybinding(new KeyBinding(Keyboard.getKeyName(id), id), position, free);
  78.                         getInstance().keybindings.add(workingKeybinding);
  79.                     } else {
  80.                         workingKeybinding = null;
  81.                     }
  82.  
  83.                 } else if (line.contains("~") && workingKeybinding != null) {
  84.                     String[] exploded = line.split("~");
  85.                     MusePoint2D position = new MusePoint2D(Double.parseDouble(exploded[1]), Double.parseDouble(exploded[2]));
  86.                     IPowerModule module = ModuleManager.getModule(exploded[0]);
  87.                     if (module != null) {
  88.                         ClickableModule cmodule = new ClickableModule(module, position);
  89.                         workingKeybinding.bindModule(cmodule);
  90.                     }
  91.  
  92.                 }
  93.             }
  94.             reader.close();
  95.         } catch (Exception e) {
  96.             MuseLogger.logError("Problem reading in keyconfig :(");
  97.             e.printStackTrace();
  98.         }
  99.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement