freezetimers: remove
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* 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.freezetimers;
|
||||
|
||||
import java.awt.Font;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@AllArgsConstructor
|
||||
public enum FontStyle
|
||||
{
|
||||
BOLD("Bold", Font.BOLD),
|
||||
ITALIC("Italic", Font.ITALIC),
|
||||
PLAIN("Plain", Font.PLAIN);
|
||||
|
||||
private String name;
|
||||
private int font;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* Copyright (c) 2019, pklite <https://github.com/pklite/pklite>
|
||||
* 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.freezetimers;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.ConfigTitleSection;
|
||||
import net.runelite.client.config.Range;
|
||||
import net.runelite.client.config.Title;
|
||||
import net.runelite.client.config.Units;
|
||||
|
||||
@ConfigGroup("freezetimers")
|
||||
public interface FreezeTimersConfig extends Config
|
||||
{
|
||||
@ConfigTitleSection(
|
||||
keyName = "timersTitle",
|
||||
name = "Timers",
|
||||
description = "",
|
||||
position = 1
|
||||
)
|
||||
default Title timersTitle()
|
||||
{
|
||||
return new Title();
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showOverlay",
|
||||
name = "Show Players",
|
||||
description = "Configure if the player overlay should be shown",
|
||||
position = 2,
|
||||
titleSection = "timersTitle"
|
||||
)
|
||||
default boolean showPlayers()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showNpcs",
|
||||
name = "Show NPCs",
|
||||
description = "Configure if the npc overlay should be shown",
|
||||
position = 3,
|
||||
titleSection = "timersTitle"
|
||||
)
|
||||
default boolean showNpcs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "FreezeTimers",
|
||||
name = "Show Freeze Timers",
|
||||
description = "Toggle overlay for Freeze timers",
|
||||
position = 4,
|
||||
titleSection = "timersTitle"
|
||||
)
|
||||
default boolean FreezeTimers()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "TB",
|
||||
name = "Show TB Timers",
|
||||
description = "Toggle overlay for TB timers",
|
||||
position = 5,
|
||||
titleSection = "timersTitle"
|
||||
)
|
||||
default boolean TB()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "Veng",
|
||||
name = "Show Veng Timers",
|
||||
description = "Toggle overlay for Veng timers",
|
||||
position = 6,
|
||||
titleSection = "timersTitle"
|
||||
)
|
||||
default boolean Veng()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigTitleSection(
|
||||
keyName = "overlayTitle",
|
||||
name = "Overlay",
|
||||
description = "",
|
||||
position = 7
|
||||
)
|
||||
default Title overlayTitle()
|
||||
{
|
||||
return new Title();
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "xoffset",
|
||||
name = "X Offset",
|
||||
description = "Increasing this will push further away from model. Does not apply to text timers.",
|
||||
position = 8,
|
||||
titleSection = "overlayTitle"
|
||||
)
|
||||
@Units(Units.PIXELS)
|
||||
default int offset()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "noImage",
|
||||
name = "Text Timers",
|
||||
description = "Remove Images from Timers",
|
||||
position = 9,
|
||||
titleSection = "overlayTitle"
|
||||
)
|
||||
default boolean noImage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "fontStyle",
|
||||
name = "Font Style",
|
||||
description = "Bold/Italics/Plain",
|
||||
position = 10,
|
||||
titleSection = "overlayTitle"
|
||||
)
|
||||
default FontStyle fontStyle()
|
||||
{
|
||||
return FontStyle.BOLD;
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 9,
|
||||
max = 14
|
||||
)
|
||||
@ConfigItem(
|
||||
keyName = "textSize",
|
||||
name = "Text Size",
|
||||
description = "Text Size for Timers.",
|
||||
position = 11,
|
||||
titleSection = "overlayTitle"
|
||||
)
|
||||
@Units(Units.POINTS)
|
||||
default int textSize()
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
}
|
||||
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* Copyright (c) 2019, kyle <https://github.com/kyleeld>
|
||||
* Copyright (c) 2019, pklite <https://github.com/pklite/pklite>
|
||||
* 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.freezetimers;
|
||||
|
||||
import java.awt.Color;
|
||||
import static java.awt.Color.WHITE;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@Singleton
|
||||
public class FreezeTimersOverlay extends Overlay
|
||||
{
|
||||
private final FreezeTimersPlugin plugin;
|
||||
private final Client client;
|
||||
private final Font timerFont = FontManager.getRunescapeBoldFont().deriveFont(14.0f);
|
||||
private final BufferedImage FREEZE_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "freeze.png");
|
||||
private final BufferedImage FREEZE_IMMUNE_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "freezeimmune.png");
|
||||
private final BufferedImage TB_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "teleblock.png");
|
||||
private final BufferedImage TB_IMMUNE_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "teleblockimmune.png");
|
||||
private final BufferedImage VENG_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "veng.png");
|
||||
private final Timers timers;
|
||||
|
||||
|
||||
@Inject
|
||||
public FreezeTimersOverlay(final FreezeTimersPlugin plugin, final Client client, final Timers timers)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.client = client;
|
||||
this.timers = timers;
|
||||
setPriority(OverlayPriority.HIGHEST);
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setLayer(OverlayLayer.UNDER_WIDGETS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (plugin.isShowPlayers())
|
||||
{
|
||||
client.getPlayers().forEach((p) -> renderOverlayFor(graphics, p));
|
||||
}
|
||||
if (plugin.isShowNpcs())
|
||||
{
|
||||
client.getNpcs().forEach((npc) -> renderOverlayFor(graphics, npc));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderOverlayFor(Graphics2D g, Actor actor)
|
||||
{
|
||||
if (timers.areAllTimersZero(actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int overlaysDrawn = 0;
|
||||
|
||||
if (drawFreezeOverlay(g, actor, overlaysDrawn) && plugin.isFreezeTimers())
|
||||
{
|
||||
overlaysDrawn++;
|
||||
}
|
||||
if (drawTBOverlay(g, actor, overlaysDrawn) && plugin.isTB())
|
||||
{
|
||||
overlaysDrawn++;
|
||||
}
|
||||
if (drawVengOverlay(g, actor, overlaysDrawn) && plugin.isVeng())
|
||||
{
|
||||
overlaysDrawn++;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean drawFreezeOverlay(Graphics2D g, Actor actor, int overlaysDrawn)
|
||||
{
|
||||
final long currentTick = System.currentTimeMillis();
|
||||
if (timers.getTimerReApply(actor, TimerType.FREEZE) <= currentTick)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long finishedAt;
|
||||
BufferedImage image;
|
||||
if (timers.getTimerEnd(actor, TimerType.FREEZE) > currentTick)
|
||||
{
|
||||
finishedAt = timers.getTimerEnd(actor, TimerType.FREEZE);
|
||||
image = FREEZE_IMAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
finishedAt = timers.getTimerReApply(actor, TimerType.FREEZE);
|
||||
image = FREEZE_IMMUNE_IMAGE;
|
||||
}
|
||||
|
||||
final String text = processTickCounter(finishedAt);
|
||||
final Point poi = actor.getCanvasTextLocation(g, text, 0);
|
||||
|
||||
if (poi == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Point fixedPoint = new Point(poi.getX(), poi.getY());
|
||||
|
||||
if (plugin.isNoImage())
|
||||
{
|
||||
if (image == FREEZE_IMAGE)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.WHITE, fixedPoint, false, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.YELLOW, fixedPoint, false, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderActorText(g, actor, text, overlaysDrawn, image);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean drawTBOverlay(Graphics2D g, Actor actor, int overlaysDrawn)
|
||||
{
|
||||
final long currentTick = System.currentTimeMillis();
|
||||
if (!plugin.isTB())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (timers.getTimerReApply(actor, TimerType.TELEBLOCK) <= currentTick)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long finishedAt;
|
||||
BufferedImage image;
|
||||
if (timers.getTimerEnd(actor, TimerType.TELEBLOCK) > currentTick)
|
||||
{
|
||||
finishedAt = timers.getTimerEnd(actor, TimerType.TELEBLOCK);
|
||||
image = TB_IMAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
finishedAt = timers.getTimerReApply(actor, TimerType.TELEBLOCK);
|
||||
image = TB_IMMUNE_IMAGE;
|
||||
}
|
||||
|
||||
final String text = processTickCounter(finishedAt);
|
||||
final Point poi = actor.getCanvasTextLocation(g, text, 0);
|
||||
|
||||
if (poi == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Point fixedPoint = new Point(poi.getX() + 20, poi.getY());
|
||||
|
||||
if (plugin.isNoImage())
|
||||
{
|
||||
if (timers.getTimerReApply(actor, TimerType.FREEZE) <= currentTick)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.CYAN, poi, false, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, " | " + text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.CYAN, fixedPoint, false, 0);
|
||||
}
|
||||
|
||||
if (timers.getTimerReApply(actor, TimerType.VENG) >= currentTick)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, " | " + text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.CYAN, fixedPoint, false, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderActorText(g, actor, text, overlaysDrawn, image);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean drawVengOverlay(Graphics2D g, Actor actor, int overlaysDrawn)
|
||||
{
|
||||
final long currentTick = System.currentTimeMillis();
|
||||
if (!plugin.isVeng())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (timers.getTimerEnd(actor, TimerType.VENG) <= currentTick)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final long finishedAt = timers.getTimerEnd(actor, TimerType.VENG);
|
||||
|
||||
final String text = processTickCounter(finishedAt);
|
||||
final Point poi = actor.getCanvasTextLocation(g, text, 0);
|
||||
|
||||
if (poi == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Point fixedPoint = new Point(poi.getX() - 20, poi.getY());
|
||||
if (plugin.isNoImage())
|
||||
{
|
||||
if (timers.getTimerEnd(actor, TimerType.FREEZE) <= currentTick)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.RED, poi, false, 0);
|
||||
}
|
||||
if (timers.getTimerEnd(actor, TimerType.FREEZE) >= currentTick)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, text + " | ", plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.RED, fixedPoint, false, 0);
|
||||
}
|
||||
if (timers.getTimerEnd(actor, TimerType.TELEBLOCK) >= currentTick)
|
||||
{
|
||||
OverlayUtil.renderTextLocation(g, text + " | ", plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.RED, fixedPoint, false, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderActorText(g, actor, text, overlaysDrawn, VENG_IMAGE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void renderActorText(Graphics2D g, Actor actor, String text, int overlaysDrawn, BufferedImage image)
|
||||
{
|
||||
final int yOffset = (overlaysDrawn * 18);
|
||||
g.setFont(timerFont);
|
||||
g.setColor(WHITE);
|
||||
final int xOffset = plugin.getOffset();
|
||||
renderActorTextAndImage(g, actor, text, Color.WHITE, image, yOffset,
|
||||
xOffset);
|
||||
}
|
||||
|
||||
private void renderImageLocation(Graphics2D graphics, Point imgLoc, BufferedImage image)
|
||||
{
|
||||
final int x = imgLoc.getX();
|
||||
final int y = imgLoc.getY();
|
||||
|
||||
graphics.drawImage(image, x, y, null);
|
||||
}
|
||||
|
||||
private void renderActorTextAndImage(Graphics2D graphics, Actor actor, String text, Color color, BufferedImage image, int yOffset, int xOffset)
|
||||
{
|
||||
Point textLocation = new Point(actor.getCanvasImageLocation(image, 0).getX() + xOffset, actor.getCanvasImageLocation(image, 0).getY() + yOffset);
|
||||
renderImageLocation(graphics, textLocation, image);
|
||||
xOffset = image.getWidth() + 1;
|
||||
yOffset = (image.getHeight() - (int) graphics.getFontMetrics().getStringBounds(text, graphics).getHeight());
|
||||
textLocation = new Point(textLocation.getX() + xOffset, textLocation.getY() + image.getHeight() - yOffset);
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, text, color);
|
||||
}
|
||||
|
||||
private String processTickCounter(long finishedAt)
|
||||
{
|
||||
final long currentTick = System.currentTimeMillis();
|
||||
final long tickDifference = finishedAt - currentTick;
|
||||
long seconds = tickDifference / 1000;
|
||||
seconds++;
|
||||
final int minutes = (int) (seconds / 60);
|
||||
seconds = seconds % 60;
|
||||
String text = seconds > 9 ? seconds + "" : "0" + seconds;
|
||||
if (minutes > 0)
|
||||
{
|
||||
text = minutes + ":" + text;
|
||||
}
|
||||
return text + "";
|
||||
}
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* Copyright (c) 2019, pklite <https://github.com/pklite/pklite>
|
||||
* 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.freezetimers;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.PlayerDeath;
|
||||
import net.runelite.api.events.SpotAnimationChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.plugins.multiindicators.MapLocations;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.PvPUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Freeze Timers",
|
||||
description = "Shows a freeze timer overlay on players",
|
||||
tags = {"freeze", "timers", "barrage", "teleblock", "pklite"},
|
||||
type = PluginType.PVP,
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Singleton
|
||||
public class FreezeTimersPlugin extends Plugin
|
||||
{
|
||||
private static final int VORKATH_REGION = 9023;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private Timers timers;
|
||||
|
||||
@Inject
|
||||
private PrayerTracker prayerTracker;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersOverlay overlay;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersConfig config;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean showPlayers;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean showNpcs;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean FreezeTimers;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean TB;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean Veng;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int offset;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean noImage;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private FontStyle fontStyle;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int textSize;
|
||||
|
||||
public void startUp()
|
||||
{
|
||||
updateConfig();
|
||||
|
||||
overlayManager.add(overlay);
|
||||
}
|
||||
|
||||
public void shutDown()
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
}
|
||||
|
||||
@Provides
|
||||
public FreezeTimersConfig getConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(FreezeTimersConfig.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onSpotAnimationChanged(SpotAnimationChanged graphicChanged)
|
||||
{
|
||||
final int oldGraphic = prayerTracker.getSpotanimLastTick(graphicChanged.getActor());
|
||||
final int newGraphic = graphicChanged.getActor().getSpotAnimation();
|
||||
|
||||
if (oldGraphic == newGraphic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final PlayerSpellEffect effect = PlayerSpellEffect.getFromSpotAnim(newGraphic);
|
||||
|
||||
if (effect == PlayerSpellEffect.NONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
|
||||
if (timers.getTimerReApply(graphicChanged.getActor(), effect.getType()) > currentTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long length = effect.getTimerLengthTicks();
|
||||
|
||||
if (effect.isHalvable() && prayerTracker.getPrayerIconLastTick(graphicChanged.getActor()) == 2)
|
||||
{
|
||||
length /= 2;
|
||||
}
|
||||
|
||||
timers.setTimerEnd(graphicChanged.getActor(), effect.getType(),
|
||||
currentTime + length);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick tickEvent)
|
||||
{
|
||||
prayerTracker.gameTick();
|
||||
|
||||
for (Actor actor : client.getPlayers())
|
||||
{
|
||||
if (prayerTracker.getSpotanimLastTick(actor) != actor.getSpotAnimation())
|
||||
{
|
||||
SpotAnimationChanged callback = new SpotAnimationChanged();
|
||||
callback.setActor(actor);
|
||||
client.getCallbacks().post(SpotAnimationChanged.class, callback);
|
||||
}
|
||||
}
|
||||
|
||||
List<Actor> teleblocked = timers.getAllActorsOnTimer(TimerType.TELEBLOCK);
|
||||
|
||||
if (!teleblocked.isEmpty())
|
||||
{
|
||||
final EnumSet<WorldType> worldTypes = client.getWorldType();
|
||||
|
||||
for (Actor actor : teleblocked)
|
||||
{
|
||||
final WorldPoint actorLoc = actor.getWorldLocation();
|
||||
|
||||
if (!WorldType.isAllPvpWorld(worldTypes) && (actorLoc.getY() < 3525 || PvPUtil.getWildernessLevelFrom(actorLoc) <= 0))
|
||||
{
|
||||
timers.setTimerReApply(actor, TimerType.TELEBLOCK, System.currentTimeMillis());
|
||||
}
|
||||
else if (WorldType.isPvpWorld(worldTypes) &&
|
||||
MapLocations.getPvpSafeZones(actorLoc.getPlane()).contains(actorLoc.getX(), actorLoc.getY()))
|
||||
{
|
||||
timers.setTimerReApply(actor, TimerType.TELEBLOCK, System.currentTimeMillis());
|
||||
}
|
||||
else if (WorldType.isDeadmanWorld(worldTypes) &&
|
||||
MapLocations.getDeadmanSafeZones(actorLoc.getPlane()).contains(actorLoc.getX(), actorLoc.getY()))
|
||||
{
|
||||
timers.setTimerReApply(actor, TimerType.TELEBLOCK, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onPlayerDeath(PlayerDeath event)
|
||||
{
|
||||
final Player localPlayer = client.getLocalPlayer();
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
|
||||
for (TimerType type : TimerType.values())
|
||||
{
|
||||
if (timers.getTimerReApply(localPlayer, type) <= currentTime)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
timers.setTimerReApply(localPlayer, type, currentTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onNpcDespawned(NpcDespawned event)
|
||||
{
|
||||
if (!isAtVorkath())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final NPC npc = event.getNpc();
|
||||
|
||||
if (npc.getName() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (npc.getName().equals("Zombified Spawn"))
|
||||
{
|
||||
timers.setTimerReApply(client.getLocalPlayer(), TimerType.FREEZE,
|
||||
System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChatMessage(ChatMessage event)
|
||||
{
|
||||
if (event.getType() != ChatMessageType.GAMEMESSAGE
|
||||
|| !event.getMessage().contains("Your Tele Block has been removed"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
timers.setTimerReApply(client.getLocalPlayer(), TimerType.TELEBLOCK, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private boolean isAtVorkath()
|
||||
{
|
||||
return ArrayUtils.contains(client.getMapRegions(), VORKATH_REGION);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (event.getGroup().equals("freezetimers"))
|
||||
{
|
||||
updateConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConfig()
|
||||
{
|
||||
this.showPlayers = config.showPlayers();
|
||||
this.showNpcs = config.showNpcs();
|
||||
this.FreezeTimers = config.FreezeTimers();
|
||||
this.TB = config.TB();
|
||||
this.Veng = config.Veng();
|
||||
this.offset = config.offset();
|
||||
this.noImage = config.noImage();
|
||||
this.fontStyle = config.fontStyle();
|
||||
this.textSize = config.textSize();
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* Copyright (c) 2019, pklite <https://github.com/pklite/pklite>
|
||||
* 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.freezetimers;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum PlayerSpellEffect
|
||||
{
|
||||
BIND("Bind", 181, 4800, false, 0, TimerType.FREEZE),
|
||||
SNARE("Snare", 180, 9600, false, 1, TimerType.FREEZE),
|
||||
ENTANGLE("Entangle", 179, 14400, false, 2, TimerType.FREEZE),
|
||||
RUSH("Ice Rush", 361, 4800, false, 3, TimerType.FREEZE),
|
||||
BURST("Ice Burst", 363, 9600, false, 4, TimerType.FREEZE),
|
||||
BLITZ("Ice Blitz", 367, 14400, false, 5, TimerType.FREEZE),
|
||||
BARRAGE("Ice Barrage", 369, 19200, false, 6, TimerType.FREEZE),
|
||||
TELEBLOCK("Teleblock", 345, 300000, true, 7, TimerType.TELEBLOCK),
|
||||
VENG("Vengeance", 726, 30000, false, 8, TimerType.VENG),
|
||||
VENG_OTHER("Vengeance Other", 725, 30000, false, 9, TimerType.VENG),
|
||||
NONE("Nothing", -69, 420, true, 9999, TimerType.THIS_SHIT_BROKE);
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final String name;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final int spotAnimId;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final int timerLengthTicks;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean halvable;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final int spriteIdx;
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final TimerType type;
|
||||
|
||||
static PlayerSpellEffect getFromSpotAnim(int spotAnim)
|
||||
{
|
||||
for (PlayerSpellEffect effect : values())
|
||||
{
|
||||
if (effect.getSpotAnimId() == spotAnim)
|
||||
{
|
||||
return effect;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, pklite <https://github.com/pklite/pklite>
|
||||
* 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.freezetimers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
class PrayerTracker
|
||||
{
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
private final Map<Actor, HashMap<String, Integer>> lastTick = new HashMap<>();
|
||||
private final Map<Actor, HashMap<String, Integer>> newTick = new HashMap<>();
|
||||
|
||||
public void gameTick()
|
||||
{
|
||||
lastTick.clear();
|
||||
lastTick.putAll(newTick);
|
||||
newTick.clear();
|
||||
for (Player p : client.getPlayers())
|
||||
{
|
||||
processActor(p);
|
||||
}
|
||||
for (NPC npc : client.getNpcs())
|
||||
{
|
||||
processActor(npc);
|
||||
}
|
||||
}
|
||||
|
||||
private void processActor(Actor actor)
|
||||
{
|
||||
if (!newTick.containsKey(actor))
|
||||
{
|
||||
newTick.put(actor, new HashMap<>());
|
||||
}
|
||||
if (actor instanceof Player)
|
||||
{
|
||||
newTick.get(actor).put("PrayerIcon", ((Player) actor).getOverheadIcon() == null ? -1 : ((Player) actor).getOverheadIcon().ordinal());
|
||||
}
|
||||
newTick.get(actor).put("SpotAnim", actor.getSpotAnimation());
|
||||
}
|
||||
|
||||
int getPrayerIconLastTick(Actor p)
|
||||
{
|
||||
return lastTick.getOrDefault(p, new HashMap<>()).getOrDefault("PrayerIcon", -1337);
|
||||
}
|
||||
|
||||
int getSpotanimLastTick(Actor p)
|
||||
{
|
||||
return lastTick.getOrDefault(p, new HashMap<>()).getOrDefault("SpotAnim", -1337);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, pklite <https://github.com/pklite/pklite>
|
||||
* 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.freezetimers;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum TimerType
|
||||
{
|
||||
FREEZE(3000),
|
||||
VENG(0),
|
||||
TELEBLOCK(45000),
|
||||
THIS_SHIT_BROKE(-1);
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final int immunityTime;
|
||||
|
||||
TimerType(int immunityTime)
|
||||
{
|
||||
this.immunityTime = immunityTime;
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, pklite <https://github.com/pklite/pklite>
|
||||
* 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.freezetimers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Actor;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
class Timers
|
||||
{
|
||||
private final Map<Actor, HashMap<TimerType, Long>> timerMap = new HashMap<>();
|
||||
|
||||
void setTimerEnd(Actor actor, TimerType type, long n)
|
||||
{
|
||||
if (!timerMap.containsKey(actor))
|
||||
{
|
||||
timerMap.put(actor, new HashMap<>());
|
||||
}
|
||||
|
||||
timerMap.get(actor).put(type, n + type.getImmunityTime());
|
||||
}
|
||||
|
||||
void setTimerReApply(Actor actor, TimerType type, long n)
|
||||
{
|
||||
if (!timerMap.containsKey(actor))
|
||||
{
|
||||
timerMap.put(actor, new HashMap<>());
|
||||
}
|
||||
|
||||
timerMap.get(actor).put(type, n);
|
||||
}
|
||||
|
||||
long getTimerEnd(Actor actor, TimerType type)
|
||||
{
|
||||
if (!timerMap.containsKey(actor))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return timerMap.get(actor).getOrDefault(type, (long) type.getImmunityTime()) - type.getImmunityTime();
|
||||
}
|
||||
|
||||
long getTimerReApply(Actor actor, TimerType type)
|
||||
{
|
||||
if (!timerMap.containsKey(actor))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return timerMap.get(actor).getOrDefault(type, (long) 0);
|
||||
}
|
||||
|
||||
List<Actor> getAllActorsOnTimer(TimerType type)
|
||||
{
|
||||
final List<Actor> actors = new ArrayList<>();
|
||||
final Iterator<Actor> it = timerMap.keySet().iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
final Actor actor = it.next();
|
||||
|
||||
for (TimerType timerType : TimerType.values())
|
||||
{
|
||||
if (getTimerReApply(actor, timerType) > System.currentTimeMillis())
|
||||
{
|
||||
break;
|
||||
}
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
|
||||
final long end = getTimerReApply(actor, type);
|
||||
|
||||
if (end > System.currentTimeMillis())
|
||||
{
|
||||
actors.add(actor);
|
||||
}
|
||||
}
|
||||
|
||||
return actors;
|
||||
}
|
||||
|
||||
boolean areAllTimersZero(Actor actor)
|
||||
{
|
||||
for (TimerType type : TimerType.values())
|
||||
{
|
||||
if (getTimerReApply(actor, type) > System.currentTimeMillis())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 195 B |
Binary file not shown.
|
Before Width: | Height: | Size: 492 B |
Binary file not shown.
|
Before Width: | Height: | Size: 216 B |
Binary file not shown.
|
Before Width: | Height: | Size: 468 B |
Binary file not shown.
|
Before Width: | Height: | Size: 251 B |
Reference in New Issue
Block a user