Merge pull request #402 from Sethtroll/addcluebarrows
Add Clue Scroll/Barrows to screenshot plugin
This commit is contained in:
@@ -56,6 +56,8 @@ public class WidgetID
|
|||||||
public static final int BA_HEALER_GROUP_ID = 488;
|
public static final int BA_HEALER_GROUP_ID = 488;
|
||||||
public static final int LEVEL_UP_GROUP_ID = 233;
|
public static final int LEVEL_UP_GROUP_ID = 233;
|
||||||
public static final int QUEST_COMPLETED_GROUP_ID = 277;
|
public static final int QUEST_COMPLETED_GROUP_ID = 277;
|
||||||
|
public static final int CLUE_SCROLL_REWARD_GROUP_ID = 73;
|
||||||
|
public static final int BARROWS_REWARD_GROUP_ID = 155;
|
||||||
|
|
||||||
static class WorldMap
|
static class WorldMap
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,8 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.screenshot;
|
package net.runelite.client.plugins.screenshot;
|
||||||
|
|
||||||
import net.runelite.client.plugins.screenshot.imgur.ImageUploadRequest;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import net.runelite.client.plugins.screenshot.imgur.ImageUploadResponse;
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -36,48 +35,56 @@ import java.awt.Toolkit;
|
|||||||
import java.awt.TrayIcon;
|
import java.awt.TrayIcon;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.client.events.ClientUILoaded;
|
|
||||||
import net.runelite.api.events.WidgetHiddenChanged;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.client.Notifier;
|
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
|
||||||
import net.runelite.client.plugins.Plugin;
|
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
|
||||||
import net.runelite.client.ui.ClientUI;
|
|
||||||
import net.runelite.client.ui.FontManager;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.text.DateFormat;
|
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.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.runelite.api.ChatMessageType;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.events.ChatMessage;
|
||||||
|
import net.runelite.api.events.WidgetHiddenChanged;
|
||||||
|
import net.runelite.api.widgets.Widget;
|
||||||
|
import static net.runelite.api.widgets.WidgetID.BARROWS_REWARD_GROUP_ID;
|
||||||
|
import static net.runelite.api.widgets.WidgetID.CLUE_SCROLL_REWARD_GROUP_ID;
|
||||||
|
import static net.runelite.api.widgets.WidgetID.LEVEL_UP_GROUP_ID;
|
||||||
|
import static net.runelite.api.widgets.WidgetID.QUEST_COMPLETED_GROUP_ID;
|
||||||
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
|
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
||||||
|
import net.runelite.client.Notifier;
|
||||||
|
import net.runelite.client.RuneLite;
|
||||||
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.events.ClientUILoaded;
|
||||||
|
import net.runelite.client.plugins.Plugin;
|
||||||
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
|
import net.runelite.client.plugins.screenshot.imgur.ImageUploadRequest;
|
||||||
|
import net.runelite.client.plugins.screenshot.imgur.ImageUploadResponse;
|
||||||
|
import net.runelite.client.ui.ClientUI;
|
||||||
|
import net.runelite.client.ui.FontManager;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
|
import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
|
||||||
import static net.runelite.api.widgets.WidgetID.LEVEL_UP_GROUP_ID;
|
|
||||||
import static net.runelite.api.widgets.WidgetID.QUEST_COMPLETED_GROUP_ID;
|
|
||||||
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
|
||||||
import okhttp3.HttpUrl;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Screenshot plugin"
|
name = "Screenshot plugin"
|
||||||
@@ -92,6 +99,13 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MMM. dd, yyyy", Locale.US);
|
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MMM. dd, yyyy", Locale.US);
|
||||||
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("h.m.s a d MMM. yyyy", Locale.US);
|
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("h.m.s a d MMM. yyyy", Locale.US);
|
||||||
|
|
||||||
|
private static final Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)");
|
||||||
|
|
||||||
|
private String clueType;
|
||||||
|
private Integer clueNumber;
|
||||||
|
|
||||||
|
private Integer barrowsNumber;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ScreenshotConfig config;
|
ScreenshotConfig config;
|
||||||
|
|
||||||
@@ -179,6 +193,44 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onChatMessage(ChatMessage event)
|
||||||
|
{
|
||||||
|
if (event.getType() != ChatMessageType.SERVER && event.getType() != ChatMessageType.FILTERED)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getMessage().contains("Treasure"))
|
||||||
|
{
|
||||||
|
String chatMessage = event.getMessage().replaceAll("<col=3300ff>", "");
|
||||||
|
|
||||||
|
if (chatMessage.startsWith("You have completed"))
|
||||||
|
{
|
||||||
|
Matcher m = NUMBER_PATTERN.matcher(chatMessage);
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
clueNumber = Integer.valueOf(m.group());
|
||||||
|
clueType = chatMessage.substring(chatMessage.lastIndexOf(m.group()) + m.group().length() + 1, chatMessage.indexOf("Treasure") - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getMessage().contains("Barrows"))
|
||||||
|
{
|
||||||
|
String chatMessage = event.getMessage().replaceAll("<col=ff0000>", "");
|
||||||
|
|
||||||
|
if (chatMessage.startsWith("Your Barrows chest count is"))
|
||||||
|
{
|
||||||
|
Matcher m = NUMBER_PATTERN.matcher(chatMessage);
|
||||||
|
if (m.find())
|
||||||
|
{
|
||||||
|
barrowsNumber = Integer.valueOf(m.group());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void hideWidgets(WidgetHiddenChanged event)
|
public void hideWidgets(WidgetHiddenChanged event)
|
||||||
{
|
{
|
||||||
@@ -226,6 +278,29 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
fileName = text.substring(19, text.length() - 1);
|
fileName = text.substring(19, text.length() - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CLUE_SCROLL_REWARD_GROUP_ID:
|
||||||
|
{
|
||||||
|
if (clueType == null || clueNumber == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName = Character.toUpperCase(clueType.charAt(0)) + clueType.substring(1) + "(" + clueNumber + ")";
|
||||||
|
clueType = null;
|
||||||
|
clueNumber = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BARROWS_REWARD_GROUP_ID:
|
||||||
|
{
|
||||||
|
if (barrowsNumber == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName = "Barrows(" + barrowsNumber + ")";
|
||||||
|
barrowsNumber = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -365,4 +440,22 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public int getClueNumber()
|
||||||
|
{
|
||||||
|
return clueNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public String getClueType()
|
||||||
|
{
|
||||||
|
return clueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public int getBarrowsNumber()
|
||||||
|
{
|
||||||
|
return barrowsNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.screenshot;
|
||||||
|
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.testing.fieldbinder.Bind;
|
||||||
|
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import static net.runelite.api.ChatMessageType.SERVER;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.events.ChatMessage;
|
||||||
|
import net.runelite.client.Notifier;
|
||||||
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
|
import net.runelite.client.ui.ClientUI;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class ScreenshotPluginTest
|
||||||
|
{
|
||||||
|
private static final String CLUE_SCROLL = "<col=3300ff>You have completed 28 medium Treasure Trails</col>";
|
||||||
|
private static final String BARROWS_CHEST = "Your Barrows chest count is <col=ff0000>310</col>";
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
Client client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ScreenshotPlugin screenshotPlugin;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ScreenshotConfig screenshotConfig;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
Notifier notifier;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ClientUI clientUi;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
OverlayRenderer overlayRenderer;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
RuneLiteConfig config;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ScheduledExecutorService service;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before()
|
||||||
|
{
|
||||||
|
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testcluescroll()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Seth", CLUE_SCROLL, null);
|
||||||
|
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
|
assertEquals("medium", screenshotPlugin.getClueType());
|
||||||
|
assertEquals(28, screenshotPlugin.getClueNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testbarrowschest()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Seth", BARROWS_CHEST, null);
|
||||||
|
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
|
assertEquals(310, screenshotPlugin.getBarrowsNumber());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user