runelite-client: add xp drop plugin which colors based on prayers

This commit is contained in:
Adam
2018-01-27 20:05:55 -05:00
parent ff1c56812a
commit 07d57f0c72
5 changed files with 286 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ public class WidgetID
public static final int CLUE_SCROLL_REWARD_GROUP_ID = 73;
public static final int BARROWS_REWARD_GROUP_ID = 155;
public static final int MOTHERLODE_MINE_GROUP_ID = 382;
public static final int EXPERIENCE_DROP_GROUP_ID = 122;
static class WorldMap
{
@@ -265,4 +266,15 @@ public class WidgetID
{
static final int NAME_TEXT = 2;
}
static class ExperienceDrop
{
static final int DROP_1 = 15;
static final int DROP_2 = 16;
static final int DROP_3 = 17;
static final int DROP_4 = 18;
static final int DROP_5 = 19;
static final int DROP_6 = 20;
static final int DROP_7 = 21;
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2018, Cameron <https://github.com/noremac201>
* 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.experiencedrop;
import java.awt.Color;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup(
keyName = "xpdrop",
name = "Experience Drop",
description = "Configuration for experience drops customization"
)
public interface ExperienceDropConfig extends Config
{
@ConfigItem(
keyName = "enabled",
name = "Enabled",
description = "Configures whether or not plugin is enabled."
)
default boolean enabled()
{
return true;
}
@ConfigItem(
keyName = "meleePrayerColor",
name = "Melee Prayer Color",
description = "Xp Drop color when a melee prayer is active"
)
default Color getMeleePrayerColor()
{
return new Color(0x15, 0x80, 0xAD);
}
@ConfigItem(
keyName = "rangePrayerColor",
name = "Range Prayer Color",
description = "Xp Drop color when a range prayer is active"
)
default Color getRangePrayerColor()
{
return new Color(0x15, 0x80, 0xAD);
}
@ConfigItem(
keyName = "magePrayerColor",
name = "Mage Prayer Color",
description = "Xp Drop color when a mage prayer is active"
)
default Color getMagePrayerColor()
{
return new Color(0x15, 0x80, 0xAD);
}
}

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2018, Cameron <https://github.com/noremac201>
* 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.experiencedrop;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.events.WidgetHiddenChanged;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@PluginDescriptor(
name = "Experience drop plugin"
)
public class ExperienceDropPlugin extends Plugin
{
@Inject
Client client;
@Inject
ExperienceDropConfig config;
@Provides
ExperienceDropConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(ExperienceDropConfig.class);
}
@Subscribe
public void onWidgetHidden(WidgetHiddenChanged event)
{
Widget widget = event.getWidget();
int group = WidgetInfo.TO_GROUP(widget.getId());
if (group != WidgetID.EXPERIENCE_DROP_GROUP_ID)
{
return;
}
PrayerType prayer = getActivePrayerType();
if (!config.enabled() || widget.isHidden() || prayer == null)
{
return;
}
String text = widget.getText();
if (text != null)
{
switch (prayer)
{
case MELEE:
widget.setTextColor(config.getMeleePrayerColor().getRGB());
break;
case RANGE:
widget.setTextColor(config.getRangePrayerColor().getRGB());
break;
case MAGIC:
widget.setTextColor(config.getMagePrayerColor().getRGB());
break;
}
}
}
private PrayerType getActivePrayerType()
{
for (XpPrayer prayer : XpPrayer.values())
{
if (client.isPrayerActive(prayer.getPrayer()))
{
return prayer.getType();
}
}
return null;
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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.experiencedrop;
enum PrayerType
{
MELEE,
RANGE,
MAGIC;
}

View File

@@ -0,0 +1,61 @@
/*
* 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.experiencedrop;
import lombok.Getter;
import net.runelite.api.Prayer;
import static net.runelite.api.Prayer.*;
import static net.runelite.client.plugins.experiencedrop.PrayerType.MAGIC;
import static net.runelite.client.plugins.experiencedrop.PrayerType.MELEE;
import static net.runelite.client.plugins.experiencedrop.PrayerType.RANGE;
enum XpPrayer
{
XP_BURST_OF_STRENGTH(BURST_OF_STRENGTH, MELEE),
XP_CLARITY_OF_THOUGHT(CLARITY_OF_THOUGHT, MELEE),
XP_SHARP_EYE(SHARP_EYE, RANGE),
XP_MYSTIC_WILL(MYSTIC_WILL, MAGIC),
XP_SUPERHUMAN_STRENGTH(SUPERHUMAN_STRENGTH, MELEE),
XP_IMPROVED_REFLEXES(IMPROVED_REFLEXES, MELEE),
XP_HAWK_EYE(HAWK_EYE, RANGE),
XP_MYSTIC_LORE(MYSTIC_LORE, MAGIC),
XP_ULTIMATE_STRENGTH(ULTIMATE_STRENGTH, MELEE),
XP_INCREDIBLE_REFLEXES(INCREDIBLE_REFLEXES, MELEE),
XP_EAGLE_EYE(EAGLE_EYE, RANGE),
XP_MYSTIC_MIGHT(MYSTIC_MIGHT, MAGIC),
XP_CHIVALRY(CHIVALRY, MELEE),
XP_PIETY(PIETY, MELEE);
@Getter
private final Prayer prayer;
@Getter
private final PrayerType type;
XpPrayer(Prayer prayer, PrayerType type)
{
this.prayer = prayer;
this.type = type;
}
}