Merge pull request #341 from deathbeam/superantifire-timer

Add support for super antifire potion and antidote++ potion
This commit is contained in:
Adam
2018-01-09 07:49:34 -05:00
committed by GitHub
5 changed files with 72 additions and 2 deletions

View File

@@ -44,7 +44,9 @@ public enum GameTimer
MAGICIMBUE("magicimbue", 15, ChronoUnit.SECONDS), MAGICIMBUE("magicimbue", 15, ChronoUnit.SECONDS),
FULLTB("teleblock", 5, ChronoUnit.MINUTES), FULLTB("teleblock", 5, ChronoUnit.MINUTES),
HALFTB("teleblock", 150, ChronoUnit.SECONDS), HALFTB("teleblock", 150, ChronoUnit.SECONDS),
SUPERANTIVENOM("antivenom", 3, ChronoUnit.MINUTES); SUPERANTIVENOM("antivenom", 3, ChronoUnit.MINUTES),
SUPERANTIFIRE("superantifire", 2, ChronoUnit.MINUTES),
ANTIDOTEPLUSPLUS("antidoteplusplus", 12, ChronoUnit.MINUTES);
private final String imageResource; private final String imageResource;
private final Duration duration; private final Duration duration;

View File

@@ -124,4 +124,24 @@ public interface TimersConfig extends Config
{ {
return true; return true;
} }
@ConfigItem(
keyName = "showSuperAntiFire",
name = "Super Antifire timer",
description = "Configures whether super antifire timer is displayed"
)
default boolean showSuperAntiFire()
{
return true;
}
@ConfigItem(
keyName = "showAntidotePlusPlus",
name = "Antidote++ timer",
description = "Configures whether antidote++ timer is displayed"
)
default boolean showAntidotePlusPlus()
{
return true;
}
} }

View File

@@ -24,16 +24,28 @@
*/ */
package net.runelite.client.plugins.timers; package net.runelite.client.plugins.timers;
import static net.runelite.client.plugins.timers.GameTimer.ANTIDOTEPLUSPLUS;
import static net.runelite.client.plugins.timers.GameTimer.ANTIFIRE;
import static net.runelite.client.plugins.timers.GameTimer.CANNON;
import static net.runelite.client.plugins.timers.GameTimer.EXANTIFIRE;
import static net.runelite.client.plugins.timers.GameTimer.FULLTB;
import static net.runelite.client.plugins.timers.GameTimer.HALFTB;
import static net.runelite.client.plugins.timers.GameTimer.MAGICIMBUE;
import static net.runelite.client.plugins.timers.GameTimer.OVERLOAD;
import static net.runelite.client.plugins.timers.GameTimer.STAMINA;
import static net.runelite.client.plugins.timers.GameTimer.SUPERANTIFIRE;
import static net.runelite.client.plugins.timers.GameTimer.SUPERANTIVENOM;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides; import com.google.inject.Provides;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.ItemID;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.events.ChatMessage; import net.runelite.client.events.ChatMessage;
import net.runelite.client.events.ConfigChanged; import net.runelite.client.events.ConfigChanged;
import net.runelite.client.events.MenuOptionClicked;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import static net.runelite.client.plugins.timers.GameTimer.*;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
@PluginDescriptor( @PluginDescriptor(
@@ -90,11 +102,37 @@ public class TimersPlugin extends Plugin
{ {
removeGameTimer(SUPERANTIVENOM); removeGameTimer(SUPERANTIVENOM);
} }
if (!config.showTeleblock()) if (!config.showTeleblock())
{ {
removeGameTimer(FULLTB); removeGameTimer(FULLTB);
removeGameTimer(HALFTB); removeGameTimer(HALFTB);
} }
if (!config.showSuperAntiFire())
{
removeGameTimer(SUPERANTIFIRE);
}
if (!config.showAntidotePlusPlus())
{
removeGameTimer(ANTIDOTEPLUSPLUS);
}
}
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event)
{
if (config.showAntidotePlusPlus()
&& event.getMenuOption().contains("Drink")
&& (event.getId() == ItemID.ANTIDOTE1_5958
|| event.getId() == ItemID.ANTIDOTE2_5956
|| event.getId() == ItemID.ANTIDOTE3_5954
|| event.getId() == ItemID.ANTIDOTE4_5952))
{
// Needs menu option hook because drink message is intercepting with antipoison message
createGameTimer(ANTIDOTEPLUSPLUS);
}
} }
@Subscribe @Subscribe
@@ -171,6 +209,16 @@ public class TimersPlugin extends Plugin
{ {
createGameTimer(HALFTB); createGameTimer(HALFTB);
} }
if (event.getMessage().contains("You drink some of your super antifire potion") && config.showSuperAntiFire())
{
createGameTimer(SUPERANTIFIRE);
}
if (event.getMessage().equals("<col=7f007f>Your super antifire potion has expired.</col>") && config.showSuperAntiFire())
{
removeGameTimer(SUPERANTIFIRE);
}
} }
public void createGameTimer(GameTimer timer) public void createGameTimer(GameTimer timer)

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B