Add fairy ring plugin
Displays location of fairy ring destination on the fairy ring ui.
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Yoav Ram <https://github.com/yoyo421>
|
||||
* Copyright (c) 2018, Infinitay <https://github.com/Infinitay>
|
||||
* 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.fairyring;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Fairy Ring Helper"
|
||||
)
|
||||
public class FairyRingPlugin extends Plugin
|
||||
{
|
||||
private static final String[] leftDial = new String[]{"A", "D", "C", "B"};
|
||||
private static final String[] middleDial = new String[]{"I", "L", "K", "J"};
|
||||
private static final String[] rightDial = new String[]{"P", "S", "R", "Q"};
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Subscribe
|
||||
public void onVarbitChanged(VarbitChanged event)
|
||||
{
|
||||
setWidgetTextToDestination();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onWidgetLoaded(WidgetLoaded widgetLoaded)
|
||||
{
|
||||
if (widgetLoaded.getGroupId() == WidgetID.FAIRY_RING_CODE_GROUP_ID)
|
||||
{
|
||||
setWidgetTextToDestination();
|
||||
}
|
||||
}
|
||||
|
||||
private void setWidgetTextToDestination()
|
||||
{
|
||||
Widget fairyRingTeleportButton = client.getWidget(WidgetInfo.FAIRY_RING_TELEPORT_BUTTON);
|
||||
if (fairyRingTeleportButton != null && !fairyRingTeleportButton.isHidden())
|
||||
{
|
||||
String destination;
|
||||
try
|
||||
{
|
||||
FairyRings fairyRingDestination = getFairyRingDestination(client.getSetting(Varbits.FAIRY_RING_DIAL_ADCB),
|
||||
client.getSetting(Varbits.FAIRY_RIGH_DIAL_ILJK), client.getSetting(Varbits.FAIRY_RING_DIAL_PSRQ));
|
||||
destination = fairyRingDestination.getDestination();
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
destination = "Invalid location";
|
||||
}
|
||||
|
||||
fairyRingTeleportButton.setText(destination);
|
||||
}
|
||||
}
|
||||
|
||||
private FairyRings getFairyRingDestination(int varbitValueDialLeft, int varbitValueDialMiddle, int varbitValueDialRight)
|
||||
{
|
||||
return FairyRings.valueOf(leftDial[varbitValueDialLeft] + middleDial[varbitValueDialMiddle] + rightDial[varbitValueDialRight]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Yoav Ram <https://github.com/yoyo421>
|
||||
* Copyright (c) 2018, Infinitay <https://github.com/Infinitay>
|
||||
* 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.fairyring;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum FairyRings
|
||||
{
|
||||
// A
|
||||
AIQ("Mudskipper Point"),
|
||||
AIR("(Island) South-east of Ardougne"),
|
||||
AJQ("Cave south of Dorgesh-Kaan"),
|
||||
AJR("Slayer cave"),
|
||||
AJS("Penguins near Miscellania"),
|
||||
AKQ("Piscatoris Hunter area"),
|
||||
AKS("Feldip Hunter area"),
|
||||
ALP("(Island) Lighthouse"),
|
||||
ALQ("Haunted Woods east of Canifis"),
|
||||
ALR("Abyssal Area"),
|
||||
ALS("McGrubor's Wood"),
|
||||
|
||||
// B
|
||||
BIP("(Island) South-west of Mort Myre"),
|
||||
BIQ("Kalphite Hive"),
|
||||
BIS("Ardougne Zoo - Unicorns"),
|
||||
BJR("Realm of the Fisher King"),
|
||||
BJS("(Island) Near Zul-Andra"),
|
||||
BKP("South of Castle Wars"),
|
||||
BKQ("Enchanted Valley"),
|
||||
BKR("Mort Myre Swamp, south of Canifis"),
|
||||
BKS("Zanaris"),
|
||||
BLP("TzHaar area"),
|
||||
BLR("Legends' Guild"),
|
||||
|
||||
// C
|
||||
CIP("(Island) Miscellania"),
|
||||
CIQ("North-west of Yanille"),
|
||||
CIS("North of the Arceuus House Library"),
|
||||
CJR("Sinclair Mansion (east)"),
|
||||
CKP("Cosmic entity's plane"),
|
||||
CKR("South of Tai Bwo Wannai Village"),
|
||||
CKS("Canifis"),
|
||||
CLP("(Island) South of Draynor Village"),
|
||||
CLR("(Island) Ape Atoll"),
|
||||
CLS("(Island) Hazelmere's home"),
|
||||
|
||||
// D
|
||||
DIP("(Sire Boss) Abyssal Nexus"),
|
||||
DIR("Gorak's Plane"),
|
||||
DIQ("Player-owned house"),
|
||||
DIS("Wizards' Tower"),
|
||||
DJP("Tower of Life"),
|
||||
DJR("Chasm of Fire"),
|
||||
DKP("South of Musa Point"),
|
||||
DKR("Edgeville, Grand Exchange"),
|
||||
DKS("Polar Hunter area"),
|
||||
DLQ("North of Nardah"),
|
||||
DLR("(Island) Poison Waste south of Isafdar"),
|
||||
DLS("Myreque hideout under The Hollows");
|
||||
|
||||
@Getter
|
||||
private final String destination;
|
||||
}
|
||||
Reference in New Issue
Block a user