screenshot-plugin: run image saving logic in another thread
This commit is contained in:
@@ -46,6 +46,7 @@ import java.text.DateFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -120,6 +121,9 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private OverlayRenderer overlayRenderer;
|
private OverlayRenderer overlayRenderer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ScheduledExecutorService executor;
|
||||||
|
|
||||||
private JButton titleBarButton;
|
private JButton titleBarButton;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -397,15 +401,20 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File playerFolder = RuneLite.SCREENSHOT_DIR;
|
File playerFolder;
|
||||||
|
|
||||||
if (client.getLocalPlayer() != null)
|
if (client.getLocalPlayer() != null)
|
||||||
{
|
{
|
||||||
playerFolder = new File(RuneLite.SCREENSHOT_DIR, client.getLocalPlayer().getName());
|
playerFolder = new File(RuneLite.SCREENSHOT_DIR, client.getLocalPlayer().getName());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerFolder = RuneLite.SCREENSHOT_DIR;
|
||||||
|
}
|
||||||
|
|
||||||
playerFolder.mkdirs();
|
playerFolder.mkdirs();
|
||||||
|
|
||||||
|
executor.execute(() ->
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File screenshotFile = new File(playerFolder, fileName + ".png");
|
File screenshotFile = new File(playerFolder, fileName + ".png");
|
||||||
@@ -426,6 +435,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
log.warn("error writing screenshot", ex);
|
log.warn("error writing screenshot", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadScreenshot(File screenshotFile) throws IOException
|
private void uploadScreenshot(File screenshotFile) throws IOException
|
||||||
|
|||||||
Reference in New Issue
Block a user