Stop screenshotPlugin from overwriting previous screenshots

This commit is contained in:
Cameron Moberg
2018-07-21 14:40:19 -04:00
committed by Jordan Atwood
parent 46811b52eb
commit 23413bf0b3

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())