From 341ea528f709784b465f943a56efff1b6e0ae1fc Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 18 May 2019 21:32:00 +1000 Subject: [PATCH 1/5] Moved Climb-Up/Down plugin into MenuEntrySwapper --- .../plugins/climbupclimbdown/ClimbPlugin.java | 111 ------------------ .../ShiftCtrlInputListener.java | 62 ---------- .../MenuEntrySwapperConfig.java | 10 ++ .../MenuEntrySwapperPlugin.java | 33 ++++++ .../ShiftClickInputListener.java | 8 ++ 5 files changed, 51 insertions(+), 173 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ClimbPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ShiftCtrlInputListener.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ClimbPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ClimbPlugin.java deleted file mode 100644 index 4bc899a5e4..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ClimbPlugin.java +++ /dev/null @@ -1,111 +0,0 @@ -package net.runelite.client.plugins.climbupclimbdown; - -import javax.inject.Inject; -import javax.inject.Singleton; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.MenuEntry; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.input.KeyManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.PluginType; - -@PluginDescriptor( - name = "Climb Up Climb Down", - description = "Hold Shift to Climb up, Ctrl to Climb down", - tags = {"climb", "stairs", "ladder", "swap", "key", "input"}, - type = PluginType.UTILITY -) -@Slf4j -@Singleton -public class ClimbPlugin extends Plugin -{ - - @Inject - Client client; - - @Inject - KeyManager keyManager; - - @Inject - ShiftCtrlInputListener inputListener; - - @Getter - @Setter - private boolean isHoldingShift; - - @Getter - @Setter - private boolean isHoldingCtrl; - - @Override - protected void startUp() throws Exception - { - enableCustomization(); - } - - @Override - protected void shutDown() throws Exception - { - disableCustomization(); - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) - { - try - { - if (menuEntryAdded.getOption().equalsIgnoreCase("climb")) - { - if (isHoldingCtrl ^ isHoldingShift) - { - if (isHoldingShift) - { - stripExceptFor("climb-up"); - } - if (isHoldingCtrl) - { - stripExceptFor("climb-down"); - } - } - } - } - catch (Exception e) - { - log.error("Uh oh!", e); - } - } - - - private void enableCustomization() - { - keyManager.registerKeyListener(inputListener); - } - - private void disableCustomization() - { - keyManager.unregisterKeyListener(inputListener); - } - - private void stripExceptFor(String option) - { - MenuEntry[] newEntries = new MenuEntry[1]; - - for (MenuEntry entry : client.getMenuEntries()) - { - if (entry.getOption().equalsIgnoreCase(option)) - { - newEntries[0] = entry; - } - } - - if (newEntries[0] != null) - { - client.setMenuEntries(newEntries); - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ShiftCtrlInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ShiftCtrlInputListener.java deleted file mode 100644 index 4535c116ba..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/climbupclimbdown/ShiftCtrlInputListener.java +++ /dev/null @@ -1,62 +0,0 @@ -package net.runelite.client.plugins.climbupclimbdown; - -import java.awt.event.KeyEvent; -import javax.inject.Inject; -import lombok.extern.slf4j.Slf4j; -import net.runelite.client.input.KeyListener; - -@Slf4j -public class ShiftCtrlInputListener implements KeyListener -{ - @Inject - ClimbPlugin plugin; - - @Override - public void keyTyped(KeyEvent e) - { - } - - @Override - public void keyPressed(KeyEvent e) - { - switch (e.getKeyCode()) - { - case KeyEvent.VK_SHIFT: - if (plugin.isHoldingShift()) - { - return; - } - plugin.setHoldingShift(true); - break; - case KeyEvent.VK_CONTROL: - if (plugin.isHoldingCtrl()) - { - return; - } - plugin.setHoldingCtrl(true); - break; - } - } - - @Override - public void keyReleased(KeyEvent e) - { - switch (e.getKeyCode()) - { - case KeyEvent.VK_SHIFT: - if (!plugin.isHoldingShift()) - { - return; - } - plugin.setHoldingShift(false); - break; - case KeyEvent.VK_CONTROL: - if (!plugin.isHoldingCtrl()) - { - return; - } - plugin.setHoldingCtrl(false); - break; - } - } -} 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 fbfe53c822..f1a39f4427 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 @@ -302,4 +302,14 @@ public interface MenuEntrySwapperConfig extends Config { return true; } + + @ConfigItem( + keyName = "swapClimbUpDown", + name = "Climb", + description = "Swap Climb-Up/Down depending on Shift or Control key " + ) + default boolean swapClimbUpDown() + { + return false; + } } 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 0308323471..39f54920f6 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 @@ -128,9 +128,14 @@ public class MenuEntrySwapperPlugin extends Plugin @Getter private boolean configuringShiftClick = false; + @Getter @Setter private boolean shiftModifier = false; + @Getter + @Setter + private boolean controlModifier = false; + @Provides MenuEntrySwapperConfig provideConfig(ConfigManager configManager) { @@ -452,6 +457,16 @@ public class MenuEntrySwapperPlugin extends Plugin } } + else if (option.equalsIgnoreCase("climb") && config.swapClimbUpDown()) { + if (controlModifier ^ shiftModifier) { + if (shiftModifier) { + stripExceptFor("climb-up"); + } + if (controlModifier) { + stripExceptFor("climb-down"); + } + } + } else if (config.swapTravel() && option.equals("pass") && target.equals("energy barrier")) { swap(client, "pay-toll(2-ecto)", option, target, true); @@ -603,6 +618,24 @@ public class MenuEntrySwapperPlugin extends Plugin } } + private void stripExceptFor(String option) + { + MenuEntry[] newEntries = new MenuEntry[1]; + + for (MenuEntry entry : client.getMenuEntries()) + { + if (entry.getOption().equalsIgnoreCase(option)) + { + newEntries[0] = entry; + } + } + + if (newEntries[0] != null) + { + client.setMenuEntries(newEntries); + } + } + @Subscribe public void onPostItemComposition(PostItemComposition event) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java index f7dde77e00..cea447b527 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java @@ -54,6 +54,10 @@ public class ShiftClickInputListener implements KeyListener { plugin.setShiftModifier(true); } + if (event.getKeyCode() == KeyEvent.VK_CONTROL) + { + plugin.setControlModifier(true); + } } @Override @@ -63,5 +67,9 @@ public class ShiftClickInputListener implements KeyListener { plugin.setShiftModifier(false); } + if (event.getKeyCode() == KeyEvent.VK_CONTROL) + { + plugin.setControlModifier(false); + } } } From 7e41f58fa282563dcf5dadde11fad3d2a1352122 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 18 May 2019 22:10:36 +1000 Subject: [PATCH 2/5] Checkstyle fixes --- .../menuentryswapper/MenuEntrySwapperPlugin.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 39f54920f6..e20ead4eeb 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 @@ -457,12 +457,16 @@ public class MenuEntrySwapperPlugin extends Plugin } } - else if (option.equalsIgnoreCase("climb") && config.swapClimbUpDown()) { - if (controlModifier ^ shiftModifier) { - if (shiftModifier) { + else if (option.equalsIgnoreCase("climb") && config.swapClimbUpDown()) + { + if (controlModifier ^ shiftModifier) + { + if (shiftModifier) + { stripExceptFor("climb-up"); } - if (controlModifier) { + if (controlModifier) + { stripExceptFor("climb-down"); } } From d8bb022e4eaacc263c0052e41aefd2c0267f2755 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 18 May 2019 22:26:46 +1000 Subject: [PATCH 3/5] Added copyright text to TickCounter plugin - sourced author from original push request --- .../tickcounter/TickCounterConfig.java | 25 +++++++++++++++++++ .../tickcounter/TickCounterOverlay.java | 25 +++++++++++++++++++ .../tickcounter/TickCounterPlugin.java | 25 +++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterConfig.java index a08f012e7a..ef349f58d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterConfig.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2018, James Munson + * 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 HOLDER 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.tickcounter; import java.awt.Color; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterOverlay.java index 397392ad8c..2a05b06833 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterOverlay.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2018, James Munson + * 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 HOLDER 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.tickcounter; import java.awt.Dimension; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java index fd4a8a935a..11c9d349d6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2018, James Munson + * 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 HOLDER 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.tickcounter; import com.google.inject.Provides; From 63e813b6b89ea613575771e17316a7022ce30949 Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 19 May 2019 18:49:49 +1000 Subject: [PATCH 4/5] no longer strip entire menu, using swap function --- .../MenuEntrySwapperPlugin.java | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) 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 e20ead4eeb..7804079226 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 @@ -463,11 +463,11 @@ public class MenuEntrySwapperPlugin extends Plugin { if (shiftModifier) { - stripExceptFor("climb-up"); + swap(client, "climb-up", option, target, true); } if (controlModifier) { - stripExceptFor("climb-down"); + swap(client, "climb-down", option, target, true); } } } @@ -622,24 +622,6 @@ public class MenuEntrySwapperPlugin extends Plugin } } - private void stripExceptFor(String option) - { - MenuEntry[] newEntries = new MenuEntry[1]; - - for (MenuEntry entry : client.getMenuEntries()) - { - if (entry.getOption().equalsIgnoreCase(option)) - { - newEntries[0] = entry; - } - } - - if (newEntries[0] != null) - { - client.setMenuEntries(newEntries); - } - } - @Subscribe public void onPostItemComposition(PostItemComposition event) { From 041281128a6a45763ccc6bb2833692984ff211d6 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 20 May 2019 17:06:02 +1000 Subject: [PATCH 5/5] removed Getter for modifiers that no longer require it --- .../client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java | 2 -- 1 file changed, 2 deletions(-) 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 7804079226..8cb4c4c2d6 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 @@ -128,11 +128,9 @@ public class MenuEntrySwapperPlugin extends Plugin @Getter private boolean configuringShiftClick = false; - @Getter @Setter private boolean shiftModifier = false; - @Getter @Setter private boolean controlModifier = false;