diff --git a/src/Game/Client.java b/src/Game/Client.java index ddf1ba4c..d5113b29 100644 --- a/src/Game/Client.java +++ b/src/Game/Client.java @@ -65,6 +65,11 @@ import javax.swing.JPanel; import org.json.JSONArray; import org.json.JSONObject; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.Callable; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; /** * This class prepares the client for login, handles chat messages, and performs player related @@ -75,6 +80,9 @@ public class Client { // Game's client instance public static Object instance; + // Create an executor for scheduling future actions. (Pool size of 1 for a single-threaded scheduler) + public static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); + public static Map> tracerInstructions = new LinkedHashMap>(); @@ -503,6 +511,13 @@ public static void adaptLoginInfo() { } } + public static Callable takeLevelUpScreenshot = () -> { + // Add the screenshot to the queue + Renderer.takeScreenshot(true); + + return null; + }; + public static int shadowSleepCount; /* @@ -3395,7 +3410,8 @@ public static String colorizeMessage(String colorMessage, int type) { if (screenshotMessage && Settings.AUTO_SCREENSHOT.get(Settings.currentProfile) && !Replay.isPlaying) { - Renderer.takeScreenshot(true); + // Take the screenshot after a 1 second delay + executor.schedule(takeLevelUpScreenshot, 1, TimeUnit.SECONDS); } if (blueMessage) { // this is one of the messages which we must overwrite expected color for