Add agility arena timer
Add a timer infobox to show how long until the next ticket location change
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Alex Kolpa <akolpa1990@gmail.com>
|
||||
* 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.agility;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.imageio.ImageIO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.infobox.Timer;
|
||||
|
||||
@Slf4j
|
||||
public class AgilityArenaTimer extends Timer
|
||||
{
|
||||
public AgilityArenaTimer(Plugin plugin)
|
||||
{
|
||||
super(1, ChronoUnit.MINUTES, getTicketImage(), plugin);
|
||||
setTooltip("Time left until location changes");
|
||||
}
|
||||
|
||||
private static BufferedImage image;
|
||||
private static BufferedImage getTicketImage()
|
||||
{
|
||||
if (image != null)
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
image = ImageIO.read(AgilityArenaTimer.class.getResourceAsStream( "agilityarenaticket.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("unable to load image", ex);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@@ -134,4 +134,15 @@ public interface AgilityConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "agilityArenaTimer",
|
||||
name = "Agility Arena timer",
|
||||
description = "Configures whether Agility Arena timer is displayed",
|
||||
position = 10
|
||||
)
|
||||
default boolean showAgilityArenaTimer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import static net.runelite.api.Skill.AGILITY;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.TileObject;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.DecorativeObjectChanged;
|
||||
import net.runelite.api.events.DecorativeObjectDespawned;
|
||||
import net.runelite.api.events.DecorativeObjectSpawned;
|
||||
@@ -64,6 +65,7 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Agility"
|
||||
@@ -92,6 +94,9 @@ public class AgilityPlugin extends Plugin
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private InfoBoxManager infoBoxManager;
|
||||
|
||||
@Inject
|
||||
private AgilityConfig config;
|
||||
|
||||
@@ -130,6 +135,7 @@ public class AgilityPlugin extends Plugin
|
||||
case LOGIN_SCREEN:
|
||||
session = null;
|
||||
lastArenaTicketPosition = null;
|
||||
removeAgilityArenaTimer();
|
||||
break;
|
||||
case LOADING:
|
||||
markOfGrace = null;
|
||||
@@ -139,11 +145,21 @@ public class AgilityPlugin extends Plugin
|
||||
if (!isInAgilityArena())
|
||||
{
|
||||
lastArenaTicketPosition = null;
|
||||
removeAgilityArenaTimer();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (!config.showAgilityArenaTimer())
|
||||
{
|
||||
removeAgilityArenaTimer();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onExperienceChanged(ExperienceChanged event)
|
||||
{
|
||||
@@ -230,9 +246,17 @@ public class AgilityPlugin extends Plugin
|
||||
if (!Objects.equals(lastArenaTicketPosition, newTicketPosition))
|
||||
{
|
||||
// We don't want to notify when players first enter the course
|
||||
if (lastArenaTicketPosition != null && config.notifyAgilityArena())
|
||||
if (lastArenaTicketPosition != null)
|
||||
{
|
||||
notifier.notify("Ticket location changed");
|
||||
if (config.notifyAgilityArena())
|
||||
{
|
||||
notifier.notify("Ticket location changed");
|
||||
}
|
||||
|
||||
if (config.showAgilityArenaTimer())
|
||||
{
|
||||
showNewAgilityArenaTimer();
|
||||
}
|
||||
}
|
||||
|
||||
lastArenaTicketPosition = newTicketPosition;
|
||||
@@ -245,6 +269,17 @@ public class AgilityPlugin extends Plugin
|
||||
return AGILITY_ARENA_REGION_ID == client.getLocalPlayer().getWorldLocation().getRegionID();
|
||||
}
|
||||
|
||||
private void removeAgilityArenaTimer()
|
||||
{
|
||||
infoBoxManager.removeIf(infoBox -> infoBox instanceof AgilityArenaTimer);
|
||||
}
|
||||
|
||||
private void showNewAgilityArenaTimer()
|
||||
{
|
||||
removeAgilityArenaTimer();
|
||||
infoBoxManager.addInfoBox(new AgilityArenaTimer(this));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectSpawned(GameObjectSpawned event)
|
||||
{
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 742 B |
Reference in New Issue
Block a user