diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingConfig.java deleted file mode 100644 index 65900900d8..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingConfig.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2018, Fluffeh - * 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.flinching; - -import java.awt.Color; -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; -import net.runelite.client.config.Stub; - -@ConfigGroup("flinching") -public interface FlinchingConfig extends Config -{ - - @ConfigItem( - keyName = "flinchStub", - name = "Flinch", - description = "", - position = 1 - ) - default Stub flinchStub() - { - return new Stub(); - } - - @ConfigItem( - position = 2, - keyName = "flinchOnHitReceivedDelay", - name = "Flinch Hit Received Delay", - description = "Slightly longer delay after being attacked milliseconds", - parent = "flinchStub" - ) - default int getFlinchAttackedDelay() - { - return 6600; - } - - @ConfigItem( - position = 3, - keyName = "flinchDelay", - name = "Flinch Timer Delay", - description = "Shows the appropriate time to attack while flinching milliseconds", - parent = "flinchStub" - ) - default int getFlinchDelay() - { - return 5400; - } - - @ConfigItem( - keyName = "overlayStub", - name = "Overlay", - description = "", - position = 4 - ) - default Stub overlayStub() - { - return new Stub(); - } - - @ConfigItem( - position = 5, - keyName = "flinchOverlaySize", - name = "Overlay Diameter", - description = "Flinch overlay timer diameter", - parent = "overlayStub" - ) - default int getFlinchOverlaySize() - { - return 30; - } - - @ConfigItem( - position = 6, - keyName = "hexColorFlinch", - name = "Overlay Color", - description = "Color of flinching timer overlay", - parent = "overlayStub" - ) - default Color getFlinchOverlayColor() - { - return Color.CYAN; - } - - @ConfigItem( - position = 7, - keyName = "flinchResetOnHit", - name = "Reset on Hit", - description = "Timer resets after every attack from your character" - ) - default boolean getFlinchResetOnHit() - { - return true; - } - - @ConfigItem( - position = 8, - keyName = "flinchResetOnHitReceived", - name = "Reset on Hit Received", - description = "Timer resets when your character gets attacked" - ) - default boolean getFlinchResetOnHitReceived() - { - return true; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingOverlay.java deleted file mode 100644 index a46289ad80..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingOverlay.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2018, Fluffeh - * 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.flinching; - - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.util.Map; -import javax.inject.Inject; -import javax.inject.Singleton; -import net.runelite.api.Client; -import net.runelite.api.Perspective; -import net.runelite.api.Point; -import net.runelite.api.coords.LocalPoint; -import net.runelite.api.coords.WorldPoint; -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.components.ProgressPieComponent; - -@Singleton -public class FlinchingOverlay extends Overlay -{ - private final Client client; - private final FlinchingPlugin plugin; - - private Color color; - private Color borderColor; - - private int overlaySize; - - @Inject - FlinchingOverlay(Client client, FlinchingPlugin plugin) - { - setPosition(OverlayPosition.DYNAMIC); - setLayer(OverlayLayer.ABOVE_SCENE); - this.plugin = plugin; - this.client = client; - - overlaySize = this.plugin.getFlinchOverlaySize(); - } - - @Override - public Dimension render(Graphics2D graphics) - { - drawOverlays(graphics); - return null; - } - - public void updateConfig() - { - borderColor = plugin.getFlinchOverlayColor(); - color = new Color(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue(), 100); - - overlaySize = plugin.getFlinchOverlaySize(); - } - - private void drawOverlays(Graphics2D graphics) - { - for (Map.Entry entry : plugin.GetTargets().entrySet()) - { - FlinchingTarget target = entry.getValue(); - - drawFlinchTimer(graphics, target.worldLocation, target.GetRemainingTimePercent()); - } - } - - - private void drawFlinchTimer(Graphics2D graphics, WorldPoint targetLocation, double fillAmount) - { - if (targetLocation.getPlane() != client.getPlane()) - { - return; - } - - LocalPoint localLoc = LocalPoint.fromWorld(client, targetLocation); - if (localLoc == null) - { - return; - } - - Point loc = Perspective.localToCanvas(client, localLoc, client.getPlane()); - - ProgressPieComponent pie = new ProgressPieComponent(); - pie.setDiameter(overlaySize); - pie.setFill(color); - pie.setBorderColor(borderColor); - pie.setPosition(loc); - pie.setProgress(fillAmount); - pie.render(graphics); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingPlugin.java deleted file mode 100644 index 0ed62ecd06..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingPlugin.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (c) 2018, Fluffeh - * 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.flinching; - -import com.google.inject.Provides; -import java.awt.Color; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import javax.inject.Inject; -import javax.inject.Singleton; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Actor; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.NPC; -import net.runelite.api.Player; -import net.runelite.api.events.ConfigChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.HitsplatApplied; -import net.runelite.api.events.NpcDespawned; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.PluginType; -import net.runelite.client.ui.overlay.OverlayManager; - - -@Slf4j -@Singleton -@PluginDescriptor( - name = "Flinching Timer", - description = "Time your attacks while flinching", - tags = {"overlay", "flinching", "timers", "combat"}, - type = PluginType.PVM, - enabledByDefault = false -) - -public class FlinchingPlugin extends Plugin -{ - @Inject - private Client client; - - @Inject - private OverlayManager overlayManager; - - @Inject - private FlinchingConfig config; - - @Inject - private FlinchingOverlay overlay; - - private int currentWorld = -1; - - private int currentInteractingId = -1; - private final Map flinchingTargets = new HashMap<>(); - - private boolean resetOnHit = true; - private boolean resetOnHitReceived = true; - - private int getFlinchAttackedDelay; - private int getFlinchDelay; - @Getter(AccessLevel.PACKAGE) - private int flinchOverlaySize; - @Getter(AccessLevel.PACKAGE) - private Color flinchOverlayColor; - private boolean getFlinchResetOnHit; - private boolean getFlinchResetOnHitReceived; - - @Provides - FlinchingConfig provideConfig(ConfigManager configManager) - { - return configManager.getConfig(FlinchingConfig.class); - } - - @Override - protected void startUp() - { - updateConfig(); - - overlayManager.add(overlay); - - overlay.updateConfig(); - resetOnHit = this.getFlinchResetOnHit; - resetOnHitReceived = this.getFlinchResetOnHitReceived; - - ClearTargets(); - } - - @Override - protected void shutDown() - { - ClearTargets(); - } - - @Subscribe - public void onConfigChanged(ConfigChanged event) - { - if (event.getGroup().equals("flinching")) - { - updateConfig(); - - overlay.updateConfig(); - resetOnHit = this.getFlinchResetOnHit; - resetOnHitReceived = this.getFlinchResetOnHitReceived; - - for (Map.Entry integerFlinchingTargetEntry : flinchingTargets.entrySet()) - { - FlinchingTarget target = integerFlinchingTargetEntry.getValue(); - if (target != null) - { - target.SetDelayTime(this.getFlinchDelay, this.getFlinchAttackedDelay); - } - } - } - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - if (event.getGameState() == GameState.LOGGED_IN) - { - if (currentWorld == -1) - { - currentWorld = client.getWorld(); - } - else if (currentWorld != client.getWorld()) - { - ClearTargets(); - } - } - } - - private void ClearTargets() - { - Iterator> it = flinchingTargets.entrySet().iterator(); - - while (it.hasNext()) - { - it.remove(); - } - } - - @Subscribe - private void onGameTick(GameTick tick) - { - if (client.getGameState() == GameState.LOGGED_IN) - { - return; - } - - TickTargets(); - checkInteracting(); - } - - @Subscribe - public void onHitsplatApplied(HitsplatApplied hitsplatApplied) - { - Actor actor = hitsplatApplied.getActor(); - - if (actor instanceof NPC) - { - NPC hitTarget = (NPC) actor; - - int hitId = hitTarget.getId(); - if (hitId == currentInteractingId) - { - if (!flinchingTargets.containsKey(hitId)) - { - TargetGained(hitTarget); - } - else - { - FlinchingTarget currentTarget = flinchingTargets.get(hitId); - if (currentTarget != null) - { - if (resetOnHit) - { - currentTarget.TargetHit(); - } - } - } - } - } - else if (resetOnHitReceived && actor == client.getLocalPlayer()) - { - PlayerHit(); - } - } - - private void checkInteracting() - { - Player localPlayer = client.getLocalPlayer(); - Actor interacting = localPlayer.getInteracting(); - - if (interacting instanceof NPC) - { - NPC newTarget = (NPC) interacting; - currentInteractingId = newTarget.getId(); - - if (newTarget.getHealth() <= 0 || newTarget.isDead()) - { - if (flinchingTargets.containsKey(currentInteractingId)) - { - flinchingTargets.remove(currentInteractingId); - currentInteractingId = -1; - } - } - } - } - - private void TickTargets() - { - Iterator> it = flinchingTargets.entrySet().iterator(); - - while (it.hasNext()) - { - FlinchingTarget target = it.next().getValue(); - if (target != null) - { - target.Tick(); - if (!target.isActive) - { - it.remove(); - } - } - else - { - it.remove(); - } - } - } - - @Subscribe - public void onNpcDespawned(NpcDespawned npcDespawned) - { - NPC actor = npcDespawned.getNpc(); - - int actorId = actor.getId(); - if (actor.isDead() && flinchingTargets.containsKey(actorId)) - { - TargetLost(actorId); - } - } - - private void TargetLost(int targetId) - { - flinchingTargets.remove(targetId); - } - - private void TargetGained(NPC _newTarget) - { - FlinchingTarget newTarget = new FlinchingTarget(_newTarget); - newTarget.SetDelayTime(config.getFlinchDelay(), config.getFlinchAttackedDelay()); - flinchingTargets.put(_newTarget.getId(), newTarget); - } - - private void PlayerHit() - { - for (Map.Entry integerFlinchingTargetEntry : flinchingTargets.entrySet()) - { - FlinchingTarget target = integerFlinchingTargetEntry.getValue(); - if (target != null) - { - target.PlayerHit(); - } - } - } - - Map GetTargets() - { - return (flinchingTargets); - } - - private void updateConfig() - { - this.getFlinchAttackedDelay = config.getFlinchAttackedDelay(); - this.getFlinchDelay = config.getFlinchDelay(); - this.flinchOverlaySize = config.getFlinchOverlaySize(); - this.flinchOverlayColor = config.getFlinchOverlayColor(); - this.getFlinchResetOnHit = config.getFlinchResetOnHit(); - this.getFlinchResetOnHitReceived = config.getFlinchResetOnHitReceived(); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingTarget.java b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingTarget.java deleted file mode 100644 index 58d90cb247..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingTarget.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2018, Fluffeh - * 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.flinching; - -import java.time.Duration; -import java.time.Instant; -import lombok.AccessLevel; -import lombok.Getter; -import net.runelite.api.NPC; -import net.runelite.api.coords.WorldPoint; - -public class FlinchingTarget -{ - private int currentDisplayLength = 5400; - - private boolean usingHitDelay = false; - - private int displayLength = 5400; - private int displayHitReceivedLength = 6600; - private Instant lastAttacked; - - public boolean isActive; - - @Getter(AccessLevel.PACKAGE) - private int objectId; - private NPC targetObject; - - @Getter(AccessLevel.PACKAGE) - public WorldPoint worldLocation; - - FlinchingTarget(NPC target) - { - isActive = true; - - this.targetObject = target; - this.lastAttacked = Instant.now(); - this.objectId = target.getId(); - this.worldLocation = target.getWorldLocation(); - } - - void TargetHit() - { - boolean shouldHit = true; - if (usingHitDelay) - { - if (GetRemainingTime() > displayLength) - { - shouldHit = false; - } - } - - if (shouldHit) - { - lastAttacked = Instant.now(); - - usingHitDelay = false; - currentDisplayLength = displayLength; - } - } - - double GetRemainingTimePercent() - { - double remainingTime = GetRemainingTime(); - double timePercent = remainingTime / currentDisplayLength; - if (timePercent < 0) - { - timePercent = 0; - } - else if (timePercent > 1) - { - timePercent = 1; - } - - return (timePercent); - } - - private double GetRemainingTime() - { - Duration duration = Duration.between(lastAttacked, Instant.now()); - return ((currentDisplayLength - ((double) duration.toMillis()))); - } - - void Tick() - { - if (targetObject == null) - { - isActive = false; - } - else - { - worldLocation = targetObject.getWorldLocation(); - - double remainingTime = GetRemainingTime(); - if (remainingTime <= 0) - { - isActive = false; - } - } - } - - void SetDelayTime(int delayTime, int delayHitReceivedTime) - { - displayLength = delayTime; - displayHitReceivedLength = delayHitReceivedTime; - - if (usingHitDelay) - { - currentDisplayLength = displayHitReceivedLength; - } - else - { - currentDisplayLength = displayLength; - } - } - - void PlayerHit() - { - usingHitDelay = true; - currentDisplayLength = displayHitReceivedLength; - - lastAttacked = Instant.now(); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java index 9e6af3cc93..61f438f638 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java @@ -51,6 +51,7 @@ import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.NPCManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.OverlayManager; @Slf4j @@ -58,6 +59,7 @@ import net.runelite.client.ui.overlay.OverlayManager; name = "NPC Status Timer", description = "Adds a timer on NPC's for their attacks and flinching.", tags = {"flinch", "npc"}, + type = PluginType.PVM, enabledByDefault = false ) @Singleton