Fixed the dupe check code

This commit is contained in:
Eric-Turner
2016-05-22 09:13:47 -04:00
parent 0dfc4d854e
commit 327d0ca8f9
+14 -3
View File
@@ -151,9 +151,20 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
Rectangle parabotScreen = new Rectangle((int) getLocation().getX(), (int) getLocation().getY(), getWidth(), getHeight()); Rectangle parabotScreen = new Rectangle((int) getLocation().getX(), (int) getLocation().getY(), getWidth(), getHeight());
BufferedImage image = robot.createScreenCapture(parabotScreen); BufferedImage image = robot.createScreenCapture(parabotScreen);
String randString = StringUtils.randomString(10); String randString = StringUtils.randomString(10);
for (int x = 0; x < Directories.getScreenshotDir().listFiles().length; x++) { boolean search = true;
if (Directories.getScreenshotDir().listFiles()[x].getAbsoluteFile().getName().contains(randString)) { boolean duplicate = false;
randString = randString + StringUtils.randomString(4); while(search == true){
for (File f : Directories.getScreenshotDir().listFiles()){
if (f.getAbsoluteFile().getName().contains(randString)) {
duplicate = true;
break;
}
}
if (!duplicate){
search = false;
} else {
randString = StringUtils.randomString(10);
duplicate = false;
} }
} }
File file = new File(Directories.getScreenshotDir().getPath() + "/" + randString + ".png"); File file = new File(Directories.getScreenshotDir().getPath() + "/" + randString + ".png");