From 1779d833024ef80e12b9662b3773885d882fabf7 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 23 Jan 2020 11:16:22 -0500 Subject: [PATCH 01/10] clientloader: throw classnotfoundexception when trying to load classes from the closed jar This allows showing the classname when an exception is thrown due to the jar being closed --- .../java/net/runelite/client/rs/ClientLoader.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java index 10fa8e9fd4..4309a10bbf 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java @@ -451,7 +451,17 @@ public class ClientLoader implements Supplier protected Class findClass(String name) throws ClassNotFoundException { String entryName = name.replace('.', '/').concat(".class"); - JarEntry jarEntry = jarFile.getJarEntry(entryName); + JarEntry jarEntry; + + try + { + jarEntry = jarFile.getJarEntry(entryName); + } + catch (IllegalStateException ex) + { + throw new ClassNotFoundException(name, ex); + } + if (jarEntry == null) { throw new ClassNotFoundException(name); From 7c20e05bf9bcaf60cb9b26df2ef7adbf57ad63fd Mon Sep 17 00:00:00 2001 From: melkypie <5113962+melkypie@users.noreply.github.com> Date: Thu, 23 Jan 2020 22:53:36 +0200 Subject: [PATCH 02/10] chatcommands: fix cox pb tracking --- .../client/plugins/chatcommands/ChatCommandsPlugin.java | 5 +++-- .../client/plugins/chatcommands/ChatCommandsPluginTest.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 669d7c775f..283b09b750 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -88,7 +88,7 @@ public class ChatCommandsPlugin extends Plugin { private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (.+) (?:kill|harvest|lap|completion) count is: (\\d+)"); private static final Pattern RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: (\\d+)"); - private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete! Duration ([0-9:]+)"); + private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete! Duration: ([0-9:]+)"); private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: (\\d+)"); private static final Pattern BARROWS_PATTERN = Pattern.compile("Your Barrows chest count is: (\\d+)"); private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: [0-9:]+\\. Personal best: ([0-9:]+)"); @@ -215,7 +215,8 @@ public class ChatCommandsPlugin extends Plugin { if (chatMessage.getType() != ChatMessageType.TRADE && chatMessage.getType() != ChatMessageType.GAMEMESSAGE - && chatMessage.getType() != ChatMessageType.SPAM) + && chatMessage.getType() != ChatMessageType.SPAM + && chatMessage.getType() != ChatMessageType.FRIENDSCHATNOTIFICATION) { return; } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java index 69e3b01397..ab7daaff99 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java @@ -29,6 +29,7 @@ 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.FRIENDSCHATNOTIFICATION; import static net.runelite.api.ChatMessageType.GAMEMESSAGE; import static net.runelite.api.ChatMessageType.TRADE; import net.runelite.api.Client; @@ -366,7 +367,7 @@ public class ChatCommandsPluginTest { when(client.getUsername()).thenReturn("Adam"); - ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Congratulations - your raid is complete! Duration 37:04", null, 0); + ChatMessage chatMessage = new ChatMessage(null, FRIENDSCHATNOTIFICATION, "", "Congratulations - your raid is complete! Duration: 37:04", null, 0); chatCommandsPlugin.onChatMessage(chatMessage); chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Chambers of Xeric count is: 51.", null, 0); @@ -382,7 +383,7 @@ public class ChatCommandsPluginTest when(client.getUsername()).thenReturn("Adam"); when(configManager.getConfiguration(anyString(), anyString(), any())).thenReturn(2224); - ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Congratulations - your raid is complete! Duration 1:45:04", null, 0); + ChatMessage chatMessage = new ChatMessage(null, FRIENDSCHATNOTIFICATION, "", "Congratulations - your raid is complete! Duration: 1:45:04", null, 0); chatCommandsPlugin.onChatMessage(chatMessage); chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Chambers of Xeric count is: 52.", null, 0); From 853897ef4187e9abb7f88f3f48559fc00ec3dffe Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 23 Jan 2020 17:51:46 -0500 Subject: [PATCH 03/10] Revert "clientui: forcibly bring client to front on Windows on request focus" This reverts commit 8f5b45ddbe0f0098c22f58b81bcd82924d2e381e. The minimize/maximize is noticible when playing with the client visible, but not in focus. --- .../java/net/runelite/client/ui/ClientUI.java | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 9d0522392f..13595170b2 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -591,34 +591,6 @@ public class ClientUI { OSXUtil.requestFocus(); } - // The workaround for Windows is to minimise and then un-minimise the client to bring - // it to the front because java.awt.Window#toFront doesn't work reliably. - // See https://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front/7435722#7435722 - else if (OSType.getOSType() == OSType.Windows && !frame.isFocused()) - { - SwingUtilities.invokeLater(() -> - { - if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH) - { - frame.setExtendedState(JFrame.ICONIFIED); - frame.setExtendedState(JFrame.MAXIMIZED_BOTH); - } - else - { - // If the client is snapped to the top and bottom edges of the screen, setExtendedState will - // will reset it so setSize and setLocation ensure that the client doesn't move or resize. - // It is done this way because Windows does not support JFrame.MAXIMIZED_VERT - int x = frame.getLocation().x; - int y = frame.getLocation().y; - int width = frame.getWidth(); - int height = frame.getHeight(); - frame.setExtendedState(JFrame.ICONIFIED); - frame.setExtendedState(JFrame.NORMAL); - frame.setLocation(x, y); - frame.setSize(width, height); - } - }); - } frame.requestFocus(); giveClientFocus(); From 81dec7c136e506933c9c0694b2e0adcf7a1cf4c2 Mon Sep 17 00:00:00 2001 From: dekvall Date: Fri, 24 Jan 2020 12:14:10 +0100 Subject: [PATCH 04/10] clanchat plugin: strip leading / from clan tab chat messages Users might accidentally prepend their message with / by force of habit. --- .../net/runelite/client/plugins/clanchat/ClanChatPlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java index cfc1447b50..e6c811a86c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java @@ -528,7 +528,9 @@ public class ClanChatPlugin extends Plugin { final int[] intStack = client.getIntStack(); final int size = client.getIntStackSize(); - intStack[size - 1] = config.clanTabChat() ? 1 : 0; + // If the user accidentally adds a / when the config and the clan chat tab is active, handle it like a normal message + boolean alterClanChatDispatch = config.clanTabChat() && !client.getVar(VarClientStr.CHATBOX_TYPED_TEXT).startsWith("/"); + intStack[size - 1] = alterClanChatDispatch ? 1 : 0; break; } case "confirmClanKick": From 517f60bc05d9828d5acdc629373fe5e99360dbed Mon Sep 17 00:00:00 2001 From: Daniel Bolink Date: Thu, 5 Sep 2019 23:09:43 -0700 Subject: [PATCH 05/10] widgetoverlay: make LMS info box movable --- .../main/java/net/runelite/api/widgets/WidgetID.java | 12 ++++++++++++ .../java/net/runelite/api/widgets/WidgetInfo.java | 3 +++ .../runelite/client/ui/overlay/WidgetOverlay.java | 2 ++ 3 files changed, 17 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index 774d275765..1795e4d6c8 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -147,6 +147,8 @@ public class WidgetID public static final int EXPLORERS_RING_ALCH_GROUP_ID = 483; public static final int OPTIONS_GROUP_ID = 261; public static final int GWD_KC_GROUP_ID = 406; + public static final int LMS_GROUP_ID = 333; + public static final int LMS_INGAME_GROUP_ID = 328; static class WorldMap { @@ -852,4 +854,14 @@ public class WidgetID { static final int CONTAINER = 0; } + + static class Lms + { + static final int INFO = 2; + } + + static class LmsKDA + { + static final int INFO = 4; + } } diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index 770895b1ed..382e59707e 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -157,6 +157,9 @@ public enum WidgetInfo MINIMAP_WORLDMAP_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB), MINIMAP_WIKI_BANNER(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WIKI_BANNER), + LMS_INFO(WidgetID.LMS_GROUP_ID, WidgetID.Lms.INFO), + LMS_KDA(WidgetID.LMS_INGAME_GROUP_ID, WidgetID.LmsKDA.INFO), + LOGIN_CLICK_TO_PLAY_SCREEN(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, 0), LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, WidgetID.LoginClickToPlayScreen.MESSAGE_OF_THE_DAY), diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java index 442df47631..8c95a12816 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java @@ -55,6 +55,8 @@ public class WidgetOverlay extends Overlay .put(WidgetInfo.SKOTIZO_CONTAINER, OverlayPosition.TOP_LEFT) .put(WidgetInfo.KOUREND_FAVOUR_OVERLAY, OverlayPosition.TOP_CENTER) .put(WidgetInfo.PYRAMID_PLUNDER_DATA, OverlayPosition.TOP_CENTER) + .put(WidgetInfo.LMS_INFO, OverlayPosition.TOP_CENTER) + .put(WidgetInfo.LMS_KDA, OverlayPosition.TOP_CENTER) .build(); public static Collection createOverlays(final Client client) From 769e7d2ff18b85563d9e84da13a7055429e45d17 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 25 Jan 2020 09:20:31 -0500 Subject: [PATCH 06/10] api: add dragging flag to widget item --- .../src/main/java/net/runelite/api/widgets/WidgetItem.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java index c39e961f81..1d868e62b6 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java @@ -63,6 +63,10 @@ public class WidgetItem * The widget which contains this item. */ private final Widget widget; + /** + * Whether or not this widget item is being dragged. + */ + private final boolean dragging; /** * Gets the upper-left coordinate of where the widget is being drawn From f37c981197ad27be1a375bbe6ee781205ae9622d Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 20 Jan 2020 10:20:16 -0500 Subject: [PATCH 07/10] task: use lambdas for scheduled method invokes --- .../client/plugins/PluginManager.java | 35 +++++++++++-- .../runelite/client/task/ScheduledMethod.java | 49 +++++-------------- .../net/runelite/client/task/Scheduler.java | 13 +++-- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index fadd54ebc9..3cbcc57385 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -38,6 +38,11 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import java.io.IOException; +import java.lang.invoke.CallSite; +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -57,8 +62,6 @@ import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import net.runelite.client.events.SessionClose; -import net.runelite.client.events.SessionOpen; import net.runelite.client.RuneLite; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigManager; @@ -66,11 +69,14 @@ import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.PluginChanged; +import net.runelite.client.events.SessionClose; +import net.runelite.client.events.SessionOpen; import net.runelite.client.task.Schedule; import net.runelite.client.task.ScheduledMethod; import net.runelite.client.task.Scheduler; import net.runelite.client.ui.SplashScreen; import net.runelite.client.util.GameEventManager; +import net.runelite.client.util.ReflectUtil; @Singleton @Slf4j @@ -501,7 +507,30 @@ public class PluginManager continue; } - ScheduledMethod scheduledMethod = new ScheduledMethod(schedule, method, plugin); + Runnable runnable = null; + try + { + final Class clazz = method.getDeclaringClass(); + final MethodHandles.Lookup caller = ReflectUtil.privateLookupIn(clazz); + final MethodType subscription = MethodType.methodType(method.getReturnType(), method.getParameterTypes()); + final MethodHandle target = caller.findVirtual(clazz, method.getName(), subscription); + final CallSite site = LambdaMetafactory.metafactory( + caller, + "run", + MethodType.methodType(Runnable.class, clazz), + subscription, + target, + subscription); + + final MethodHandle factory = site.getTarget(); + runnable = (Runnable) factory.bindTo(plugin).invokeExact(); + } + catch (Throwable e) + { + log.warn("Unable to create lambda for method {}", method, e); + } + + ScheduledMethod scheduledMethod = new ScheduledMethod(schedule, method, plugin, runnable); log.debug("Scheduled task {}", scheduledMethod); scheduler.addScheduledMethod(scheduledMethod); diff --git a/runelite-client/src/main/java/net/runelite/client/task/ScheduledMethod.java b/runelite-client/src/main/java/net/runelite/client/task/ScheduledMethod.java index e91a5a89ff..5e39b49f0e 100644 --- a/runelite-client/src/main/java/net/runelite/client/task/ScheduledMethod.java +++ b/runelite-client/src/main/java/net/runelite/client/task/ScheduledMethod.java @@ -26,49 +26,22 @@ package net.runelite.client.task; import java.lang.reflect.Method; import java.time.Instant; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +@RequiredArgsConstructor +@ToString +@Getter public class ScheduledMethod { private final Schedule schedule; private final Method method; private final Object object; + @EqualsAndHashCode.Exclude + private final Runnable lambda; + @Setter private Instant last = Instant.now(); - - public ScheduledMethod(Schedule schedule, Method method, Object object) - { - this.schedule = schedule; - this.method = method; - this.object = object; - } - - @Override - public String toString() - { - return "ScheduledMethod{" + "schedule=" + schedule + ", method=" + method + ", object=" + object + '}'; - } - - public Schedule getSchedule() - { - return schedule; - } - - public Method getMethod() - { - return method; - } - - public Object getObject() - { - return object; - } - - public Instant getLast() - { - return last; - } - - public void setLast(Instant last) - { - this.last = last; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java b/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java index 2f6446c3ab..8ecf6ab665 100644 --- a/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java +++ b/runelite-client/src/main/java/net/runelite/client/task/Scheduler.java @@ -93,11 +93,18 @@ public class Scheduler private void run(ScheduledMethod scheduledMethod) { - Method method = scheduledMethod.getMethod(); - try { - method.invoke(scheduledMethod.getObject()); + Runnable lambda = scheduledMethod.getLambda(); + if (lambda != null) + { + lambda.run(); + } + else + { + Method method = scheduledMethod.getMethod(); + method.invoke(scheduledMethod.getObject()); + } } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { From ee2b2012e46fb5540aea125e61aa1a80c4d588c2 Mon Sep 17 00:00:00 2001 From: Vuk <46850780+VukAnd@users.noreply.github.com> Date: Mon, 27 Jan 2020 20:11:19 +0100 Subject: [PATCH 08/10] clue plugin: rename Elf Camp to Iorwerth Camp --- .../client/plugins/cluescrolls/clues/CoordinateClue.java | 6 +++--- .../plugins/cluescrolls/clues/hotcold/HotColdLocation.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java index 6561fdce5a..bc8ef25910 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java @@ -86,7 +86,7 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati .put(new WorldPoint(3770, 3898, 0), "On the small island north-east of Fossil Island's mushroom forest.") // Hard .put(new WorldPoint(2209, 3161, 0), "North-east of Tyras Camp (BJS).") - .put(new WorldPoint(2181, 3206, 0), "South of Elf Camp.") + .put(new WorldPoint(2181, 3206, 0), "South of Iorwerth Camp.") .put(new WorldPoint(3081, 3209, 0), "Small Island (CLP).") .put(new WorldPoint(3399, 3246, 0), "Behind the Duel Arena.") .put(new WorldPoint(2699, 3251, 0), "Little island (AIR).") @@ -141,7 +141,7 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati .put(new WorldPoint(3587, 3180, 0), "Meiyerditch.") .put(new WorldPoint(2820, 3078, 0), "Tai Bwo Wannai. Hardwood Grove.") .put(new WorldPoint(3811, 3060, 0), "Small island north-east of Mos Le'Harmless.") - .put(new WorldPoint(2180, 3282, 0), "North of Elf Camp.") + .put(new WorldPoint(2180, 3282, 0), "North of Iorwerth Camp.") .put(new WorldPoint(2870, 2997, 0), "North-east of Shilo Village.") .put(new WorldPoint(3302, 2988, 0), "On top of a cliff to the west of Pollnivneach.") .put(new WorldPoint(2511, 2980, 0), "Just south of Gu'Tanoth, west of gnome glider.") @@ -170,7 +170,7 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati .put(new WorldPoint(2872, 3937, 0), "Weiss.") .put(new WorldPoint(2484, 4016, 0), "Northeast corner of the Island of Stone.") // Master - .put(new WorldPoint(2178, 3209, 0), "South of Elf Camp.") + .put(new WorldPoint(2178, 3209, 0), "South of Iorwerth Camp.") .put(new WorldPoint(2155, 3100, 0), "South of Port Tyras (BJS).") .put(new WorldPoint(2217, 3092, 0), "Poison Waste island (DLR).") .put(new WorldPoint(3830, 3060, 0), "Small island located north-east of Mos Le'Harmless.") diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdLocation.java index 939ea47962..992001e0df 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdLocation.java @@ -140,8 +140,8 @@ public enum HotColdLocation WESTERN_PROVINCE_PISCATORIS(new WorldPoint(2337, 3689, 0), WESTERN_PROVINCE, "Piscatoris Fishing Colony"), WESTERN_PROVINCE_PISCATORIS_HUNTER_AREA(new WorldPoint(2359, 3564, 0), WESTERN_PROVINCE, "Eastern part of Piscatoris Hunter area, south-west of the Falconry."), WESTERN_PROVINCE_ARANDAR(new WorldPoint(2366, 3318, 0), WESTERN_PROVINCE, "South-west of the crystal gate to Arandar."), - WESTERN_PROVINCE_ELF_CAMP_EAST(new WorldPoint(2270, 3244, 0), WESTERN_PROVINCE, "East of Elf Camp."), - WESTERN_PROVINCE_ELF_CAMP_NW(new WorldPoint(2174, 3280, 0), WESTERN_PROVINCE, "North-west of Elf Camp."), + WESTERN_PROVINCE_ELF_CAMP_EAST(new WorldPoint(2270, 3244, 0), WESTERN_PROVINCE, "East of Iorwerth Camp."), + WESTERN_PROVINCE_ELF_CAMP_NW(new WorldPoint(2174, 3280, 0), WESTERN_PROVINCE, "North-west of Iorwerth Camp."), WESTERN_PROVINCE_LLETYA(new WorldPoint(2335, 3166, 0), WESTERN_PROVINCE, "In Lletya."), WESTERN_PROVINCE_TYRAS(new WorldPoint(2204, 3157, 0), WESTERN_PROVINCE, "Near Tyras Camp."), WESTERN_PROVINCE_ZULANDRA(new WorldPoint(2196, 3057, 0), WESTERN_PROVINCE, "The northern house at Zul-Andra."), From 8708788004d15cb87c0f334a7b4b9492de4c4792 Mon Sep 17 00:00:00 2001 From: Zach Waller Date: Mon, 27 Jan 2020 15:27:52 -0500 Subject: [PATCH 09/10] menu swapper: add bank deposit/withdraw shift click Co-authored-by: Adam --- .../MenuEntrySwapperConfig.java | 30 ++++++---- .../MenuEntrySwapperPlugin.java | 55 +++++++++++++------ .../menuentryswapper/ShiftDepositMode.java | 52 ++++++++++++++++++ .../menuentryswapper/ShiftWithdrawMode.java | 52 ++++++++++++++++++ .../MenuEntrySwapperPluginTest.java | 41 ++++++++++++-- 5 files changed, 198 insertions(+), 32 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftDepositMode.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftWithdrawMode.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index da98cfb9d4..15393366df 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -382,16 +382,6 @@ public interface MenuEntrySwapperConfig extends Config return false; } - @ConfigItem( - keyName = "swapBankOp", - name = "Swap Bank Op", - description = "Swaps the extra menu option in banks (Wield, Eat, etc.) when holding shift" - ) - default boolean swapBankOp() - { - return false; - } - @ConfigItem( keyName = "swapNpcContact", name = "NPC Contact", @@ -401,4 +391,24 @@ public interface MenuEntrySwapperConfig extends Config { return false; } + + @ConfigItem( + keyName = "bankWithdrawShiftClick", + name = "Bank Withdraw Shift-Click", + description = "Swaps the behavior of shift-click when withdrawing from bank." + ) + default ShiftWithdrawMode bankWithdrawShiftClick() + { + return ShiftWithdrawMode.OFF; + } + + @ConfigItem( + keyName = "bankDepositShiftClick", + name = "Bank Deposit Shift-Click", + description = "Swaps the behavior of shift-click when depositing to bank." + ) + default ShiftDepositMode bankDepositShiftClick() + { + return ShiftDepositMode.OFF; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index e5d3c227d9..3b3f225267 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -307,30 +307,49 @@ public class MenuEntrySwapperPlugin extends Plugin // widget ticking and prior to our client tick event. This is because drag start // is what builds the context menu row which is what the eventual click will use + // Swap to shift-click deposit behavior // Deposit- op 2 is the current withdraw amount 1/5/10/x - if (shiftModifier && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getIdentifier() == 2 - && config.swapBankOp() && menuEntryAdded.getOption().startsWith("Deposit-")) + if (shiftModifier && config.bankDepositShiftClick() != ShiftDepositMode.OFF + && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getIdentifier() == 2 + && menuEntryAdded.getOption().startsWith("Deposit-")) { - MenuEntry[] menuEntries = client.getMenuEntries(); + ShiftDepositMode shiftDepositMode = config.bankDepositShiftClick(); + final int actionId = shiftDepositMode.getMenuAction().getId(); + final int opId = shiftDepositMode.getIdentifier(); + bankModeSwap(actionId, opId); + } - // Find the extra menu option; they don't have fixed names, so check - // based on the menu identifier - for (int i = menuEntries.length - 1; i >= 0; --i) + // Swap to shift-click withdraw behavior + // Deposit- op 1 is the current withdraw amount 1/5/10/x + if (shiftModifier && config.bankWithdrawShiftClick() != ShiftWithdrawMode.OFF + && menuEntryAdded.getType() == MenuAction.CC_OP.getId() && menuEntryAdded.getIdentifier() == 1 + && menuEntryAdded.getOption().startsWith("Withdraw-")) + { + ShiftWithdrawMode shiftWithdrawMode = config.bankWithdrawShiftClick(); + final int actionId = shiftWithdrawMode.getMenuAction().getId(); + final int opId = shiftWithdrawMode.getIdentifier(); + bankModeSwap(actionId, opId); + } + } + + private void bankModeSwap(int entryTypeId, int entryIdentifier) + { + MenuEntry[] menuEntries = client.getMenuEntries(); + + for (int i = menuEntries.length - 1; i >= 0; --i) + { + MenuEntry entry = menuEntries[i]; + + if (entry.getType() == entryTypeId && entry.getIdentifier() == entryIdentifier) { - MenuEntry entry = menuEntries[i]; + // Raise the priority of the op so it doesn't get sorted later + entry.setType(MenuAction.CC_OP.getId()); - // The extra options are always option 9 - if (entry.getType() == MenuAction.CC_OP_LOW_PRIORITY.getId() && entry.getIdentifier() == 9) - { - // we must also raise the priority of the op so it doesn't get sorted later - entry.setType(MenuAction.CC_OP.getId()); + menuEntries[i] = menuEntries[menuEntries.length - 1]; + menuEntries[menuEntries.length - 1] = entry; - menuEntries[i] = menuEntries[menuEntries.length - 1]; - menuEntries[menuEntries.length - 1] = entry; - - client.setMenuEntries(menuEntries); - break; - } + client.setMenuEntries(menuEntries); + break; } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftDepositMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftDepositMode.java new file mode 100644 index 0000000000..da490eb6a6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftDepositMode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020, Zach + * 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.menuentryswapper; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.runelite.api.MenuAction; + +@Getter +@RequiredArgsConstructor +public enum ShiftDepositMode +{ + DEPOSIT_1("Deposit-1", MenuAction.CC_OP, 3), + DEPOSIT_5("Deposit-5", MenuAction.CC_OP, 4), + DEPOSIT_10("Deposit-10", MenuAction.CC_OP, 5), + DEPOSIT_X("Deposit-X", MenuAction.CC_OP_LOW_PRIORITY, 6), + DEPOSIT_ALL("Deposit-All", MenuAction.CC_OP_LOW_PRIORITY, 8), + EXTRA_OP("Eat/Wield/Etc.", MenuAction.CC_OP_LOW_PRIORITY, 9), + OFF("Off", MenuAction.UNKNOWN, 0); + + private final String name; + private final MenuAction menuAction; + private final int identifier; + + @Override + public String toString() + { + return name; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftWithdrawMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftWithdrawMode.java new file mode 100644 index 0000000000..30260d8fd6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftWithdrawMode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020, Zach + * 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.menuentryswapper; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.runelite.api.MenuAction; + +@Getter +@RequiredArgsConstructor +public enum ShiftWithdrawMode +{ + WITHDRAW_1("Withdraw-1", MenuAction.CC_OP, 2), + WITHDRAW_5("Withdraw-5", MenuAction.CC_OP, 3), + WITHDRAW_10("Withdraw-10", MenuAction.CC_OP, 4), + WITHDRAW_X("Withdraw-X", MenuAction.CC_OP, 5), + WITHDRAW_ALL("Withdraw-All", MenuAction.CC_OP_LOW_PRIORITY, 7), + WITHDRAW_ALL_BUT_1("Withdraw-All-But-1", MenuAction.CC_OP_LOW_PRIORITY, 8), + OFF("Off", MenuAction.UNKNOWN, 0); + + private final String name; + private final MenuAction menuAction; + private final int identifier; + + @Override + public String toString() + { + return name; + } +} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java index 8aedec91cd..da2e028af6 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPluginTest.java @@ -303,14 +303,14 @@ public class MenuEntrySwapperPluginTest } @Test - public void testBankExtraOp() + public void testShiftWithdraw() { - when(config.swapBankOp()).thenReturn(true); + when(config.bankDepositShiftClick()).thenReturn(ShiftDepositMode.EXTRA_OP); menuEntrySwapperPlugin.setShiftModifier(true); entries = new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), - menu("Weild", "Abyssal whip", MenuAction.CC_OP_LOW_PRIORITY, 9), + menu("Wield", "Abyssal whip", MenuAction.CC_OP_LOW_PRIORITY, 9), menu("Deposit-1", "Abyssal whip", MenuAction.CC_OP, 2), }; @@ -329,7 +329,40 @@ public class MenuEntrySwapperPluginTest assertArrayEquals(new MenuEntry[]{ menu("Cancel", "", MenuAction.CANCEL), menu("Deposit-1", "Abyssal whip", MenuAction.CC_OP, 2), - menu("Weild", "Abyssal whip", MenuAction.CC_OP, 9), + menu("Wield", "Abyssal whip", MenuAction.CC_OP, 9), + }, argumentCaptor.getValue()); + } + + @Test + public void testShiftDeposit() + { + when(config.bankDepositShiftClick()).thenReturn(ShiftDepositMode.DEPOSIT_ALL); + menuEntrySwapperPlugin.setShiftModifier(true); + + entries = new MenuEntry[]{ + menu("Cancel", "", MenuAction.CANCEL), + menu("Wield", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 9), + menu("Deposit-All", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 8), + menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), + }; + + menuEntrySwapperPlugin.onMenuEntryAdded(new MenuEntryAdded( + "Deposit-1", + "Rune arrow", + MenuAction.CC_OP.getId(), + 2, + -1, + -1 + )); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(MenuEntry[].class); + verify(client).setMenuEntries(argumentCaptor.capture()); + + assertArrayEquals(new MenuEntry[]{ + menu("Cancel", "", MenuAction.CANCEL), + menu("Wield", "Rune arrow", MenuAction.CC_OP_LOW_PRIORITY, 9), + menu("Deposit-1", "Rune arrow", MenuAction.CC_OP, 2), + menu("Deposit-All", "Rune arrow", MenuAction.CC_OP, 8), }, argumentCaptor.getValue()); } } \ No newline at end of file From 6cda7e8858e4d0919cac7da52a8d2aa8249eaf4f Mon Sep 17 00:00:00 2001 From: Henry Darnell Date: Tue, 28 Jan 2020 07:52:22 -0600 Subject: [PATCH 10/10] Capitalize "discord" in info panel (#10667) --- .../main/java/net/runelite/client/plugins/info/InfoPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java index 86a31a983c..d691cef668 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java @@ -174,7 +174,7 @@ public class InfoPanel extends PluginPanel }); actionsContainer.add(buildLinkPanel(GITHUB_ICON, "Report an issue or", "make a suggestion", RuneLiteProperties.getGithubLink())); - actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "discord server", RuneLiteProperties.getDiscordInvite())); + actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "Discord server", RuneLiteProperties.getDiscordInvite())); actionsContainer.add(buildLinkPanel(PATREON_ICON, "Become a patron to", "help support RuneLite", RuneLiteProperties.getPatreonLink())); actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", RuneLiteProperties.getWikiLink()));