diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index d345b27aa8..df7951b840 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -54,6 +54,7 @@ public enum WidgetInfo WORLD_MAP_SURFACE_SELECTOR(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.SURFACE_SELECTOR), WORLD_MAP_TOOLTIP(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.TOOLTIP), WORLD_MAP_OPTION(WidgetID.WORLD_MAP_MENU_GROUP_ID, WidgetID.WorldMap.OPTION), + WORLD_MAP_BUTTON_BORDER(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB), CLUE_SCROLL_TEXT(WidgetID.CLUE_SCROLL_GROUP_ID, WidgetID.Cluescroll.CLUE_TEXT), CLUE_SCROLL_REWARD_ITEM_CONTAINER(WidgetID.CLUE_SCROLL_REWARD_GROUP_ID, WidgetID.Cluescroll.CLUE_SCROLL_ITEM_CONTAINER), @@ -161,6 +162,7 @@ public enum WidgetInfo MINIMAP_HEALTH_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.HEALTH_ORB), MINIMAP_SPEC_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.SPEC_ORB), MINIMAP_WORLDMAP_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB), + MINIMAP_WORLD_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB), LOGIN_CLICK_TO_PLAY_SCREEN(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, 0), LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, WidgetID.LoginClickToPlayScreen.MESSAGE_OF_THE_DAY), diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java index 34db13d2e9..20013adc67 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java @@ -24,17 +24,18 @@ */ package net.runelite.client.config; +import java.util.ArrayList; import java.util.Collection; public class ConfigDescriptor { private final ConfigGroup group; - private final Collection items; + private final Collection itemGroups; - public ConfigDescriptor(ConfigGroup group, Collection items) + public ConfigDescriptor(ConfigGroup group, Collection itemGroups) { this.group = group; - this.items = items; + this.itemGroups = itemGroups; } public ConfigGroup getGroup() @@ -42,8 +43,22 @@ public class ConfigDescriptor return group; } + public Collection getItemGroups() + { + return itemGroups; + } + public Collection getItems() { - return items; + Collection allItems = new ArrayList<>(); + for (ConfigItemsGroup g : itemGroups) + { + for (ConfigItemDescriptor item : g.getItems()) + { + allItems.add(item); + } + } + return allItems; } -} + +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java index b50094826e..44b93f2e1c 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java @@ -46,4 +46,7 @@ public @interface ConfigItem String warning() default ""; boolean secret() default false; + + String group() default ""; + } diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigItemsGroup.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigItemsGroup.java new file mode 100644 index 0000000000..51363c81c4 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigItemsGroup.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018, Craftiii4 + * 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.config; + +import lombok.AccessLevel; +import lombok.Getter; +import java.util.ArrayList; +import java.util.Collection; + +public class ConfigItemsGroup +{ + + @Getter(AccessLevel.PUBLIC) + private final String group; + + @Getter(AccessLevel.PUBLIC) + private Collection items; + + public ConfigItemsGroup(String group) + { + this.group = group; + this.items = new ArrayList<>(); + } + + public void addItem(ConfigItemDescriptor item) + { + items.add(item); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index 927712f2b4..ae0df8d39a 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -47,7 +47,9 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -462,7 +464,35 @@ public class ConfigManager .result()) .collect(Collectors.toList()); - return new ConfigDescriptor(group, items); + Collection itemGroups = new ArrayList<>(); + + for (ConfigItemDescriptor item : items) + { + String groupName = item.getItem().group(); + boolean found = false; + for (ConfigItemsGroup g : itemGroups) + { + if (g.getGroup().equals(groupName)) + { + g.addItem(item); + found = true; + break; + } + } + if (!found) + { + ConfigItemsGroup newGroup = new ConfigItemsGroup(groupName); + newGroup.addItem(item); + itemGroups.add(newGroup); + } + } + + itemGroups = itemGroups.stream().sorted((a, b) -> ComparisonChain.start() + .compare(a.getGroup(), b.getGroup()) + .result()) + .collect(Collectors.toList()); + + return new ConfigDescriptor(group, itemGroups); } /** diff --git a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java index 6c62b3e081..33cbdb1510 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java +++ b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java @@ -108,6 +108,10 @@ public enum AgilityShortcut AL_KHARID_MINING_PITCLIFF_SCRAMBLE(38, "Rocks", new WorldPoint(3305, 3315, 0), ROCKS_16549, ROCKS_16550), YANILLE_WALL_GRAPPLE(39, "Grapple Wall", new WorldPoint(2552, 3072, 0), WALL_17047), NEITIZNOT_BRIDGE_REPAIR(40, "Bridge Repair - Quest", new WorldPoint(2315, 3828, 0), ROPE_BRIDGE_21306, ROPE_BRIDGE_21307), + NEITIZNOT_BRIDGE_SOUTHEAST(40, "Rope Bridge", null, ROPE_BRIDGE_21308, ROPE_BRIDGE_21309), + NEITIZNOT_BRIDGE_NORTHWEST(40, "Rope Bridge", null, ROPE_BRIDGE_21310, ROPE_BRIDGE_21311), + NEITIZNOT_BRIDGE_NORTH(40, "Rope Bridge", null, ROPE_BRIDGE_21312, ROPE_BRIDGE_21313), + NEITIZNOT_BRIDGE_NORTHEAST(40, "Broken Rope bridge", null, ROPE_BRIDGE_21314, ROPE_BRIDGE_21315), KOUREND_LAKE_JUMP_EAST(40, "Stepping Stones", new WorldPoint(1612, 3570, 0), STEPPING_STONE_29729, STEPPING_STONE_29730), KOUREND_LAKE_JUMP_WEST(40, "Stepping Stones", new WorldPoint(1604, 3572, 0), STEPPING_STONE_29729, STEPPING_STONE_29730), YANILLE_DUNGEON_BALANCE(40, "Balancing Ledge", null, BALANCING_LEDGE_23548), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java index 1e7b7cb3d4..1ed00bf1fe 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java @@ -1,59 +1,57 @@ -/* - * Copyright (c) 2019 Hydrox6 - * 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.ammo; - -import java.awt.image.BufferedImage; -import lombok.Getter; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.ui.overlay.infobox.Counter; -import net.runelite.client.util.StackFormatter; - -public class AmmoCounter extends Counter -{ - @Getter - private int itemID; - - @Getter - private String name; - - public AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image) - { - super(image, plugin, count); - this.itemID = itemID; - this.name = name; - } - - @Override - public String getText() - { - return StackFormatter.quantityToRSDecimalStack(getCount()); - } - - @Override - public String getTooltip() - { - return name; - } -} +/* + * Copyright (c) 2019 Hydrox6 + * 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.ammo; + +import java.awt.image.BufferedImage; +import lombok.Getter; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.ui.overlay.infobox.Counter; +import net.runelite.client.util.StackFormatter; + +class AmmoCounter extends Counter +{ + @Getter + private final int itemID; + private final String name; + + AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image) + { + super(image, plugin, count); + this.itemID = itemID; + this.name = name; + } + + @Override + public String getText() + { + return StackFormatter.quantityToRSDecimalStack(getCount()); + } + + @Override + public String getTooltip() + { + return name; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java index b2466994a1..8aa9c80601 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java @@ -43,8 +43,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; @PluginDescriptor( name = "Ammo", description = "Shows the current ammo the player has equipped", - tags = {"bolts", "darts", "chinchompa"}, - type = "utility" + tags = {"bolts", "darts", "chinchompa", "equipment"} ) public class AmmoPlugin extends Plugin { @@ -63,20 +62,21 @@ public class AmmoPlugin extends Plugin private AmmoCounter counterBox; @Override - public void startUp() throws Exception + protected void startUp() throws Exception { clientThread.invokeLater(() -> { - ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT); + final ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT); + if (container != null) { - parseInventory(container.getItems()); + checkInventory(container.getItems()); } }); } @Override - public void shutDown() throws Exception + protected void shutDown() throws Exception { infoBoxManager.removeInfoBox(counterBox); counterBox = null; @@ -90,10 +90,10 @@ public class AmmoPlugin extends Plugin return; } - parseInventory(event.getItemContainer().getItems()); + checkInventory(event.getItemContainer().getItems()); } - private void parseInventory(Item[] items) + private void checkInventory(final Item[] items) { // Check for weapon slot items. This overrides the ammo slot, // as the player will use the thrown weapon (eg. chinchompas, knives, darts) @@ -126,7 +126,7 @@ public class AmmoPlugin extends Plugin updateInfobox(ammo, comp); } - private void updateInfobox(Item item, ItemComposition comp) + private void updateInfobox(final Item item, final ItemComposition comp) { if (counterBox != null && counterBox.getItemID() == item.getId()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java index 6b80dd4ce3..3e9fc7d6ec 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java @@ -1,43 +1,68 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; +import lombok.Getter; import net.runelite.api.Actor; -import net.runelite.client.plugins.freezetimers.Spell; import net.runelite.client.util.Text; +import org.jetbrains.annotations.NotNull; -public class Barrage -extends Spell { - public static final long DURATION = 20000L; +public class Barrage extends Spell +{ + + + @Getter + public static final long DURATION = 20000; private long remainingTime; + @Getter private boolean isFinished; - public Barrage(Actor affectedTarget, Actor caster) { + + public Barrage(Actor affectedTarget, Actor caster) + { super(affectedTarget, caster); } - public long getRemainingTime() { + public long getRemainingTime() + { long elapsedTime = System.currentTimeMillis() - this.startTime; - if (Barrage.getDURATION() > elapsedTime) { - return Barrage.getDURATION() - elapsedTime; + if (getDURATION() > elapsedTime) + { + return getDURATION() - elapsedTime; } - this.isFinished = true; - return 0L; - } - - public boolean equals(Object o) { - if (o instanceof Barrage) { - Barrage barrage = (Barrage)o; - return Text.standardize(this.getAffectedTarget().getName()).equals(Text.standardize(((Barrage)o).getAffectedTarget().getName())) && this.getStartTime() == ((Barrage)o).getStartTime(); + else + { + this.isFinished = true; + return 0; } - return false; } - public static long getDURATION() { - return 20000L; + public boolean equals(Object o) + { + if (o instanceof Barrage) + { + Barrage barrage = (Barrage) o; + if (Text.standardize(this.getAffectedTarget().getName()).equals(Text.standardize(((Barrage) o) + .getAffectedTarget().getName())) && this.getStartTime() == ((Barrage) o).getStartTime()) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } } - @Override - public boolean isFinished() { - return this.isFinished; - } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java index 512905759d..8d484f11cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java @@ -5,38 +5,75 @@ import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -@ConfigGroup(value="freezetimers") -public interface FreezeTimersConfig -extends Config { - @ConfigItem(position=0, keyName="freezeenable", name="Enable PvP freeze timers", description="Configures whether or not to show freeze timers.") - default public boolean EnableFreezeTimers() { +@ConfigGroup("freezetimers") +public interface FreezeTimersConfig extends Config +{ + + @ConfigItem( + position = 0, + keyName = "freezeenable", + name = "Enable PvP freeze timers", + description = "Configures whether or not to show freeze timers." + ) + default boolean EnableFreezeTimers() + { return false; } - @ConfigItem(position=1, keyName="tilehighlight", name="Frozen opponent tile highlighting", description="Configures whether or not to highlight tiles frozen opponents are standing on.") - default public boolean drawTiles() { + @ConfigItem( + position = 1, + keyName = "tilehighlight", + name = "Frozen opponent tile highlighting", + description = "Configures whether or not to highlight tiles frozen opponents are standing on." + ) + default boolean drawTiles() + { return false; } - @ConfigItem(position=2, keyName="timercolor", name="Freeze Timer Color", description="Color of freeze timer") - default public Color FreezeTimerColor() { + @ConfigItem( + position = 2, + keyName = "timercolor", + name = "Freeze Timer Color", + description = "Color of freeze timer" + ) + default Color FreezeTimerColor() + { return new Color(0, 184, 212); } - @ConfigItem(position=3, keyName="spellIcon", name="Show spell icon", description="Shows the spell icon for the freeze spell affecting the target") - default public boolean spellIcon() { + @ConfigItem( + position = 3, + keyName = "spellIcon", + name = "Show spell icon", + description = "Shows the spell icon for the freeze spell affecting the target" + ) + default boolean spellIcon() + { return true; } - @ConfigItem(position=4, keyName="refreezeTimer", name="Refreeze Timer", description="Show a timer that counts up until the target can be refrozen") - default public boolean refreezeTimer() { + @ConfigItem( + position = 4, + keyName = "refreezeTimer", + name = "Refreeze Timer", + description = "Show a timer that counts up until the target can be refrozen" + ) + default boolean refreezeTimer() + { return true; } - @ConfigItem(position=5, keyName="refreezeTimerColor", name="Refreeze color", description="The color for the timer that counts until the target can be refrozen") - default public Color RefreezeTimerColor() { + @ConfigItem( + position = 5, + keyName = "refreezeTimerColor", + name = "Refreeze color", + description = "The color for the timer that counts until the target can be refrozen" + ) + default Color RefreezeTimerColor() + { return Color.red; - } + } @ConfigItem(position = 6, keyName = "tbtimer", name = "Tele Block Timer", description = "Enables tele block timer") default boolean TBTimer() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java index 1d7dbd162e..5718c506d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java @@ -1,24 +1,25 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; import java.awt.Graphics2D; -import java.awt.Stroke; -import java.awt.image.BufferedImage; -import java.util.function.BiConsumer; +import java.awt.font.TextLayout; +import java.awt.image.*; import javax.inject.Inject; import javax.inject.Singleton; -import net.runelite.api.Client; -import net.runelite.api.HeadIcon; -import net.runelite.api.Player; -import net.runelite.api.Point; + +import net.runelite.api.*; import net.runelite.client.game.SpriteManager; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersPlugin; -import net.runelite.client.plugins.freezetimers.FreezeTimersService; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; @@ -26,8 +27,8 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; @Singleton -public class FreezeTimersOverlay -extends Overlay { +public class FreezeTimersOverlay extends Overlay +{ private final FreezeTimersService FreezeTimersService; private final FreezeTimersConfig config; private final FreezeTimersPlugin plugin; @@ -35,123 +36,165 @@ extends Overlay { private final Client client; @Inject - private FreezeTimersOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService2, FreezeTimersPlugin plugin, Client client, SpriteManager spriteManager) { + private FreezeTimersOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService, FreezeTimersPlugin plugin, Client client, SpriteManager spriteManager) + { this.config = config; - this.FreezeTimersService = FreezeTimersService2; + this.FreezeTimersService = FreezeTimersService; this.plugin = plugin; this.client = client; this.spriteManager = spriteManager; - this.setPosition(OverlayPosition.DYNAMIC); - this.setPriority(OverlayPriority.MED); + setPosition(OverlayPosition.DYNAMIC); + setPriority(OverlayPriority.MED); } @Override - public Dimension render(Graphics2D graphics) { - if (!this.config.EnableFreezeTimers()) { + public Dimension render(Graphics2D graphics) + { + if (!config.EnableFreezeTimers()) + { return null; } - this.FreezeTimersService.forEachPlayer((player, color) -> this.renderPlayerOverlay(graphics, (Player)player, (Color)color)); + FreezeTimersService.forEachPlayer((player, color) -> renderPlayerOverlay(graphics, player, color)); return null; } - private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) { - BufferedImage clanchatImage; + private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) + { int timer = 0; String name = actor.getName(); - int freezetype = this.plugin.freezetype(name); - boolean frozenoverlay = false; + int freezetype = plugin.freezetype(name); + boolean frozenoverlay = false; int offset = 5; - long dtime = this.plugin.opponentfreezetime(name); - long tbed = plugin.istbed(name); + long dtime = plugin.opponentfreezetime(name); + long tbed = plugin.istbed(name); Point textLocation = null; HeadIcon headIcon = actor.getOverheadIcon(); int freezetime = 0; - if (freezetype == 1 || freezetype == 4) { + if (freezetype == 1 || freezetype == 4) + { freezetime = 5000; - } else if (freezetype == 2 || freezetype == 5) { + } + else if (freezetype == 2 || freezetype == 5) + { freezetime = 10000; - } else if (freezetype == 3 || freezetype == 6) { + } + else if (freezetype == 3 || freezetype == 6) + { freezetime = 15000; - } else if (freezetype == 7) { + } + else if (freezetype == 7) + { freezetime = 20000; - } else if (freezetype == 8) { + } + else if (freezetype == 8) + { freezetime = 2500; - } else if (freezetype == 9) { + } + else if (freezetype == 9) + { freezetime = 5000; - } else if (freezetype == 10) { + } + else if (freezetype == 10) + { freezetime = 7500; } + long currenttime = System.currentTimeMillis(); long timediff = currenttime - dtime; - timer = (freezetime - (int)timediff) / 1000; - if (timediff < (long)freezetime) { - textLocation = actor.getCanvasTextLocation(graphics, String.valueOf(timer), actor.getLogicalHeight() + config.FreezeTimerPos()); + timer = (freezetime - (int) timediff) / 1000; + + if (timediff < freezetime) + { + // if the freezetimer is still active. . . + textLocation = actor.getCanvasTextLocation(graphics, String.valueOf((timer)), offset); textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); - } else if (timediff < (long)(freezetime + 3000)) { - timer = Math.abs(timer); - ++timer; - if (this.config.refreezeTimer()) { - textLocation = actor.getCanvasTextLocation(graphics, String.valueOf(timer), actor.getLogicalHeight() + config.FreezeTimerPos()); - textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); - graphics.setFont(FontManager.getRunescapeBoldFont()); - if (headIcon != null) { + } + else + { + if (timediff < freezetime + 3000) + { + timer = Math.abs(timer); + timer += 1; + if (config.refreezeTimer()) + { + textLocation = actor.getCanvasTextLocation(graphics, String.valueOf((timer)), offset); textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); + graphics.setFont(FontManager.getRunescapeBoldFont()); + if (headIcon != null) + { + textLocation = new Point(textLocation.getX() + 10, textLocation.getY() + 5); + } + frozenoverlay = true; + OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf((timer)), config.RefreezeTimerColor()); + return; } - frozenoverlay = true; - OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), this.config.RefreezeTimerColor()); - return; } - } else { - this.plugin.deleteopponent(name); - } - if (textLocation != null && (clanchatImage = this.plugin.GetFreezeIcon(freezetype - 1)) != null) { - int width = clanchatImage.getWidth(); - int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent(); - Point imageLocation = new Point(textLocation.getX(), textLocation.getY() - (config.FreezeTimerPos() / 2)); - graphics.setFont(FontManager.getRunescapeFont()); - graphics.setStroke(new BasicStroke(3.0f)); - if (this.config.spellIcon()) { - frozenoverlay = true; - graphics.drawOval(imageLocation.getX(), imageLocation.getY(), clanchatImage.getWidth(), clanchatImage.getHeight()); - OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); - OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), color); - } else { - graphics.setColor(Color.cyan); - graphics.drawOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), graphics.getFontMetrics().getHeight()); - graphics.setColor(Color.blue); - graphics.fillOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), graphics.getFontMetrics().getHeight()); - OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), Color.WHITE); + else + { + plugin.deleteopponent(name); } } - if (config.TBTimer()) { - if (tbed > 0) { - int type = plugin.tbtype(name); - int tbexpiry; - if (type > 0) { - if (type == 1) { - tbexpiry = 300000; - } else if (type == 2) { - tbexpiry = 150000; - } else { - return; - } - long tbtime = currenttime - tbed; - int tbtimer = (tbexpiry - (int) tbtime) / 1000; - if (tbtime < tbexpiry) { - textLocation = actor.getCanvasTextLocation(graphics, Integer.toString(tbtimer), actor.getLogicalHeight() + config.FreezeTimerPos()); - if (frozenoverlay) { - textLocation = new Point(textLocation.getX() + 40, textLocation.getY() - config.FreezeTimerPos()); - } else { - textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); - } - } else { - plugin.deletetb(name); - } - } + if (textLocation != null) + { + BufferedImage clanchatImage = plugin.GetFreezeIcon(freezetype - 1); - } - } - } -} + if (clanchatImage != null) + { + int width = clanchatImage.getWidth(); + int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent(); + Point imageLocation = new Point(textLocation.getX() - width, ((textLocation.getY() - + graphics.getFontMetrics().getHeight()) + 10)); + graphics.setFont(FontManager.getRunescapeFont()); + // graphics.setStroke(new BasicStroke(3)); + if (config.spellIcon()) + { + frozenoverlay = true; + // graphics.drawOval(imageLocation.getX(), imageLocation.getY(), clanchatImage.getWidth(), clanchatImage.getHeight()); + OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); + OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), color); + + } + else + { + graphics.setColor(Color.cyan); + graphics.drawOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), + graphics.getFontMetrics().getHeight()); + graphics.setColor(Color.blue); + graphics.fillOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), + graphics.getFontMetrics().getHeight()); + + OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), Color.WHITE); + } + } + if (config.TBTimer()) { + if (tbed > 0) { + int type = plugin.tbtype(name); + int tbexpiry; + if (type > 0) { + if (type == 1) { + tbexpiry = 300000; + } else if (type == 2) { + tbexpiry = 150000; + } else { + return; + } + long tbtime = currenttime - tbed; + int tbtimer = (tbexpiry - (int) tbtime) / 1000; + if (tbtime < tbexpiry) { + textLocation = actor.getCanvasTextLocation(graphics, Integer.toString(tbtimer), actor.getLogicalHeight() + config.FreezeTimerPos()); + if (frozenoverlay) { + textLocation = new Point(textLocation.getX() + 40, textLocation.getY() - config.FreezeTimerPos()); + } else { + textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); + } + } else { + plugin.deletetb(name); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java index 50f81cf94f..5e0c7a7824 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java @@ -1,99 +1,86 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; - - - - +import net.runelite.api.events.*; +import net.runelite.client.eventbus.Subscribe; import com.google.inject.Provides; +import javax.inject.Inject; import java.awt.*; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; import java.awt.image.*; -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.DataBuffer; -import java.awt.image.DataBufferByte; -import java.awt.image.ImageObserver; -import java.awt.image.IndexColorModel; -import java.awt.image.WritableRaster; import java.util.*; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.inject.Inject; + import net.runelite.api.*; -import net.runelite.api.Actor; -import net.runelite.api.Client; -import net.runelite.api.events.*; -import net.runelite.api.GameState; -import net.runelite.api.HeadIcon; -import net.runelite.api.IndexedSprite; -import net.runelite.api.Player; -import net.runelite.api.Skill; + import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.AnimationChanged; -import net.runelite.api.events.ExperienceChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.MenuOptionClicked; import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.SpriteManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.freezetimers.Barrage; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersOverlay; -import net.runelite.client.plugins.freezetimers.FreezeTimersTileOverlay; -import net.runelite.client.plugins.freezetimers.Spell; -import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ImageUtil; import org.slf4j.Logger; @PluginDescriptor( - name = "Freeze Timers", - description = "PVP Freeze Timers", - tags = {"PvP", "Freeze", "Timers"}, - type = "PVP" + name = "Freeze Timers", + description = "PVP Freeze Timers", + type = "PVP", + tags = {"PvP", "Freeze", "Timers", "pklite"} ) - -public class FreezeTimersPlugin -extends Plugin { +public class FreezeTimersPlugin extends Plugin +{ @Inject private OverlayManager overlayManager; + @Inject private FreezeTimersConfig config; + @Inject private FreezeTimersOverlay FreezeTimersOverlay; + @Inject private FreezeTimersTileOverlay FreezeTimersTileOverlay; + @Inject private Client client; + @Inject private SpriteManager spriteManager; - - private static final int[] FREEZE_ICONS = { - SpriteID.SPELL_BIND, - SpriteID.SPELL_SNARE, - SpriteID.SPELL_ENTANGLE, - SpriteID.SPELL_ICE_RUSH, - SpriteID.SPELL_ICE_BURST, - SpriteID.SPELL_ICE_BLITZ, - SpriteID.SPELL_ICE_BARRAGE, - SpriteID.SPELL_BIND, - SpriteID.SPELL_SNARE, - SpriteID.SPELL_ENTANGLE, - SpriteID.SPELL_TELE_BLOCK - }; - private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(25, 25); + + @Provides + FreezeTimersConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(FreezeTimersConfig.class); + } + + private static final int[] FREEZE_ICONS = + { + SpriteID.SPELL_BIND, + SpriteID.SPELL_SNARE, + SpriteID.SPELL_ENTANGLE, + SpriteID.SPELL_ICE_RUSH, + SpriteID.SPELL_ICE_BURST, + SpriteID.SPELL_ICE_BLITZ, + SpriteID.SPELL_ICE_BARRAGE, + SpriteID.SPELL_BIND, + SpriteID.SPELL_SNARE, + SpriteID.SPELL_ENTANGLE, + SpriteID.SPELL_TELE_BLOCK + }; + + private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(25, 25); private static final Color FREEZE_ICON_OUTLINE_COLOR = new Color(33, 33, 33); private final BufferedImage[] FreezeIcons = new BufferedImage[FREEZE_ICONS.length]; + private final int SPLASH_ID = 85; Map tbedthings = new HashMap<>(); Map tbtypes = new HashMap<>(); @@ -108,248 +95,319 @@ extends Plugin { String currtarget; String spell; - @Provides - FreezeTimersConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(FreezeTimersConfig.class); - } @Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { if (gameStateChanged.getGameState() == GameState.LOGGED_IN) { - this.loadFreezeIcons(); + loadFreezeIcons(); } } @Override protected void startUp() throws Exception { - this.overlayManager.add(this.FreezeTimersOverlay); - this.overlayManager.add(this.FreezeTimersTileOverlay); + overlayManager.add(FreezeTimersOverlay); + overlayManager.add(FreezeTimersTileOverlay); } @Override protected void shutDown() throws Exception { - this.overlayManager.remove(this.FreezeTimersOverlay); - this.overlayManager.remove(this.FreezeTimersTileOverlay); - this.frozenthings.clear(); - this.frozenthingpoints.clear(); - this.tbedthings.clear(); - this.tbtypes.clear(); + overlayManager.remove(FreezeTimersOverlay); + overlayManager.remove(FreezeTimersTileOverlay); + frozenthings.clear(); + frozenthingpoints.clear(); + tbedthings.clear(); + tbtypes.clear(); } + @Subscribe - public void onMenuOptionClicked(MenuOptionClicked event) { - if (event.getMenuTarget().contains("->")) { - Pattern spattern = Pattern.compile(">(.+?)"); - Pattern ppattern = Pattern.compile("> (.+?)")) + { + final Pattern spattern = Pattern.compile(">(.+?)"); + final Pattern ppattern = Pattern.compile("> (.+?) 0 && this.currtarget != null) { - if (this.frozenthings.containsKey(this.currtarget)) { - this.currtarget = null; + if (xp > 0 && currtarget != null) + { + if (frozenthings.containsKey(currtarget)) + { + currtarget = null; return; } WorldPoint targetPosition = null; - for (Player player : this.client.getPlayers()) { - String playerName; - if (player == null || !(playerName = player.getName()).equals(this.currtarget)) continue; - if (player.getOverheadIcon() != null && player.getOverheadIcon().equals((Object)HeadIcon.MAGIC)) { - praymage = true; + for (Player player : client.getPlayers()) + { + if (player == null) + { + continue; + } + String playerName = player.getName(); + if (playerName.equals(currtarget)) + { + if (player.getOverheadIcon() != null) + { + if (player.getOverheadIcon().equals(HeadIcon.MAGIC)) + { + praymage = true; + } + } + targetPosition = player.getWorldLocation(); + break; } - targetPosition = player.getWorldLocation(); - break; } - if (targetPosition != null) { - if (this.spell.equals("Bind") && xp > 30) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - if (praymage) { - this.freezetype.put(this.currtarget, 8); - } else { - this.freezetype.put(this.currtarget, 1); + if (targetPosition != null) + { + if (spell.equals("Bind") && xp > 30) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + if (praymage) + { + freezetype.put(currtarget, 8); } - } else if (this.spell.equals("Snare") && xp > 60) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - if (praymage) { - this.freezetype.put(this.currtarget, 9); - } else { - this.freezetype.put(this.currtarget, 2); + else + { + freezetype.put(currtarget, 1); } - } else if (this.spell.equals("Entangle") && xp >= 89) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - if (praymage) { - this.freezetype.put(this.currtarget, 10); - } else { - this.freezetype.put(this.currtarget, 3); + } + else if (spell.equals("Snare") && xp > 60) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + if (praymage) + { + freezetype.put(currtarget, 9); } - } else if (this.spell.equals("Ice Rush") && xp > 34) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 4); - } else if (this.spell.equals("Ice Burst") && xp > 40) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 5); - } else if (this.spell.equals("Ice Blitz") && xp > 46) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 6); - } else if (this.spell.equals("Ice Barrage") && xp > 52) { - Barrage barrage = new Barrage(this.client.getLocalPlayer().getInteracting(), this.client.getLocalPlayer()); - this.testMap.put(this.currtarget, barrage); - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 7); - } else if (spell.equals("Tele Block") && xp == 95) { - if (config.TBTimer()) { - if (praymage) { - this.tbtypes.put(this.currtarget, 2); - } else { - this.tbtypes.put(this.currtarget, 1); - } - this.tbedthings.put(this.currtarget, System.currentTimeMillis()); - } + else + { + freezetype.put(currtarget, 2); + } + } + else if (spell.equals("Entangle") && xp >= 89) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + if (praymage) + { + freezetype.put(currtarget, 10); + } + else + { + freezetype.put(currtarget, 3); + } + } + else if (spell.equals("Ice Rush") && xp > 34) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 4); + } + else if (spell.equals("Ice Burst") && xp > 40) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 5); + } + else if (spell.equals("Ice Blitz") && xp > 46) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 6); + } + else if (spell.equals("Ice Barrage") && xp > 52) + { + Barrage barrage = new Barrage(client.getLocalPlayer().getInteracting(), client.getLocalPlayer()); + testMap.put(currtarget, barrage); + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 7); + } + } else if (spell.equals("Tele Block") && xp == 95) { + if (config.TBTimer()) { + if (praymage) { + tbtypes.put(currtarget, 2); + } else { + tbtypes.put(currtarget, 1); + } + tbedthings.put(currtarget, System.currentTimeMillis()); } } } - if (this.currtarget != null && this.ticks > this.currticks + 1) { - Player local = this.client.getLocalPlayer(); + if (currtarget != null && ticks > currticks + 1) + { + Player local = client.getLocalPlayer(); Actor interacting = local.getInteracting(); - if (interacting != null) { - if (!interacting.getName().equals(this.currtarget)) { - this.currtarget = null; + if (interacting != null) + { + if (!interacting.getName().equals(currtarget)) + { + currtarget = null; } - } else { - this.currtarget = null; + } + else + { + currtarget = null; } } - ++this.ticks; + ticks++; } - public long opponentfreezetime(String name) { - if (this.frozenthings.containsKey(name)) { - return this.frozenthings.get(name); + public long opponentfreezetime(String name) + { + if (frozenthings.containsKey(name)) + { + return frozenthings.get(name); } - return 0L; + return 0; } - public WorldPoint playerpos(String name) { - if (this.frozenthingpoints.containsKey(name)) { - return this.frozenthingpoints.get(name); + public WorldPoint playerpos(String name) + { + if (frozenthingpoints.containsKey(name)) + { + return frozenthingpoints.get(name); } return null; } - public void updatePosition(String name, WorldPoint point) { - if (this.frozenthingpoints.containsKey(name)) { - this.frozenthingpoints.remove(name); - this.frozenthingpoints.put(name, point); + public void updatePosition(String name, WorldPoint point) + { + if (frozenthingpoints.containsKey(name)) + { + frozenthingpoints.remove(name); + frozenthingpoints.put(name, point); } } - public int freezetype(String name) { - if (this.freezetype.containsKey(name)) { - return this.freezetype.get(name); + public int freezetype(String name) + { + if (freezetype.containsKey(name)) + { + return freezetype.get(name); } return 0; } - public long istbed(String name) { - if (this.tbedthings.containsKey(name)) { - return this.tbedthings.get(name); - } - return 0; - } - public int tbtype(String name) { - if (this.tbtypes.containsKey(name)) { - return this.tbtypes.get(name); - } - return 0; - } - public void deleteopponent(String name) { - if (this.frozenthings.containsKey(name)) { - this.frozenthings.remove(name); + + public long istbed(String name) { + if (tbedthings.containsKey(name)) { + return tbedthings.get(name); } - if (this.frozenthingpoints.containsKey(name)) { - this.frozenthingpoints.remove(name); + return 0; + } + public int tbtype(String name) { + if (tbtypes.containsKey(name)) { + return tbtypes.get(name); } - if (this.freezetype.containsKey(name)) { - this.freezetype.remove(name); + return 0; + } + + public void deleteopponent(String name) + { + if (frozenthings.containsKey(name)) + { + frozenthings.remove(name); + } + if (frozenthingpoints.containsKey(name)) + { + frozenthingpoints.remove(name); + } + if (freezetype.containsKey(name)) + { + freezetype.remove(name); } } - public void deletetb(String name) { - if (this.tbedthings.containsKey(name)) { - this.tbedthings.remove(name); - } - if (this.tbtypes.containsKey(name)) { - this.tbtypes.remove(name); - } - } - private void loadFreezeIcons() { - IndexedSprite[] freezeIcons = new IndexedSprite[]{}; - IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length); + + public void deletetb(String name) { + if (tbedthings.containsKey(name)) { + tbedthings.remove(name); + } + if (tbtypes.containsKey(name)) { + tbtypes.remove(name); + } + } + + private void loadFreezeIcons() + { + final IndexedSprite[] freezeIcons = {}; + final IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length); int curPosition = 0; - int i = 0; - while (i < FREEZE_ICONS.length) { - int resource = FREEZE_ICONS[i]; - this.FreezeIcons[i] = FreezeTimersPlugin.rgbaToIndexedBufferedImage(FreezeTimersPlugin.FreezeIconFromSprite(this.spriteManager.getSprite(resource, 0))); - newfreezeIcons[curPosition] = FreezeTimersPlugin.createIndexedSprite(this.client, this.FreezeIcons[i]); - ++i; - ++curPosition; + + for (int i = 0; i < FREEZE_ICONS.length; i++, curPosition++) + { + final int resource = FREEZE_ICONS[i]; + FreezeIcons[i] = rgbaToIndexedBufferedImage(FreezeIconFromSprite(spriteManager.getSprite(resource, 0))); + newfreezeIcons[curPosition] = createIndexedSprite(client, FreezeIcons[i]); } } @@ -373,7 +431,7 @@ extends Plugin { } private static BufferedImage rgbaToIndexedBufferedImage(BufferedImage sourceBufferedImage) { - BufferedImage indexedImage = new BufferedImage(sourceBufferedImage.getWidth(), sourceBufferedImage.getHeight(), 13); + BufferedImage indexedImage = new BufferedImage(sourceBufferedImage.getWidth(), sourceBufferedImage.getHeight(), BufferedImage.TYPE_BYTE_INDEXED); ColorModel cm = indexedImage.getColorModel(); IndexColorModel icm = (IndexColorModel)cm; int size = icm.getMapSize(); @@ -383,21 +441,23 @@ extends Plugin { icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); - WritableRaster raster = indexedImage.getRaster(); - int pixel = raster.getSample(0, 0, 0); - IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel); - BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null); + + final WritableRaster raster = indexedImage.getRaster(); + final int pixel = raster.getSample(0, 0, 0); + final IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel); + final BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null); resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null); return resultIndexedImage; } - private static BufferedImage FreezeIconFromSprite(BufferedImage freezeSprite) { - BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, FreezeTimersPlugin.FREEZE_ICON_DIMENSION.width, FreezeTimersPlugin.FREEZE_ICON_DIMENSION.height); + private static BufferedImage FreezeIconFromSprite(final BufferedImage freezeSprite) + { + final BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, FREEZE_ICON_DIMENSION.width, FREEZE_ICON_DIMENSION.height); return ImageUtil.outlineImage(freezeCanvas, FREEZE_ICON_OUTLINE_COLOR); } - BufferedImage GetFreezeIcon(int id) { - return this.FreezeIcons[id]; + BufferedImage GetFreezeIcon(int id) + { + return FreezeIcons[id]; } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java index 257aae69b8..912c106ba1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java @@ -1,81 +1,123 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; import java.awt.Color; -import java.util.List; +import java.util.Objects; import java.util.function.BiConsumer; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Player; import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersPlugin; + @Singleton -public class FreezeTimersService { +public class FreezeTimersService +{ private final Client client; private final FreezeTimersConfig config; private final FreezeTimersPlugin plugin; @Inject - private FreezeTimersService(Client client, FreezeTimersConfig config, FreezeTimersPlugin plugin) { + private FreezeTimersService(Client client, FreezeTimersConfig config, FreezeTimersPlugin plugin) + { this.config = config; this.plugin = plugin; this.client = client; } - public void forEachPlayer(BiConsumer consumer) { - for (Player player : this.client.getPlayers()) { - if (player == null || player.getName() == null) continue; + public void forEachPlayer(final BiConsumer consumer) + { + + for (Player player : client.getPlayers()) + { + if (player == null || player.getName() == null) + { + continue; + } + String name = player.getName(); - int freezetype = this.plugin.freezetype(name); - long tbed = plugin.istbed(name); - long dtime = this.plugin.opponentfreezetime(name); + int freezetype = plugin.freezetype(name); + long dtime = plugin.opponentfreezetime(name); + long tbed = plugin.istbed(name); int freezetime = 0; - if (freezetype == 1 || freezetype == 4) { + if (freezetype == 1 || freezetype == 4) + { freezetime = 5000; - } else if (freezetype == 2 || freezetype == 5) { + } + else if (freezetype == 2 || freezetype == 5) + { freezetime = 10000; - } else if (freezetype == 3 || freezetype == 6) { + } + else if (freezetype == 3 || freezetype == 6) + { freezetime = 15000; - } else if (freezetype == 7) { + } + else if (freezetype == 7) + { freezetime = 20000; - } else if (freezetype == 8) { + } + else if (freezetype == 8) + { freezetime = 2500; - } else if (freezetype == 9) { + } + else if (freezetype == 9) + { freezetime = 5000; - } else if (freezetype == 10) { + } + else if (freezetype == 10) + { freezetime = 7500; } - if (dtime <= 0L) continue; - long currenttime = System.currentTimeMillis(); - long timediff = currenttime - dtime; - if (timediff < (long)freezetime) { - WorldPoint lastWorldPoint; - WorldPoint currentWorldPoint = player.getWorldLocation(); - if (currentWorldPoint.equals(lastWorldPoint = this.plugin.playerpos(name))) { - consumer.accept(player, this.config.FreezeTimerColor()); - continue; + if (dtime > 0) + { + long currenttime = System.currentTimeMillis(); + long timediff = currenttime - dtime; + if (timediff < freezetime) + { + WorldPoint currentWorldPoint = player.getWorldLocation(); + WorldPoint lastWorldPoint = plugin.playerpos(name); + if (currentWorldPoint.equals(lastWorldPoint)) + { + consumer.accept(player, config.FreezeTimerColor()); + } + else + { + if (timediff < 605) + { + plugin.updatePosition(name, currentWorldPoint); + consumer.accept(player, config.FreezeTimerColor()); + } + else + { + plugin.deleteopponent(name); + } + } } - if (timediff < 605L) { - this.plugin.updatePosition(name, currentWorldPoint); - consumer.accept(player, this.config.FreezeTimerColor()); - continue; + else + { + if (timediff < freezetime + 3000) + { + consumer.accept(player, Color.YELLOW); + } + else + { + plugin.deleteopponent(name); + } + if (tbed > 0) { + consumer.accept(player, config.FreezeTimerColor()); + return; + } } - this.plugin.deleteopponent(name); - continue; } - if (timediff < (long)(freezetime + 3000)) { - consumer.accept(player, Color.YELLOW); - continue; - } else { - this.plugin.deleteopponent(name); - } - if (tbed > 0) { - consumer.accept(player, config.FreezeTimerColor()); - return; - } } } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java index a945470c85..37eea87b7a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java @@ -1,46 +1,57 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; -import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; -import java.util.function.BiConsumer; import javax.inject.Inject; -import net.runelite.api.Player; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersService; 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; -public class FreezeTimersTileOverlay -extends Overlay { +public class FreezeTimersTileOverlay extends Overlay +{ private final FreezeTimersService FreezeTimersService; private final FreezeTimersConfig config; @Inject - private FreezeTimersTileOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService2) { + private FreezeTimersTileOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService) + { this.config = config; - this.FreezeTimersService = FreezeTimersService2; - this.setLayer(OverlayLayer.ABOVE_SCENE); - this.setPosition(OverlayPosition.DYNAMIC); - this.setPriority(OverlayPriority.MED); + this.FreezeTimersService = FreezeTimersService; + setLayer(OverlayLayer.ABOVE_SCENE); + setPosition(OverlayPosition.DYNAMIC); + setPriority(OverlayPriority.MED); } @Override - public Dimension render(Graphics2D graphics) { - if (!this.config.drawTiles()) { + public Dimension render(Graphics2D graphics) + { + if (!config.drawTiles()) + { return null; } - this.FreezeTimersService.forEachPlayer((player, color) -> { - Polygon poly = player.getCanvasTilePoly(); - if (poly != null) { + + FreezeTimersService.forEachPlayer((player, color) -> + { + final Polygon poly = player.getCanvasTilePoly(); + + if (poly != null) + { OverlayUtil.renderPolygon(graphics, poly, color); } }); + return null; } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java index 8bc136fbb5..a2d47b7695 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java @@ -1,35 +1,41 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; -public enum PlayerSpellEffect { +import lombok.Getter; +import lombok.Setter; + +public enum PlayerSpellEffect +{ + + BARRAGE("Ice Barrage", 20000, false), BLITZ("Ice Blitz", 15000, false); - - private final String SPELL_NAME; - private long startTime; - private int duration; - private boolean halvable; - private PlayerSpellEffect(String name, int duration, boolean halvable) { + @Getter + private final String SPELL_NAME; + @Getter + private long startTime; + @Getter + private int duration; + @Getter + private boolean halvable; + //private final BufferedImage SPELL_ICON; + + + + PlayerSpellEffect(String name, int duration, boolean halvable) + { this.SPELL_NAME = name; this.duration = duration; this.halvable = halvable; this.startTime = System.currentTimeMillis(); } - - public String getSPELL_NAME() { - return this.SPELL_NAME; - } - - public long getStartTime() { - return this.startTime; - } - - public int getDuration() { - return this.duration; - } - - public boolean isHalvable() { - return this.halvable; - } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java index d9033a7c0d..5407951aa8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java @@ -1,34 +1,34 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; +import lombok.Getter; import net.runelite.api.Actor; -public abstract class Spell { +public abstract class Spell +{ + + @Getter private final Actor affectedTarget; + @Getter private final Actor caster; + @Getter public final long startTime; private long remainingTime; + @Getter private boolean isFinished; - protected Spell(Actor affectedTarget, Actor caster) { + protected Spell(Actor affectedTarget, Actor caster) + { this.affectedTarget = affectedTarget; this.caster = caster; - this.startTime = System.currentTimeMillis(); - } - - public Actor getAffectedTarget() { - return this.affectedTarget; - } - - public Actor getCaster() { - return this.caster; - } - - public long getStartTime() { - return this.startTime; - } - - public boolean isFinished() { - return this.isFinished; + startTime = System.currentTimeMillis(); } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java index e61b94fc95..e55b528c11 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java @@ -1,74 +1,70 @@ /* - * Decompiled with CFR 0.139. + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * */ + package net.runelite.client.plugins.pvptools; -import java.awt.BorderLayout; -import java.awt.Canvas; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.LayoutManager; -import java.awt.Point; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.ClipboardOwner; -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; -import java.util.function.Consumer; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; import net.runelite.api.Client; -import net.runelite.client.plugins.pvptools.PvpToolsPlugin; import net.runelite.client.ui.FontManager; -public class CurrentPlayersJFrame -extends JFrame { - public JList currentPlayersJList; +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionListener; +import java.util.List; - CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) { - int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); - int y = client.getCanvas().getLocationOnScreen().y; - JPanel scrollContainerCurrent = new JPanel(new BorderLayout()); - JScrollPane jScrollPane = new JScrollPane(scrollContainerCurrent); - JButton refreshJButton = new JButton("Refresh"); - refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener); - JButton copyJButton = new JButton("Copy List"); - this.currentPlayersJList = new JList(list.toArray()); - ActionListener copyButtonActionListener = e -> { - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuilder stringBuilder = new StringBuilder(); - list.forEach(s -> { - stringBuilder.append((String)s); - stringBuilder.append(System.getProperty("line.separator")); - }); - StringSelection stringSelection = new StringSelection(stringBuilder.toString()); - clipboard.setContents(stringSelection, stringSelection); - }; - copyJButton.addActionListener(copyButtonActionListener); - this.setTitle("Current CC Members"); - this.setDefaultCloseOperation(2); - JLabel titleLabel = new JLabel("Current CC Members"); - titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(1, 18.0f)); - this.currentPlayersJList.setFont(new Font("Arial", 0, 14)); - scrollContainerCurrent.add((Component)refreshJButton, "North"); - scrollContainerCurrent.add((Component)titleLabel, "Center"); - JPanel footerPanel = new JPanel(new BorderLayout()); - footerPanel.add((Component)this.currentPlayersJList, "North"); - footerPanel.add((Component)copyJButton, "Center"); - scrollContainerCurrent.add((Component)footerPanel, "South"); - this.add(jScrollPane); - this.setLocation(x, y); - this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); - this.pack(); - this.setVisible(true); - } +public class CurrentPlayersJFrame extends JFrame +{ + + public JList currentPlayersJList; + + CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) + { + super(); + int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); + int y = client.getCanvas().getLocationOnScreen().y; + JPanel scrollContainerCurrent = new JPanel(new BorderLayout()); + + JScrollPane jScrollPane = new JScrollPane(scrollContainerCurrent); + JButton refreshJButton = new JButton("Refresh"); + refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener); + JButton copyJButton = new JButton("Copy List"); + currentPlayersJList = new JList(list.toArray()); + ActionListener copyButtonActionListener = e -> + { + StringSelection stringSelection; + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuilder stringBuilder = new StringBuilder(); + list.forEach(s -> + { + stringBuilder.append(s); + stringBuilder.append(System.getProperty("line.separator")); + }); + stringSelection = new StringSelection(stringBuilder.toString()); + clipboard.setContents(stringSelection, stringSelection); + }; + copyJButton.addActionListener(copyButtonActionListener); + this.setTitle("Current CC Members"); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + JLabel titleLabel = new JLabel("Current CC Members"); + titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18)); + currentPlayersJList.setFont(new Font("Arial", Font.PLAIN, 14)); + scrollContainerCurrent.add(refreshJButton, BorderLayout.NORTH); + scrollContainerCurrent.add(titleLabel, BorderLayout.CENTER); + JPanel footerPanel = new JPanel(new BorderLayout()); + footerPanel.add(currentPlayersJList, BorderLayout.NORTH); + footerPanel.add(copyJButton, BorderLayout.CENTER); + scrollContainerCurrent.add(footerPanel, BorderLayout.SOUTH); + this.add(jScrollPane); + this.setLocation(x, y); + this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); + this.pack(); + this.setVisible(true); + } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java index 324db3869a..a30dd9a04e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java @@ -1,74 +1,79 @@ /* - * Decompiled with CFR 0.139. + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * */ + package net.runelite.client.plugins.pvptools; import java.awt.BorderLayout; -import java.awt.Canvas; -import java.awt.Component; -import java.awt.Dimension; +import java.awt.Container; import java.awt.Font; -import java.awt.LayoutManager; -import java.awt.Point; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.ClipboardOwner; import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; -import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; -import java.util.function.Consumer; +import java.util.Vector; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import net.runelite.api.ClanMember; import net.runelite.api.Client; -import net.runelite.client.plugins.pvptools.PvpToolsPlugin; import net.runelite.client.ui.FontManager; -public class MissingPlayersJFrame -extends JFrame { - public JList missingPlayersJList; +public class MissingPlayersJFrame extends JFrame +{ - MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) { - int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); - int y = client.getCanvas().getLocationOnScreen().y; - JPanel scrollConatiner = new JPanel(new BorderLayout()); - JScrollPane jScrollPane = new JScrollPane(scrollConatiner); - JButton refreshJButton = new JButton("Refresh"); - refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener); - JButton copyJButton = new JButton("Copy List"); - this.missingPlayersJList = new JList(list.toArray()); - ActionListener copyButtonActionListener = e -> { - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuilder stringBuilder = new StringBuilder(); - list.forEach(s -> { - stringBuilder.append((String)s); - stringBuilder.append(System.getProperty("line.separator")); - }); - StringSelection stringSelection = new StringSelection(stringBuilder.toString()); - clipboard.setContents(stringSelection, stringSelection); - }; - copyJButton.addActionListener(copyButtonActionListener); - this.setTitle("Missing CC Members"); - this.setDefaultCloseOperation(2); - JLabel titleLabel = new JLabel("Missing CC Members"); - titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(1, 18.0f)); - this.missingPlayersJList.setFont(new Font("Arial", 0, 14)); - scrollConatiner.add((Component)refreshJButton, "North"); - scrollConatiner.add((Component)titleLabel, "Center"); - JPanel footerPanel = new JPanel(new BorderLayout()); - footerPanel.add((Component)this.missingPlayersJList, "North"); - footerPanel.add((Component)copyJButton, "Center"); - scrollConatiner.add((Component)footerPanel, "South"); - this.add(jScrollPane); - this.setLocation(x, y); - this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); - this.pack(); - this.setVisible(true); - } + public JList missingPlayersJList; + + MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) + { + super(); + int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); + int y = client.getCanvas().getLocationOnScreen().y; + JPanel scrollConatiner = new JPanel(new BorderLayout()); + + JScrollPane jScrollPane = new JScrollPane(scrollConatiner); + JButton refreshJButton = new JButton("Refresh"); + refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener); + JButton copyJButton = new JButton("Copy List"); + missingPlayersJList = new JList(list.toArray()); + ActionListener copyButtonActionListener = e -> + { + StringSelection stringSelection; + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuilder stringBuilder = new StringBuilder(); + list.forEach(s -> + { + stringBuilder.append(s); + stringBuilder.append(System.getProperty("line.separator")); + }); + stringSelection = new StringSelection(stringBuilder.toString()); + clipboard.setContents(stringSelection, stringSelection); + }; + copyJButton.addActionListener(copyButtonActionListener); + this.setTitle("Missing CC Members"); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + JLabel titleLabel = new JLabel("Missing CC Members"); + titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18)); + missingPlayersJList.setFont(new Font("Arial", Font.PLAIN, 14)); + scrollConatiner.add(refreshJButton, BorderLayout.NORTH); + scrollConatiner.add(titleLabel, BorderLayout.CENTER); + JPanel footerPanel = new JPanel(new BorderLayout()); + footerPanel.add(missingPlayersJList, BorderLayout.NORTH); + footerPanel.add(copyJButton, BorderLayout.CENTER); + scrollConatiner.add(footerPanel, BorderLayout.SOUTH); + this.add(jScrollPane); + this.setLocation(x, y); + this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); + this.pack(); + this.setVisible(true); + } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java index d88182db0e..a6a1392763 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java @@ -1,69 +1,147 @@ /* - * Decompiled with CFR 0.139. + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * */ + package net.runelite.client.plugins.pvptools; +import java.awt.Color; +import java.security.Key; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; import net.runelite.client.config.Keybind; -@ConfigGroup(value="pvptools") -public interface PvpToolsConfig -extends Config { - @ConfigItem(keyName="countPlayers", name="Count Players", description="When in PvP zones, counts the attackable players in and not in player's CC", position=3) - default public boolean countPlayers() { - return true; - } +@ConfigGroup("pvptools") +public interface PvpToolsConfig extends Config +{ + @ConfigItem( + keyName = "countPlayers", + name = "Count Players", + description = "When in PvP zones, counts the attackable players in and not in player's CC", + position = 3 + ) + default boolean countPlayers() + { + return true; + } - @ConfigItem(keyName="countOverHeads", name="Count Enemy Overheads", description="Counts the number of each protection prayer attackable targets not in your CC are currently using", position=4) - default public boolean countOverHeads() { - return true; - } + @ConfigItem( + keyName = "countOverHeads", + name = "Count Enemy Overheads", + description = "Counts the number of each protection prayer attackable targets not in your CC are currently" + + " using", + position = 4 + ) + default boolean countOverHeads() + { + return true; + } - @ConfigItem(keyName="fallInHelper", name="Fall In Helper", description="Hides all non-friendly player entities other than the one that is attacking you.", position=5) - default public boolean fallInHelper() { - return true; - } + @ConfigItem( + keyName = "fallInHelper", + name = "Fall In Helper", + description = "Hides all non-friendly player entities other than the one that is attacking you.", + position = 5 + ) + default boolean fallInHelper() + { + return true; + } - @ConfigItem(keyName="hotkey", name="Fall In Hotkey", description="Turns the fall in helper on or off when you press this hotkey", position=6) - default public Keybind hotkey() { - return Keybind.NOT_SET; - } + @ConfigItem( + keyName = "hotkey", + name = "Fall In Hotkey", + description = "Turns the fall in helper on or off when you press this hotkey", + position = 6 + ) + default Keybind hotkey() + { + return Keybind.NOT_SET; + } - @ConfigItem(keyName="attackOptionsClan", name="Hide CC Attack Option", description="Hides the attack option for people in the same CC", position=7) - default public boolean attackOptionsClan() { - return false; - } + @ConfigItem( + keyName = "attackOptionsClan", + name = "Move CC Attack Option", + description = "Moves the attack option for people in the same CC", + position = 7, + group = "Right-Click Attack Options" + ) + default boolean attackOptionsClan() + { + return false; + } - @ConfigItem(keyName="attackOptionsFriend", name="Hide Friend Attack Options", description="Hides the attack option for people on your friends list", position=8) - default public boolean attackOptionsFriend() { - return false; - } + @ConfigItem( + keyName = "attackOptionsFriend", + name = "Move Friend Attack Options", + description = "Moves the attack option for people on your friends list", + position = 8, + group = "Right-Click Attack Options" + ) + default boolean attackOptionsFriend() + { + return false; + } - @ConfigItem(keyName="attackOptionsHotkey", name="Attack Option Hotkey", description="Enables a hotkey for attack options to disable or enable hiding quickly", position=10) - default public Keybind attackOptionsHotkey() { - return Keybind.CTRL; - } + @ConfigItem( + keyName = "attackOptionsHotkey", + name = "Attack Option Hotkey", + description = "Enables a hotkey for attack options to disable or enable hiding quickly", + position = 10, + group = "Right-Click Attack Options" + ) + default Keybind attackOptionsHotkey() + { + return Keybind.CTRL; + } - @ConfigItem(keyName="levelRangeAttackOptions", name="Hide Other Attack Options", description="Hides the attack option for people that are outside your level range", position=9) - default public boolean levelRangeAttackOptions() { - return false; - } + @ConfigItem( + keyName = "levelRangeAttackOptions", + name = "Moves Other Attack Options", + description = "Moves the attack option for people that are outside your level range", + position = 9, + group = "Right-Click Attack Options" + ) + default boolean levelRangeAttackOptions() + { + return false; + } - @ConfigItem(keyName="riskCalculator", name="Risk Calculator", description="Enables a panel in the PvP Tools Panel that shows the players current risk", position=13) - default public boolean riskCalculatorEnabled() { - return true; - } + @ConfigItem( + keyName = "riskCalculator", + name = "Risk Calculator", + description = "Enables a panel in the PvP Tools Panel that shows the players current risk", + position = 13 + ) + default boolean riskCalculatorEnabled() + { + return true; + } - @ConfigItem(keyName="missingPlayers", name="Missing CC Players", description="Adds a button to the PvP Tools panel that opens a window showing which CC members are not at the current players location", position=14) - default public boolean missingPlayersEnabled() { - return true; - } + @ConfigItem( + keyName = "missingPlayers", + name = "Missing CC Players", + description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at" + + " the current players location", + position = 14 + ) + default boolean missingPlayersEnabled() { return true; } + + @ConfigItem( + keyName = "currentPlayers", + name = "Current CC Players", + description = "Adds a button to the PvP Tools panel that opens a window showing which CC members currently at" + + " the players location", + position = 15 + ) + default boolean currentPlayersEnabled() + { + return true; + } - @ConfigItem(keyName="currentPlayers", name="Current CC Players", description="Adds a button to the PvP Tools panel that opens a window showing which CC members currently at the players location", position=15) - default public boolean currentPlayersEnabled() { - return true; - } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java index b24b66dab7..f9abf719c7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java @@ -1,21 +1,23 @@ /* - * Decompiled with CFR 0.139. + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * */ + package net.runelite.client.plugins.pvptools; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.Polygon; -import java.awt.Shape; -import java.awt.Stroke; +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; import javax.inject.Inject; + +import net.runelite.api.Actor; import net.runelite.api.Client; +import net.runelite.api.Player; import net.runelite.api.Point; -import net.runelite.client.plugins.pvptools.PvpToolsConfig; -import net.runelite.client.plugins.pvptools.PvpToolsPlugin; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; @@ -23,39 +25,47 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; -public class PvpToolsOverlay -extends Overlay { - private PvpToolsPlugin pvpToolsPlugin; - private PvpToolsConfig pvpToolsConfig; - private Client client; +public class PvpToolsOverlay extends Overlay +{ + private PvpToolsPlugin pvpToolsPlugin; + private PvpToolsConfig pvpToolsConfig; + private Client client; - @Inject - private PvpToolsOverlay(PvpToolsConfig pvpToolsConfig, PvpToolsPlugin pvpToolsPlugin, Client client) { - this.pvpToolsPlugin = pvpToolsPlugin; - this.pvpToolsConfig = pvpToolsConfig; - this.client = client; - this.setLayer(OverlayLayer.ABOVE_WIDGETS); - this.setPriority(OverlayPriority.HIGH); - this.setPosition(OverlayPosition.DYNAMIC); - } - - @Override - public Dimension render(Graphics2D graphics) { - if (this.pvpToolsConfig.fallInHelper() && this.pvpToolsPlugin.fallinHelperEnabled) { - graphics.setFont(FontManager.getRunescapeFont().deriveFont(28)); - OverlayUtil.renderTextLocation(graphics, new Point(200, 80), "FALL IN HELPER ENABLED", Color.YELLOW); - } - return null; - } - - private void renderPoly(Graphics2D graphics, Color color, Polygon polygon) { - if (polygon != null) { - graphics.setColor(color); - graphics.setStroke(new BasicStroke(2.0f)); - graphics.draw(polygon); - graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); - graphics.fill(polygon); - } - } + @Inject + private PvpToolsOverlay(PvpToolsConfig pvpToolsConfig, PvpToolsPlugin pvpToolsPlugin, Client client) + { + this.pvpToolsPlugin = pvpToolsPlugin; + this.pvpToolsConfig = pvpToolsConfig; + this.client = client; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DYNAMIC); } + + @Override + public Dimension render(Graphics2D graphics) + { + if (pvpToolsConfig.fallInHelper()) + { + if (pvpToolsPlugin.fallinHelperEnabled) + { + graphics.setFont(FontManager.getRunescapeFont().deriveFont(28)); + OverlayUtil.renderTextLocation(graphics, new Point(200, 80), "FALL IN HELPER ENABLED", Color.YELLOW); + } + } + return null; + } + + private void renderPoly(Graphics2D graphics, Color color, Polygon polygon) + { + if (polygon != null) + { + graphics.setColor(color); + graphics.setStroke(new BasicStroke(2)); + graphics.draw(polygon); + graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); + graphics.fill(polygon); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java index 8856c37b32..9d82932fa2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java @@ -1,138 +1,166 @@ /* - * Decompiled with CFR 0.139. + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * */ + package net.runelite.client.plugins.pvptools; import com.google.common.base.MoreObjects; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.Font; import java.awt.GridLayout; -import java.awt.LayoutManager; import javax.inject.Inject; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.border.Border; import javax.swing.border.EmptyBorder; +import lombok.extern.slf4j.Slf4j; import net.runelite.client.RuneLiteProperties; import net.runelite.client.plugins.info.JRichTextPane; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.PluginPanel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class PvpToolsPanel -extends PluginPanel { - private static final Logger log = LoggerFactory.getLogger(PvpToolsPanel.class); - private final JLabel loggedLabel = new JLabel(); - private final JRichTextPane emailLabel = new JRichTextPane(); - public JLabel numCC = new JLabel(); - public JLabel numOther = new JLabel(); - public JLabel numMageJLabel = new JLabel(" "); - public JLabel numRangeJLabel = new JLabel(" "); - public JLabel numMeleeJLabel = new JLabel(" "); - public JLabel totalRiskLabel = new JLabel(" "); - public JLabel riskProtectingItem = new JLabel(" "); - public JLabel biggestItemLabel = new JLabel("Protected Item: "); - public JButton missingPlayers = new JButton("Show missing CC members"); - public JButton currentPlayers = new JButton("Show current CC members"); - public JLabel numBrews = new JLabel(); - @Inject - private JPanel pvpToolsPanel = new JPanel(new GridLayout(11, 1)); - private JPanel missingPlayersPanel = new JPanel(); - private JPanel currentPlayersPanel = new JPanel(); +@Slf4j +public class PvpToolsPanel extends PluginPanel +{ - public static String htmlLabel(String key, String value) { - return "" + key + "" + value + ""; - } + private final JLabel loggedLabel = new JLabel(); + private final JRichTextPane emailLabel = new JRichTextPane(); + public JLabel numCC = new JLabel(); + public JLabel numOther = new JLabel(); + public JLabel numMageJLabel = new JLabel(" "); + public JLabel numRangeJLabel = new JLabel(" "); + public JLabel numMeleeJLabel = new JLabel(" "); + public JLabel totalRiskLabel = new JLabel(" "); + public JLabel riskProtectingItem = new JLabel(" "); + public JLabel biggestItemLabel = new JLabel("Protected Item: "); + public JButton missingPlayers = new JButton("Show missing CC members"); + public JButton currentPlayers = new JButton("Show current CC members"); + public JLabel numBrews = new JLabel(); + @Inject + private JPanel pvpToolsPanel = new JPanel(new GridLayout(11, 1)); + private JPanel missingPlayersPanel = new JPanel(); + private JPanel currentPlayersPanel = new JPanel(); - void init() { - this.setLayout(new BorderLayout()); - this.setBackground(ColorScheme.DARK_GRAY_COLOR); - this.setBorder(new EmptyBorder(10, 10, 10, 10)); - JPanel versionPanel = new JPanel(); - versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); - versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); - versionPanel.setLayout(new GridLayout(0, 1)); - JPanel riskPanel = new JPanel(); - riskPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); - riskPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); - riskPanel.setLayout(new GridLayout(0, 1)); - Font smallFont = FontManager.getRunescapeSmallFont(); - this.numCC.setText(PvpToolsPanel.htmlLabel("Friendly Player Count: ", "0")); - this.numOther.setText(PvpToolsPanel.htmlLabel("Other Player Count: ", "0")); - this.numBrews.setText(PvpToolsPanel.htmlLabel("Player brew count: ", "0")); - this.numMageJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Mage: ", "0")); - this.numMageJLabel.setFont(FontManager.getRunescapeFont()); - this.numRangeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Range: ", "0")); - this.numRangeJLabel.setFont(FontManager.getRunescapeFont()); - this.numMeleeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Melee: ", "0")); - this.numMeleeJLabel.setFont(FontManager.getRunescapeFont()); - this.totalRiskLabel.setText(PvpToolsPanel.htmlLabel("Total risk: ", "0")); - this.totalRiskLabel.setFont(FontManager.getRunescapeFont()); - this.riskProtectingItem.setText(PvpToolsPanel.htmlLabel("Risk Protecting Item: ", "0")); - this.riskProtectingItem.setFont(FontManager.getRunescapeFont()); - this.biggestItemLabel.setText("Most Valuable Item: "); - JLabel revision = new JLabel(); - revision.setFont(smallFont); - revision.setText("Oldschool revision: "); - JLabel launcher = new JLabel(PvpToolsPanel.htmlLabel("Launcher version: ", MoreObjects.firstNonNull(RuneLiteProperties.getLauncherVersion(), "Unknown"))); - launcher.setFont(smallFont); - this.loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR); - this.loggedLabel.setFont(smallFont); - this.emailLabel.setForeground(Color.WHITE); - this.emailLabel.setFont(smallFont); - versionPanel.add(this.numCC); - versionPanel.add(this.numOther); - versionPanel.add(this.numBrews); - versionPanel.add(this.numMageJLabel); - versionPanel.add(this.numRangeJLabel); - versionPanel.add(this.numMeleeJLabel); - versionPanel.add(Box.createGlue()); - versionPanel.add(this.loggedLabel); - versionPanel.add(this.emailLabel); - riskPanel.add(this.totalRiskLabel); - riskPanel.add(this.riskProtectingItem); - riskPanel.add(this.biggestItemLabel); - this.add((Component)versionPanel, "North"); - this.add((Component)riskPanel, "Center"); - this.currentPlayers.setVisible(false); - this.missingPlayers.setVisible(false); - this.missingPlayersPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); - this.missingPlayersPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); - this.missingPlayersPanel.setLayout(new GridLayout(0, 1)); - this.missingPlayersPanel.add((Component)this.missingPlayers, "Last"); - this.missingPlayersPanel.add((Component)this.currentPlayers, "Last"); - this.add((Component)this.missingPlayersPanel, "Last"); - } - public void disablePlayerCount() { - this.numOther.setText("Disabled"); - this.numCC.setText("Disabled"); - this.numCC.repaint(); - this.numOther.repaint(); - } + public static String htmlLabel(String key, String value) + { + return "" + key + "" + value + ""; + } - public void disablePrayerCount() { - this.numMageJLabel.setText("disabled"); - this.numRangeJLabel.setText("disabled"); - this.numMeleeJLabel.setText("disabled"); - this.numMageJLabel.repaint(); - this.numRangeJLabel.repaint(); - this.numMeleeJLabel.repaint(); - } + void init() + { + setLayout(new BorderLayout()); + setBackground(ColorScheme.DARK_GRAY_COLOR); + setBorder(new EmptyBorder(10, 10, 10, 10)); - public void disableRiskCalculator() { - this.totalRiskLabel.setText("disabled"); - this.riskProtectingItem.setText("disabled"); - this.biggestItemLabel.setText("disabled"); - this.totalRiskLabel.repaint(); - this.riskProtectingItem.repaint(); - this.biggestItemLabel.repaint(); - } + + + JPanel versionPanel = new JPanel(); + versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + versionPanel.setLayout(new GridLayout(0, 1)); + + JPanel riskPanel = new JPanel(); + riskPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + riskPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + riskPanel.setLayout(new GridLayout(0, 1)); + + final Font smallFont = FontManager.getRunescapeSmallFont(); + + numCC.setText(htmlLabel("Friendly Player Count: ", "0")); + numOther.setText(htmlLabel("Other Player Count: ", "0")); + numBrews.setText(htmlLabel("Player brew count: ", "0")); + numMageJLabel.setText(htmlLabel("Enemies Praying Mage: ", "0")); + numMageJLabel.setFont(FontManager.getRunescapeFont()); + numRangeJLabel.setText(htmlLabel("Enemies Praying Range: ", "0")); + numRangeJLabel.setFont(FontManager.getRunescapeFont()); + numMeleeJLabel.setText(htmlLabel("Enemies Praying Melee: ", "0")); + numMeleeJLabel.setFont(FontManager.getRunescapeFont()); + + totalRiskLabel.setText(htmlLabel("Total risk: ", "0")); + totalRiskLabel.setFont(FontManager.getRunescapeFont()); + riskProtectingItem.setText(htmlLabel("Risk Protecting Item: ", "0")); + riskProtectingItem.setFont(FontManager.getRunescapeFont()); + biggestItemLabel.setText("Most Valuable Item: "); + + + JLabel revision = new JLabel(); + revision.setFont(smallFont); + + revision.setText("Oldschool revision: "); + + JLabel launcher = new JLabel(htmlLabel("Launcher version: ", MoreObjects + .firstNonNull(RuneLiteProperties.getLauncherVersion(), "Unknown"))); + launcher.setFont(smallFont); + + loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR); + loggedLabel.setFont(smallFont); + + emailLabel.setForeground(Color.WHITE); + emailLabel.setFont(smallFont); + + versionPanel.add(numCC); + versionPanel.add(numOther); + versionPanel.add(numBrews); + versionPanel.add(numMageJLabel); + versionPanel.add(numRangeJLabel); + versionPanel.add(numMeleeJLabel); + + versionPanel.add(Box.createGlue()); + versionPanel.add(loggedLabel); + versionPanel.add(emailLabel); + + riskPanel.add(totalRiskLabel); + riskPanel.add(riskProtectingItem); + riskPanel.add(biggestItemLabel); + + add(versionPanel, BorderLayout.NORTH); + add(riskPanel, BorderLayout.CENTER); + + currentPlayers.setVisible(false); + missingPlayers.setVisible(false); + missingPlayersPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + missingPlayersPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + missingPlayersPanel.setLayout(new GridLayout(0, 1)); + missingPlayersPanel.add(missingPlayers, BorderLayout.AFTER_LAST_LINE); + missingPlayersPanel.add(currentPlayers, BorderLayout.AFTER_LAST_LINE); + add(missingPlayersPanel, BorderLayout.AFTER_LAST_LINE); + + } + + public void disablePlayerCount() + { + this.numOther.setText("Disabled"); + this.numCC.setText("Disabled"); + this.numCC.repaint(); + this.numOther.repaint(); + } + + public void disablePrayerCount() + { + this.numMageJLabel.setText("disabled"); + this.numRangeJLabel.setText("disabled"); + this.numMeleeJLabel.setText("disabled"); + this.numMageJLabel.repaint(); + this.numRangeJLabel.repaint(); + this.numMeleeJLabel.repaint(); + } + + public void disableRiskCalculator() + { + this.totalRiskLabel.setText("disabled"); + this.riskProtectingItem.setText("disabled"); + this.biggestItemLabel.setText("disabled"); + this.totalRiskLabel.repaint(); + this.riskProtectingItem.repaint(); + this.biggestItemLabel.repaint(); + } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java index 4bf40b3a9a..b36894ab54 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java @@ -1,475 +1,691 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.pvptools; -import javax.inject.*; - -import com.google.inject.Inject; -import net.runelite.client.plugins.*; -import net.runelite.client.plugins.clanchat.*; -import java.util.function.*; -import java.awt.event.*; -import java.util.stream.*; -import java.util.concurrent.*; -import net.runelite.client.config.*; -import com.google.inject.*; -import net.runelite.client.ui.overlay.*; -import net.runelite.client.input.*; -import net.runelite.client.ui.*; -import java.awt.image.*; -import net.runelite.client.eventbus.*; -import org.apache.commons.lang3.*; -import net.runelite.api.events.*; -import net.runelite.client.util.*; -import net.runelite.api.*; -import net.runelite.client.game.*; -import java.util.*; +import com.google.inject.Provides; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.NavigableMap; +import java.util.Objects; +import java.util.TreeMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ScheduledExecutorService; +import java.util.stream.Collectors; +import javax.inject.Inject; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import net.runelite.api.ClanMember; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.InventoryID; +import net.runelite.api.Item; +import net.runelite.api.ItemComposition; +import net.runelite.api.MenuEntry; +import net.runelite.api.Player; +import net.runelite.api.SkullIcon; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.FocusChanged; +import net.runelite.api.events.GameStateChanged; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.api.events.MenuEntryAdded; +import net.runelite.api.events.PlayerDespawned; +import net.runelite.api.events.PlayerSpawned; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.game.AsyncBufferedImage; +import net.runelite.client.game.ClanManager; +import net.runelite.client.game.ItemManager; +import net.runelite.client.input.KeyManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginManager; +import net.runelite.client.plugins.clanchat.ClanChatPlugin; +import static net.runelite.client.plugins.pvptools.PvpToolsPanel.htmlLabel; +import net.runelite.client.ui.ClientToolbar; +import net.runelite.client.ui.NavigationButton; +import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.util.HotkeyListener; +import net.runelite.client.util.ImageUtil; +import net.runelite.client.util.PvPUtil; +import static net.runelite.client.util.StackFormatter.quantityToRSDecimalStack; +import net.runelite.client.util.Text; +import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( - name = "PvP Tools", - description = "Enable the PvP Tools panel", - tags = { "panel", "pvp", "pk", "pklite" }, - type="PVP" + name = "PvP Tools", + description = "Enable the PvP Tools panel", + tags = {"panel", "pvp", "pk", "pklite"} ) public class PvpToolsPlugin extends Plugin { - @Inject - PvpToolsOverlay pvpToolsOverlay; - boolean fallinHelperEnabled; - private PvpToolsPanel panel; - private MissingPlayersJFrame missingPlayersJFrame; - private CurrentPlayersJFrame currentPlayersJFrame; - private NavigationButton navButton; - private boolean attackHotKeyPressed; - private boolean hideAll; - @Inject - private ScheduledExecutorService executorService; - @Inject - private OverlayManager overlayManager; - @Inject - private Client client; - @Inject - private ItemManager itemManager; - private PvpToolsPlugin uhPvpToolsPlugin; - final ActionListener playersButtonActionListener; - final ActionListener currentPlayersActionListener; - @Inject - private ClientToolbar clientToolbar; - @Inject - private KeyManager keyManager; - @Inject - private PvpToolsConfig config; - @Inject - private PluginManager pluginManager; - @Inject - private ClanManager clanManager; - private ClanChatPlugin clanChatPlugin; - private final HotkeyListener hotkeyListener; - private final HotkeyListener attackOptionsHotKeyListener; - private int[] overheadCount; - private Comparator itemPriceComparator; - private String mtarget; + @Inject + PvpToolsOverlay pvpToolsOverlay; + boolean fallinHelperEnabled = false; + private PvpToolsPanel panel; + private MissingPlayersJFrame missingPlayersJFrame; + private CurrentPlayersJFrame currentPlayersJFrame; + private NavigationButton navButton; + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) + private boolean attackHotKeyPressed; + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) + private boolean hideAll; + @Inject + private ScheduledExecutorService executorService; + @Inject + private OverlayManager overlayManager; + @Inject + private Client client; + @Inject + private ItemManager itemManager; + private PvpToolsPlugin uhPvpToolsPlugin = this; - public PvpToolsPlugin() { - this.fallinHelperEnabled = false; - this.uhPvpToolsPlugin = this; - this.playersButtonActionListener = new ActionListener() { - @Override - public void actionPerformed(final ActionEvent e) { - if (PvpToolsPlugin.this.missingPlayersJFrame != null) { - PvpToolsPlugin.this.missingPlayersJFrame.dispose(); - PvpToolsPlugin.this.missingPlayersJFrame = null; - PvpToolsPlugin.this.missingPlayersJFrame = new MissingPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getMissingMembers()); - } - else { - PvpToolsPlugin.this.missingPlayersJFrame = new MissingPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getMissingMembers()); - } - } - }; - this.currentPlayersActionListener = new ActionListener() { - @Override - public void actionPerformed(final ActionEvent e) { - if (PvpToolsPlugin.this.currentPlayersJFrame != null) { - PvpToolsPlugin.this.currentPlayersJFrame.dispose(); - PvpToolsPlugin.this.currentPlayersJFrame = null; - PvpToolsPlugin.this.currentPlayersJFrame = new CurrentPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getCurrentMembers()); - } - else { - PvpToolsPlugin.this.currentPlayersJFrame = new CurrentPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getCurrentMembers()); - } - } - }; - this.hotkeyListener = new HotkeyListener(() -> this.config.hotkey()) { - @Override - public void hotkeyPressed() { - PvpToolsPlugin.this.toggleFallinHelper(); - } - }; - this.attackOptionsHotKeyListener = new HotkeyListener(() -> this.config.attackOptionsHotkey()) { - long lastPress = 0L; + /** + * ActionListener for the missing cc members and refresh buttons + */ + final ActionListener playersButtonActionListener = new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + if (missingPlayersJFrame != null) + { + missingPlayersJFrame.dispose(); + missingPlayersJFrame = null; + missingPlayersJFrame = new MissingPlayersJFrame(client, uhPvpToolsPlugin, getMissingMembers()); + } + else + { + missingPlayersJFrame = new MissingPlayersJFrame(client, uhPvpToolsPlugin, getMissingMembers()); + } + } + }; - @Override - public void keyPressed(final KeyEvent e) { - PvpToolsPlugin.this.attackHotKeyPressed = true; - } + final ActionListener currentPlayersActionListener = new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + if (currentPlayersJFrame != null) + { + currentPlayersJFrame.dispose(); + currentPlayersJFrame = null; + currentPlayersJFrame = new CurrentPlayersJFrame(client, uhPvpToolsPlugin, getCurrentMembers()); + } + else + { + currentPlayersJFrame = new CurrentPlayersJFrame(client, uhPvpToolsPlugin, getCurrentMembers()); + } + } + }; - @Override - public void keyReleased(final KeyEvent e) { - PvpToolsPlugin.this.attackHotKeyPressed = (System.currentTimeMillis() - this.lastPress < 800L); - this.lastPress = System.currentTimeMillis(); - } - }; - this.overheadCount = new int[] { 0, 0, 0 }; - this.itemPriceComparator = new Comparator() { - @Override - public int compare(final Item o1, final Item o2) { - return PvpToolsPlugin.this.itemManager.getItemPrice(PvpToolsPlugin.this.itemManager.getItemComposition(o1.getId()).getPrice()) - PvpToolsPlugin.this.itemManager.getItemPrice(PvpToolsPlugin.this.itemManager.getItemComposition(o2.getId()).getPrice()); - } - }; - } - public List getMissingMembers() { - CopyOnWriteArrayList ccMembers = ClanChatPlugin.getClanMembers(); - ArrayList missingMembers = new ArrayList(); - for (ClanMember clanMember : this.client.getClanMembers()) { - List arrayList; - if (Objects.isNull(clanMember) || (arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList())).contains(Text.removeTags(Text.standardize(clanMember.getUsername()))) || missingMembers.contains(clanMember.getUsername())) continue; - missingMembers.add("[W" + clanMember.getWorld() + "] - " + clanMember.getUsername()); - } - return missingMembers; - } + @Inject + private ClientToolbar clientToolbar; - public List getCurrentMembers() { - CopyOnWriteArrayList ccMembers = ClanChatPlugin.getClanMembers(); - ArrayList currentMembers = new ArrayList(); - for (ClanMember clanMember : this.client.getClanMembers()) { - List arrayList; - if (Objects.isNull(clanMember) || !(arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList())).contains(Text.removeTags(Text.standardize(clanMember.getUsername()))) || currentMembers.contains(clanMember.getUsername())) continue; - currentMembers.add(clanMember.getUsername()); - } - return currentMembers; - } + @Inject + private KeyManager keyManager; - @Provides - PvpToolsConfig config(final ConfigManager configManager) { - return configManager.getConfig(PvpToolsConfig.class); - } + @Inject + private PvpToolsConfig config; - @Override - protected void startUp() throws Exception { - this.overlayManager.add(this.pvpToolsOverlay); - this.keyManager.registerKeyListener(this.hotkeyListener); - final BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "skull.png"); - (this.panel = new PvpToolsPanel()).init(); - this.navButton = NavigationButton.builder().tooltip("PvP Tools").icon(icon).priority(5).panel(this.panel).build(); - this.panel.missingPlayers.addActionListener(this.playersButtonActionListener); - this.panel.currentPlayers.addActionListener(this.currentPlayersActionListener); - this.clientToolbar.addNavigation(this.navButton); - this.keyManager.registerKeyListener(this.attackOptionsHotKeyListener); - if (this.config.missingPlayersEnabled()) { - this.panel.missingPlayers.setVisible(true); - } - if (this.config.currentPlayersEnabled()) { - this.panel.currentPlayers.setVisible(true); - } - } + @Inject + private PluginManager pluginManager; - @Override - protected void shutDown() throws Exception { - this.overlayManager.remove(this.pvpToolsOverlay); - this.keyManager.unregisterKeyListener(this.hotkeyListener); - this.keyManager.unregisterKeyListener(this.attackOptionsHotKeyListener); - this.clientToolbar.removeNavigation(this.navButton); - } + @Inject + private ClanManager clanManager; - @Subscribe - public void onConfigChanged(final ConfigChanged configChanged) { - if (configChanged.getGroup().equals("pvptools")) { - final String key = configChanged.getKey(); - switch (key) { - case "countPlayers": { - if (this.config.countPlayers()) { - this.updatePlayers(); - } - if (!this.config.countPlayers()) { - this.panel.disablePlayerCount(); - break; - } - break; - } - case "countOverHeads": { - if (this.config.countOverHeads()) { - this.countOverHeads(); - } - if (!this.config.countOverHeads()) { - this.panel.disablePrayerCount(); - break; - } - break; - } - case "riskCalculator": { - if (this.config.riskCalculatorEnabled()) { - this.getCarriedWealth(); - } - if (!this.config.riskCalculatorEnabled()) { - this.panel.disableRiskCalculator(); - break; - } - break; - } - case "missingPlayers": { - if (this.config.missingPlayersEnabled()) { - this.panel.missingPlayers.setVisible(true); - break; - } - break; - } - case "currentPlayers": { - if (this.config.currentPlayersEnabled()) { - this.panel.currentPlayers.setVisible(true); - break; - } - break; - } - } - } - } - @Subscribe - public void onItemContainerChanged(final ItemContainerChanged event) { - if (event.getItemContainer().equals(this.client.getItemContainer(InventoryID.INVENTORY)) && this.config.riskCalculatorEnabled()) { - this.getCarriedWealth(); - } - } + private ClanChatPlugin clanChatPlugin; + /** + * The HotKeyListener for the hot key assigned in the config that triggers the Fall In Helper feature + */ + private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey()) + { + public void hotkeyPressed() + { + toggleFallinHelper(); + } + }; - @Subscribe - public void onGameStateChanged(final GameStateChanged event) { - if (event.getGameState().equals(GameState.LOGGED_IN) && this.config.riskCalculatorEnabled()) { - this.getCarriedWealth(); - } - if (event.getGameState().equals(GameState.LOGGED_IN) && this.config.countPlayers()) { - this.updatePlayers(); - } - } - @Subscribe - public void onPlayerSpawned(final PlayerSpawned event) { - if (this.config.countPlayers() && PvPUtil.isAttackable(this.client, event.getPlayer())) { - this.updatePlayers(); - } - if (this.config.countOverHeads()) { - this.countOverHeads(); - } - } + private final HotkeyListener attackOptionsHotKeyListener = new HotkeyListener(() -> config.attackOptionsHotkey()) + { + long lastPress = 0; - @Subscribe - public void onPlayerDespawned(final PlayerDespawned event) { - if (this.config.countPlayers() && PvPUtil.isAttackable(this.client, event.getPlayer())) { - this.updatePlayers(); - } - if (this.config.countOverHeads()) { - this.countOverHeads(); - } - } + @Override + public void keyPressed(KeyEvent e) + { + attackHotKeyPressed = true; + } - @Subscribe - public void onMenuEntryAdded(final MenuEntryAdded menuEntryAdded) { - if (!this.attackHotKeyPressed && (this.config.attackOptionsFriend() || this.config.attackOptionsClan() || this.config.levelRangeAttackOptions())) { - if (this.client.getGameState() != GameState.LOGGED_IN) { - return; - } - final Player[] players = this.client.getCachedPlayers(); - Player player = null; - final int identifier = menuEntryAdded.getIdentifier(); - if (identifier >= 0 && identifier < players.length) { - player = players[identifier]; - } - if (player == null) { - return; - } - final String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase(); - final String mtarget = Text.removeTags(menuEntryAdded.getTarget()).toLowerCase(); - if ((this.attackHotKeyPressed && this.config.attackOptionsClan()) || this.config.attackOptionsFriend() || this.config.levelRangeAttackOptions()) { - if (this.config.attackOptionsFriend() && player.isFriend()) { - this.moveEntry(mtarget); - } - if (this.config.attackOptionsClan() && player.isClanMember()) { - this.moveEntry(mtarget); - } - if (this.config.levelRangeAttackOptions() && !PvPUtil.isAttackable(this.client, player)) { - this.moveEntry(mtarget); - } - } - } - } + @Override + public void keyReleased(KeyEvent e) + { + attackHotKeyPressed = (System.currentTimeMillis() - lastPress) < 800; + lastPress = System.currentTimeMillis(); + } + }; - private void moveEntry(final String mtarget) { - this.mtarget = mtarget; - MenuEntry[] menuEntries = this.client.getMenuEntries(); - final MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; - String target = lastEntry.getTarget(); - final int idx = target.indexOf(62); - if (idx != -1) { - target = target.substring(idx + 1); - } - if (menuEntries[menuEntries.length - 1] != null) {} - if (lastEntry.getOption().contains("attack".toLowerCase())) { - menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1); - } - if (lastEntry.getOption().equals("Attack")) { - menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1); - } - this.client.setMenuEntries(menuEntries); - } + private int[] overheadCount = new int[]{0, 0, 0}; - @Subscribe - public void onFocusChanged(final FocusChanged focusChanged) { - if (!focusChanged.isFocused()) { - this.setAttackHotKeyPressed(false); - } - } + private Comparator itemPriceComparator = new Comparator() + { + @Override + public int compare(Item o1, Item o2) + { + return (itemManager.getItemPrice(itemManager.getItemComposition(o1.getId()).getPrice()) + - itemManager.getItemPrice(itemManager.getItemComposition(o2.getId()).getPrice())); + } + }; + private String mtarget; - private void toggleFallinHelper() { - if (!this.fallinHelperEnabled) { - this.client.setIsHidingEntities(true); - this.client.setPlayersHidden(true); - this.fallinHelperEnabled = true; - } - else { - this.client.setIsHidingEntities(false); - this.client.setPlayersHidden(false); - this.fallinHelperEnabled = false; - } - } + public List getMissingMembers() + { + CopyOnWriteArrayList ccMembers = ClanChatPlugin.getClanMembers(); + ArrayList missingMembers = new ArrayList(); + for (ClanMember clanMember:client.getClanMembers()) + { + if (!Objects.isNull(clanMember)) + { + List arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList()); + if (!arrayList.contains(Text.removeTags(Text.standardize(clanMember.getUsername())))) + { + if (!missingMembers.contains(clanMember.getUsername())) + { + missingMembers.add("[W" + clanMember.getWorld() + "] - " + clanMember.getUsername()); + } + } + } + } - private void updatePrayerNumbers() { - this.panel.numMageJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Mage: ", String.valueOf(this.overheadCount[0]))); - this.panel.numRangeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Range: ", String.valueOf(this.overheadCount[1]))); - this.panel.numMeleeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Melee: ", String.valueOf(this.overheadCount[2]))); - this.panel.numMageJLabel.repaint(); - this.panel.numRangeJLabel.repaint(); - this.panel.numMeleeJLabel.repaint(); - } + return missingMembers; - private void updatePlayers() { - if (this.config.countPlayers()) { - int cc = 0; - int other = 0; - for (final Player p : this.client.getPlayers()) { - if (Objects.nonNull(p) && PvPUtil.isAttackable(this.client, p)) { - if (p.isClanMember()) { - ++cc; - } - else { - ++other; - } - } - } - this.panel.numOther.setText(PvpToolsPanel.htmlLabel("Other Player Count: ", String.valueOf(other))); - this.panel.numCC.setText(PvpToolsPanel.htmlLabel("Friendly Player Count: ", String.valueOf(cc))); - this.panel.numCC.repaint(); - this.panel.numOther.repaint(); - } - } + //Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername) + //.toArray()).collect(Collectors.toList()); + } - private void countOverHeads() { - this.overheadCount = new int[] { 0, 0, 0 }; - for (final Player p : this.client.getPlayers()) { - if (Objects.nonNull(p) && PvPUtil.isAttackable(this.client, p) && !p.isClanMember() && p.getOverheadIcon() != null) { - switch (p.getOverheadIcon()) { - case MAGIC: { - final int[] overheadCount = this.overheadCount; - final int n = 0; - ++overheadCount[n]; - continue; - } - case RANGED: { - final int[] overheadCount2 = this.overheadCount; - final int n2 = 1; - ++overheadCount2[n2]; - continue; - } - case MELEE: { - final int[] overheadCount3 = this.overheadCount; - final int n3 = 2; - ++overheadCount3[n3]; - continue; - } - } - } - } - this.updatePrayerNumbers(); - } + public List getCurrentMembers() + { + CopyOnWriteArrayList ccMembers = ClanChatPlugin.getClanMembers(); + ArrayList currentMembers = new ArrayList(); + for (ClanMember clanMember:client.getClanMembers()) + { + if (!Objects.isNull(clanMember)) + { + List arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList()); + if (arrayList.contains(Text.removeTags(Text.standardize(clanMember.getUsername())))) + { + if (!currentMembers.contains(clanMember.getUsername())) + { + currentMembers.add(clanMember.getUsername()); + } + } + } + } - private void getCarriedWealth() { - if (!this.config.riskCalculatorEnabled()) { - return; - } - if (this.client.getItemContainer(InventoryID.EQUIPMENT) == null) { - return; - } - if (this.client.getItemContainer(InventoryID.INVENTORY).getItems() == null) { - return; - } - final Item[] items = ArrayUtils.addAll(Objects.requireNonNull(this.client.getItemContainer(InventoryID.EQUIPMENT)).getItems(), Objects.requireNonNull(this.client.getItemContainer(InventoryID.INVENTORY)).getItems()); - final TreeMap priceMap = new TreeMap(Comparator.comparingInt(Integer::intValue)); - int wealth = 0; - for (final Item i : items) { - int value = this.itemManager.getItemPrice(i.getId()) * i.getQuantity(); - final ItemComposition itemComposition = this.itemManager.getItemComposition(i.getId()); - if (!itemComposition.isTradeable() && value == 0) { - value = itemComposition.getPrice() * i.getQuantity(); - priceMap.put(value, i); - } - else { - value = this.itemManager.getItemPrice(i.getId()) * i.getQuantity(); - if (i.getId() > 0 && value > 0) { - priceMap.put(value, i); - } - } - wealth += value; - } - this.panel.totalRiskLabel.setText(PvpToolsPanel.htmlLabel("Total risk: ", StackFormatter.quantityToRSDecimalStack(wealth))); - this.panel.totalRiskLabel.repaint(); - int itemLimit = 0; - if (this.client.getLocalPlayer().getSkullIcon() != null && this.client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL) { - itemLimit = 1; - } - if (this.client.getLocalPlayer().getSkullIcon() == null) { - itemLimit = 4; - } - AsyncBufferedImage itemImage = null; - final NavigableMap descendingMap = priceMap.descendingMap(); - for (int j = 0; j < itemLimit; ++j) { - if (j == 0) { - if (!descendingMap.isEmpty()) { - itemImage = this.itemManager.getImage(descendingMap.pollFirstEntry().getValue().getId()); - } - } - else if (!descendingMap.isEmpty()) { - this.itemManager.getItemComposition(priceMap.descendingMap().pollFirstEntry().getValue().getId()).getName(); - } - } - this.panel.riskProtectingItem.setText(PvpToolsPanel.htmlLabel("Risk Protecting Item: ", StackFormatter.quantityToRSDecimalStack(descendingMap.keySet().stream().mapToInt(Integer::intValue).sum()))); - this.panel.riskProtectingItem.repaint(); - this.panel.biggestItemLabel.setText("Most Valuable Item: "); - if (itemImage != null) { - itemImage.addTo(this.panel.biggestItemLabel); - } - this.panel.biggestItemLabel.repaint(); - } + return currentMembers; - boolean isAttackHotKeyPressed() { - return this.attackHotKeyPressed; - } + //Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername) + //.toArray()).collect(Collectors.toList()); + } - void setAttackHotKeyPressed(final boolean attackHotKeyPressed) { - this.attackHotKeyPressed = attackHotKeyPressed; - } - boolean isHideAll() { - return this.hideAll; - } - void setHideAll(final boolean hideAll) { - this.hideAll = hideAll; - } + @Provides + PvpToolsConfig config(ConfigManager configManager) + { + return configManager.getConfig(PvpToolsConfig.class); + } + + @Override + protected void startUp() throws Exception + { + + overlayManager.add(pvpToolsOverlay); + + keyManager.registerKeyListener(hotkeyListener); + final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "skull.png"); + + panel = new PvpToolsPanel(); + panel.init(); + + navButton = NavigationButton.builder() + .tooltip("PvP Tools") + .icon(icon) + .priority(5) + .panel(panel) + .build(); + + panel.missingPlayers.addActionListener(playersButtonActionListener); + panel.currentPlayers.addActionListener(currentPlayersActionListener); + clientToolbar.addNavigation(navButton); + + + keyManager.registerKeyListener(attackOptionsHotKeyListener); + + if (config.missingPlayersEnabled()) + { + panel.missingPlayers.setVisible(true); + } + + if (config.currentPlayersEnabled()) + { + panel.currentPlayers.setVisible(true); + } + } + + @Override + protected void shutDown() throws Exception + { + overlayManager.remove(pvpToolsOverlay); + keyManager.unregisterKeyListener(hotkeyListener); + keyManager.unregisterKeyListener(attackOptionsHotKeyListener); + clientToolbar.removeNavigation(navButton); + } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (configChanged.getGroup().equals("pvptools")) + { + switch (configChanged.getKey()) + { + case "countPlayers": + if (config.countPlayers()) + { + updatePlayers(); + } + if (!config.countPlayers()) + { + panel.disablePlayerCount(); + } + break; + case "countOverHeads": + if (config.countOverHeads()) + { + countOverHeads(); + } + if (!config.countOverHeads()) + { + panel.disablePrayerCount(); + } + break; + case "riskCalculator": + if (config.riskCalculatorEnabled()) + { + getCarriedWealth(); + } + if (!config.riskCalculatorEnabled()) + { + panel.disableRiskCalculator(); + } + break; + case "missingPlayers": + if (config.missingPlayersEnabled()) + { + panel.missingPlayers.setVisible(true); + } + break; + case "currentPlayers": + if (config.currentPlayersEnabled()) + { + panel.currentPlayers.setVisible(true); + } + break; + default: + break; + } + } + } + + @Subscribe + public void onItemContainerChanged(ItemContainerChanged event) + { + if (event.getItemContainer().equals(client.getItemContainer(InventoryID.INVENTORY)) && + config.riskCalculatorEnabled()) + { + getCarriedWealth(); + } + } + + @Subscribe + public void onGameStateChanged(GameStateChanged event) + { + if (event.getGameState().equals(GameState.LOGGED_IN) && config.riskCalculatorEnabled()) + { + getCarriedWealth(); + } + if (event.getGameState().equals(GameState.LOGGED_IN)) + { + if (config.countPlayers()) + { + updatePlayers(); + } + } + } + + @Subscribe + public void onPlayerSpawned(PlayerSpawned event) + { + if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer())) + { + updatePlayers(); + } + if (config.countOverHeads()) + { + countOverHeads(); + } + } + + @Subscribe + public void onPlayerDespawned(PlayerDespawned event) + { + if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer())) + { + updatePlayers(); + } + if (config.countOverHeads()) + { + countOverHeads(); + } + } + + @Subscribe + public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) + { + if (!attackHotKeyPressed) + { + if (config.attackOptionsFriend() || config.attackOptionsClan() || config.levelRangeAttackOptions()) + { + if (client.getGameState() != GameState.LOGGED_IN) + { + return; + } + Player[] players = client.getCachedPlayers(); + Player player = null; + int identifier = menuEntryAdded.getIdentifier(); + if (identifier >= 0 && identifier < players.length) + { + player = players[identifier]; + } + if (player == null) + { + return; + } + final String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase(); + final String mtarget = Text.removeTags(menuEntryAdded.getTarget()).toLowerCase(); + if (attackHotKeyPressed && config.attackOptionsClan() || config.attackOptionsFriend() || + config.levelRangeAttackOptions()) + { + if (config.attackOptionsFriend() && player.isFriend()) + { + moveEntry(mtarget); + } + if (config.attackOptionsClan() && player.isClanMember()) + { + moveEntry(mtarget); + } + if (config.levelRangeAttackOptions() && !PvPUtil.isAttackable(client, player)) + { + moveEntry(mtarget); + } + } + } + } + } + + + private void moveEntry(String mtarget) + { + this.mtarget = mtarget; + MenuEntry[] menuEntries = client.getMenuEntries(); + MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; + + // strip out existing '); + if (idx != -1) + { + target = target.substring(idx + 1); + } + /*System.out.println("Contents : " + lastEntry.getTarget()); + System.out.println("Contents : " + lastEntry.getIdentifier()); + System.out.println("Contents : " + lastEntry.getOption()); + System.out.println("length : " + menuEntries.length);*/ + if (menuEntries[menuEntries.length - 1] != null) + { + //System.out.println(menuEntries.length + ": " + menuEntries[menuEntries.length-1]); + } + if (lastEntry.getOption().contains("attack".toLowerCase())) + { + ArrayUtils.shift(menuEntries, 1); + //ArrayUtils.add(menuEntries, menuEntries.length - 2); + //menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1); + //menuEntrySwapperPlugin.swap("attack", option, mtarget, false); + } + if (lastEntry.getOption().equals("Attack")) + { + ArrayUtils.shift(menuEntries, 1); + + //menuEntries = ArrayUtils.sremove(menuEntries, menuEntries.length - 1); + //menuEntrySwapperPlugin.swap("attack", option, mtarget, false); + } + client.setMenuEntries(menuEntries); + + } + + @Subscribe + public void onFocusChanged(FocusChanged focusChanged) + { + if (!focusChanged.isFocused()) + { + setAttackHotKeyPressed(false); + } + } + + /** + * Enables or disables the fall in helper feature + */ + private void toggleFallinHelper() + { + if (!fallinHelperEnabled) + { + client.setIsHidingEntities(true); + client.setPlayersHidden(true); + fallinHelperEnabled = true; + } + else + { + client.setIsHidingEntities(false); + client.setPlayersHidden(false); + fallinHelperEnabled = false; + } + + } + + /** + * Updates the PvP Tools panel with the numbers for enemy protection prayers + */ + private void updatePrayerNumbers() + { + panel.numMageJLabel.setText(htmlLabel("Enemies Praying Mage: ", String.valueOf(overheadCount[0]))); + panel.numRangeJLabel.setText(htmlLabel("Enemies Praying Range: ", String.valueOf(overheadCount[1]))); + panel.numMeleeJLabel.setText(htmlLabel("Enemies Praying Melee: ", String.valueOf(overheadCount[2]))); + panel.numMageJLabel.repaint(); + panel.numRangeJLabel.repaint(); + panel.numMeleeJLabel.repaint(); + } + + /** + * + */ + private void updatePlayers() + { + if (config.countPlayers()) + { + int cc = 0; + int other = 0; + for (Player p : client.getPlayers()) + { + if (Objects.nonNull(p)) + { + if (PvPUtil.isAttackable(client, p)) + { + if (p.isClanMember()) + { + cc++; + } + else + { + other++; + } + } + } + } + + panel.numOther.setText(htmlLabel("Other Player Count: ", String.valueOf(other))); + panel.numCC.setText(htmlLabel("Friendly Player Count: ", String.valueOf(cc))); + panel.numCC.repaint(); + panel.numOther.repaint(); + } + } + + private void countOverHeads() + { + overheadCount = new int[]{0, 0, 0}; + for (Player p : client.getPlayers()) + { + if (Objects.nonNull(p)) + { + if (PvPUtil.isAttackable(client, p)) + { + if (!p.isClanMember() && !(p.getOverheadIcon() == null)) + { + switch (p.getOverheadIcon()) + { + case MAGIC: + overheadCount[0]++; + break; + case RANGED: + overheadCount[1]++; + break; + case MELEE: + overheadCount[2]++; + break; + } + } + } + } + } + updatePrayerNumbers(); + } + + /** + * Calculates the player's risk based on Item Price of all items in their inventory and equipment + */ + private void getCarriedWealth() + { + if (!config.riskCalculatorEnabled()) + { + return; + } + if (client.getItemContainer(InventoryID.EQUIPMENT) == null) + { + return; + } + if (client.getItemContainer(InventoryID.INVENTORY).getItems() == null) + { + return; + } + Item[] items = ArrayUtils.addAll(Objects.requireNonNull(client.getItemContainer(InventoryID.EQUIPMENT)).getItems(), + Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()); + TreeMap priceMap = new TreeMap<>(Comparator.comparingInt(Integer::intValue)); + int wealth = 0; + for (Item i : items) + { + int value = (itemManager.getItemPrice(i.getId()) * i.getQuantity()); + + final ItemComposition itemComposition = itemManager.getItemComposition(i.getId()); + if (!itemComposition.isTradeable() && value == 0) + { + value = itemComposition.getPrice() * i.getQuantity(); + priceMap.put(value, i); + } + else + { + value = itemManager.getItemPrice(i.getId()) * i.getQuantity(); + if (i.getId() > 0 && value > 0) + { + priceMap.put(value, i); + } + } + wealth += value; + } + panel.totalRiskLabel.setText(htmlLabel("Total risk: ", quantityToRSDecimalStack(wealth))); + panel.totalRiskLabel.repaint(); + + int itemLimit = 0; + if (client.getLocalPlayer().getSkullIcon() != null) + { + if (client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL) + { + itemLimit = 1; + } + } + if (client.getLocalPlayer().getSkullIcon() == null) + { + itemLimit = 4; + } + + AsyncBufferedImage itemImage = null; + + NavigableMap descendingMap = priceMap.descendingMap(); + + for (int i = 0; i < itemLimit; i++) + { + if (i == 0) + { + if (!descendingMap.isEmpty()) + { + itemImage = itemManager.getImage(descendingMap.pollFirstEntry().getValue().getId()); + } + } + else + { + if (!descendingMap.isEmpty()) + { + itemManager.getItemComposition(priceMap.descendingMap().pollFirstEntry().getValue().getId()) + .getName(); + } + } + } + panel.riskProtectingItem.setText(htmlLabel("Risk Protecting Item: ", + quantityToRSDecimalStack(descendingMap.keySet().stream().mapToInt(Integer::intValue).sum()))); + panel.riskProtectingItem.repaint(); + + panel.biggestItemLabel.setText("Most Valuable Item: "); + if (itemImage != null) + { + itemImage.addTo(panel.biggestItemLabel); + } + panel.biggestItemLabel.repaint(); + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java index f7034af63f..9212432d7e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java @@ -63,6 +63,7 @@ import java.awt.image.BufferedImage; name = "Supplies Used Tracker", description = "Tracks supplies used during the session", tags = {"cost"}, + type = "PVM", enabledByDefault = false ) @Slf4j diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersConfig.java index 75436c045c..9da7fa9ece 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersConfig.java @@ -1,34 +1,68 @@ package net.runelite.client.plugins.whalewatchers; -import java.awt.*; -import net.runelite.client.config.*; +import java.awt.Color; +import net.runelite.client.config.Alpha; +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; @ConfigGroup("WhaleWatchers") public interface WhaleWatchersConfig extends Config { - @ConfigItem(position = 1, keyName = "protectItemWarning", name = "Protect Item Warning", description = "Warns you when you are skulled and don't have protect item turned on.") - default boolean protectItemWarning() { - return false; - } - - @ConfigItem(position = 2, keyName = "showDamageCounter", name = "Damage Counter", description = "Shows damage you've done and damage your opponent has done to you while in a fight") - default boolean showDamageCounter() { - return true; - } - - @Alpha - @ConfigItem(position = 3, keyName = "damageBackgroundColor", name = "Counter Background Color", description = "The background color for the damage counter overlay") - default Color damageBackgroundColor() { - return Color.darkGray; - } - - @ConfigItem(position = 4, keyName = "smiteableWarning", name = "Smite Warning", description = "Displays a warning overlay when your prayer is at a smiteable level") - default boolean smiteableWarning() { - return true; - } - - @ConfigItem(position = 5, keyName = "gloryWarning", name = "Glory Warning", description = "Displays a warning box while you are wearing an uncharged glory") - default boolean gloryWarning() { - return true; - } + + @ConfigItem( + position = 1, + keyName = "protectItemWarning", + name = "Protect Item Warning", + description = "Warns you when you are skulled and don't have protect item turned on." + ) + default boolean protectItemWarning() + { + return false; + } + + @ConfigItem( + position = 2, + keyName = "showDamageCounter", + name = "Damage Counter", + description = "Shows damage you've done and damage your opponent has done to you while in a fight" + ) + default boolean showDamageCounter() + { + return true; + } + + @Alpha + @ConfigItem( + position = 3, + keyName = "damageBackgroundColor", + name = "Counter Background Color", + description = "The background color for the damage counter overlay" + ) + default Color damageBackgroundColor() + { + return Color.darkGray; + } + + @ConfigItem( + position = 4, + keyName = "smiteableWarning", + name = "Smite Warning", + description = "Displays a warning overlay when your prayer is at a smiteable level" + ) + default boolean smiteableWarning() + { + return true; + } + + @ConfigItem( + position = 5, + keyName = "gloryWarning", + name = "Glory Warning", + description = "Displays a warning box while you are wearing an uncharged glory" + ) + default boolean gloryWarning() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java index dd30579485..61bfaf0d47 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java @@ -1,48 +1,72 @@ package net.runelite.client.plugins.whalewatchers; -import net.runelite.api.*; -import javax.inject.*; -import net.runelite.client.ui.overlay.*; -import net.runelite.api.kit.*; -import java.awt.*; -import net.runelite.client.ui.overlay.components.*; -import java.awt.image.*; -import net.runelite.client.game.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.ItemID; +import net.runelite.api.kit.KitType; +import net.runelite.client.game.AsyncBufferedImage; +import net.runelite.client.game.ItemManager; +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.components.ImageComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TextComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; +import org.apache.commons.lang3.ObjectUtils; public class WhaleWatchersGloryOverlay extends Overlay { - private Client client; - private final WhaleWatchersConfig config; - private WhaleWatchersPlugin plugin; - private PanelComponent panelComponent; - @Inject - private ItemManager itemManager; - - @Inject - public WhaleWatchersGloryOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { - this.client = client; - this.config = config; - this.plugin = plugin; - this.setLayer(OverlayLayer.ABOVE_WIDGETS); - this.setPriority(OverlayPriority.HIGH); - this.setPosition(OverlayPosition.DETACHED); - this.panelComponent = new PanelComponent(); - } - - @Override - public Dimension render(final Graphics2D graphics) { - this.panelComponent.getChildren().clear(); - int amuletID = 0; - try { - amuletID = this.client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET); - } - catch (NullPointerException ex) {} - if (this.config.gloryWarning() && amuletID == 1704) { - this.panelComponent.setBackgroundColor(Color.lightGray); - final AsyncBufferedImage gloryImage = this.itemManager.getImage(1704); - this.panelComponent.getChildren().add(TitleComponent.builder().text("Uncharged Glory").color(Color.BLACK).build()); - this.panelComponent.getChildren().add(new ImageComponent(gloryImage)); - } - return this.panelComponent.render(graphics); - } + private Client client; + private final WhaleWatchersConfig config; + private WhaleWatchersPlugin plugin; + private PanelComponent panelComponent; + + @Inject + private ItemManager itemManager; + + @Inject + public WhaleWatchersGloryOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DETACHED); + panelComponent = new PanelComponent(); + } + + @Override + public Dimension render(Graphics2D graphics) + { + panelComponent.getChildren().clear(); + int amuletID = 0; + try + { + amuletID = client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET); + } + catch (NullPointerException e) + { + + } + if (config.gloryWarning() && amuletID == ItemID.AMULET_OF_GLORY) + { + panelComponent.setBackgroundColor(Color.lightGray); + final AsyncBufferedImage gloryImage = itemManager.getImage(ItemID.AMULET_OF_GLORY); + + panelComponent.getChildren().add(TitleComponent.builder() + .text("Uncharged Glory") + .color(Color.BLACK) + .build()); + + panelComponent.getChildren().add(new ImageComponent(gloryImage)); + } + + return panelComponent.render(graphics); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java index 2365bbfe38..a21d4cbaae 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java @@ -1,51 +1,79 @@ package net.runelite.client.plugins.whalewatchers; -import net.runelite.api.*; -import net.runelite.client.ui.overlay.*; -import javax.inject.*; -import net.runelite.client.ui.overlay.components.*; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +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.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; public class WhaleWatchersOverlay extends Overlay { - private Client client; - private final WhaleWatchersConfig config; - private WhaleWatchersPlugin plugin; - private PanelComponent panelComponent; - private String lastOpponent; - - @Inject - public WhaleWatchersOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { - this.lastOpponent = "-"; - this.client = client; - this.config = config; - this.plugin = plugin; - this.setLayer(OverlayLayer.ABOVE_WIDGETS); - this.setPriority(OverlayPriority.HIGH); - this.setPosition(OverlayPosition.DETACHED); - this.panelComponent = new PanelComponent(); - } - - @Override - public Dimension render(final Graphics2D graphics) { - this.panelComponent.getChildren().clear(); - if (this.plugin.inCombat && this.config.showDamageCounter()) { - this.panelComponent.setBackgroundColor(this.config.damageBackgroundColor()); - final String opp = (this.client.getLocalPlayer().getInteracting() != null) ? this.client.getLocalPlayer().getInteracting().getName() : this.lastOpponent; - if (this.client.getLocalPlayer().getInteracting() != null) { - this.lastOpponent = this.client.getLocalPlayer().getInteracting().getName(); - } - final String opponent = "Fight vs " + opp; - final String damageTaken = "Damage Taken: " + this.plugin.damageTaken; - final String damageDealt = "Damage Dealt: " + this.plugin.damageDone; - this.panelComponent.getChildren().add(TitleComponent.builder().text(opponent).color(Color.BLACK).build()); - this.panelComponent.getChildren().add(TitleComponent.builder().text(damageDealt).color(Color.BLACK).build()); - this.panelComponent.getChildren().add(TitleComponent.builder().text(damageTaken).color(Color.BLACK).build()); - this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(damageDealt) + graphics.getFontMetrics().stringWidth(opponent) + 10, 0)); - } - else { - this.panelComponent.getChildren().clear(); - } - return this.panelComponent.render(graphics); - } + private Client client; + private final WhaleWatchersConfig config; + private WhaleWatchersPlugin plugin; + private PanelComponent panelComponent; + private String lastOpponent = "-"; + + @Inject + public WhaleWatchersOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DETACHED); + panelComponent = new PanelComponent(); + } + + @Override + public Dimension render(Graphics2D graphics) + { + panelComponent.getChildren().clear(); + + if (plugin.inCombat && config.showDamageCounter()) + { + panelComponent.setBackgroundColor(config.damageBackgroundColor()); + String opp = client.getLocalPlayer().getInteracting() != null ? + client.getLocalPlayer().getInteracting().getName() : lastOpponent; + if (client.getLocalPlayer().getInteracting() != null) + { + lastOpponent = client.getLocalPlayer().getInteracting().getName(); + } + final String opponent = "Fight vs " + opp; + String damageTaken = "Damage Taken: " + plugin.damageTaken; + String damageDealt = "Damage Dealt: " + plugin.damageDone; + + panelComponent.getChildren().add(TitleComponent.builder() + .text(opponent) + .color(Color.BLACK) + .build()); + + panelComponent.getChildren().add(TitleComponent.builder() + .text(damageDealt) + .color(Color.BLACK) + .build()); + + panelComponent.getChildren().add(TitleComponent.builder() + .text(damageTaken) + .color(Color.BLACK) + .build()); + + panelComponent.setPreferredSize(new Dimension( + graphics.getFontMetrics().stringWidth(damageDealt) + + + graphics.getFontMetrics().stringWidth(opponent) + 10,0)); + + } + else + { + panelComponent.getChildren().clear(); + } + return panelComponent.render(graphics); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java index 48a9b20581..b08d7e4ca4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java @@ -1,200 +1,316 @@ package net.runelite.client.plugins.whalewatchers; - -import org.jetbrains.annotations.*; -import net.runelite.client.plugins.*; -import net.runelite.client.game.*; -import net.runelite.client.config.*; -import com.google.inject.*; -import net.runelite.client.ui.overlay.*; -import net.runelite.client.eventbus.*; -import net.runelite.api.kit.*; -import org.apache.commons.lang3.*; -import net.runelite.api.*; -import net.runelite.api.events.*; -import java.util.*; +import com.google.inject.Provides; +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import javax.inject.Inject; +import lombok.Getter; +import net.runelite.api.Actor; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.InventoryID; +import net.runelite.api.ItemContainer; +import net.runelite.api.ItemID; +import net.runelite.api.MenuAction; +import net.runelite.api.Player; +import net.runelite.api.PlayerComposition; +import net.runelite.api.Skill; +import net.runelite.api.SkullIcon; +import net.runelite.api.VarPlayer; +import net.runelite.api.Varbits; +import net.runelite.api.WorldType; +import static net.runelite.api.WorldType.*; +import net.runelite.api.events.ExperienceChanged; +import net.runelite.api.events.GameStateChanged; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.HitsplatApplied; +import net.runelite.api.events.InteractingChanged; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.api.events.MenuOptionClicked; +import net.runelite.api.events.PlayerMenuOptionClicked; +import net.runelite.api.events.VarbitChanged; +import net.runelite.api.kit.KitType; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.game.ItemManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.util.WorldUtil; +import org.apache.commons.lang3.ObjectUtils; +import org.jetbrains.annotations.NotNull; @PluginDescriptor( - name = "Whale Watchers", - description = "A Plugin to save help whales in the wild", - tags = { "whale watchers", "whale", "protect item", "warning", "pklite" }, - type = "PVP", - enabledByDefault = false + name = "Whale Watchers", + description = "A Plugin to save help whales in the wild", + tags = {"whale watchers", "whale", "protect item", "warning", "pklite"}, + enabledByDefault = true, + hidden = false, + developerPlugin = false, + type = "PVP", + loadWhenOutdated = false ) public class WhaleWatchersPlugin extends Plugin { - @Inject - private Client client; - @Inject - private WhaleWatchersConfig config; - @Inject - private WhaleWatchersOverlay overlay; - @Inject - private WhaleWatchersProtOverlay whaleWatchersProtOverlay; - @Inject - private WhaleWatchersSmiteableOverlay whaleWatchersSmiteableOverlay; - @Inject - private WhaleWatchersGloryOverlay whaleWatchersGloryOverlay; - @Inject - private OverlayManager overlayManager; - @Inject - private ItemManager itemManager; - public boolean enableOverlay; - private int lastXP; - public int damageDone; - public int damageTaken; - public boolean inCombat; - private int tickCountdown; - private boolean displaySmiteOverlay; - private boolean displayGloryOverlay; - - public WhaleWatchersPlugin() { - this.enableOverlay = false; - this.lastXP = 0; - this.damageDone = 0; - this.damageTaken = 0; - this.inCombat = false; - this.tickCountdown = 0; - } - - @Provides - WhaleWatchersConfig getConfig(final ConfigManager configManager) { - return configManager.getConfig(WhaleWatchersConfig.class); - } - - @Override - protected void startUp() throws Exception { - this.overlayManager.add(this.overlay); - this.overlayManager.add(this.whaleWatchersProtOverlay); - this.overlayManager.add(this.whaleWatchersSmiteableOverlay); - this.overlayManager.add(this.whaleWatchersGloryOverlay); - } - - @Override - protected void shutDown() throws Exception { - this.overlayManager.remove(this.overlay); - this.overlayManager.remove(this.whaleWatchersProtOverlay); - this.overlayManager.remove(this.whaleWatchersSmiteableOverlay); - this.overlayManager.remove(this.whaleWatchersGloryOverlay); - } - - @Subscribe - public void onHitsplatApplied(final HitsplatApplied event) { - if (this.config.showDamageCounter()) { - if (!(event.getActor() == this.client.getLocalPlayer() | event.getActor() == this.client.getLocalPlayer().getInteracting())) { - return; - } - if (this.isAttackingPlayer(this.client) || this.inCombat) { - this.inCombat = true; - if (event.getActor() == this.client.getLocalPlayer()) { - this.damageTaken += event.getHitsplat().getAmount(); - } - if (event.getActor() == this.client.getLocalPlayer().getInteracting()) { - this.damageDone += event.getHitsplat().getAmount(); - } - } - } - } - - @Subscribe - public void onItemContainerChanged(final ItemContainerChanged event) { - if (this.config.gloryWarning() && event.getItemContainer().equals(InventoryID.EQUIPMENT)) { - final int amuletID = ObjectUtils.defaultIfNull(this.client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET), 0); - if (amuletID == 1704) { - this.displayGloryOverlay = true; - } - else { - this.displayGloryOverlay = false; - } - } - else { - this.displayGloryOverlay = false; - } - } - - @Subscribe - public void onExperienceChanged(final ExperienceChanged event) { - final Skill skill = event.getSkill(); - final Player player = this.client.getLocalPlayer(); - if (skill.equals(Skill.HITPOINTS) && player.getInteracting() instanceof Player) { - this.lastXP = this.client.getSkillExperience(skill); - } - } - - @Subscribe - public void onMenuOptionClicked(final MenuOptionClicked event) { - if (this.config.showDamageCounter() && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER)) { - this.inCombat = true; - } - } - - @Subscribe - public void onVarbitChanged(final VarbitChanged event) { - if (this.config.showDamageCounter() && this.client.getVar(VarPlayer.ATTACKING_PLAYER) == -1 && this.inCombat) { - this.tickCountdown = 10; - } - if (this.config.protectItemWarning()) { - try { - if (this.client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL) { - if ((this.client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 0 && this.client.getVar(Varbits.IN_WILDERNESS) == 1) || this.client.getWorldType().contains(WorldType.PVP)) { - this.enableOverlay = true; - } - if (this.client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 1 || this.client.getVar(Varbits.IN_WILDERNESS) == 0 || this.client.getWorldType().contains(WorldType.PVP_HIGH_RISK) || this.client.getWorld() == 365) { - this.enableOverlay = false; - } - } - else { - this.enableOverlay = false; - } - } - catch (NullPointerException ex) {} - } - } - - @Subscribe - public void onGameTick(final GameTick event) { - if (this.tickCountdown > 0 && this.tickCountdown < 11) { - --this.tickCountdown; - if (this.tickCountdown == 1 && !this.isAttackingPlayer(this.client)) { - this.inCombat = false; - this.damageDone = 0; - this.damageTaken = 0; - return; - } - } - if (this.config.smiteableWarning() && (this.client.getVar(Varbits.IN_WILDERNESS) == 1 || WorldType.isPvpWorld(this.client.getWorldType()))) { - if (this.client.getLocalPlayer().getSkullIcon() != null && this.client.getLocalPlayer().getSkullIcon().equals(SkullIcon.SKULL)) { - final int currentHealth = this.client.getLocalPlayer().getHealth(); - final int currentPrayer = this.client.getBoostedSkillLevel(Skill.PRAYER); - if (currentPrayer <= Math.ceil(currentHealth / 4)) { - this.displaySmiteOverlay = true; - } - else { - this.displaySmiteOverlay = false; - } - } - else { - this.displaySmiteOverlay = false; - } - } - else { - this.displaySmiteOverlay = false; - } - } - public boolean isAttackingPlayer(@NotNull final Client c) { - if (this.client.getVar(Varbits.IN_WILDERNESS) == 1 && this.client.getLocalPlayer().getInteracting() != null) { - return true; - } - final int varp = c.getVar(VarPlayer.ATTACKING_PLAYER); - return varp != -1; - } + @Inject + private Client client; - public boolean isDisplaySmiteOverlay() { - return this.displaySmiteOverlay; - } + @Inject + private WhaleWatchersConfig config; + + @Inject + private WhaleWatchersOverlay overlay; + + @Inject + private WhaleWatchersProtOverlay whaleWatchersProtOverlay; + + @Inject + private WhaleWatchersSmiteableOverlay whaleWatchersSmiteableOverlay; + + @Inject + private WhaleWatchersGloryOverlay whaleWatchersGloryOverlay; + + @Inject + private OverlayManager overlayManager; + + @Inject + private ItemManager itemManager; + + public boolean enableOverlay = false; + private int lastXP = 0; + public int damageDone = 0; + public int damageTaken = 0; + public boolean inCombat = false; + private int tickCountdown = 0; + @Getter + private boolean displaySmiteOverlay; + @Getter + private boolean displayGloryOverlay; + + @Provides + WhaleWatchersConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(WhaleWatchersConfig.class); + } + + @Override + protected void startUp() throws Exception + { + overlayManager.add(overlay); + overlayManager.add(whaleWatchersProtOverlay); + overlayManager.add(whaleWatchersSmiteableOverlay); + overlayManager.add(whaleWatchersGloryOverlay); + } + + @Override + protected void shutDown() throws Exception + { + overlayManager.remove(overlay); + overlayManager.remove(whaleWatchersProtOverlay); + overlayManager.remove(whaleWatchersSmiteableOverlay); + overlayManager.remove(whaleWatchersGloryOverlay); + } + + + @Subscribe + public void onHitsplatApplied(HitsplatApplied event) + { + if (config.showDamageCounter()) + { + if (!(event.getActor() == client.getLocalPlayer() | + event.getActor() == client.getLocalPlayer().getInteracting())) + { + return; + } + if (isAttackingPlayer(client) || inCombat) + { + inCombat = true; + + if (event.getActor() == client.getLocalPlayer()) + { + damageTaken += event.getHitsplat().getAmount(); + + } + if (event.getActor() == client.getLocalPlayer().getInteracting()) + { + damageDone += event.getHitsplat().getAmount(); + } + } + } + } + + + /** + * final Player target = (Player) event.getTarget(); + * if (lastInteracting == null) + * { + * lastInteracting = target; + * inCombat = true; + * interactingStarted = System.currentTimeMillis(); + * } + * List optionsList = Arrays.asList(client.getPlayerOptions()); + *

+ * if (target == lastInteracting || target == null) + * { + * inCombat = true; + * lastInteracting = target; + * interactingStarted = System.currentTimeMillis(); + * } + * if (target != lastInteracting && target != null && lastInteracting != null) + * { + * damageDone = 0; + * damageTaken = 0; + * interactingStarted = System.currentTimeMillis(); + * inCombat = true; + * } + **/ + + @Subscribe + public void onItemContainerChanged(ItemContainerChanged event) + { + if (config.gloryWarning() && event.getItemContainer().equals(InventoryID.EQUIPMENT)) + { + final int amuletID = ObjectUtils.defaultIfNull(client.getLocalPlayer() + .getPlayerComposition().getEquipmentId(KitType.AMULET), 0); + if (amuletID == ItemID.AMULET_OF_GLORY) + { + displayGloryOverlay = true; + } + else + { + displayGloryOverlay = false; + } + } + else + { + displayGloryOverlay = false; + } + } + + @Subscribe + public void onExperienceChanged(ExperienceChanged event) + { + final Skill skill = event.getSkill(); + final Player player = client.getLocalPlayer(); + if (skill.equals(Skill.HITPOINTS)) + { + if (player.getInteracting() instanceof Player) + { + //lient.getLogger().info(String.valueOf(Math.round((client.getSkillExperience(skill) - lastXP) / 1.33)) + 2); + lastXP = client.getSkillExperience(skill); + } + } + } + + @Subscribe + public void onMenuOptionClicked(MenuOptionClicked event) + { + if (config.showDamageCounter() && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER)) + { + inCombat = true; + } + } + + @Subscribe + public void onVarbitChanged(VarbitChanged event) + { + if (config.showDamageCounter()) + { + if (client.getVar(VarPlayer.ATTACKING_PLAYER) == -1) + { + if (inCombat) + { + //damageTaken = 0; + //damageDone = 0; + tickCountdown = 10; + } + } + } + + if (config.protectItemWarning()) + { + try + { + if (client.getLocalPlayer().getSkullIcon() == (SkullIcon.SKULL)) + { + if (client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 0 && client.getVar(Varbits.IN_WILDERNESS) == 1 || + client.getWorldType().contains(PVP)) + { + enableOverlay = true; + } + if (client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 1 || client.getVar(Varbits.IN_WILDERNESS) == 0 || + client.getWorldType().contains(PVP_HIGH_RISK) || client.getWorld() == 365) + { + enableOverlay = false; + } + } + else + { + enableOverlay = false; + } + } + catch (NullPointerException e) + { + + } + } + } + + @Subscribe + public void onGameTick(GameTick event) + { + + if (tickCountdown > 0 && tickCountdown < 11) + { + tickCountdown--; + if (tickCountdown == 1) + { + if (!isAttackingPlayer(client)) + { + inCombat = false; + damageDone = 0; + damageTaken = 0; + return; + } + } + } + + if (config.smiteableWarning() && (client.getVar(Varbits.IN_WILDERNESS) == 1 || isPvpWorld(client.getWorldType()))) + { + if (client.getLocalPlayer().getSkullIcon() != null && client.getLocalPlayer().getSkullIcon().equals(SkullIcon.SKULL)) + { + final int currentHealth = client.getLocalPlayer().getHealth(); + final int currentPrayer = client.getBoostedSkillLevel(Skill.PRAYER); + if (currentPrayer <= (Math.ceil(currentHealth / 4))) + { + displaySmiteOverlay = true; + } + else + { + displaySmiteOverlay = false; + } + } + else + { + displaySmiteOverlay = false; + } + } + else + { + displaySmiteOverlay = false; + } + } + + public boolean isAttackingPlayer(@NotNull Client c) + { + if (client.getVar(Varbits.IN_WILDERNESS) == 1 && client.getLocalPlayer().getInteracting() != null) + { + return true; + } + int varp = c.getVar(VarPlayer.ATTACKING_PLAYER); + return varp != -1; + } - public boolean isDisplayGloryOverlay() { - return this.displayGloryOverlay; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java index 5c8fa24b84..9e6e081931 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java @@ -1,44 +1,59 @@ package net.runelite.client.plugins.whalewatchers; -import javax.inject.*; - +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Stroke; +import javax.inject.Inject; +import net.runelite.api.Client; import net.runelite.api.Point; -import net.runelite.client.ui.*; -import net.runelite.api.*; -import net.runelite.client.ui.overlay.*; -import java.awt.*; +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.ui.overlay.components.PanelComponent; public class WhaleWatchersProtOverlay extends Overlay { - private Client client; - private final WhaleWatchersConfig config; - private WhaleWatchersPlugin plugin; - - @Inject - public WhaleWatchersProtOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { - this.client = client; - this.config = config; - this.plugin = plugin; - this.setLayer(OverlayLayer.ABOVE_WIDGETS); - this.setPriority(OverlayPriority.HIGH); - this.setPosition(OverlayPosition.DYNAMIC); - } - - @Override - public Dimension render(final Graphics2D graphics) { - if (this.plugin.enableOverlay && this.config.protectItemWarning()) { - final Rectangle rectangle = new Rectangle(); - rectangle.setBounds(this.client.getCanvas().getBounds()); - rectangle.setLocation(this.client.getCanvas().getLocation()); - final Stroke oldStroke = graphics.getStroke(); - graphics.setStroke(new BasicStroke(10.0f)); - graphics.setColor(Color.RED); - graphics.draw(rectangle); - final Font font = FontManager.getRunescapeBoldFont().deriveFont(1, 72.0f); - graphics.setFont(font); - OverlayUtil.renderTextLocation(graphics, new Point((int)rectangle.getCenterX() - 50, font.getSize()), "Protect item prayer disabled!!!", Color.red); - graphics.setStroke(oldStroke); - } - return null; - } + + private Client client; + private final WhaleWatchersConfig config; + private WhaleWatchersPlugin plugin; + + @Inject + public WhaleWatchersProtOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DYNAMIC); + + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (plugin.enableOverlay && config.protectItemWarning()) + { + Rectangle rectangle = new Rectangle(); + rectangle.setBounds(client.getCanvas().getBounds()); + rectangle.setLocation(client.getCanvas().getLocation()); + Stroke oldStroke = graphics.getStroke(); + graphics.setStroke(new BasicStroke(10)); + graphics.setColor(Color.RED); + graphics.draw(rectangle); + Font font = FontManager.getRunescapeBoldFont().deriveFont(Font.BOLD, 72); + graphics.setFont(font); + OverlayUtil.renderTextLocation(graphics, new Point((int) rectangle.getCenterX() - 50, font.getSize()), "Protect item prayer disabled!!!", Color.red); + graphics.setStroke(oldStroke); + } + return null; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java index 683841d246..6e4d502851 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java @@ -1,39 +1,59 @@ package net.runelite.client.plugins.whalewatchers; -import net.runelite.api.*; -import net.runelite.client.ui.overlay.*; -import javax.inject.*; -import java.awt.*; -import net.runelite.client.ui.overlay.components.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +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.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; public class WhaleWatchersSmiteableOverlay extends Overlay { - private Client client; - private WhaleWatchersPlugin plugin; - private PanelComponent panelComponent; - - @Inject - public WhaleWatchersSmiteableOverlay(final WhaleWatchersPlugin plugin) { - this.plugin = plugin; - this.setLayer(OverlayLayer.ABOVE_WIDGETS); - this.setPriority(OverlayPriority.HIGH); - this.setPosition(OverlayPosition.BOTTOM_RIGHT); - this.panelComponent = new PanelComponent(); - } - - @Override - public Dimension render(final Graphics2D graphics) { - final String subText = "You could be smited in 1 tick"; - this.panelComponent.getChildren().clear(); - if (this.plugin.isDisplaySmiteOverlay()) { - this.panelComponent.setBackgroundColor(Color.WHITE); - this.panelComponent.getChildren().add(TitleComponent.builder().text("LOW PRAYER WARNING").color(Color.BLACK).build()); - this.panelComponent.getChildren().add(TitleComponent.builder().text(subText).color(Color.BLACK).build()); - this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(subText) + 20, 0)); - } - else { - this.panelComponent.getChildren().clear(); - } - return this.panelComponent.render(graphics); - } + private Client client; + private WhaleWatchersPlugin plugin; + private PanelComponent panelComponent; + + + @Inject + public WhaleWatchersSmiteableOverlay( WhaleWatchersPlugin plugin) + { + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.BOTTOM_RIGHT); + + panelComponent = new PanelComponent(); + } + + @Override + public Dimension render(Graphics2D graphics) + { + String subText = "You could be smited in 1 tick"; + panelComponent.getChildren().clear(); + if (plugin.isDisplaySmiteOverlay()) + { + panelComponent.setBackgroundColor(Color.WHITE); + panelComponent.getChildren().add(TitleComponent.builder() + .text("LOW PRAYER WARNING") + .color(Color.BLACK) + .build()); + panelComponent.getChildren().add(TitleComponent.builder() + .text(subText) + .color(Color.BLACK) + .build()); + + panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(subText) + + 20 , 0)); + } + else + { + panelComponent.getChildren().clear(); + } + return panelComponent.render(graphics); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java index fbe8ecdbaa..28f299ed0e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java @@ -428,6 +428,13 @@ class WorldSwitcherPanel extends PluginPanel void populate(List worlds) { + Map pingHistory = new HashMap<>(); + + for (WorldTableRow row : rows) + { + pingHistory.put(row.getWorld().getId(), row.getPing()); + } + rows.clear(); for (int i = 0; i < worlds.size(); i++) @@ -450,7 +457,8 @@ class WorldSwitcherPanel extends PluginPanel break; } - rows.add(buildRow(world, i % 2 == 0, world.getId() == plugin.getCurrentWorld() && plugin.getLastWorld() != 0, plugin.isFavorite(world))); + Integer ping = pingHistory.getOrDefault(world.getId(), 0); + rows.add(buildRow(world, i % 2 == 0, world.getId() == plugin.getCurrentWorld() && plugin.getLastWorld() != 0, plugin.isFavorite(world), ping)); } updateList(); @@ -599,7 +607,7 @@ class WorldSwitcherPanel extends PluginPanel /** * Builds a table row, that displays the world's information. */ - private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite) + private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite, Integer ping) { WorldTableRow row = new WorldTableRow(world, current, favorite, world1 -> diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java index 77157bb490..b49a56a2a0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java @@ -41,7 +41,7 @@ enum QuestStartLocation IMP_CATCHER("Imp Catcher", new WorldPoint(3108, 3160, 0)), THE_KNIGHTS_SWORD("The Knight's Sword", new WorldPoint(2976, 3342, 0)), MISTHALIN_MYSTERY("Misthalin Mystery", new WorldPoint(3234, 3155, 0)), - PIRATES_TREASURE("Pirate's Treasure", new WorldPoint(3050, 3248, 0)), + PIRATES_TREASURE("Pirate's Treasure", new WorldPoint(3051, 3252, 0)), PRINCE_ALI_RESCUE("Prince Ali Rescue", new WorldPoint(3301, 3163, 0)), THE_RESTLESS_GHOST("The Restless Ghost", new WorldPoint(3240, 3210, 0)), RUNE_MYSTERIES("Rune Mysteries", new WorldPoint(3210, 3220, 0)), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderConfig.java new file mode 100644 index 0000000000..da657fdee1 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderConfig.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.worldmaphider; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("worldMapHider") +public interface WorldMapHiderConfig extends Config +{ + @ConfigItem( + position = 0, + keyName = "hideWorldMapButton", + name = "Hide World Map Button", + description = "Hides the world map button. Prevents missclicks that open the world map" + ) + default boolean hideWorldMapButton() + { + return false; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderPlugin.java new file mode 100644 index 0000000000..d1f2971cd6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderPlugin.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.worldmaphider; + +import com.google.common.collect.ImmutableList; +import com.google.inject.Provides; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.WidgetLoaded; +import net.runelite.api.events.WidgetMenuOptionClicked; +import net.runelite.api.widgets.WidgetID; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.menus.MenuManager; +import net.runelite.client.menus.WidgetMenuOption; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; + +@PluginDescriptor( + name = "Hide Worldmap Button", + description = "Hides the world map button", + type = "PVM", + tags = {"world", "world map", "hide", "button", "map", "hide world map", "pklite"} +) +public class WorldMapHiderPlugin extends Plugin +{ + @Inject + private Client client; + + @Inject + private MenuManager menuManager; + + @Inject + private WorldMapHiderConfig config; + + @Inject + private ConfigManager configManager; + + private WidgetMenuOption hideWidgetMenuOption = new WidgetMenuOption("Hide Map Button", + "Hide Map Button", WidgetInfo.WORLD_MAP_OPTION); + + private ImmutableList widgetList = + ImmutableList.of(WidgetInfo.WORLD_MAP_OPTION, WidgetInfo.WORLD_MAP_BUTTON_BORDER, + WidgetInfo.MINIMAP_WORLD_ORB); + + @Provides + WorldMapHiderConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(WorldMapHiderConfig.class); + } + + @Override + protected void startUp() + { + menuManager.addManagedCustomMenu(hideWidgetMenuOption); + } + + @Override + protected void shutDown() throws Exception + { + if (config.hideWorldMapButton()) + { + setMapHidden(false); + } + menuManager.removeManagedCustomMenu(hideWidgetMenuOption); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (config.hideWorldMapButton()) + { + setMapHidden(true); + } + if (!config.hideWorldMapButton()) + { + setMapHidden(false); + } + } + + @Subscribe + public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event) + { + if (event.getMenuOption().equals("Hide Map Button")) + { + configManager.setConfiguration("worldMapHider", "hideWorldMapButton", true); + } + } + + @Subscribe + public void onWidgetLoaded(WidgetLoaded event) + { + if (config.hideWorldMapButton() && event.getGroupId() == WidgetID.MINIMAP_GROUP_ID) + { + setMapHidden(true); + } + } + + private void setMapHidden(Boolean hidden) + { + if (widgetList.size() > 0) + widgetList.forEach(widgetInfo -> + { + if (widgetInfo != null && client.getWidget(widgetInfo) != null) + { + client.getWidget(widgetInfo).setHidden(hidden); + } + }); + } + +}