Merge pull request #4393 from Noremac201/screenshot-timer

Stop screenshot plugin from overwriting pictures
This commit is contained in:
Tomas Slusny
2019-07-12 12:49:10 +02:00
committed by GitHub

View File

@@ -648,6 +648,14 @@ public class ScreenshotPlugin extends Plugin
{
File screenshotFile = new File(playerFolder, fileName + ".png");
// To make sure that screenshots don't get overwritten, check if file exists,
// and if it does create file with same name and suffix.
int i = 1;
while (screenshotFile.exists())
{
screenshotFile = new File(playerFolder, fileName + String.format("(%d)", i++) + ".png");
}
ImageIO.write(screenshot, "PNG", screenshotFile);
if (config.uploadScreenshot())