Merge pull request #295 from SRLJustin/master
Moved Climb-Up/Down plugin into MenuEntrySwapper
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -302,4 +302,14 @@ public interface MenuEntrySwapperConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "swapClimbUpDown",
|
||||||
|
name = "Climb",
|
||||||
|
description = "Swap Climb-Up/Down depending on Shift or Control key "
|
||||||
|
)
|
||||||
|
default boolean swapClimbUpDown()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean shiftModifier = false;
|
private boolean shiftModifier = false;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private boolean controlModifier = false;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
MenuEntrySwapperConfig provideConfig(ConfigManager configManager)
|
MenuEntrySwapperConfig provideConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -452,6 +455,20 @@ public class MenuEntrySwapperPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (option.equalsIgnoreCase("climb") && config.swapClimbUpDown())
|
||||||
|
{
|
||||||
|
if (controlModifier ^ shiftModifier)
|
||||||
|
{
|
||||||
|
if (shiftModifier)
|
||||||
|
{
|
||||||
|
swap(client, "climb-up", option, target, true);
|
||||||
|
}
|
||||||
|
if (controlModifier)
|
||||||
|
{
|
||||||
|
swap(client, "climb-down", option, target, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (config.swapTravel() && option.equals("pass") && target.equals("energy barrier"))
|
else if (config.swapTravel() && option.equals("pass") && target.equals("energy barrier"))
|
||||||
{
|
{
|
||||||
swap(client, "pay-toll(2-ecto)", option, target, true);
|
swap(client, "pay-toll(2-ecto)", option, target, true);
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ public class ShiftClickInputListener implements KeyListener
|
|||||||
{
|
{
|
||||||
plugin.setShiftModifier(true);
|
plugin.setShiftModifier(true);
|
||||||
}
|
}
|
||||||
|
if (event.getKeyCode() == KeyEvent.VK_CONTROL)
|
||||||
|
{
|
||||||
|
plugin.setControlModifier(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,5 +67,9 @@ public class ShiftClickInputListener implements KeyListener
|
|||||||
{
|
{
|
||||||
plugin.setShiftModifier(false);
|
plugin.setShiftModifier(false);
|
||||||
}
|
}
|
||||||
|
if (event.getKeyCode() == KeyEvent.VK_CONTROL)
|
||||||
|
{
|
||||||
|
plugin.setControlModifier(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, James Munson <https://github.com/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;
|
package net.runelite.client.plugins.tickcounter;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, James Munson <https://github.com/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;
|
package net.runelite.client.plugins.tickcounter;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, James Munson <https://github.com/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;
|
package net.runelite.client.plugins.tickcounter;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|||||||
Reference in New Issue
Block a user