fixes screen shotting local players deaths (#1198)
Signed-off-by: PKLite <stonewall@pklite.xyz>
This commit is contained in:
@@ -115,9 +115,9 @@ import okhttp3.Response;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Screenshot",
|
name = "Screenshot",
|
||||||
description = "Enable the manual and automatic taking of screenshots",
|
description = "Enable the manual and automatic taking of screenshots",
|
||||||
tags = {"external", "images", "imgur", "integration", "notifications"}
|
tags = {"external", "images", "imgur", "integration", "notifications"}
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -136,8 +136,8 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
private static final Pattern UNTRADEABLE_DROP_PATTERN = Pattern.compile(".*Untradeable drop: ([^<>]+)(?:</col>)?");
|
private static final Pattern UNTRADEABLE_DROP_PATTERN = Pattern.compile(".*Untradeable drop: ([^<>]+)(?:</col>)?");
|
||||||
private static final Pattern DUEL_END_PATTERN = Pattern.compile("You have now (won|lost) ([0-9]+) duels?\\.");
|
private static final Pattern DUEL_END_PATTERN = Pattern.compile("You have now (won|lost) ([0-9]+) duels?\\.");
|
||||||
private static final ImmutableList<String> PET_MESSAGES = ImmutableList.of("You have a funny feeling like you're being followed",
|
private static final ImmutableList<String> PET_MESSAGES = ImmutableList.of("You have a funny feeling like you're being followed",
|
||||||
"You feel something weird sneaking into your backpack",
|
"You feel something weird sneaking into your backpack",
|
||||||
"You have a funny feeling like you would have been followed");
|
"You have a funny feeling like you would have been followed");
|
||||||
|
|
||||||
private static String format(Date date)
|
private static String format(Date date)
|
||||||
{
|
{
|
||||||
@@ -253,25 +253,25 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), "screenshot.png");
|
final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), "screenshot.png");
|
||||||
|
|
||||||
titleBarButton = NavigationButton.builder()
|
titleBarButton = NavigationButton.builder()
|
||||||
.tab(false)
|
.tab(false)
|
||||||
.tooltip("Take screenshot")
|
.tooltip("Take screenshot")
|
||||||
.icon(iconImage)
|
.icon(iconImage)
|
||||||
.onClick(() -> takeScreenshot(format(new Date())))
|
.onClick(() -> takeScreenshot(format(new Date())))
|
||||||
.popup(ImmutableMap
|
.popup(ImmutableMap
|
||||||
.<String, Runnable>builder()
|
.<String, Runnable>builder()
|
||||||
.put("Open screenshot folder...", () ->
|
.put("Open screenshot folder...", () ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Desktop.getDesktop().open(SCREENSHOT_DIR);
|
Desktop.getDesktop().open(SCREENSHOT_DIR);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
log.warn("Error opening screenshot dir", ex);
|
log.warn("Error opening screenshot dir", ex);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
clientToolbar.addNavigation(titleBarButton);
|
clientToolbar.addNavigation(titleBarButton);
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
private void onGameStateChanged(GameStateChanged event)
|
private void onGameStateChanged(GameStateChanged event)
|
||||||
{
|
{
|
||||||
if (event.getGameState() == GameState.LOGGED_IN
|
if (event.getGameState() == GameState.LOGGED_IN
|
||||||
&& reportButton == null)
|
&& reportButton == null)
|
||||||
{
|
{
|
||||||
reportButton = spriteManager.getSprite(SpriteID.CHATBOX_REPORT_BUTTON, 0);
|
reportButton = spriteManager.getSprite(SpriteID.CHATBOX_REPORT_BUTTON, 0);
|
||||||
}
|
}
|
||||||
@@ -358,9 +358,17 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
|
|
||||||
private void onAnimationChanged(AnimationChanged e)
|
private void onAnimationChanged(AnimationChanged e)
|
||||||
{
|
{
|
||||||
//this got refactored somewhere, but some things were missing
|
|
||||||
if (!this.screenshotFriendDeath || !this.screenshotPlayerDeath)
|
if (e.getActor().getAnimation() != 836)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.screenshotPlayerDeath && client.getLocalPlayer().equals(e.getActor()))
|
||||||
|
{
|
||||||
|
takeScreenshot("Death");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(e.getActor() instanceof Player))
|
if (!(e.getActor() instanceof Player))
|
||||||
return;
|
return;
|
||||||
@@ -705,7 +713,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
Consumer<Image> imageCallback = (img) ->
|
Consumer<Image> imageCallback = (img) ->
|
||||||
{
|
{
|
||||||
// This callback is on the game thread, move to executor thread
|
// This callback is on the game thread, move to executor thread
|
||||||
executor.submit(() -> takeScreenshot(fileName, img, subdirectory));
|
executor.submit(() -> takeScreenshot(fileName, img, subdirectory));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -721,8 +729,8 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
private void takeScreenshot(String fileName, Image image, @Nullable String subdirectory)
|
private void takeScreenshot(String fileName, Image image, @Nullable String subdirectory)
|
||||||
{
|
{
|
||||||
BufferedImage screenshot = this.includeFrame
|
BufferedImage screenshot = this.includeFrame
|
||||||
? new BufferedImage(clientUi.getWidth(), clientUi.getHeight(), BufferedImage.TYPE_INT_ARGB)
|
? new BufferedImage(clientUi.getWidth(), clientUi.getHeight(), BufferedImage.TYPE_INT_ARGB)
|
||||||
: new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
: new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
Graphics graphics = screenshot.getGraphics();
|
Graphics graphics = screenshot.getGraphics();
|
||||||
|
|
||||||
@@ -826,10 +834,10 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
RequestBody body = RequestBody.Companion.create(json, JSON);
|
RequestBody body = RequestBody.Companion.create(json, JSON);
|
||||||
request = new Request.Builder()
|
request = new Request.Builder()
|
||||||
.url(IMGUR_IMAGE_UPLOAD_URL)
|
.url(IMGUR_IMAGE_UPLOAD_URL)
|
||||||
.addHeader("Authorization", "Client-ID " + IMGUR_CLIENT_ID)
|
.addHeader("Authorization", "Client-ID " + IMGUR_CLIENT_ID)
|
||||||
.post(body)
|
.post(body)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request != null)
|
if (request != null)
|
||||||
@@ -848,13 +856,13 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
try (InputStream in = response.body().byteStream())
|
try (InputStream in = response.body().byteStream())
|
||||||
{
|
{
|
||||||
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
|
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
|
||||||
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
|
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
|
||||||
|
|
||||||
if (imageUploadResponse.isSuccess())
|
if (imageUploadResponse.isSuccess())
|
||||||
{
|
{
|
||||||
String link = imageUploadResponse.getData().getLink();
|
String link = imageUploadResponse.getData().getLink();
|
||||||
|
|
||||||
Clipboard.store(link);
|
Clipboard.store(link);
|
||||||
|
|
||||||
if (notifyWhenTaken)
|
if (notifyWhenTaken)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user