Merge pull request #20 from runelite-extended/pvpupdate

PvP update
This commit is contained in:
Kyleeld
2019-04-21 00:27:31 +01:00
committed by GitHub
33 changed files with 2750 additions and 1694 deletions

View File

@@ -54,6 +54,7 @@ public enum WidgetInfo
WORLD_MAP_SURFACE_SELECTOR(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.SURFACE_SELECTOR), 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_TOOLTIP(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.TOOLTIP),
WORLD_MAP_OPTION(WidgetID.WORLD_MAP_MENU_GROUP_ID, WidgetID.WorldMap.OPTION), 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_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), 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_HEALTH_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.HEALTH_ORB),
MINIMAP_SPEC_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.SPEC_ORB), MINIMAP_SPEC_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.SPEC_ORB),
MINIMAP_WORLDMAP_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_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(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), LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, WidgetID.LoginClickToPlayScreen.MESSAGE_OF_THE_DAY),

View File

@@ -24,17 +24,18 @@
*/ */
package net.runelite.client.config; package net.runelite.client.config;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
public class ConfigDescriptor public class ConfigDescriptor
{ {
private final ConfigGroup group; private final ConfigGroup group;
private final Collection<ConfigItemDescriptor> items; private final Collection<ConfigItemsGroup> itemGroups;
public ConfigDescriptor(ConfigGroup group, Collection<ConfigItemDescriptor> items) public ConfigDescriptor(ConfigGroup group, Collection<ConfigItemsGroup> itemGroups)
{ {
this.group = group; this.group = group;
this.items = items; this.itemGroups = itemGroups;
} }
public ConfigGroup getGroup() public ConfigGroup getGroup()
@@ -42,8 +43,22 @@ public class ConfigDescriptor
return group; return group;
} }
public Collection<ConfigItemsGroup> getItemGroups()
{
return itemGroups;
}
public Collection<ConfigItemDescriptor> getItems() public Collection<ConfigItemDescriptor> getItems()
{ {
return items; Collection<ConfigItemDescriptor> allItems = new ArrayList<>();
for (ConfigItemsGroup g : itemGroups)
{
for (ConfigItemDescriptor item : g.getItems())
{
allItems.add(item);
}
}
return allItems;
} }
}
}

View File

@@ -46,4 +46,7 @@ public @interface ConfigItem
String warning() default ""; String warning() default "";
boolean secret() default false; boolean secret() default false;
String group() default "";
} }

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2018, Craftiii4 <craftiii4@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.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<ConfigItemDescriptor> items;
public ConfigItemsGroup(String group)
{
this.group = group;
this.items = new ArrayList<>();
}
public void addItem(ConfigItemDescriptor item)
{
items.add(item);
}
}

View File

@@ -47,7 +47,9 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -462,7 +464,35 @@ public class ConfigManager
.result()) .result())
.collect(Collectors.toList()); .collect(Collectors.toList());
return new ConfigDescriptor(group, items); Collection<ConfigItemsGroup> 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);
} }
/** /**

View File

@@ -108,6 +108,10 @@ public enum AgilityShortcut
AL_KHARID_MINING_PITCLIFF_SCRAMBLE(38, "Rocks", new WorldPoint(3305, 3315, 0), ROCKS_16549, ROCKS_16550), 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), 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_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_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), 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), YANILLE_DUNGEON_BALANCE(40, "Balancing Ledge", null, BALANCING_LEDGE_23548),

View File

@@ -1,59 +1,57 @@
/* /*
* Copyright (c) 2019 Hydrox6 <ikada@protonmail.ch> * Copyright (c) 2019 Hydrox6 <ikada@protonmail.ch>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this * 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * 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 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.client.plugins.ammo; package net.runelite.client.plugins.ammo;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import lombok.Getter; import lombok.Getter;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.Counter; import net.runelite.client.ui.overlay.infobox.Counter;
import net.runelite.client.util.StackFormatter; import net.runelite.client.util.StackFormatter;
public class AmmoCounter extends Counter class AmmoCounter extends Counter
{ {
@Getter @Getter
private int itemID; private final int itemID;
private final String name;
@Getter
private String name; AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image)
{
public AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image) super(image, plugin, count);
{ this.itemID = itemID;
super(image, plugin, count); this.name = name;
this.itemID = itemID; }
this.name = name;
} @Override
public String getText()
@Override {
public String getText() return StackFormatter.quantityToRSDecimalStack(getCount());
{ }
return StackFormatter.quantityToRSDecimalStack(getCount());
} @Override
public String getTooltip()
@Override {
public String getTooltip() return name;
{ }
return name; }
}
}

View File

@@ -43,8 +43,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
@PluginDescriptor( @PluginDescriptor(
name = "Ammo", name = "Ammo",
description = "Shows the current ammo the player has equipped", description = "Shows the current ammo the player has equipped",
tags = {"bolts", "darts", "chinchompa"}, tags = {"bolts", "darts", "chinchompa", "equipment"}
type = "utility"
) )
public class AmmoPlugin extends Plugin public class AmmoPlugin extends Plugin
{ {
@@ -63,20 +62,21 @@ public class AmmoPlugin extends Plugin
private AmmoCounter counterBox; private AmmoCounter counterBox;
@Override @Override
public void startUp() throws Exception protected void startUp() throws Exception
{ {
clientThread.invokeLater(() -> clientThread.invokeLater(() ->
{ {
ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT); final ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT);
if (container != null) if (container != null)
{ {
parseInventory(container.getItems()); checkInventory(container.getItems());
} }
}); });
} }
@Override @Override
public void shutDown() throws Exception protected void shutDown() throws Exception
{ {
infoBoxManager.removeInfoBox(counterBox); infoBoxManager.removeInfoBox(counterBox);
counterBox = null; counterBox = null;
@@ -90,10 +90,10 @@ public class AmmoPlugin extends Plugin
return; 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, // Check for weapon slot items. This overrides the ammo slot,
// as the player will use the thrown weapon (eg. chinchompas, knives, darts) // as the player will use the thrown weapon (eg. chinchompas, knives, darts)
@@ -126,7 +126,7 @@ public class AmmoPlugin extends Plugin
updateInfobox(ammo, comp); 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()) if (counterBox != null && counterBox.getItemID() == item.getId())
{ {

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import lombok.Getter;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.client.plugins.freezetimers.Spell;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import org.jetbrains.annotations.NotNull;
public class Barrage public class Barrage extends Spell
extends Spell { {
public static final long DURATION = 20000L;
@Getter
public static final long DURATION = 20000;
private long remainingTime; private long remainingTime;
@Getter
private boolean isFinished; private boolean isFinished;
public Barrage(Actor affectedTarget, Actor caster) {
public Barrage(Actor affectedTarget, Actor caster)
{
super(affectedTarget, caster); super(affectedTarget, caster);
} }
public long getRemainingTime() { public long getRemainingTime()
{
long elapsedTime = System.currentTimeMillis() - this.startTime; long elapsedTime = System.currentTimeMillis() - this.startTime;
if (Barrage.getDURATION() > elapsedTime) { if (getDURATION() > elapsedTime)
return Barrage.getDURATION() - elapsedTime; {
return getDURATION() - elapsedTime;
} }
this.isFinished = true; else
return 0L; {
} this.isFinished = true;
return 0;
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();
} }
return false;
} }
public static long getDURATION() { public boolean equals(Object o)
return 20000L; {
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;
}
} }

View File

@@ -5,38 +5,75 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
@ConfigGroup(value="freezetimers") @ConfigGroup("freezetimers")
public interface FreezeTimersConfig public interface FreezeTimersConfig extends Config
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() { @ConfigItem(
position = 0,
keyName = "freezeenable",
name = "Enable PvP freeze timers",
description = "Configures whether or not to show freeze timers."
)
default boolean EnableFreezeTimers()
{
return false; 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.") @ConfigItem(
default public boolean drawTiles() { 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; return false;
} }
@ConfigItem(position=2, keyName="timercolor", name="Freeze Timer Color", description="Color of freeze timer") @ConfigItem(
default public Color FreezeTimerColor() { position = 2,
keyName = "timercolor",
name = "Freeze Timer Color",
description = "Color of freeze timer"
)
default Color FreezeTimerColor()
{
return new Color(0, 184, 212); 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") @ConfigItem(
default public boolean spellIcon() { 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; return true;
} }
@ConfigItem(position=4, keyName="refreezeTimer", name="Refreeze Timer", description="Show a timer that counts up until the target can be refrozen") @ConfigItem(
default public boolean refreezeTimer() { 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; return true;
} }
@ConfigItem(position=5, keyName="refreezeTimerColor", name="Refreeze color", description="The color for the timer that counts until the target can be refrozen") @ConfigItem(
default public Color RefreezeTimerColor() { 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; return Color.red;
} }
@ConfigItem(position = 6, keyName = "tbtimer", name = "Tele Block Timer", description = "Enables tele block timer") @ConfigItem(position = 6, keyName = "tbtimer", name = "Tele Block Timer", description = "Enables tele block timer")
default boolean TBTimer() { default boolean TBTimer() {

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Stroke; import java.awt.font.TextLayout;
import java.awt.image.BufferedImage; import java.awt.image.*;
import java.util.function.BiConsumer;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.HeadIcon; import net.runelite.api.*;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.client.game.SpriteManager; 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.FontManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition; 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; import net.runelite.client.ui.overlay.OverlayUtil;
@Singleton @Singleton
public class FreezeTimersOverlay public class FreezeTimersOverlay extends Overlay
extends Overlay { {
private final FreezeTimersService FreezeTimersService; private final FreezeTimersService FreezeTimersService;
private final FreezeTimersConfig config; private final FreezeTimersConfig config;
private final FreezeTimersPlugin plugin; private final FreezeTimersPlugin plugin;
@@ -35,123 +36,165 @@ extends Overlay {
private final Client client; private final Client client;
@Inject @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.config = config;
this.FreezeTimersService = FreezeTimersService2; this.FreezeTimersService = FreezeTimersService;
this.plugin = plugin; this.plugin = plugin;
this.client = client; this.client = client;
this.spriteManager = spriteManager; this.spriteManager = spriteManager;
this.setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
this.setPriority(OverlayPriority.MED); setPriority(OverlayPriority.MED);
} }
@Override @Override
public Dimension render(Graphics2D graphics) { public Dimension render(Graphics2D graphics)
if (!this.config.EnableFreezeTimers()) { {
if (!config.EnableFreezeTimers())
{
return null; return null;
} }
this.FreezeTimersService.forEachPlayer((player, color) -> this.renderPlayerOverlay(graphics, (Player)player, (Color)color)); FreezeTimersService.forEachPlayer((player, color) -> renderPlayerOverlay(graphics, player, color));
return null; return null;
} }
private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) { private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color)
BufferedImage clanchatImage; {
int timer = 0; int timer = 0;
String name = actor.getName(); String name = actor.getName();
int freezetype = this.plugin.freezetype(name); int freezetype = plugin.freezetype(name);
boolean frozenoverlay = false; boolean frozenoverlay = false;
int offset = 5; int offset = 5;
long dtime = this.plugin.opponentfreezetime(name); long dtime = plugin.opponentfreezetime(name);
long tbed = plugin.istbed(name); long tbed = plugin.istbed(name);
Point textLocation = null; Point textLocation = null;
HeadIcon headIcon = actor.getOverheadIcon(); HeadIcon headIcon = actor.getOverheadIcon();
int freezetime = 0; int freezetime = 0;
if (freezetype == 1 || freezetype == 4) { if (freezetype == 1 || freezetype == 4)
{
freezetime = 5000; freezetime = 5000;
} else if (freezetype == 2 || freezetype == 5) { }
else if (freezetype == 2 || freezetype == 5)
{
freezetime = 10000; freezetime = 10000;
} else if (freezetype == 3 || freezetype == 6) { }
else if (freezetype == 3 || freezetype == 6)
{
freezetime = 15000; freezetime = 15000;
} else if (freezetype == 7) { }
else if (freezetype == 7)
{
freezetime = 20000; freezetime = 20000;
} else if (freezetype == 8) { }
else if (freezetype == 8)
{
freezetime = 2500; freezetime = 2500;
} else if (freezetype == 9) { }
else if (freezetype == 9)
{
freezetime = 5000; freezetime = 5000;
} else if (freezetype == 10) { }
else if (freezetype == 10)
{
freezetime = 7500; freezetime = 7500;
} }
long currenttime = System.currentTimeMillis(); long currenttime = System.currentTimeMillis();
long timediff = currenttime - dtime; long timediff = currenttime - dtime;
timer = (freezetime - (int)timediff) / 1000; timer = (freezetime - (int) timediff) / 1000;
if (timediff < (long)freezetime) {
textLocation = actor.getCanvasTextLocation(graphics, String.valueOf(timer), actor.getLogicalHeight() + config.FreezeTimerPos()); 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()); textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos());
} else if (timediff < (long)(freezetime + 3000)) { }
timer = Math.abs(timer); else
++timer; {
if (this.config.refreezeTimer()) { if (timediff < freezetime + 3000)
textLocation = actor.getCanvasTextLocation(graphics, String.valueOf(timer), actor.getLogicalHeight() + config.FreezeTimerPos()); {
textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); timer = Math.abs(timer);
graphics.setFont(FontManager.getRunescapeBoldFont()); timer += 1;
if (headIcon != null) { if (config.refreezeTimer())
{
textLocation = actor.getCanvasTextLocation(graphics, String.valueOf((timer)), offset);
textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); 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 { else
this.plugin.deleteopponent(name); {
} 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);
} }
} }
if (config.TBTimer()) { if (textLocation != null)
if (tbed > 0) { {
int type = plugin.tbtype(name); BufferedImage clanchatImage = plugin.GetFreezeIcon(freezetype - 1);
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 (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);
}
}
}
}
}
}
}

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import net.runelite.api.events.*;
import net.runelite.client.eventbus.Subscribe;
import com.google.inject.Provides; import com.google.inject.Provides;
import javax.inject.Inject;
import java.awt.*; import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.*; 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.*;
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.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.inject.Inject;
import net.runelite.api.*; 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.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.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.SpriteManager; import net.runelite.client.game.SpriteManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import 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.ui.overlay.OverlayManager;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
@PluginDescriptor( @PluginDescriptor(
name = "Freeze Timers", name = "Freeze Timers",
description = "PVP Freeze Timers", description = "PVP Freeze Timers",
tags = {"PvP", "Freeze", "Timers"}, type = "PVP",
type = "PVP" tags = {"PvP", "Freeze", "Timers", "pklite"}
) )
public class FreezeTimersPlugin extends Plugin
public class FreezeTimersPlugin {
extends Plugin {
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject @Inject
private FreezeTimersConfig config; private FreezeTimersConfig config;
@Inject @Inject
private FreezeTimersOverlay FreezeTimersOverlay; private FreezeTimersOverlay FreezeTimersOverlay;
@Inject @Inject
private FreezeTimersTileOverlay FreezeTimersTileOverlay; private FreezeTimersTileOverlay FreezeTimersTileOverlay;
@Inject @Inject
private Client client; private Client client;
@Inject @Inject
private SpriteManager spriteManager; private SpriteManager spriteManager;
private static final int[] FREEZE_ICONS = { @Provides
SpriteID.SPELL_BIND, FreezeTimersConfig provideConfig(ConfigManager configManager)
SpriteID.SPELL_SNARE, {
SpriteID.SPELL_ENTANGLE, return configManager.getConfig(FreezeTimersConfig.class);
SpriteID.SPELL_ICE_RUSH, }
SpriteID.SPELL_ICE_BURST,
SpriteID.SPELL_ICE_BLITZ, private static final int[] FREEZE_ICONS =
SpriteID.SPELL_ICE_BARRAGE, {
SpriteID.SPELL_BIND, SpriteID.SPELL_BIND,
SpriteID.SPELL_SNARE, SpriteID.SPELL_SNARE,
SpriteID.SPELL_ENTANGLE, SpriteID.SPELL_ENTANGLE,
SpriteID.SPELL_TELE_BLOCK SpriteID.SPELL_ICE_RUSH,
}; SpriteID.SPELL_ICE_BURST,
private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(25, 25); 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 static final Color FREEZE_ICON_OUTLINE_COLOR = new Color(33, 33, 33);
private final BufferedImage[] FreezeIcons = new BufferedImage[FREEZE_ICONS.length]; private final BufferedImage[] FreezeIcons = new BufferedImage[FREEZE_ICONS.length];
private final int SPLASH_ID = 85; private final int SPLASH_ID = 85;
Map<String, Long> tbedthings = new HashMap<>(); Map<String, Long> tbedthings = new HashMap<>();
Map<String, Integer> tbtypes = new HashMap<>(); Map<String, Integer> tbtypes = new HashMap<>();
@@ -108,248 +95,319 @@ extends Plugin {
String currtarget; String currtarget;
String spell; String spell;
@Provides
FreezeTimersConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(FreezeTimersConfig.class);
}
@Subscribe @Subscribe
public void onGameStateChanged(GameStateChanged gameStateChanged) { public void onGameStateChanged(GameStateChanged gameStateChanged) {
if (gameStateChanged.getGameState() == GameState.LOGGED_IN) { if (gameStateChanged.getGameState() == GameState.LOGGED_IN) {
this.loadFreezeIcons(); loadFreezeIcons();
} }
} }
@Override @Override
protected void startUp() throws Exception { protected void startUp() throws Exception {
this.overlayManager.add(this.FreezeTimersOverlay); overlayManager.add(FreezeTimersOverlay);
this.overlayManager.add(this.FreezeTimersTileOverlay); overlayManager.add(FreezeTimersTileOverlay);
} }
@Override @Override
protected void shutDown() throws Exception { protected void shutDown() throws Exception {
this.overlayManager.remove(this.FreezeTimersOverlay); overlayManager.remove(FreezeTimersOverlay);
this.overlayManager.remove(this.FreezeTimersTileOverlay); overlayManager.remove(FreezeTimersTileOverlay);
this.frozenthings.clear(); frozenthings.clear();
this.frozenthingpoints.clear(); frozenthingpoints.clear();
this.tbedthings.clear(); tbedthings.clear();
this.tbtypes.clear(); tbtypes.clear();
} }
@Subscribe @Subscribe
public void onMenuOptionClicked(MenuOptionClicked event) { public void onMenuOptionClicked(MenuOptionClicked event)
if (event.getMenuTarget().contains("->")) { {
Pattern spattern = Pattern.compile(">(.+?)</col>"); if (event.getMenuTarget().contains("->"))
Pattern ppattern = Pattern.compile("> <col=ffffff>(.+?)<col="); {
Matcher smatch = spattern.matcher(event.getMenuTarget()); final Pattern spattern = Pattern.compile(">(.+?)</col>");
Matcher pmatch = ppattern.matcher(event.getMenuTarget()); final Pattern ppattern = Pattern.compile("> <col=ffffff>(.+?)<col=");
final Matcher smatch = spattern.matcher(event.getMenuTarget());
final Matcher pmatch = ppattern.matcher(event.getMenuTarget());
smatch.find(); smatch.find();
pmatch.find(); pmatch.find();
if (smatch.group(1) != null && pmatch.group(1) != null) { if (smatch.group(1) != null && pmatch.group(1) != null)
this.currticks = this.ticks; {
this.spell = smatch.group(1); currticks = ticks;
this.currtarget = pmatch.group(1).replace("\u00a0", " "); spell = smatch.group(1);
currtarget = pmatch.group(1).replace(" ", " ");
} }
} }
} }
@Subscribe @Subscribe
public void onExperienceChanged(ExperienceChanged event) { public void onExperienceChanged(ExperienceChanged event)
if (event.getSkill() == Skill.MAGIC) { {
int xp = this.client.getSkillExperience(Skill.MAGIC); if (event.getSkill() == Skill.MAGIC)
int gains = xp - this.lastxp; {
this.lastxp = xp; final int xp = client.getSkillExperience(Skill.MAGIC);
if (!this.magexp.containsKey(this.ticks)) { int gains = xp - lastxp;
this.magexp.clear(); lastxp = xp;
this.magexp.put(this.ticks, gains); if (!magexp.containsKey(ticks))
{
magexp.clear();
magexp.put(ticks, gains);
} }
} }
} }
@Subscribe @Subscribe
private void onAnimationChanged(AnimationChanged event) { private void onAnimationChanged(AnimationChanged event)
Logger l = this.client.getLogger(); {
Actor subject = event.getActor(); Logger l = client.getLogger();
Actor target = subject.getInteracting(); final Actor subject = event.getActor();
if (subject.getAnimation() == 1979) { final Actor target = subject.getInteracting();
try {
if (target.getGraphic() == 85 || target.getGraphic() != -1) { if (subject.getAnimation() == 1979)
{
try
{
if (target.getGraphic() == SPLASH_ID || target.getGraphic() != -1)
{
return; return;
} }
if (this.frozenthings.containsKey(target.getName())) { if (frozenthings.containsKey(target.getName()))
{
return; return;
} }
this.testMap.put(target.getName(), new Barrage(target, subject)); testMap.put(target.getName(), new Barrage(target, subject));
this.freezetype.put(target.getName(), 7); freezetype.put(target.getName(), 7);
this.frozenthings.put(target.getName(), System.currentTimeMillis()); frozenthings.put(target.getName(), System.currentTimeMillis());
this.frozenthingpoints.put(target.getName(), target.getWorldLocation()); frozenthingpoints.put(target.getName(), target.getWorldLocation());
} }
catch (NullPointerException nullPointerException) { catch (NullPointerException e)
// empty catch block {
//no
} }
} }
} }
@Subscribe @Subscribe
public void onGameTick(GameTick event) { public void onGameTick(GameTick event)
{
int xp = 0; int xp = 0;
boolean praymage = false; boolean praymage = false;
if (this.magexp.containsKey(this.ticks)) { if (magexp.containsKey(ticks))
xp = this.magexp.get(this.ticks); {
xp = magexp.get(ticks);
} }
if (xp > 0 && this.currtarget != null) { if (xp > 0 && currtarget != null)
if (this.frozenthings.containsKey(this.currtarget)) { {
this.currtarget = null; if (frozenthings.containsKey(currtarget))
{
currtarget = null;
return; return;
} }
WorldPoint targetPosition = null; WorldPoint targetPosition = null;
for (Player player : this.client.getPlayers()) { for (Player player : client.getPlayers())
String playerName; {
if (player == null || !(playerName = player.getName()).equals(this.currtarget)) continue; if (player == null)
if (player.getOverheadIcon() != null && player.getOverheadIcon().equals((Object)HeadIcon.MAGIC)) { {
praymage = true; 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 (targetPosition != null)
if (this.spell.equals("Bind") && xp > 30) { {
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); if (spell.equals("Bind") && xp > 30)
this.frozenthingpoints.put(this.currtarget, targetPosition); {
if (praymage) { frozenthings.put(currtarget, System.currentTimeMillis());
this.freezetype.put(this.currtarget, 8); frozenthingpoints.put(currtarget, targetPosition);
} else { if (praymage)
this.freezetype.put(this.currtarget, 1); {
freezetype.put(currtarget, 8);
} }
} else if (this.spell.equals("Snare") && xp > 60) { else
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); {
this.frozenthingpoints.put(this.currtarget, targetPosition); freezetype.put(currtarget, 1);
if (praymage) {
this.freezetype.put(this.currtarget, 9);
} else {
this.freezetype.put(this.currtarget, 2);
} }
} else if (this.spell.equals("Entangle") && xp >= 89) { }
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); else if (spell.equals("Snare") && xp > 60)
this.frozenthingpoints.put(this.currtarget, targetPosition); {
if (praymage) { frozenthings.put(currtarget, System.currentTimeMillis());
this.freezetype.put(this.currtarget, 10); frozenthingpoints.put(currtarget, targetPosition);
} else { if (praymage)
this.freezetype.put(this.currtarget, 3); {
freezetype.put(currtarget, 9);
} }
} else if (this.spell.equals("Ice Rush") && xp > 34) { else
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); {
this.frozenthingpoints.put(this.currtarget, targetPosition); freezetype.put(currtarget, 2);
this.freezetype.put(this.currtarget, 4); }
} else if (this.spell.equals("Ice Burst") && xp > 40) { }
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); else if (spell.equals("Entangle") && xp >= 89)
this.frozenthingpoints.put(this.currtarget, targetPosition); {
this.freezetype.put(this.currtarget, 5); frozenthings.put(currtarget, System.currentTimeMillis());
} else if (this.spell.equals("Ice Blitz") && xp > 46) { frozenthingpoints.put(currtarget, targetPosition);
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); if (praymage)
this.frozenthingpoints.put(this.currtarget, targetPosition); {
this.freezetype.put(this.currtarget, 6); freezetype.put(currtarget, 10);
} else if (this.spell.equals("Ice Barrage") && xp > 52) { }
Barrage barrage = new Barrage(this.client.getLocalPlayer().getInteracting(), this.client.getLocalPlayer()); else
this.testMap.put(this.currtarget, barrage); {
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); freezetype.put(currtarget, 3);
this.frozenthingpoints.put(this.currtarget, targetPosition); }
this.freezetype.put(this.currtarget, 7); }
} else if (spell.equals("Tele Block") && xp == 95) { else if (spell.equals("Ice Rush") && xp > 34)
if (config.TBTimer()) { {
if (praymage) { frozenthings.put(currtarget, System.currentTimeMillis());
this.tbtypes.put(this.currtarget, 2); frozenthingpoints.put(currtarget, targetPosition);
} else { freezetype.put(currtarget, 4);
this.tbtypes.put(this.currtarget, 1); }
} else if (spell.equals("Ice Burst") && xp > 40)
this.tbedthings.put(this.currtarget, System.currentTimeMillis()); {
} 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) { if (currtarget != null && ticks > currticks + 1)
Player local = this.client.getLocalPlayer(); {
Player local = client.getLocalPlayer();
Actor interacting = local.getInteracting(); Actor interacting = local.getInteracting();
if (interacting != null) { if (interacting != null)
if (!interacting.getName().equals(this.currtarget)) { {
this.currtarget = null; if (!interacting.getName().equals(currtarget))
{
currtarget = null;
} }
} else { }
this.currtarget = null; else
{
currtarget = null;
} }
} }
++this.ticks; ticks++;
} }
public long opponentfreezetime(String name) { public long opponentfreezetime(String name)
if (this.frozenthings.containsKey(name)) { {
return this.frozenthings.get(name); if (frozenthings.containsKey(name))
{
return frozenthings.get(name);
} }
return 0L; return 0;
} }
public WorldPoint playerpos(String name) { public WorldPoint playerpos(String name)
if (this.frozenthingpoints.containsKey(name)) { {
return this.frozenthingpoints.get(name); if (frozenthingpoints.containsKey(name))
{
return frozenthingpoints.get(name);
} }
return null; return null;
} }
public void updatePosition(String name, WorldPoint point) { public void updatePosition(String name, WorldPoint point)
if (this.frozenthingpoints.containsKey(name)) { {
this.frozenthingpoints.remove(name); if (frozenthingpoints.containsKey(name))
this.frozenthingpoints.put(name, point); {
frozenthingpoints.remove(name);
frozenthingpoints.put(name, point);
} }
} }
public int freezetype(String name) { public int freezetype(String name)
if (this.freezetype.containsKey(name)) { {
return this.freezetype.get(name); if (freezetype.containsKey(name))
{
return freezetype.get(name);
} }
return 0; return 0;
} }
public long istbed(String name) {
if (this.tbedthings.containsKey(name)) { public long istbed(String name) {
return this.tbedthings.get(name); if (tbedthings.containsKey(name)) {
} return 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);
} }
if (this.frozenthingpoints.containsKey(name)) { return 0;
this.frozenthingpoints.remove(name); }
public int tbtype(String name) {
if (tbtypes.containsKey(name)) {
return tbtypes.get(name);
} }
if (this.freezetype.containsKey(name)) { return 0;
this.freezetype.remove(name); }
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)) { public void deletetb(String name) {
this.tbedthings.remove(name); if (tbedthings.containsKey(name)) {
} tbedthings.remove(name);
if (this.tbtypes.containsKey(name)) { }
this.tbtypes.remove(name); if (tbtypes.containsKey(name)) {
} tbtypes.remove(name);
} }
private void loadFreezeIcons() { }
IndexedSprite[] freezeIcons = new IndexedSprite[]{};
IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length); private void loadFreezeIcons()
{
final IndexedSprite[] freezeIcons = {};
final IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length);
int curPosition = 0; int curPosition = 0;
int i = 0;
while (i < FREEZE_ICONS.length) { for (int i = 0; i < FREEZE_ICONS.length; i++, curPosition++)
int resource = FREEZE_ICONS[i]; {
this.FreezeIcons[i] = FreezeTimersPlugin.rgbaToIndexedBufferedImage(FreezeTimersPlugin.FreezeIconFromSprite(this.spriteManager.getSprite(resource, 0))); final int resource = FREEZE_ICONS[i];
newfreezeIcons[curPosition] = FreezeTimersPlugin.createIndexedSprite(this.client, this.FreezeIcons[i]); FreezeIcons[i] = rgbaToIndexedBufferedImage(FreezeIconFromSprite(spriteManager.getSprite(resource, 0)));
++i; newfreezeIcons[curPosition] = createIndexedSprite(client, FreezeIcons[i]);
++curPosition;
} }
} }
@@ -373,7 +431,7 @@ extends Plugin {
} }
private static BufferedImage rgbaToIndexedBufferedImage(BufferedImage sourceBufferedImage) { 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(); ColorModel cm = indexedImage.getColorModel();
IndexColorModel icm = (IndexColorModel)cm; IndexColorModel icm = (IndexColorModel)cm;
int size = icm.getMapSize(); int size = icm.getMapSize();
@@ -383,21 +441,23 @@ extends Plugin {
icm.getReds(reds); icm.getReds(reds);
icm.getGreens(greens); icm.getGreens(greens);
icm.getBlues(blues); icm.getBlues(blues);
WritableRaster raster = indexedImage.getRaster();
int pixel = raster.getSample(0, 0, 0); final WritableRaster raster = indexedImage.getRaster();
IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel); final int pixel = raster.getSample(0, 0, 0);
BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null); 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); resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null);
return resultIndexedImage; return resultIndexedImage;
} }
private static BufferedImage FreezeIconFromSprite(BufferedImage freezeSprite) { private static BufferedImage FreezeIconFromSprite(final BufferedImage freezeSprite)
BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, FreezeTimersPlugin.FREEZE_ICON_DIMENSION.width, FreezeTimersPlugin.FREEZE_ICON_DIMENSION.height); {
final BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, FREEZE_ICON_DIMENSION.width, FREEZE_ICON_DIMENSION.height);
return ImageUtil.outlineImage(freezeCanvas, FREEZE_ICON_OUTLINE_COLOR); return ImageUtil.outlineImage(freezeCanvas, FREEZE_ICON_OUTLINE_COLOR);
} }
BufferedImage GetFreezeIcon(int id) { BufferedImage GetFreezeIcon(int id)
return this.FreezeIcons[id]; {
return FreezeIcons[id];
} }
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import java.awt.Color; import java.awt.Color;
import java.util.List; import java.util.Objects;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.client.plugins.freezetimers.FreezeTimersConfig;
import net.runelite.client.plugins.freezetimers.FreezeTimersPlugin;
@Singleton @Singleton
public class FreezeTimersService { public class FreezeTimersService
{
private final Client client; private final Client client;
private final FreezeTimersConfig config; private final FreezeTimersConfig config;
private final FreezeTimersPlugin plugin; private final FreezeTimersPlugin plugin;
@Inject @Inject
private FreezeTimersService(Client client, FreezeTimersConfig config, FreezeTimersPlugin plugin) { private FreezeTimersService(Client client, FreezeTimersConfig config, FreezeTimersPlugin plugin)
{
this.config = config; this.config = config;
this.plugin = plugin; this.plugin = plugin;
this.client = client; this.client = client;
} }
public void forEachPlayer(BiConsumer<Player, Color> consumer) { public void forEachPlayer(final BiConsumer<Player, Color> consumer)
for (Player player : this.client.getPlayers()) { {
if (player == null || player.getName() == null) continue;
for (Player player : client.getPlayers())
{
if (player == null || player.getName() == null)
{
continue;
}
String name = player.getName(); String name = player.getName();
int freezetype = this.plugin.freezetype(name); int freezetype = plugin.freezetype(name);
long tbed = plugin.istbed(name); long dtime = plugin.opponentfreezetime(name);
long dtime = this.plugin.opponentfreezetime(name); long tbed = plugin.istbed(name);
int freezetime = 0; int freezetime = 0;
if (freezetype == 1 || freezetype == 4) { if (freezetype == 1 || freezetype == 4)
{
freezetime = 5000; freezetime = 5000;
} else if (freezetype == 2 || freezetype == 5) { }
else if (freezetype == 2 || freezetype == 5)
{
freezetime = 10000; freezetime = 10000;
} else if (freezetype == 3 || freezetype == 6) { }
else if (freezetype == 3 || freezetype == 6)
{
freezetime = 15000; freezetime = 15000;
} else if (freezetype == 7) { }
else if (freezetype == 7)
{
freezetime = 20000; freezetime = 20000;
} else if (freezetype == 8) { }
else if (freezetype == 8)
{
freezetime = 2500; freezetime = 2500;
} else if (freezetype == 9) { }
else if (freezetype == 9)
{
freezetime = 5000; freezetime = 5000;
} else if (freezetype == 10) { }
else if (freezetype == 10)
{
freezetime = 7500; freezetime = 7500;
} }
if (dtime <= 0L) continue; if (dtime > 0)
long currenttime = System.currentTimeMillis(); {
long timediff = currenttime - dtime; long currenttime = System.currentTimeMillis();
if (timediff < (long)freezetime) { long timediff = currenttime - dtime;
WorldPoint lastWorldPoint; if (timediff < freezetime)
WorldPoint currentWorldPoint = player.getWorldLocation(); {
if (currentWorldPoint.equals(lastWorldPoint = this.plugin.playerpos(name))) { WorldPoint currentWorldPoint = player.getWorldLocation();
consumer.accept(player, this.config.FreezeTimerColor()); WorldPoint lastWorldPoint = plugin.playerpos(name);
continue; 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) { else
this.plugin.updatePosition(name, currentWorldPoint); {
consumer.accept(player, this.config.FreezeTimerColor()); if (timediff < freezetime + 3000)
continue; {
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;
}
} }
} }
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.util.function.BiConsumer;
import javax.inject.Inject; 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.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
public class FreezeTimersTileOverlay public class FreezeTimersTileOverlay extends Overlay
extends Overlay { {
private final FreezeTimersService FreezeTimersService; private final FreezeTimersService FreezeTimersService;
private final FreezeTimersConfig config; private final FreezeTimersConfig config;
@Inject @Inject
private FreezeTimersTileOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService2) { private FreezeTimersTileOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService)
{
this.config = config; this.config = config;
this.FreezeTimersService = FreezeTimersService2; this.FreezeTimersService = FreezeTimersService;
this.setLayer(OverlayLayer.ABOVE_SCENE); setLayer(OverlayLayer.ABOVE_SCENE);
this.setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
this.setPriority(OverlayPriority.MED); setPriority(OverlayPriority.MED);
} }
@Override @Override
public Dimension render(Graphics2D graphics) { public Dimension render(Graphics2D graphics)
if (!this.config.drawTiles()) { {
if (!config.drawTiles())
{
return null; return null;
} }
this.FreezeTimersService.forEachPlayer((player, color) -> {
Polygon poly = player.getCanvasTilePoly(); FreezeTimersService.forEachPlayer((player, color) ->
if (poly != null) { {
final Polygon poly = player.getCanvasTilePoly();
if (poly != null)
{
OverlayUtil.renderPolygon(graphics, poly, color); OverlayUtil.renderPolygon(graphics, poly, color);
} }
}); });
return null; return null;
} }
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
public enum PlayerSpellEffect { import lombok.Getter;
import lombok.Setter;
public enum PlayerSpellEffect
{
BARRAGE("Ice Barrage", 20000, false), BARRAGE("Ice Barrage", 20000, false),
BLITZ("Ice Blitz", 15000, 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.SPELL_NAME = name;
this.duration = duration; this.duration = duration;
this.halvable = halvable; this.halvable = halvable;
this.startTime = System.currentTimeMillis(); 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;
}
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import lombok.Getter;
import net.runelite.api.Actor; import net.runelite.api.Actor;
public abstract class Spell { public abstract class Spell
{
@Getter
private final Actor affectedTarget; private final Actor affectedTarget;
@Getter
private final Actor caster; private final Actor caster;
@Getter
public final long startTime; public final long startTime;
private long remainingTime; private long remainingTime;
@Getter
private boolean isFinished; private boolean isFinished;
protected Spell(Actor affectedTarget, Actor caster) { protected Spell(Actor affectedTarget, Actor caster)
{
this.affectedTarget = affectedTarget; this.affectedTarget = affectedTarget;
this.caster = caster; this.caster = caster;
this.startTime = System.currentTimeMillis(); 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;
} }
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/ */
package net.runelite.client.plugins.pvptools; 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.api.Client;
import net.runelite.client.plugins.pvptools.PvpToolsPlugin;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
public class CurrentPlayersJFrame import javax.swing.*;
extends JFrame { import java.awt.*;
public JList currentPlayersJList; 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<String> list) { public class CurrentPlayersJFrame extends JFrame
int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); {
int y = client.getCanvas().getLocationOnScreen().y;
JPanel scrollContainerCurrent = new JPanel(new BorderLayout()); public JList currentPlayersJList;
JScrollPane jScrollPane = new JScrollPane(scrollContainerCurrent);
JButton refreshJButton = new JButton("Refresh"); CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener); {
JButton copyJButton = new JButton("Copy List"); super();
this.currentPlayersJList = new JList<Object>(list.toArray()); int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth();
ActionListener copyButtonActionListener = e -> { int y = client.getCanvas().getLocationOnScreen().y;
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); JPanel scrollContainerCurrent = new JPanel(new BorderLayout());
StringBuilder stringBuilder = new StringBuilder();
list.forEach(s -> { JScrollPane jScrollPane = new JScrollPane(scrollContainerCurrent);
stringBuilder.append((String)s); JButton refreshJButton = new JButton("Refresh");
stringBuilder.append(System.getProperty("line.separator")); refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener);
}); JButton copyJButton = new JButton("Copy List");
StringSelection stringSelection = new StringSelection(stringBuilder.toString()); currentPlayersJList = new JList(list.toArray());
clipboard.setContents(stringSelection, stringSelection); ActionListener copyButtonActionListener = e ->
}; {
copyJButton.addActionListener(copyButtonActionListener); StringSelection stringSelection;
this.setTitle("Current CC Members"); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
this.setDefaultCloseOperation(2); StringBuilder stringBuilder = new StringBuilder();
JLabel titleLabel = new JLabel("Current CC Members"); list.forEach(s ->
titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(1, 18.0f)); {
this.currentPlayersJList.setFont(new Font("Arial", 0, 14)); stringBuilder.append(s);
scrollContainerCurrent.add((Component)refreshJButton, "North"); stringBuilder.append(System.getProperty("line.separator"));
scrollContainerCurrent.add((Component)titleLabel, "Center"); });
JPanel footerPanel = new JPanel(new BorderLayout()); stringSelection = new StringSelection(stringBuilder.toString());
footerPanel.add((Component)this.currentPlayersJList, "North"); clipboard.setContents(stringSelection, stringSelection);
footerPanel.add((Component)copyJButton, "Center"); };
scrollContainerCurrent.add((Component)footerPanel, "South"); copyJButton.addActionListener(copyButtonActionListener);
this.add(jScrollPane); this.setTitle("Current CC Members");
this.setLocation(x, y); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); JLabel titleLabel = new JLabel("Current CC Members");
this.pack(); titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18));
this.setVisible(true); 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);
}
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/ */
package net.runelite.client.plugins.pvptools; package net.runelite.client.plugins.pvptools;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Canvas; import java.awt.Container;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.Vector;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import net.runelite.api.ClanMember;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.plugins.pvptools.PvpToolsPlugin;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
public class MissingPlayersJFrame public class MissingPlayersJFrame extends JFrame
extends JFrame { {
public JList missingPlayersJList;
MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list) { public JList missingPlayersJList;
int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth();
int y = client.getCanvas().getLocationOnScreen().y; MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
JPanel scrollConatiner = new JPanel(new BorderLayout()); {
JScrollPane jScrollPane = new JScrollPane(scrollConatiner); super();
JButton refreshJButton = new JButton("Refresh"); int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth();
refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener); int y = client.getCanvas().getLocationOnScreen().y;
JButton copyJButton = new JButton("Copy List"); JPanel scrollConatiner = new JPanel(new BorderLayout());
this.missingPlayersJList = new JList<Object>(list.toArray());
ActionListener copyButtonActionListener = e -> { JScrollPane jScrollPane = new JScrollPane(scrollConatiner);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); JButton refreshJButton = new JButton("Refresh");
StringBuilder stringBuilder = new StringBuilder(); refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener);
list.forEach(s -> { JButton copyJButton = new JButton("Copy List");
stringBuilder.append((String)s); missingPlayersJList = new JList(list.toArray());
stringBuilder.append(System.getProperty("line.separator")); ActionListener copyButtonActionListener = e ->
}); {
StringSelection stringSelection = new StringSelection(stringBuilder.toString()); StringSelection stringSelection;
clipboard.setContents(stringSelection, stringSelection); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}; StringBuilder stringBuilder = new StringBuilder();
copyJButton.addActionListener(copyButtonActionListener); list.forEach(s ->
this.setTitle("Missing CC Members"); {
this.setDefaultCloseOperation(2); stringBuilder.append(s);
JLabel titleLabel = new JLabel("Missing CC Members"); stringBuilder.append(System.getProperty("line.separator"));
titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(1, 18.0f)); });
this.missingPlayersJList.setFont(new Font("Arial", 0, 14)); stringSelection = new StringSelection(stringBuilder.toString());
scrollConatiner.add((Component)refreshJButton, "North"); clipboard.setContents(stringSelection, stringSelection);
scrollConatiner.add((Component)titleLabel, "Center"); };
JPanel footerPanel = new JPanel(new BorderLayout()); copyJButton.addActionListener(copyButtonActionListener);
footerPanel.add((Component)this.missingPlayersJList, "North"); this.setTitle("Missing CC Members");
footerPanel.add((Component)copyJButton, "Center"); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
scrollConatiner.add((Component)footerPanel, "South"); JLabel titleLabel = new JLabel("Missing CC Members");
this.add(jScrollPane); titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18));
this.setLocation(x, y); missingPlayersJList.setFont(new Font("Arial", Font.PLAIN, 14));
this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); scrollConatiner.add(refreshJButton, BorderLayout.NORTH);
this.pack(); scrollConatiner.add(titleLabel, BorderLayout.CENTER);
this.setVisible(true); 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);
}
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/ */
package net.runelite.client.plugins.pvptools; 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.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind; import net.runelite.client.config.Keybind;
@ConfigGroup(value="pvptools") @ConfigGroup("pvptools")
public interface PvpToolsConfig public interface PvpToolsConfig extends Config
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) @ConfigItem(
default public boolean countPlayers() { keyName = "countPlayers",
return true; 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) @ConfigItem(
default public boolean countOverHeads() { keyName = "countOverHeads",
return true; 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) @ConfigItem(
default public boolean fallInHelper() { keyName = "fallInHelper",
return true; 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) @ConfigItem(
default public Keybind hotkey() { keyName = "hotkey",
return Keybind.NOT_SET; 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) @ConfigItem(
default public boolean attackOptionsClan() { keyName = "attackOptionsClan",
return false; 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) @ConfigItem(
default public boolean attackOptionsFriend() { keyName = "attackOptionsFriend",
return false; 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) @ConfigItem(
default public Keybind attackOptionsHotkey() { keyName = "attackOptionsHotkey",
return Keybind.CTRL; 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) @ConfigItem(
default public boolean levelRangeAttackOptions() { keyName = "levelRangeAttackOptions",
return false; 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) @ConfigItem(
default public boolean riskCalculatorEnabled() { keyName = "riskCalculator",
return true; 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) @ConfigItem(
default public boolean missingPlayersEnabled() { keyName = "missingPlayers",
return true; 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;
}
} }

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/ */
package net.runelite.client.plugins.pvptools; package net.runelite.client.plugins.pvptools;
import java.awt.BasicStroke; import java.awt.*;
import java.awt.Color; import java.util.ArrayList;
import java.awt.Dimension; import java.util.Arrays;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.Shape;
import java.awt.Stroke;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Actor;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Player;
import net.runelite.api.Point; 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.FontManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; 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.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.OverlayUtil;
public class PvpToolsOverlay public class PvpToolsOverlay extends Overlay
extends Overlay { {
private PvpToolsPlugin pvpToolsPlugin; private PvpToolsPlugin pvpToolsPlugin;
private PvpToolsConfig pvpToolsConfig; private PvpToolsConfig pvpToolsConfig;
private Client client; private Client client;
@Inject @Inject
private PvpToolsOverlay(PvpToolsConfig pvpToolsConfig, PvpToolsPlugin pvpToolsPlugin, Client client) { private PvpToolsOverlay(PvpToolsConfig pvpToolsConfig, PvpToolsPlugin pvpToolsPlugin, Client client)
this.pvpToolsPlugin = pvpToolsPlugin; {
this.pvpToolsConfig = pvpToolsConfig; this.pvpToolsPlugin = pvpToolsPlugin;
this.client = client; this.pvpToolsConfig = pvpToolsConfig;
this.setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client;
this.setPriority(OverlayPriority.HIGH); setLayer(OverlayLayer.ABOVE_WIDGETS);
this.setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGH);
} 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);
}
}
} }
@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);
}
}
}

View File

@@ -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) <stonewall@thots.cc.usa>, 2019
*
*/ */
package net.runelite.client.plugins.pvptools; package net.runelite.client.plugins.pvptools;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.Font; import java.awt.Font;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.LayoutManager;
import javax.inject.Inject; import javax.inject.Inject;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLiteProperties; import net.runelite.client.RuneLiteProperties;
import net.runelite.client.plugins.info.JRichTextPane; import net.runelite.client.plugins.info.JRichTextPane;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PvpToolsPanel @Slf4j
extends PluginPanel { 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();
public static String htmlLabel(String key, String value) { private final JLabel loggedLabel = new JLabel();
return "<html><body style = 'color:#a5a5a5'>" + key + "<span style = 'color:white'>" + value + "</span></body></html>"; 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() { public static String htmlLabel(String key, String value)
this.numOther.setText("Disabled"); {
this.numCC.setText("Disabled"); return "<html><body style = 'color:#a5a5a5'>" + key + "<span style = 'color:white'>" + value + "</span></body></html>";
this.numCC.repaint(); }
this.numOther.repaint();
}
public void disablePrayerCount() { void init()
this.numMageJLabel.setText("disabled"); {
this.numRangeJLabel.setText("disabled"); setLayout(new BorderLayout());
this.numMeleeJLabel.setText("disabled"); setBackground(ColorScheme.DARK_GRAY_COLOR);
this.numMageJLabel.repaint(); setBorder(new EmptyBorder(10, 10, 10, 10));
this.numRangeJLabel.repaint();
this.numMeleeJLabel.repaint();
}
public void disableRiskCalculator() {
this.totalRiskLabel.setText("disabled");
this.riskProtectingItem.setText("disabled"); JPanel versionPanel = new JPanel();
this.biggestItemLabel.setText("disabled"); versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
this.totalRiskLabel.repaint(); versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
this.riskProtectingItem.repaint(); versionPanel.setLayout(new GridLayout(0, 1));
this.biggestItemLabel.repaint();
} 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();
}
} }

View File

@@ -63,6 +63,7 @@ import java.awt.image.BufferedImage;
name = "Supplies Used Tracker", name = "Supplies Used Tracker",
description = "Tracks supplies used during the session", description = "Tracks supplies used during the session",
tags = {"cost"}, tags = {"cost"},
type = "PVM",
enabledByDefault = false enabledByDefault = false
) )
@Slf4j @Slf4j

View File

@@ -1,34 +1,68 @@
package net.runelite.client.plugins.whalewatchers; package net.runelite.client.plugins.whalewatchers;
import java.awt.*; import java.awt.Color;
import net.runelite.client.config.*; 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") @ConfigGroup("WhaleWatchers")
public interface WhaleWatchersConfig extends Config 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() { @ConfigItem(
return false; position = 1,
} keyName = "protectItemWarning",
name = "Protect Item Warning",
@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") description = "Warns you when you are skulled and don't have protect item turned on."
default boolean showDamageCounter() { )
return true; default boolean protectItemWarning()
} {
return false;
@Alpha }
@ConfigItem(position = 3, keyName = "damageBackgroundColor", name = "Counter Background Color", description = "The background color for the damage counter overlay")
default Color damageBackgroundColor() { @ConfigItem(
return Color.darkGray; position = 2,
} keyName = "showDamageCounter",
name = "Damage Counter",
@ConfigItem(position = 4, keyName = "smiteableWarning", name = "Smite Warning", description = "Displays a warning overlay when your prayer is at a smiteable level") description = "Shows damage you've done and damage your opponent has done to you while in a fight"
default boolean smiteableWarning() { )
return true; default boolean showDamageCounter()
} {
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; @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;
}
} }

View File

@@ -1,48 +1,72 @@
package net.runelite.client.plugins.whalewatchers; package net.runelite.client.plugins.whalewatchers;
import net.runelite.api.*; import java.awt.Color;
import javax.inject.*; import java.awt.Dimension;
import net.runelite.client.ui.overlay.*; import java.awt.Graphics2D;
import net.runelite.api.kit.*; import javax.inject.Inject;
import java.awt.*; import net.runelite.api.Client;
import net.runelite.client.ui.overlay.components.*; import net.runelite.api.ItemID;
import java.awt.image.*; import net.runelite.api.kit.KitType;
import net.runelite.client.game.*; 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 public class WhaleWatchersGloryOverlay extends Overlay
{ {
private Client client; private Client client;
private final WhaleWatchersConfig config; private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin; private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent; private PanelComponent panelComponent;
@Inject
private ItemManager itemManager; @Inject
private ItemManager itemManager;
@Inject
public WhaleWatchersGloryOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { @Inject
this.client = client; public WhaleWatchersGloryOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin)
this.config = config; {
this.plugin = plugin; this.client = client;
this.setLayer(OverlayLayer.ABOVE_WIDGETS); this.config = config;
this.setPriority(OverlayPriority.HIGH); this.plugin = plugin;
this.setPosition(OverlayPosition.DETACHED); setLayer(OverlayLayer.ABOVE_WIDGETS);
this.panelComponent = new PanelComponent(); setPriority(OverlayPriority.HIGH);
} setPosition(OverlayPosition.DETACHED);
panelComponent = new PanelComponent();
@Override }
public Dimension render(final Graphics2D graphics) {
this.panelComponent.getChildren().clear(); @Override
int amuletID = 0; public Dimension render(Graphics2D graphics)
try { {
amuletID = this.client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET); panelComponent.getChildren().clear();
} int amuletID = 0;
catch (NullPointerException ex) {} try
if (this.config.gloryWarning() && amuletID == 1704) { {
this.panelComponent.setBackgroundColor(Color.lightGray); amuletID = client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET);
final AsyncBufferedImage gloryImage = this.itemManager.getImage(1704); }
this.panelComponent.getChildren().add(TitleComponent.builder().text("Uncharged Glory").color(Color.BLACK).build()); catch (NullPointerException e)
this.panelComponent.getChildren().add(new ImageComponent(gloryImage)); {
}
return this.panelComponent.render(graphics); }
} 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);
}
} }

View File

@@ -1,51 +1,79 @@
package net.runelite.client.plugins.whalewatchers; package net.runelite.client.plugins.whalewatchers;
import net.runelite.api.*; import java.awt.Color;
import net.runelite.client.ui.overlay.*; import java.awt.Dimension;
import javax.inject.*; import java.awt.Graphics2D;
import net.runelite.client.ui.overlay.components.*; import javax.inject.Inject;
import java.awt.*; 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 public class WhaleWatchersOverlay extends Overlay
{ {
private Client client; private Client client;
private final WhaleWatchersConfig config; private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin; private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent; private PanelComponent panelComponent;
private String lastOpponent; private String lastOpponent = "-";
@Inject @Inject
public WhaleWatchersOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { public WhaleWatchersOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin)
this.lastOpponent = "-"; {
this.client = client; this.client = client;
this.config = config; this.config = config;
this.plugin = plugin; this.plugin = plugin;
this.setLayer(OverlayLayer.ABOVE_WIDGETS); setLayer(OverlayLayer.ABOVE_WIDGETS);
this.setPriority(OverlayPriority.HIGH); setPriority(OverlayPriority.HIGH);
this.setPosition(OverlayPosition.DETACHED); setPosition(OverlayPosition.DETACHED);
this.panelComponent = new PanelComponent(); panelComponent = new PanelComponent();
} }
@Override @Override
public Dimension render(final Graphics2D graphics) { public Dimension render(Graphics2D graphics)
this.panelComponent.getChildren().clear(); {
if (this.plugin.inCombat && this.config.showDamageCounter()) { panelComponent.getChildren().clear();
this.panelComponent.setBackgroundColor(this.config.damageBackgroundColor());
final String opp = (this.client.getLocalPlayer().getInteracting() != null) ? this.client.getLocalPlayer().getInteracting().getName() : this.lastOpponent; if (plugin.inCombat && config.showDamageCounter())
if (this.client.getLocalPlayer().getInteracting() != null) { {
this.lastOpponent = this.client.getLocalPlayer().getInteracting().getName(); panelComponent.setBackgroundColor(config.damageBackgroundColor());
} String opp = client.getLocalPlayer().getInteracting() != null ?
final String opponent = "Fight vs " + opp; client.getLocalPlayer().getInteracting().getName() : lastOpponent;
final String damageTaken = "Damage Taken: " + this.plugin.damageTaken; if (client.getLocalPlayer().getInteracting() != null)
final String damageDealt = "Damage Dealt: " + this.plugin.damageDone; {
this.panelComponent.getChildren().add(TitleComponent.builder().text(opponent).color(Color.BLACK).build()); lastOpponent = client.getLocalPlayer().getInteracting().getName();
this.panelComponent.getChildren().add(TitleComponent.builder().text(damageDealt).color(Color.BLACK).build()); }
this.panelComponent.getChildren().add(TitleComponent.builder().text(damageTaken).color(Color.BLACK).build()); final String opponent = "Fight vs " + opp;
this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(damageDealt) + graphics.getFontMetrics().stringWidth(opponent) + 10, 0)); String damageTaken = "Damage Taken: " + plugin.damageTaken;
} String damageDealt = "Damage Dealt: " + plugin.damageDone;
else {
this.panelComponent.getChildren().clear(); panelComponent.getChildren().add(TitleComponent.builder()
} .text(opponent)
return this.panelComponent.render(graphics); .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);
}
} }

View File

@@ -1,200 +1,316 @@
package net.runelite.client.plugins.whalewatchers; package net.runelite.client.plugins.whalewatchers;
import com.google.inject.Provides;
import org.jetbrains.annotations.*; import java.util.Arrays;
import net.runelite.client.plugins.*; import java.util.List;
import net.runelite.client.game.*; import java.util.function.Predicate;
import net.runelite.client.config.*; import javax.inject.Inject;
import com.google.inject.*; import lombok.Getter;
import net.runelite.client.ui.overlay.*; import net.runelite.api.Actor;
import net.runelite.client.eventbus.*; import net.runelite.api.Client;
import net.runelite.api.kit.*; import net.runelite.api.GameState;
import org.apache.commons.lang3.*; import net.runelite.api.InventoryID;
import net.runelite.api.*; import net.runelite.api.ItemContainer;
import net.runelite.api.events.*; import net.runelite.api.ItemID;
import java.util.*; 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( @PluginDescriptor(
name = "Whale Watchers", name = "Whale Watchers",
description = "A Plugin to save help whales in the wild", description = "A Plugin to save help whales in the wild",
tags = { "whale watchers", "whale", "protect item", "warning", "pklite" }, tags = {"whale watchers", "whale", "protect item", "warning", "pklite"},
type = "PVP", enabledByDefault = true,
enabledByDefault = false hidden = false,
developerPlugin = false,
type = "PVP",
loadWhenOutdated = false
) )
public class WhaleWatchersPlugin extends Plugin 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) { @Inject
if (this.client.getVar(Varbits.IN_WILDERNESS) == 1 && this.client.getLocalPlayer().getInteracting() != null) { private Client client;
return true;
}
final int varp = c.getVar(VarPlayer.ATTACKING_PLAYER);
return varp != -1;
}
public boolean isDisplaySmiteOverlay() { @Inject
return this.displaySmiteOverlay; 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<String> optionsList = Arrays.asList(client.getPlayerOptions());
* <p>
* 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;
}
} }

View File

@@ -1,44 +1,59 @@
package net.runelite.client.plugins.whalewatchers; 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.api.Point;
import net.runelite.client.ui.*; import net.runelite.client.ui.FontManager;
import net.runelite.api.*; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.*; import net.runelite.client.ui.overlay.OverlayLayer;
import java.awt.*; 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 public class WhaleWatchersProtOverlay extends Overlay
{ {
private Client client;
private final WhaleWatchersConfig config; private Client client;
private WhaleWatchersPlugin plugin; private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin;
@Inject
public WhaleWatchersProtOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { @Inject
this.client = client; public WhaleWatchersProtOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin)
this.config = config; {
this.plugin = plugin; this.client = client;
this.setLayer(OverlayLayer.ABOVE_WIDGETS); this.config = config;
this.setPriority(OverlayPriority.HIGH); this.plugin = plugin;
this.setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS);
} setPriority(OverlayPriority.HIGH);
setPosition(OverlayPosition.DYNAMIC);
@Override
public Dimension render(final Graphics2D graphics) { }
if (this.plugin.enableOverlay && this.config.protectItemWarning()) {
final Rectangle rectangle = new Rectangle(); @Override
rectangle.setBounds(this.client.getCanvas().getBounds()); public Dimension render(Graphics2D graphics)
rectangle.setLocation(this.client.getCanvas().getLocation()); {
final Stroke oldStroke = graphics.getStroke(); if (plugin.enableOverlay && config.protectItemWarning())
graphics.setStroke(new BasicStroke(10.0f)); {
graphics.setColor(Color.RED); Rectangle rectangle = new Rectangle();
graphics.draw(rectangle); rectangle.setBounds(client.getCanvas().getBounds());
final Font font = FontManager.getRunescapeBoldFont().deriveFont(1, 72.0f); rectangle.setLocation(client.getCanvas().getLocation());
graphics.setFont(font); Stroke oldStroke = graphics.getStroke();
OverlayUtil.renderTextLocation(graphics, new Point((int)rectangle.getCenterX() - 50, font.getSize()), "Protect item prayer disabled!!!", Color.red); graphics.setStroke(new BasicStroke(10));
graphics.setStroke(oldStroke); graphics.setColor(Color.RED);
} graphics.draw(rectangle);
return null; 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;
}
} }

View File

@@ -1,39 +1,59 @@
package net.runelite.client.plugins.whalewatchers; package net.runelite.client.plugins.whalewatchers;
import net.runelite.api.*; import java.awt.Color;
import net.runelite.client.ui.overlay.*; import java.awt.Dimension;
import javax.inject.*; import java.awt.Graphics2D;
import java.awt.*; import javax.inject.Inject;
import net.runelite.client.ui.overlay.components.*; 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 public class WhaleWatchersSmiteableOverlay extends Overlay
{ {
private Client client; private Client client;
private WhaleWatchersPlugin plugin; private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent; private PanelComponent panelComponent;
@Inject
public WhaleWatchersSmiteableOverlay(final WhaleWatchersPlugin plugin) { @Inject
this.plugin = plugin; public WhaleWatchersSmiteableOverlay( WhaleWatchersPlugin plugin)
this.setLayer(OverlayLayer.ABOVE_WIDGETS); {
this.setPriority(OverlayPriority.HIGH); this.plugin = plugin;
this.setPosition(OverlayPosition.BOTTOM_RIGHT); setLayer(OverlayLayer.ABOVE_WIDGETS);
this.panelComponent = new PanelComponent(); setPriority(OverlayPriority.HIGH);
} setPosition(OverlayPosition.BOTTOM_RIGHT);
@Override panelComponent = new PanelComponent();
public Dimension render(final Graphics2D graphics) { }
final String subText = "You could be smited in 1 tick";
this.panelComponent.getChildren().clear(); @Override
if (this.plugin.isDisplaySmiteOverlay()) { public Dimension render(Graphics2D graphics)
this.panelComponent.setBackgroundColor(Color.WHITE); {
this.panelComponent.getChildren().add(TitleComponent.builder().text("LOW PRAYER WARNING").color(Color.BLACK).build()); String subText = "You could be smited in 1 tick";
this.panelComponent.getChildren().add(TitleComponent.builder().text(subText).color(Color.BLACK).build()); panelComponent.getChildren().clear();
this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(subText) + 20, 0)); if (plugin.isDisplaySmiteOverlay())
} {
else { panelComponent.setBackgroundColor(Color.WHITE);
this.panelComponent.getChildren().clear(); panelComponent.getChildren().add(TitleComponent.builder()
} .text("LOW PRAYER WARNING")
return this.panelComponent.render(graphics); .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);
}
} }

View File

@@ -428,6 +428,13 @@ class WorldSwitcherPanel extends PluginPanel
void populate(List<World> worlds) void populate(List<World> worlds)
{ {
Map<Integer, Integer> pingHistory = new HashMap<>();
for (WorldTableRow row : rows)
{
pingHistory.put(row.getWorld().getId(), row.getPing());
}
rows.clear(); rows.clear();
for (int i = 0; i < worlds.size(); i++) for (int i = 0; i < worlds.size(); i++)
@@ -450,7 +457,8 @@ class WorldSwitcherPanel extends PluginPanel
break; 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(); updateList();
@@ -599,7 +607,7 @@ class WorldSwitcherPanel extends PluginPanel
/** /**
* Builds a table row, that displays the world's information. * 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, WorldTableRow row = new WorldTableRow(world, current, favorite,
world1 -> world1 ->

View File

@@ -41,7 +41,7 @@ enum QuestStartLocation
IMP_CATCHER("Imp Catcher", new WorldPoint(3108, 3160, 0)), IMP_CATCHER("Imp Catcher", new WorldPoint(3108, 3160, 0)),
THE_KNIGHTS_SWORD("The Knight's Sword", new WorldPoint(2976, 3342, 0)), THE_KNIGHTS_SWORD("The Knight's Sword", new WorldPoint(2976, 3342, 0)),
MISTHALIN_MYSTERY("Misthalin Mystery", new WorldPoint(3234, 3155, 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)), PRINCE_ALI_RESCUE("Prince Ali Rescue", new WorldPoint(3301, 3163, 0)),
THE_RESTLESS_GHOST("The Restless Ghost", new WorldPoint(3240, 3210, 0)), THE_RESTLESS_GHOST("The Restless Ghost", new WorldPoint(3240, 3210, 0)),
RUNE_MYSTERIES("Rune Mysteries", new WorldPoint(3210, 3220, 0)), RUNE_MYSTERIES("Rune Mysteries", new WorldPoint(3210, 3220, 0)),

View File

@@ -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) <stonewall@thots.cc.usa>, 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;
}
}

View File

@@ -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) <stonewall@thots.cc.usa>, 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<WidgetInfo> 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);
}
});
}
}