Updated pvp plugins

This commit is contained in:
James Munson
2019-04-20 13:19:51 -07:00
parent a5383a909b
commit 88785dccf1
23 changed files with 2429 additions and 1557 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

@@ -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;
} }
else
{
this.isFinished = true; this.isFinished = true;
return 0L; return 0;
}
} }
public boolean equals(Object o) { public boolean equals(Object o)
if (o instanceof Barrage) { {
Barrage barrage = (Barrage)o; if (o instanceof Barrage)
return Text.standardize(this.getAffectedTarget().getName()).equals(Text.standardize(((Barrage)o).getAffectedTarget().getName())) && this.getStartTime() == ((Barrage)o).getStartTime(); {
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; return false;
} }
public static long getDURATION() {
return 20000L;
} }
@Override
public boolean isFinished() {
return this.isFinished;
}
} }

View File

@@ -16,9 +16,6 @@ import net.runelite.api.HeadIcon;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Point; 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;
@@ -27,7 +24,7 @@ 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;

View File

@@ -1,57 +1,31 @@
/*
* 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;
@@ -59,26 +33,37 @@ 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
FreezeTimersConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(FreezeTimersConfig.class);
}
private static final int[] FREEZE_ICONS =
{
SpriteID.SPELL_BIND, SpriteID.SPELL_BIND,
SpriteID.SPELL_SNARE, SpriteID.SPELL_SNARE,
SpriteID.SPELL_ENTANGLE, SpriteID.SPELL_ENTANGLE,
@@ -91,9 +76,11 @@ extends Plugin {
SpriteID.SPELL_ENTANGLE, SpriteID.SPELL_ENTANGLE,
SpriteID.SPELL_TELE_BLOCK SpriteID.SPELL_TELE_BLOCK
}; };
private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(25, 25);
private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(17, 17);
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,259 +95,333 @@ 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)) { {
continue;
}
String playerName = player.getName();
if (playerName.equals(currtarget))
{
if (player.getOverheadIcon() != null)
{
if (player.getOverheadIcon().equals(HeadIcon.MAGIC))
{
praymage = true; praymage = true;
} }
}
targetPosition = player.getWorldLocation(); targetPosition = player.getWorldLocation();
break; break;
} }
if (targetPosition != null) {
if (this.spell.equals("Bind") && xp > 30) {
this.frozenthings.put(this.currtarget, System.currentTimeMillis());
this.frozenthingpoints.put(this.currtarget, targetPosition);
if (praymage) {
this.freezetype.put(this.currtarget, 8);
} else {
this.freezetype.put(this.currtarget, 1);
} }
} else if (this.spell.equals("Snare") && xp > 60) { if (targetPosition != null)
this.frozenthings.put(this.currtarget, System.currentTimeMillis()); {
this.frozenthingpoints.put(this.currtarget, targetPosition); if (spell.equals("Bind") && xp > 30)
if (praymage) { {
this.freezetype.put(this.currtarget, 9); frozenthings.put(currtarget, System.currentTimeMillis());
} else { frozenthingpoints.put(currtarget, targetPosition);
this.freezetype.put(this.currtarget, 2); if (praymage)
{
freezetype.put(currtarget, 8);
} }
} else if (this.spell.equals("Entangle") && xp >= 89) { 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, 10); }
} else { else if (spell.equals("Snare") && xp > 60)
this.freezetype.put(this.currtarget, 3); {
frozenthings.put(currtarget, System.currentTimeMillis());
frozenthingpoints.put(currtarget, targetPosition);
if (praymage)
{
freezetype.put(currtarget, 9);
}
else
{
freezetype.put(currtarget, 2);
}
}
else if (spell.equals("Entangle") && xp >= 89)
{
frozenthings.put(currtarget, System.currentTimeMillis());
frozenthingpoints.put(currtarget, targetPosition);
if (praymage)
{
freezetype.put(currtarget, 10);
}
else
{
freezetype.put(currtarget, 3);
}
}
else if (spell.equals("Ice Rush") && xp > 34)
{
frozenthings.put(currtarget, System.currentTimeMillis());
frozenthingpoints.put(currtarget, targetPosition);
freezetype.put(currtarget, 4);
}
else if (spell.equals("Ice Burst") && xp > 40)
{
frozenthings.put(currtarget, System.currentTimeMillis());
frozenthingpoints.put(currtarget, targetPosition);
freezetype.put(currtarget, 5);
}
else if (spell.equals("Ice Blitz") && xp > 46)
{
frozenthings.put(currtarget, System.currentTimeMillis());
frozenthingpoints.put(currtarget, targetPosition);
freezetype.put(currtarget, 6);
}
else if (spell.equals("Ice Barrage") && xp > 52)
{
Barrage barrage = new Barrage(client.getLocalPlayer().getInteracting(), client.getLocalPlayer());
testMap.put(currtarget, barrage);
frozenthings.put(currtarget, System.currentTimeMillis());
frozenthingpoints.put(currtarget, targetPosition);
freezetype.put(currtarget, 7);
} }
} else if (this.spell.equals("Ice Rush") && xp > 34) {
this.frozenthings.put(this.currtarget, System.currentTimeMillis());
this.frozenthingpoints.put(this.currtarget, targetPosition);
this.freezetype.put(this.currtarget, 4);
} else if (this.spell.equals("Ice Burst") && xp > 40) {
this.frozenthings.put(this.currtarget, System.currentTimeMillis());
this.frozenthingpoints.put(this.currtarget, targetPosition);
this.freezetype.put(this.currtarget, 5);
} else if (this.spell.equals("Ice Blitz") && xp > 46) {
this.frozenthings.put(this.currtarget, System.currentTimeMillis());
this.frozenthingpoints.put(this.currtarget, targetPosition);
this.freezetype.put(this.currtarget, 6);
} else if (this.spell.equals("Ice Barrage") && xp > 52) {
Barrage barrage = new Barrage(this.client.getLocalPlayer().getInteracting(), this.client.getLocalPlayer());
this.testMap.put(this.currtarget, barrage);
this.frozenthings.put(this.currtarget, System.currentTimeMillis());
this.frozenthingpoints.put(this.currtarget, targetPosition);
this.freezetype.put(this.currtarget, 7);
} else if (spell.equals("Tele Block") && xp == 95) { } else if (spell.equals("Tele Block") && xp == 95) {
if (config.TBTimer()) { if (config.TBTimer()) {
if (praymage) { if (praymage) {
this.tbtypes.put(this.currtarget, 2); tbtypes.put(currtarget, 2);
} else { } else {
this.tbtypes.put(this.currtarget, 1); tbtypes.put(currtarget, 1);
} }
this.tbedthings.put(this.currtarget, System.currentTimeMillis()); tbedthings.put(currtarget, System.currentTimeMillis());
} }
} }
} }
} if (currtarget != null && ticks > currticks + 1)
if (this.currtarget != null && this.ticks > this.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))
} {
} else { currtarget = null;
this.currtarget = null;
} }
} }
++this.ticks; else
{
currtarget = null;
}
}
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) { public long istbed(String name) {
if (this.tbedthings.containsKey(name)) { if (tbedthings.containsKey(name)) {
return this.tbedthings.get(name); return tbedthings.get(name);
} }
return 0; return 0;
} }
public int tbtype(String name) { public int tbtype(String name) {
if (this.tbtypes.containsKey(name)) { if (tbtypes.containsKey(name)) {
return this.tbtypes.get(name); return tbtypes.get(name);
} }
return 0; return 0;
} }
public void deleteopponent(String name) {
if (this.frozenthings.containsKey(name)) { public void deleteopponent(String name)
this.frozenthings.remove(name); {
if (frozenthings.containsKey(name))
{
frozenthings.remove(name);
} }
if (this.frozenthingpoints.containsKey(name)) { if (frozenthingpoints.containsKey(name))
this.frozenthingpoints.remove(name); {
frozenthingpoints.remove(name);
} }
if (this.freezetype.containsKey(name)) { if (freezetype.containsKey(name))
this.freezetype.remove(name); {
} freezetype.remove(name);
}
public void deletetb(String name) {
if (this.tbedthings.containsKey(name)) {
this.tbedthings.remove(name);
}
if (this.tbtypes.containsKey(name)) {
this.tbtypes.remove(name);
}
}
private void loadFreezeIcons() {
IndexedSprite[] freezeIcons = new IndexedSprite[]{};
IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length);
int curPosition = 0;
int i = 0;
while (i < FREEZE_ICONS.length) {
int resource = FREEZE_ICONS[i];
this.FreezeIcons[i] = FreezeTimersPlugin.rgbaToIndexedBufferedImage(FreezeTimersPlugin.FreezeIconFromSprite(this.spriteManager.getSprite(resource, 0)));
newfreezeIcons[curPosition] = FreezeTimersPlugin.createIndexedSprite(this.client, this.FreezeIcons[i]);
++i;
++curPosition;
} }
} }
private static IndexedSprite createIndexedSprite(Client client, BufferedImage bufferedImage) { public void deletetb(String name) {
IndexColorModel indexedCM = (IndexColorModel)bufferedImage.getColorModel(); if (tbedthings.containsKey(name)) {
int width = bufferedImage.getWidth(); tbedthings.remove(name);
int height = bufferedImage.getHeight(); }
byte[] pixels = ((DataBufferByte)bufferedImage.getRaster().getDataBuffer()).getData(); if (tbtypes.containsKey(name)) {
int[] palette = new int[indexedCM.getMapSize()]; tbtypes.remove(name);
}
}
private void loadFreezeIcons()
{
final IndexedSprite[] freezeIcons = {};
final IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length);
int curPosition = 0;
for (int i = 0; i < FREEZE_ICONS.length; i++, curPosition++)
{
final int resource = FREEZE_ICONS[i];
FreezeIcons[i] = rgbaToIndexedBufferedImage(FreezeIconFromSprite(spriteManager.getSprite(resource, 0)));
newfreezeIcons[curPosition] = createIndexedSprite(client, FreezeIcons[i]);
}
}
private static IndexedSprite createIndexedSprite(final Client client, final BufferedImage bufferedImage)
{
final IndexColorModel indexedCM = (IndexColorModel) bufferedImage.getColorModel();
final int width = bufferedImage.getWidth();
final int height = bufferedImage.getHeight();
final byte[] pixels = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
final int[] palette = new int[indexedCM.getMapSize()];
indexedCM.getRGBs(palette); indexedCM.getRGBs(palette);
IndexedSprite newIndexedSprite = client.createIndexedSprite();
final IndexedSprite newIndexedSprite = client.createIndexedSprite();
newIndexedSprite.setPixels(pixels); newIndexedSprite.setPixels(pixels);
newIndexedSprite.setPalette(palette); newIndexedSprite.setPalette(palette);
newIndexedSprite.setWidth(width); newIndexedSprite.setWidth(width);
@@ -372,32 +433,40 @@ extends Plugin {
return newIndexedSprite; return newIndexedSprite;
} }
private static BufferedImage rgbaToIndexedBufferedImage(BufferedImage sourceBufferedImage) { private static BufferedImage rgbaToIndexedBufferedImage(final BufferedImage sourceBufferedImage)
BufferedImage indexedImage = new BufferedImage(sourceBufferedImage.getWidth(), sourceBufferedImage.getHeight(), 13); {
ColorModel cm = indexedImage.getColorModel(); final BufferedImage indexedImage = new BufferedImage(
IndexColorModel icm = (IndexColorModel)cm; sourceBufferedImage.getWidth(),
int size = icm.getMapSize(); sourceBufferedImage.getHeight(),
byte[] reds = new byte[size]; BufferedImage.TYPE_BYTE_INDEXED);
byte[] greens = new byte[size];
byte[] blues = new byte[size]; final ColorModel cm = indexedImage.getColorModel();
final IndexColorModel icm = (IndexColorModel) cm;
final int size = icm.getMapSize();
final byte[] reds = new byte[size];
final byte[] greens = new byte[size];
final byte[] blues = new byte[size];
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,75 +1,116 @@
/*
* 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 dtime = plugin.opponentfreezetime(name);
long tbed = plugin.istbed(name); long tbed = plugin.istbed(name);
long dtime = this.plugin.opponentfreezetime(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 currenttime = System.currentTimeMillis();
long timediff = currenttime - dtime; long timediff = currenttime - dtime;
if (timediff < (long)freezetime) { if (timediff < freezetime)
WorldPoint lastWorldPoint; {
WorldPoint currentWorldPoint = player.getWorldLocation(); WorldPoint currentWorldPoint = player.getWorldLocation();
if (currentWorldPoint.equals(lastWorldPoint = this.plugin.playerpos(name))) { WorldPoint lastWorldPoint = plugin.playerpos(name);
consumer.accept(player, this.config.FreezeTimerColor()); if (currentWorldPoint.equals(lastWorldPoint))
continue; {
consumer.accept(player, config.FreezeTimerColor());
} }
if (timediff < 605L) { else
this.plugin.updatePosition(name, currentWorldPoint); {
consumer.accept(player, this.config.FreezeTimerColor()); if (timediff < 605)
continue; {
plugin.updatePosition(name, currentWorldPoint);
consumer.accept(player, config.FreezeTimerColor());
} }
this.plugin.deleteopponent(name); else
continue; {
plugin.deleteopponent(name);
} }
if (timediff < (long)(freezetime + 3000)) { }
}
else
{
if (timediff < freezetime + 3000)
{
consumer.accept(player, Color.YELLOW); consumer.accept(player, Color.YELLOW);
continue; }
} else { else
this.plugin.deleteopponent(name); {
plugin.deleteopponent(name);
} }
if (tbed > 0) { if (tbed > 0) {
consumer.accept(player, config.FreezeTimerColor()); consumer.accept(player, config.FreezeTimerColor());
@@ -77,5 +118,6 @@ public class FreezeTimersService {
} }
} }
} }
}
}
} }

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);
@Getter
private final String SPELL_NAME; private final String SPELL_NAME;
@Getter
private long startTime; private long startTime;
@Getter
private int duration; private int duration;
@Getter
private boolean halvable; private boolean halvable;
//private final BufferedImage SPELL_ICON;
private PlayerSpellEffect(String name, int duration, boolean halvable) {
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,69 +1,66 @@
/* /*
* 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.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionListener;
import java.util.List;
public class CurrentPlayersJFrame extends JFrame
{
public JList currentPlayersJList; public JList currentPlayersJList;
CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list) { CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
{
super();
int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth();
int y = client.getCanvas().getLocationOnScreen().y; int y = client.getCanvas().getLocationOnScreen().y;
JPanel scrollContainerCurrent = new JPanel(new BorderLayout()); JPanel scrollContainerCurrent = new JPanel(new BorderLayout());
JScrollPane jScrollPane = new JScrollPane(scrollContainerCurrent); JScrollPane jScrollPane = new JScrollPane(scrollContainerCurrent);
JButton refreshJButton = new JButton("Refresh"); JButton refreshJButton = new JButton("Refresh");
refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener); refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener);
JButton copyJButton = new JButton("Copy List"); JButton copyJButton = new JButton("Copy List");
this.currentPlayersJList = new JList<Object>(list.toArray()); currentPlayersJList = new JList(list.toArray());
ActionListener copyButtonActionListener = e -> { ActionListener copyButtonActionListener = e ->
{
StringSelection stringSelection;
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
list.forEach(s -> { list.forEach(s ->
stringBuilder.append((String)s); {
stringBuilder.append(s);
stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append(System.getProperty("line.separator"));
}); });
StringSelection stringSelection = new StringSelection(stringBuilder.toString()); stringSelection = new StringSelection(stringBuilder.toString());
clipboard.setContents(stringSelection, stringSelection); clipboard.setContents(stringSelection, stringSelection);
}; };
copyJButton.addActionListener(copyButtonActionListener); copyJButton.addActionListener(copyButtonActionListener);
this.setTitle("Current CC Members"); this.setTitle("Current CC Members");
this.setDefaultCloseOperation(2); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JLabel titleLabel = new JLabel("Current CC Members"); JLabel titleLabel = new JLabel("Current CC Members");
titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(1, 18.0f)); titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18));
this.currentPlayersJList.setFont(new Font("Arial", 0, 14)); currentPlayersJList.setFont(new Font("Arial", Font.PLAIN, 14));
scrollContainerCurrent.add((Component)refreshJButton, "North"); scrollContainerCurrent.add(refreshJButton, BorderLayout.NORTH);
scrollContainerCurrent.add((Component)titleLabel, "Center"); scrollContainerCurrent.add(titleLabel, BorderLayout.CENTER);
JPanel footerPanel = new JPanel(new BorderLayout()); JPanel footerPanel = new JPanel(new BorderLayout());
footerPanel.add((Component)this.currentPlayersJList, "North"); footerPanel.add(currentPlayersJList, BorderLayout.NORTH);
footerPanel.add((Component)copyJButton, "Center"); footerPanel.add(copyJButton, BorderLayout.CENTER);
scrollContainerCurrent.add((Component)footerPanel, "South"); scrollContainerCurrent.add(footerPanel, BorderLayout.SOUTH);
this.add(jScrollPane); this.add(jScrollPane);
this.setLocation(x, y); this.setLocation(x, y);
this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize());
@@ -71,4 +68,3 @@ extends JFrame {
this.setVisible(true); this.setVisible(true);
} }
} }

View File

@@ -1,69 +1,75 @@
/* /*
* 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; public JList missingPlayersJList;
MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list) { MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List<String> list)
{
super();
int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth();
int y = client.getCanvas().getLocationOnScreen().y; int y = client.getCanvas().getLocationOnScreen().y;
JPanel scrollConatiner = new JPanel(new BorderLayout()); JPanel scrollConatiner = new JPanel(new BorderLayout());
JScrollPane jScrollPane = new JScrollPane(scrollConatiner); JScrollPane jScrollPane = new JScrollPane(scrollConatiner);
JButton refreshJButton = new JButton("Refresh"); JButton refreshJButton = new JButton("Refresh");
refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener); refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener);
JButton copyJButton = new JButton("Copy List"); JButton copyJButton = new JButton("Copy List");
this.missingPlayersJList = new JList<Object>(list.toArray()); missingPlayersJList = new JList(list.toArray());
ActionListener copyButtonActionListener = e -> { ActionListener copyButtonActionListener = e ->
{
StringSelection stringSelection;
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
list.forEach(s -> { list.forEach(s ->
stringBuilder.append((String)s); {
stringBuilder.append(s);
stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append(System.getProperty("line.separator"));
}); });
StringSelection stringSelection = new StringSelection(stringBuilder.toString()); stringSelection = new StringSelection(stringBuilder.toString());
clipboard.setContents(stringSelection, stringSelection); clipboard.setContents(stringSelection, stringSelection);
}; };
copyJButton.addActionListener(copyButtonActionListener); copyJButton.addActionListener(copyButtonActionListener);
this.setTitle("Missing CC Members"); this.setTitle("Missing CC Members");
this.setDefaultCloseOperation(2); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JLabel titleLabel = new JLabel("Missing CC Members"); JLabel titleLabel = new JLabel("Missing CC Members");
titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(1, 18.0f)); titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18));
this.missingPlayersJList.setFont(new Font("Arial", 0, 14)); missingPlayersJList.setFont(new Font("Arial", Font.PLAIN, 14));
scrollConatiner.add((Component)refreshJButton, "North"); scrollConatiner.add(refreshJButton, BorderLayout.NORTH);
scrollConatiner.add((Component)titleLabel, "Center"); scrollConatiner.add(titleLabel, BorderLayout.CENTER);
JPanel footerPanel = new JPanel(new BorderLayout()); JPanel footerPanel = new JPanel(new BorderLayout());
footerPanel.add((Component)this.missingPlayersJList, "North"); footerPanel.add(missingPlayersJList, BorderLayout.NORTH);
footerPanel.add((Component)copyJButton, "Center"); footerPanel.add(copyJButton, BorderLayout.CENTER);
scrollConatiner.add((Component)footerPanel, "South"); scrollConatiner.add(footerPanel, BorderLayout.SOUTH);
this.add(jScrollPane); this.add(jScrollPane);
this.setLocation(x, y); this.setLocation(x, y);
this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize());
@@ -71,4 +77,3 @@ extends JFrame {
this.setVisible(true); 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",
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; 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",
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; 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",
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; 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",
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; 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",
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; 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",
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; 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",
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; 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",
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; 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",
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; 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",
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; 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.pvpToolsPlugin = pvpToolsPlugin;
this.pvpToolsConfig = pvpToolsConfig; this.pvpToolsConfig = pvpToolsConfig;
this.client = client; this.client = client;
this.setLayer(OverlayLayer.ABOVE_WIDGETS); setLayer(OverlayLayer.ABOVE_WIDGETS);
this.setPriority(OverlayPriority.HIGH); setPriority(OverlayPriority.HIGH);
this.setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
} }
@Override @Override
public Dimension render(Graphics2D graphics) { public Dimension render(Graphics2D graphics)
if (this.pvpToolsConfig.fallInHelper() && this.pvpToolsPlugin.fallinHelperEnabled) { {
if (pvpToolsConfig.fallInHelper())
{
if (pvpToolsPlugin.fallinHelperEnabled)
{
graphics.setFont(FontManager.getRunescapeFont().deriveFont(28)); graphics.setFont(FontManager.getRunescapeFont().deriveFont(28));
OverlayUtil.renderTextLocation(graphics, new Point(200, 80), "FALL IN HELPER ENABLED", Color.YELLOW); OverlayUtil.renderTextLocation(graphics, new Point(200, 80), "FALL IN HELPER ENABLED", Color.YELLOW);
} }
}
return null; return null;
} }
private void renderPoly(Graphics2D graphics, Color color, Polygon polygon) { private void renderPoly(Graphics2D graphics, Color color, Polygon polygon)
if (polygon != null) { {
if (polygon != null)
{
graphics.setColor(color); graphics.setColor(color);
graphics.setStroke(new BasicStroke(2.0f)); graphics.setStroke(new BasicStroke(2));
graphics.draw(polygon); graphics.draw(polygon);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
graphics.fill(polygon); graphics.fill(polygon);
} }
} }
} }

View File

@@ -1,33 +1,36 @@
/* /*
* 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 JLabel loggedLabel = new JLabel();
private final JRichTextPane emailLabel = new JRichTextPane(); private final JRichTextPane emailLabel = new JRichTextPane();
public JLabel numCC = new JLabel(); public JLabel numCC = new JLabel();
@@ -46,78 +49,103 @@ extends PluginPanel {
private JPanel missingPlayersPanel = new JPanel(); private JPanel missingPlayersPanel = new JPanel();
private JPanel currentPlayersPanel = new JPanel(); private JPanel currentPlayersPanel = new JPanel();
public static String htmlLabel(String key, String value) {
public static String htmlLabel(String key, String value)
{
return "<html><body style = 'color:#a5a5a5'>" + key + "<span style = 'color:white'>" + value + "</span></body></html>"; return "<html><body style = 'color:#a5a5a5'>" + key + "<span style = 'color:white'>" + value + "</span></body></html>";
} }
void init() { void init()
this.setLayout(new BorderLayout()); {
this.setBackground(ColorScheme.DARK_GRAY_COLOR); setLayout(new BorderLayout());
this.setBorder(new EmptyBorder(10, 10, 10, 10)); setBackground(ColorScheme.DARK_GRAY_COLOR);
setBorder(new EmptyBorder(10, 10, 10, 10));
JPanel versionPanel = new JPanel(); JPanel versionPanel = new JPanel();
versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
versionPanel.setLayout(new GridLayout(0, 1)); versionPanel.setLayout(new GridLayout(0, 1));
JPanel riskPanel = new JPanel(); JPanel riskPanel = new JPanel();
riskPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); riskPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
riskPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); riskPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
riskPanel.setLayout(new GridLayout(0, 1)); riskPanel.setLayout(new GridLayout(0, 1));
Font smallFont = FontManager.getRunescapeSmallFont();
this.numCC.setText(PvpToolsPanel.htmlLabel("Friendly Player Count: ", "0")); final Font smallFont = FontManager.getRunescapeSmallFont();
this.numOther.setText(PvpToolsPanel.htmlLabel("Other Player Count: ", "0"));
this.numBrews.setText(PvpToolsPanel.htmlLabel("Player brew count: ", "0")); numCC.setText(htmlLabel("Friendly Player Count: ", "0"));
this.numMageJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Mage: ", "0")); numOther.setText(htmlLabel("Other Player Count: ", "0"));
this.numMageJLabel.setFont(FontManager.getRunescapeFont()); numBrews.setText(htmlLabel("Player brew count: ", "0"));
this.numRangeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Range: ", "0")); numMageJLabel.setText(htmlLabel("Enemies Praying Mage: ", "0"));
this.numRangeJLabel.setFont(FontManager.getRunescapeFont()); numMageJLabel.setFont(FontManager.getRunescapeFont());
this.numMeleeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Melee: ", "0")); numRangeJLabel.setText(htmlLabel("Enemies Praying Range: ", "0"));
this.numMeleeJLabel.setFont(FontManager.getRunescapeFont()); numRangeJLabel.setFont(FontManager.getRunescapeFont());
this.totalRiskLabel.setText(PvpToolsPanel.htmlLabel("Total risk: ", "0")); numMeleeJLabel.setText(htmlLabel("Enemies Praying Melee: ", "0"));
this.totalRiskLabel.setFont(FontManager.getRunescapeFont()); numMeleeJLabel.setFont(FontManager.getRunescapeFont());
this.riskProtectingItem.setText(PvpToolsPanel.htmlLabel("Risk Protecting Item: ", "0"));
this.riskProtectingItem.setFont(FontManager.getRunescapeFont()); totalRiskLabel.setText(htmlLabel("Total risk: ", "0"));
this.biggestItemLabel.setText("Most Valuable Item: "); totalRiskLabel.setFont(FontManager.getRunescapeFont());
riskProtectingItem.setText(htmlLabel("Risk Protecting Item: ", "0"));
riskProtectingItem.setFont(FontManager.getRunescapeFont());
biggestItemLabel.setText("Most Valuable Item: ");
JLabel revision = new JLabel(); JLabel revision = new JLabel();
revision.setFont(smallFont); revision.setFont(smallFont);
revision.setText("Oldschool revision: "); revision.setText("Oldschool revision: ");
JLabel launcher = new JLabel(PvpToolsPanel.htmlLabel("Launcher version: ", MoreObjects.firstNonNull(RuneLiteProperties.getLauncherVersion(), "Unknown")));
JLabel launcher = new JLabel(htmlLabel("Launcher version: ", MoreObjects
.firstNonNull(RuneLiteProperties.getLauncherVersion(), "Unknown")));
launcher.setFont(smallFont); launcher.setFont(smallFont);
this.loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
this.loggedLabel.setFont(smallFont); loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
this.emailLabel.setForeground(Color.WHITE); loggedLabel.setFont(smallFont);
this.emailLabel.setFont(smallFont);
versionPanel.add(this.numCC); emailLabel.setForeground(Color.WHITE);
versionPanel.add(this.numOther); emailLabel.setFont(smallFont);
versionPanel.add(this.numBrews);
versionPanel.add(this.numMageJLabel); versionPanel.add(numCC);
versionPanel.add(this.numRangeJLabel); versionPanel.add(numOther);
versionPanel.add(this.numMeleeJLabel); versionPanel.add(numBrews);
versionPanel.add(numMageJLabel);
versionPanel.add(numRangeJLabel);
versionPanel.add(numMeleeJLabel);
versionPanel.add(Box.createGlue()); versionPanel.add(Box.createGlue());
versionPanel.add(this.loggedLabel); versionPanel.add(loggedLabel);
versionPanel.add(this.emailLabel); versionPanel.add(emailLabel);
riskPanel.add(this.totalRiskLabel);
riskPanel.add(this.riskProtectingItem); riskPanel.add(totalRiskLabel);
riskPanel.add(this.biggestItemLabel); riskPanel.add(riskProtectingItem);
this.add((Component)versionPanel, "North"); riskPanel.add(biggestItemLabel);
this.add((Component)riskPanel, "Center");
this.currentPlayers.setVisible(false); add(versionPanel, BorderLayout.NORTH);
this.missingPlayers.setVisible(false); add(riskPanel, BorderLayout.CENTER);
this.missingPlayersPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
this.missingPlayersPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); currentPlayers.setVisible(false);
this.missingPlayersPanel.setLayout(new GridLayout(0, 1)); missingPlayers.setVisible(false);
this.missingPlayersPanel.add((Component)this.missingPlayers, "Last"); missingPlayersPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
this.missingPlayersPanel.add((Component)this.currentPlayers, "Last"); missingPlayersPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
this.add((Component)this.missingPlayersPanel, "Last"); 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() { public void disablePlayerCount()
{
this.numOther.setText("Disabled"); this.numOther.setText("Disabled");
this.numCC.setText("Disabled"); this.numCC.setText("Disabled");
this.numCC.repaint(); this.numCC.repaint();
this.numOther.repaint(); this.numOther.repaint();
} }
public void disablePrayerCount() { public void disablePrayerCount()
{
this.numMageJLabel.setText("disabled"); this.numMageJLabel.setText("disabled");
this.numRangeJLabel.setText("disabled"); this.numRangeJLabel.setText("disabled");
this.numMeleeJLabel.setText("disabled"); this.numMeleeJLabel.setText("disabled");
@@ -126,7 +154,8 @@ extends PluginPanel {
this.numMeleeJLabel.repaint(); this.numMeleeJLabel.repaint();
} }
public void disableRiskCalculator() { public void disableRiskCalculator()
{
this.totalRiskLabel.setText("disabled"); this.totalRiskLabel.setText("disabled");
this.riskProtectingItem.setText("disabled"); this.riskProtectingItem.setText("disabled");
this.biggestItemLabel.setText("disabled"); this.biggestItemLabel.setText("disabled");
@@ -135,4 +164,3 @@ extends PluginPanel {
this.biggestItemLabel.repaint(); this.biggestItemLabel.repaint();
} }
} }

View File

@@ -1,44 +1,90 @@
/*
* 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 javax.inject.*; import com.google.inject.Provides;
import java.awt.event.ActionEvent;
import com.google.inject.Inject; import java.awt.event.ActionListener;
import net.runelite.client.plugins.*; import java.awt.event.KeyEvent;
import net.runelite.client.plugins.clanchat.*; import java.awt.image.BufferedImage;
import java.util.function.*; import java.lang.reflect.Array;
import java.awt.event.*; import java.util.ArrayList;
import java.util.stream.*; import java.util.Arrays;
import java.util.concurrent.*; import java.util.Comparator;
import net.runelite.client.config.*; import java.util.List;
import com.google.inject.*; import java.util.NavigableMap;
import net.runelite.client.ui.overlay.*; import java.util.Objects;
import net.runelite.client.input.*; import java.util.TreeMap;
import net.runelite.client.ui.*; import java.util.concurrent.CopyOnWriteArrayList;
import java.awt.image.*; import java.util.concurrent.ScheduledExecutorService;
import net.runelite.client.eventbus.*; import java.util.stream.Collectors;
import org.apache.commons.lang3.*; import javax.inject.Inject;
import net.runelite.api.events.*; import lombok.AccessLevel;
import net.runelite.client.util.*; import lombok.Getter;
import net.runelite.api.*; import lombok.Setter;
import net.runelite.client.game.*; import net.runelite.api.ClanMember;
import java.util.*; import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemComposition;
import net.runelite.api.MenuEntry;
import net.runelite.api.Player;
import net.runelite.api.SkullIcon;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.PlayerDespawned;
import net.runelite.api.events.PlayerSpawned;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.AsyncBufferedImage;
import net.runelite.client.game.ClanManager;
import net.runelite.client.game.ItemManager;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginManager;
import net.runelite.client.plugins.clanchat.ClanChatPlugin;
import static net.runelite.client.plugins.pvptools.PvpToolsPanel.htmlLabel;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.PvPUtil;
import static net.runelite.client.util.StackFormatter.quantityToRSDecimalStack;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor( @PluginDescriptor(
name = "PvP Tools", name = "PvP Tools",
description = "Enable the PvP Tools panel", description = "Enable the PvP Tools panel",
tags = { "panel", "pvp", "pk", "pklite" }, tags = {"panel", "pvp", "pk", "pklite"}
type="PVP"
) )
public class PvpToolsPlugin extends Plugin public class PvpToolsPlugin extends Plugin
{ {
@Inject @Inject
PvpToolsOverlay pvpToolsOverlay; PvpToolsOverlay pvpToolsOverlay;
boolean fallinHelperEnabled; boolean fallinHelperEnabled = false;
private PvpToolsPanel panel; private PvpToolsPanel panel;
private MissingPlayersJFrame missingPlayersJFrame; private MissingPlayersJFrame missingPlayersJFrame;
private CurrentPlayersJFrame currentPlayersJFrame; private CurrentPlayersJFrame currentPlayersJFrame;
private NavigationButton navButton; private NavigationButton navButton;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean attackHotKeyPressed; private boolean attackHotKeyPressed;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean hideAll; private boolean hideAll;
@Inject @Inject
private ScheduledExecutorService executorService; private ScheduledExecutorService executorService;
@@ -48,428 +94,598 @@ public class PvpToolsPlugin extends Plugin
private Client client; private Client client;
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
private PvpToolsPlugin uhPvpToolsPlugin; private PvpToolsPlugin uhPvpToolsPlugin = this;
final ActionListener playersButtonActionListener;
final ActionListener currentPlayersActionListener; /**
* ActionListener for the missing cc members and refresh buttons
*/
final ActionListener playersButtonActionListener = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
if (missingPlayersJFrame != null)
{
missingPlayersJFrame.dispose();
missingPlayersJFrame = null;
missingPlayersJFrame = new MissingPlayersJFrame(client, uhPvpToolsPlugin, getMissingMembers());
}
else
{
missingPlayersJFrame = new MissingPlayersJFrame(client, uhPvpToolsPlugin, getMissingMembers());
}
}
};
final ActionListener currentPlayersActionListener = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
if (currentPlayersJFrame != null)
{
currentPlayersJFrame.dispose();
currentPlayersJFrame = null;
currentPlayersJFrame = new CurrentPlayersJFrame(client, uhPvpToolsPlugin, getCurrentMembers());
}
else
{
currentPlayersJFrame = new CurrentPlayersJFrame(client, uhPvpToolsPlugin, getCurrentMembers());
}
}
};
@Inject @Inject
private ClientToolbar clientToolbar; private ClientToolbar clientToolbar;
@Inject @Inject
private KeyManager keyManager; private KeyManager keyManager;
@Inject @Inject
private PvpToolsConfig config; private PvpToolsConfig config;
@Inject @Inject
private PluginManager pluginManager; private PluginManager pluginManager;
@Inject @Inject
private ClanManager clanManager; private ClanManager clanManager;
private ClanChatPlugin clanChatPlugin; private ClanChatPlugin clanChatPlugin;
private final HotkeyListener hotkeyListener; /**
private final HotkeyListener attackOptionsHotKeyListener; * The HotKeyListener for the hot key assigned in the config that triggers the Fall In Helper feature
private int[] overheadCount; */
private Comparator<Item> itemPriceComparator; private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey())
{
public void hotkeyPressed()
{
toggleFallinHelper();
}
};
private final HotkeyListener attackOptionsHotKeyListener = new HotkeyListener(() -> config.attackOptionsHotkey())
{
long lastPress = 0;
@Override
public void keyPressed(KeyEvent e)
{
attackHotKeyPressed = true;
}
@Override
public void keyReleased(KeyEvent e)
{
attackHotKeyPressed = (System.currentTimeMillis() - lastPress) < 800;
lastPress = System.currentTimeMillis();
}
};
private int[] overheadCount = new int[]{0, 0, 0};
private Comparator<Item> itemPriceComparator = new Comparator<Item>()
{
@Override
public int compare(Item o1, Item o2)
{
return (itemManager.getItemPrice(itemManager.getItemComposition(o1.getId()).getPrice())
- itemManager.getItemPrice(itemManager.getItemComposition(o2.getId()).getPrice()));
}
};
private String mtarget; private String mtarget;
public PvpToolsPlugin() { public List getMissingMembers()
this.fallinHelperEnabled = false; {
this.uhPvpToolsPlugin = this;
this.playersButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
if (PvpToolsPlugin.this.missingPlayersJFrame != null) {
PvpToolsPlugin.this.missingPlayersJFrame.dispose();
PvpToolsPlugin.this.missingPlayersJFrame = null;
PvpToolsPlugin.this.missingPlayersJFrame = new MissingPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getMissingMembers());
}
else {
PvpToolsPlugin.this.missingPlayersJFrame = new MissingPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getMissingMembers());
}
}
};
this.currentPlayersActionListener = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
if (PvpToolsPlugin.this.currentPlayersJFrame != null) {
PvpToolsPlugin.this.currentPlayersJFrame.dispose();
PvpToolsPlugin.this.currentPlayersJFrame = null;
PvpToolsPlugin.this.currentPlayersJFrame = new CurrentPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getCurrentMembers());
}
else {
PvpToolsPlugin.this.currentPlayersJFrame = new CurrentPlayersJFrame(PvpToolsPlugin.this.client, PvpToolsPlugin.this.uhPvpToolsPlugin, PvpToolsPlugin.this.getCurrentMembers());
}
}
};
this.hotkeyListener = new HotkeyListener(() -> this.config.hotkey()) {
@Override
public void hotkeyPressed() {
PvpToolsPlugin.this.toggleFallinHelper();
}
};
this.attackOptionsHotKeyListener = new HotkeyListener(() -> this.config.attackOptionsHotkey()) {
long lastPress = 0L;
@Override
public void keyPressed(final KeyEvent e) {
PvpToolsPlugin.this.attackHotKeyPressed = true;
}
@Override
public void keyReleased(final KeyEvent e) {
PvpToolsPlugin.this.attackHotKeyPressed = (System.currentTimeMillis() - this.lastPress < 800L);
this.lastPress = System.currentTimeMillis();
}
};
this.overheadCount = new int[] { 0, 0, 0 };
this.itemPriceComparator = new Comparator<Item>() {
@Override
public int compare(final Item o1, final Item o2) {
return PvpToolsPlugin.this.itemManager.getItemPrice(PvpToolsPlugin.this.itemManager.getItemComposition(o1.getId()).getPrice()) - PvpToolsPlugin.this.itemManager.getItemPrice(PvpToolsPlugin.this.itemManager.getItemComposition(o2.getId()).getPrice());
}
};
}
public List getMissingMembers() {
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers(); CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
ArrayList<String> missingMembers = new ArrayList<String>(); ArrayList missingMembers = new ArrayList();
for (ClanMember clanMember : this.client.getClanMembers()) { for (ClanMember clanMember:client.getClanMembers())
List arrayList; {
if (Objects.isNull(clanMember) || (arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList())).contains(Text.removeTags(Text.standardize(clanMember.getUsername()))) || missingMembers.contains(clanMember.getUsername())) continue; if (!Objects.isNull(clanMember))
{
List<String> arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList());
if (!arrayList.contains(Text.removeTags(Text.standardize(clanMember.getUsername()))))
{
if (!missingMembers.contains(clanMember.getUsername()))
{
missingMembers.add("[W" + clanMember.getWorld() + "] - " + clanMember.getUsername()); missingMembers.add("[W" + clanMember.getWorld() + "] - " + clanMember.getUsername());
} }
return missingMembers; }
}
} }
public List getCurrentMembers() { return missingMembers;
//Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername)
//.toArray()).collect(Collectors.toList());
}
public List getCurrentMembers()
{
CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers(); CopyOnWriteArrayList<Player> ccMembers = ClanChatPlugin.getClanMembers();
ArrayList<String> currentMembers = new ArrayList<String>(); ArrayList currentMembers = new ArrayList();
for (ClanMember clanMember : this.client.getClanMembers()) { for (ClanMember clanMember:client.getClanMembers())
List arrayList; {
if (Objects.isNull(clanMember) || !(arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList())).contains(Text.removeTags(Text.standardize(clanMember.getUsername()))) || currentMembers.contains(clanMember.getUsername())) continue; if (!Objects.isNull(clanMember))
{
List<String> arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList());
if (arrayList.contains(Text.removeTags(Text.standardize(clanMember.getUsername()))))
{
if (!currentMembers.contains(clanMember.getUsername()))
{
currentMembers.add(clanMember.getUsername()); currentMembers.add(clanMember.getUsername());
} }
return currentMembers; }
}
} }
return currentMembers;
//Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername)
//.toArray()).collect(Collectors.toList());
}
@Provides @Provides
PvpToolsConfig config(final ConfigManager configManager) { PvpToolsConfig config(ConfigManager configManager)
{
return configManager.getConfig(PvpToolsConfig.class); return configManager.getConfig(PvpToolsConfig.class);
} }
@Override @Override
protected void startUp() throws Exception { protected void startUp() throws Exception
this.overlayManager.add(this.pvpToolsOverlay); {
this.keyManager.registerKeyListener(this.hotkeyListener);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "skull.png"); overlayManager.add(pvpToolsOverlay);
(this.panel = new PvpToolsPanel()).init();
this.navButton = NavigationButton.builder().tooltip("PvP Tools").icon(icon).priority(5).panel(this.panel).build(); keyManager.registerKeyListener(hotkeyListener);
this.panel.missingPlayers.addActionListener(this.playersButtonActionListener); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "skull.png");
this.panel.currentPlayers.addActionListener(this.currentPlayersActionListener);
this.clientToolbar.addNavigation(this.navButton); panel = new PvpToolsPanel();
this.keyManager.registerKeyListener(this.attackOptionsHotKeyListener); panel.init();
if (this.config.missingPlayersEnabled()) {
this.panel.missingPlayers.setVisible(true); navButton = NavigationButton.builder()
.tooltip("PvP Tools")
.icon(icon)
.priority(5)
.panel(panel)
.build();
panel.missingPlayers.addActionListener(playersButtonActionListener);
panel.currentPlayers.addActionListener(currentPlayersActionListener);
clientToolbar.addNavigation(navButton);
keyManager.registerKeyListener(attackOptionsHotKeyListener);
if (config.missingPlayersEnabled())
{
panel.missingPlayers.setVisible(true);
} }
if (this.config.currentPlayersEnabled()) {
this.panel.currentPlayers.setVisible(true); if (config.currentPlayersEnabled())
{
panel.currentPlayers.setVisible(true);
} }
} }
@Override @Override
protected void shutDown() throws Exception { protected void shutDown() throws Exception
this.overlayManager.remove(this.pvpToolsOverlay); {
this.keyManager.unregisterKeyListener(this.hotkeyListener); overlayManager.remove(pvpToolsOverlay);
this.keyManager.unregisterKeyListener(this.attackOptionsHotKeyListener); keyManager.unregisterKeyListener(hotkeyListener);
this.clientToolbar.removeNavigation(this.navButton); keyManager.unregisterKeyListener(attackOptionsHotKeyListener);
clientToolbar.removeNavigation(navButton);
} }
@Subscribe @Subscribe
public void onConfigChanged(final ConfigChanged configChanged) { public void onConfigChanged(ConfigChanged configChanged)
if (configChanged.getGroup().equals("pvptools")) { {
final String key = configChanged.getKey(); if (configChanged.getGroup().equals("pvptools"))
switch (key) { {
case "countPlayers": { switch (configChanged.getKey())
if (this.config.countPlayers()) { {
this.updatePlayers(); case "countPlayers":
if (config.countPlayers())
{
updatePlayers();
} }
if (!this.config.countPlayers()) { if (!config.countPlayers())
this.panel.disablePlayerCount(); {
break; panel.disablePlayerCount();
} }
break; break;
case "countOverHeads":
if (config.countOverHeads())
{
countOverHeads();
} }
case "countOverHeads": { if (!config.countOverHeads())
if (this.config.countOverHeads()) { {
this.countOverHeads(); panel.disablePrayerCount();
}
if (!this.config.countOverHeads()) {
this.panel.disablePrayerCount();
break;
} }
break; break;
case "riskCalculator":
if (config.riskCalculatorEnabled())
{
getCarriedWealth();
} }
case "riskCalculator": { if (!config.riskCalculatorEnabled())
if (this.config.riskCalculatorEnabled()) { {
this.getCarriedWealth(); panel.disableRiskCalculator();
}
if (!this.config.riskCalculatorEnabled()) {
this.panel.disableRiskCalculator();
break;
} }
break; break;
} case "missingPlayers":
case "missingPlayers": { if (config.missingPlayersEnabled())
if (this.config.missingPlayersEnabled()) { {
this.panel.missingPlayers.setVisible(true); panel.missingPlayers.setVisible(true);
break;
} }
break; break;
} case "currentPlayers":
case "currentPlayers": { if (config.currentPlayersEnabled())
if (this.config.currentPlayersEnabled()) { {
this.panel.currentPlayers.setVisible(true); panel.currentPlayers.setVisible(true);
break;
} }
break; break;
} default:
break;
} }
} }
} }
@Subscribe @Subscribe
public void onItemContainerChanged(final ItemContainerChanged event) { public void onItemContainerChanged(ItemContainerChanged event)
if (event.getItemContainer().equals(this.client.getItemContainer(InventoryID.INVENTORY)) && this.config.riskCalculatorEnabled()) { {
this.getCarriedWealth(); if (event.getItemContainer().equals(client.getItemContainer(InventoryID.INVENTORY)) &&
config.riskCalculatorEnabled())
{
getCarriedWealth();
} }
} }
@Subscribe @Subscribe
public void onGameStateChanged(final GameStateChanged event) { public void onGameStateChanged(GameStateChanged event)
if (event.getGameState().equals(GameState.LOGGED_IN) && this.config.riskCalculatorEnabled()) { {
this.getCarriedWealth(); if (event.getGameState().equals(GameState.LOGGED_IN) && config.riskCalculatorEnabled())
{
getCarriedWealth();
}
if (event.getGameState().equals(GameState.LOGGED_IN))
{
if (config.countPlayers())
{
updatePlayers();
} }
if (event.getGameState().equals(GameState.LOGGED_IN) && this.config.countPlayers()) {
this.updatePlayers();
} }
} }
@Subscribe @Subscribe
public void onPlayerSpawned(final PlayerSpawned event) { public void onPlayerSpawned(PlayerSpawned event)
if (this.config.countPlayers() && PvPUtil.isAttackable(this.client, event.getPlayer())) { {
this.updatePlayers(); if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer()))
{
updatePlayers();
} }
if (this.config.countOverHeads()) { if (config.countOverHeads())
this.countOverHeads(); {
countOverHeads();
} }
} }
@Subscribe @Subscribe
public void onPlayerDespawned(final PlayerDespawned event) { public void onPlayerDespawned(PlayerDespawned event)
if (this.config.countPlayers() && PvPUtil.isAttackable(this.client, event.getPlayer())) { {
this.updatePlayers(); if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer()))
{
updatePlayers();
} }
if (this.config.countOverHeads()) { if (config.countOverHeads())
this.countOverHeads(); {
countOverHeads();
} }
} }
@Subscribe @Subscribe
public void onMenuEntryAdded(final MenuEntryAdded menuEntryAdded) { public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
if (!this.attackHotKeyPressed && (this.config.attackOptionsFriend() || this.config.attackOptionsClan() || this.config.levelRangeAttackOptions())) { {
if (this.client.getGameState() != GameState.LOGGED_IN) { if (!attackHotKeyPressed)
{
if (config.attackOptionsFriend() || config.attackOptionsClan() || config.levelRangeAttackOptions())
{
if (client.getGameState() != GameState.LOGGED_IN)
{
return; return;
} }
final Player[] players = this.client.getCachedPlayers(); Player[] players = client.getCachedPlayers();
Player player = null; Player player = null;
final int identifier = menuEntryAdded.getIdentifier(); int identifier = menuEntryAdded.getIdentifier();
if (identifier >= 0 && identifier < players.length) { if (identifier >= 0 && identifier < players.length)
{
player = players[identifier]; player = players[identifier];
} }
if (player == null) { if (player == null)
{
return; return;
} }
final String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase(); final String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase();
final String mtarget = Text.removeTags(menuEntryAdded.getTarget()).toLowerCase(); final String mtarget = Text.removeTags(menuEntryAdded.getTarget()).toLowerCase();
if ((this.attackHotKeyPressed && this.config.attackOptionsClan()) || this.config.attackOptionsFriend() || this.config.levelRangeAttackOptions()) { if (attackHotKeyPressed && config.attackOptionsClan() || config.attackOptionsFriend() ||
if (this.config.attackOptionsFriend() && player.isFriend()) { config.levelRangeAttackOptions())
this.moveEntry(mtarget); {
if (config.attackOptionsFriend() && player.isFriend())
{
moveEntry(mtarget);
} }
if (this.config.attackOptionsClan() && player.isClanMember()) { if (config.attackOptionsClan() && player.isClanMember())
this.moveEntry(mtarget); {
moveEntry(mtarget);
}
if (config.levelRangeAttackOptions() && !PvPUtil.isAttackable(client, player))
{
moveEntry(mtarget);
} }
if (this.config.levelRangeAttackOptions() && !PvPUtil.isAttackable(this.client, player)) {
this.moveEntry(mtarget);
} }
} }
} }
} }
private void moveEntry(final String mtarget) {
private void moveEntry(String mtarget)
{
this.mtarget = mtarget; this.mtarget = mtarget;
MenuEntry[] menuEntries = this.client.getMenuEntries(); MenuEntry[] menuEntries = client.getMenuEntries();
final MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
// strip out existing <col...
String target = lastEntry.getTarget(); String target = lastEntry.getTarget();
final int idx = target.indexOf(62); int idx = target.indexOf('>');
if (idx != -1) { if (idx != -1)
{
target = target.substring(idx + 1); target = target.substring(idx + 1);
} }
if (menuEntries[menuEntries.length - 1] != null) {} /*System.out.println("Contents : " + lastEntry.getTarget());
if (lastEntry.getOption().contains("attack".toLowerCase())) { System.out.println("Contents : " + lastEntry.getIdentifier());
menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1); System.out.println("Contents : " + lastEntry.getOption());
System.out.println("length : " + menuEntries.length);*/
if (menuEntries[menuEntries.length - 1] != null)
{
//System.out.println(menuEntries.length + ": " + menuEntries[menuEntries.length-1]);
} }
if (lastEntry.getOption().equals("Attack")) { if (lastEntry.getOption().contains("attack".toLowerCase()))
menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1); {
ArrayUtils.shift(menuEntries, 1);
//ArrayUtils.add(menuEntries, menuEntries.length - 2);
//menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1);
//menuEntrySwapperPlugin.swap("attack", option, mtarget, false);
} }
this.client.setMenuEntries(menuEntries); if (lastEntry.getOption().equals("Attack"))
{
ArrayUtils.shift(menuEntries, 1);
//menuEntries = ArrayUtils.sremove(menuEntries, menuEntries.length - 1);
//menuEntrySwapperPlugin.swap("attack", option, mtarget, false);
}
client.setMenuEntries(menuEntries);
} }
@Subscribe @Subscribe
public void onFocusChanged(final FocusChanged focusChanged) { public void onFocusChanged(FocusChanged focusChanged)
if (!focusChanged.isFocused()) { {
this.setAttackHotKeyPressed(false); if (!focusChanged.isFocused())
{
setAttackHotKeyPressed(false);
} }
} }
private void toggleFallinHelper() { /**
if (!this.fallinHelperEnabled) { * Enables or disables the fall in helper feature
this.client.setIsHidingEntities(true); */
this.client.setPlayersHidden(true); private void toggleFallinHelper()
this.fallinHelperEnabled = true; {
} if (!fallinHelperEnabled)
else { {
this.client.setIsHidingEntities(false); client.setIsHidingEntities(true);
this.client.setPlayersHidden(false); client.setPlayersHidden(true);
this.fallinHelperEnabled = false; fallinHelperEnabled = true;
} }
else
{
client.setIsHidingEntities(false);
client.setPlayersHidden(false);
fallinHelperEnabled = false;
} }
private void updatePrayerNumbers() {
this.panel.numMageJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Mage: ", String.valueOf(this.overheadCount[0])));
this.panel.numRangeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Range: ", String.valueOf(this.overheadCount[1])));
this.panel.numMeleeJLabel.setText(PvpToolsPanel.htmlLabel("Enemies Praying Melee: ", String.valueOf(this.overheadCount[2])));
this.panel.numMageJLabel.repaint();
this.panel.numRangeJLabel.repaint();
this.panel.numMeleeJLabel.repaint();
} }
private void updatePlayers() { /**
if (this.config.countPlayers()) { * Updates the PvP Tools panel with the numbers for enemy protection prayers
*/
private void updatePrayerNumbers()
{
panel.numMageJLabel.setText(htmlLabel("Enemies Praying Mage: ", String.valueOf(overheadCount[0])));
panel.numRangeJLabel.setText(htmlLabel("Enemies Praying Range: ", String.valueOf(overheadCount[1])));
panel.numMeleeJLabel.setText(htmlLabel("Enemies Praying Melee: ", String.valueOf(overheadCount[2])));
panel.numMageJLabel.repaint();
panel.numRangeJLabel.repaint();
panel.numMeleeJLabel.repaint();
}
/**
*
*/
private void updatePlayers()
{
if (config.countPlayers())
{
int cc = 0; int cc = 0;
int other = 0; int other = 0;
for (final Player p : this.client.getPlayers()) { for (Player p : client.getPlayers())
if (Objects.nonNull(p) && PvPUtil.isAttackable(this.client, p)) { {
if (p.isClanMember()) { if (Objects.nonNull(p))
++cc; {
if (PvPUtil.isAttackable(client, p))
{
if (p.isClanMember())
{
cc++;
} }
else { else
++other; {
other++;
} }
} }
} }
this.panel.numOther.setText(PvpToolsPanel.htmlLabel("Other Player Count: ", String.valueOf(other)));
this.panel.numCC.setText(PvpToolsPanel.htmlLabel("Friendly Player Count: ", String.valueOf(cc)));
this.panel.numCC.repaint();
this.panel.numOther.repaint();
}
} }
private void countOverHeads() { panel.numOther.setText(htmlLabel("Other Player Count: ", String.valueOf(other)));
this.overheadCount = new int[] { 0, 0, 0 }; panel.numCC.setText(htmlLabel("Friendly Player Count: ", String.valueOf(cc)));
for (final Player p : this.client.getPlayers()) { panel.numCC.repaint();
if (Objects.nonNull(p) && PvPUtil.isAttackable(this.client, p) && !p.isClanMember() && p.getOverheadIcon() != null) { panel.numOther.repaint();
switch (p.getOverheadIcon()) {
case MAGIC: {
final int[] overheadCount = this.overheadCount;
final int n = 0;
++overheadCount[n];
continue;
} }
case RANGED: {
final int[] overheadCount2 = this.overheadCount;
final int n2 = 1;
++overheadCount2[n2];
continue;
}
case MELEE: {
final int[] overheadCount3 = this.overheadCount;
final int n3 = 2;
++overheadCount3[n3];
continue;
}
}
}
}
this.updatePrayerNumbers();
} }
private void getCarriedWealth() { private void countOverHeads()
if (!this.config.riskCalculatorEnabled()) { {
overheadCount = new int[]{0, 0, 0};
for (Player p : client.getPlayers())
{
if (Objects.nonNull(p))
{
if (PvPUtil.isAttackable(client, p))
{
if (!p.isClanMember() && !(p.getOverheadIcon() == null))
{
switch (p.getOverheadIcon())
{
case MAGIC:
overheadCount[0]++;
break;
case RANGED:
overheadCount[1]++;
break;
case MELEE:
overheadCount[2]++;
break;
}
}
}
}
}
updatePrayerNumbers();
}
/**
* Calculates the player's risk based on Item Price of all items in their inventory and equipment
*/
private void getCarriedWealth()
{
if (!config.riskCalculatorEnabled())
{
return; return;
} }
if (this.client.getItemContainer(InventoryID.EQUIPMENT) == null) { if (client.getItemContainer(InventoryID.EQUIPMENT) == null)
{
return; return;
} }
if (this.client.getItemContainer(InventoryID.INVENTORY).getItems() == null) { if (client.getItemContainer(InventoryID.INVENTORY).getItems() == null)
{
return; return;
} }
final Item[] items = ArrayUtils.addAll(Objects.requireNonNull(this.client.getItemContainer(InventoryID.EQUIPMENT)).getItems(), Objects.requireNonNull(this.client.getItemContainer(InventoryID.INVENTORY)).getItems()); Item[] items = ArrayUtils.addAll(Objects.requireNonNull(client.getItemContainer(InventoryID.EQUIPMENT)).getItems(),
final TreeMap<Integer, Item> priceMap = new TreeMap<Integer, Item>(Comparator.comparingInt(Integer::intValue)); Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems());
TreeMap<Integer, Item> priceMap = new TreeMap<>(Comparator.comparingInt(Integer::intValue));
int wealth = 0; int wealth = 0;
for (final Item i : items) { for (Item i : items)
int value = this.itemManager.getItemPrice(i.getId()) * i.getQuantity(); {
final ItemComposition itemComposition = this.itemManager.getItemComposition(i.getId()); int value = (itemManager.getItemPrice(i.getId()) * i.getQuantity());
if (!itemComposition.isTradeable() && value == 0) {
final ItemComposition itemComposition = itemManager.getItemComposition(i.getId());
if (!itemComposition.isTradeable() && value == 0)
{
value = itemComposition.getPrice() * i.getQuantity(); value = itemComposition.getPrice() * i.getQuantity();
priceMap.put(value, i); priceMap.put(value, i);
} }
else { else
value = this.itemManager.getItemPrice(i.getId()) * i.getQuantity(); {
if (i.getId() > 0 && value > 0) { value = itemManager.getItemPrice(i.getId()) * i.getQuantity();
if (i.getId() > 0 && value > 0)
{
priceMap.put(value, i); priceMap.put(value, i);
} }
} }
wealth += value; wealth += value;
} }
this.panel.totalRiskLabel.setText(PvpToolsPanel.htmlLabel("Total risk: ", StackFormatter.quantityToRSDecimalStack(wealth))); panel.totalRiskLabel.setText(htmlLabel("Total risk: ", quantityToRSDecimalStack(wealth)));
this.panel.totalRiskLabel.repaint(); panel.totalRiskLabel.repaint();
int itemLimit = 0; int itemLimit = 0;
if (this.client.getLocalPlayer().getSkullIcon() != null && this.client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL) { if (client.getLocalPlayer().getSkullIcon() != null)
{
if (client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL)
{
itemLimit = 1; itemLimit = 1;
} }
if (this.client.getLocalPlayer().getSkullIcon() == null) { }
if (client.getLocalPlayer().getSkullIcon() == null)
{
itemLimit = 4; itemLimit = 4;
} }
AsyncBufferedImage itemImage = null; AsyncBufferedImage itemImage = null;
final NavigableMap<Integer, Item> descendingMap = priceMap.descendingMap();
for (int j = 0; j < itemLimit; ++j) { NavigableMap<Integer, Item> descendingMap = priceMap.descendingMap();
if (j == 0) {
if (!descendingMap.isEmpty()) { for (int i = 0; i < itemLimit; i++)
itemImage = this.itemManager.getImage(descendingMap.pollFirstEntry().getValue().getId()); {
if (i == 0)
{
if (!descendingMap.isEmpty())
{
itemImage = itemManager.getImage(descendingMap.pollFirstEntry().getValue().getId());
} }
} }
else if (!descendingMap.isEmpty()) { else
this.itemManager.getItemComposition(priceMap.descendingMap().pollFirstEntry().getValue().getId()).getName(); {
if (!descendingMap.isEmpty())
{
itemManager.getItemComposition(priceMap.descendingMap().pollFirstEntry().getValue().getId())
.getName();
} }
} }
this.panel.riskProtectingItem.setText(PvpToolsPanel.htmlLabel("Risk Protecting Item: ", StackFormatter.quantityToRSDecimalStack(descendingMap.keySet().stream().mapToInt(Integer::intValue).sum())));
this.panel.riskProtectingItem.repaint();
this.panel.biggestItemLabel.setText("Most Valuable Item: ");
if (itemImage != null) {
itemImage.addTo(this.panel.biggestItemLabel);
} }
this.panel.biggestItemLabel.repaint(); panel.riskProtectingItem.setText(htmlLabel("Risk Protecting Item: ",
quantityToRSDecimalStack(descendingMap.keySet().stream().mapToInt(Integer::intValue).sum())));
panel.riskProtectingItem.repaint();
panel.biggestItemLabel.setText("Most Valuable Item: ");
if (itemImage != null)
{
itemImage.addTo(panel.biggestItemLabel);
}
panel.biggestItemLabel.repaint();
} }
boolean isAttackHotKeyPressed() {
return this.attackHotKeyPressed;
}
void setAttackHotKeyPressed(final boolean attackHotKeyPressed) {
this.attackHotKeyPressed = attackHotKeyPressed;
}
boolean isHideAll() {
return this.hideAll;
}
void setHideAll(final boolean hideAll) {
this.hideAll = hideAll;
}
} }

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(
position = 1,
keyName = "protectItemWarning",
name = "Protect Item Warning",
description = "Warns you when you are skulled and don't have protect item turned on."
)
default boolean protectItemWarning()
{
return false; return false;
} }
@ConfigItem(position = 2, keyName = "showDamageCounter", name = "Damage Counter", description = "Shows damage you've done and damage your opponent has done to you while in a fight") @ConfigItem(
default boolean showDamageCounter() { position = 2,
keyName = "showDamageCounter",
name = "Damage Counter",
description = "Shows damage you've done and damage your opponent has done to you while in a fight"
)
default boolean showDamageCounter()
{
return true; return true;
} }
@Alpha @Alpha
@ConfigItem(position = 3, keyName = "damageBackgroundColor", name = "Counter Background Color", description = "The background color for the damage counter overlay") @ConfigItem(
default Color damageBackgroundColor() { position = 3,
keyName = "damageBackgroundColor",
name = "Counter Background Color",
description = "The background color for the damage counter overlay"
)
default Color damageBackgroundColor()
{
return Color.darkGray; return Color.darkGray;
} }
@ConfigItem(position = 4, keyName = "smiteableWarning", name = "Smite Warning", description = "Displays a warning overlay when your prayer is at a smiteable level") @ConfigItem(
default boolean smiteableWarning() { 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; return true;
} }
@ConfigItem(position = 5, keyName = "gloryWarning", name = "Glory Warning", description = "Displays a warning box while you are wearing an uncharged glory") @ConfigItem(
default boolean gloryWarning() { position = 5,
keyName = "gloryWarning",
name = "Glory Warning",
description = "Displays a warning box while you are wearing an uncharged glory"
)
default boolean gloryWarning()
{
return true; return true;
} }
} }

View File

@@ -1,13 +1,23 @@
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
{ {
@@ -15,34 +25,48 @@ public class WhaleWatchersGloryOverlay extends Overlay
private final WhaleWatchersConfig config; private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin; private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent; private PanelComponent panelComponent;
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject @Inject
public WhaleWatchersGloryOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { public WhaleWatchersGloryOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin)
{
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(); {
panelComponent.getChildren().clear();
int amuletID = 0; int amuletID = 0;
try { try
amuletID = this.client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET); {
amuletID = client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET);
} }
catch (NullPointerException ex) {} catch (NullPointerException e)
if (this.config.gloryWarning() && amuletID == 1704) { {
this.panelComponent.setBackgroundColor(Color.lightGray);
final AsyncBufferedImage gloryImage = this.itemManager.getImage(1704);
this.panelComponent.getChildren().add(TitleComponent.builder().text("Uncharged Glory").color(Color.BLACK).build());
this.panelComponent.getChildren().add(new ImageComponent(gloryImage));
} }
return this.panelComponent.render(graphics); 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,10 +1,16 @@
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
{ {
@@ -12,40 +18,62 @@ public class WhaleWatchersOverlay extends Overlay
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 ?
client.getLocalPlayer().getInteracting().getName() : lastOpponent;
if (client.getLocalPlayer().getInteracting() != null)
{
lastOpponent = client.getLocalPlayer().getInteracting().getName();
} }
final String opponent = "Fight vs " + opp; final String opponent = "Fight vs " + opp;
final String damageTaken = "Damage Taken: " + this.plugin.damageTaken; String damageTaken = "Damage Taken: " + plugin.damageTaken;
final String damageDealt = "Damage Dealt: " + this.plugin.damageDone; String damageDealt = "Damage Dealt: " + plugin.damageDone;
this.panelComponent.getChildren().add(TitleComponent.builder().text(opponent).color(Color.BLACK).build());
this.panelComponent.getChildren().add(TitleComponent.builder().text(damageDealt).color(Color.BLACK).build()); panelComponent.getChildren().add(TitleComponent.builder()
this.panelComponent.getChildren().add(TitleComponent.builder().text(damageTaken).color(Color.BLACK).build()); .text(opponent)
this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(damageDealt) + graphics.getFontMetrics().stringWidth(opponent) + 10, 0)); .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 { else
this.panelComponent.getChildren().clear(); {
panelComponent.getChildren().clear();
} }
return this.panelComponent.render(graphics); 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"},
enabledByDefault = true,
hidden = false,
developerPlugin = false,
type = "PVP", type = "PVP",
enabledByDefault = false loadWhenOutdated = false
) )
public class WhaleWatchersPlugin extends Plugin public class WhaleWatchersPlugin extends Plugin
{ {
@Inject @Inject
private Client client; private Client client;
@Inject @Inject
private WhaleWatchersConfig config; private WhaleWatchersConfig config;
@Inject @Inject
private WhaleWatchersOverlay overlay; private WhaleWatchersOverlay overlay;
@Inject @Inject
private WhaleWatchersProtOverlay whaleWatchersProtOverlay; private WhaleWatchersProtOverlay whaleWatchersProtOverlay;
@Inject @Inject
private WhaleWatchersSmiteableOverlay whaleWatchersSmiteableOverlay; private WhaleWatchersSmiteableOverlay whaleWatchersSmiteableOverlay;
@Inject @Inject
private WhaleWatchersGloryOverlay whaleWatchersGloryOverlay; private WhaleWatchersGloryOverlay whaleWatchersGloryOverlay;
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
public boolean enableOverlay;
private int lastXP; public boolean enableOverlay = false;
public int damageDone; private int lastXP = 0;
public int damageTaken; public int damageDone = 0;
public boolean inCombat; public int damageTaken = 0;
private int tickCountdown; public boolean inCombat = false;
private int tickCountdown = 0;
@Getter
private boolean displaySmiteOverlay; private boolean displaySmiteOverlay;
@Getter
private boolean displayGloryOverlay; private boolean displayGloryOverlay;
public WhaleWatchersPlugin() {
this.enableOverlay = false;
this.lastXP = 0;
this.damageDone = 0;
this.damageTaken = 0;
this.inCombat = false;
this.tickCountdown = 0;
}
@Provides @Provides
WhaleWatchersConfig getConfig(final ConfigManager configManager) { WhaleWatchersConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(WhaleWatchersConfig.class); return configManager.getConfig(WhaleWatchersConfig.class);
} }
@Override @Override
protected void startUp() throws Exception { protected void startUp() throws Exception
this.overlayManager.add(this.overlay); {
this.overlayManager.add(this.whaleWatchersProtOverlay); overlayManager.add(overlay);
this.overlayManager.add(this.whaleWatchersSmiteableOverlay); overlayManager.add(whaleWatchersProtOverlay);
this.overlayManager.add(this.whaleWatchersGloryOverlay); overlayManager.add(whaleWatchersSmiteableOverlay);
overlayManager.add(whaleWatchersGloryOverlay);
} }
@Override @Override
protected void shutDown() throws Exception { protected void shutDown() throws Exception
this.overlayManager.remove(this.overlay); {
this.overlayManager.remove(this.whaleWatchersProtOverlay); overlayManager.remove(overlay);
this.overlayManager.remove(this.whaleWatchersSmiteableOverlay); overlayManager.remove(whaleWatchersProtOverlay);
this.overlayManager.remove(this.whaleWatchersGloryOverlay); overlayManager.remove(whaleWatchersSmiteableOverlay);
overlayManager.remove(whaleWatchersGloryOverlay);
} }
@Subscribe @Subscribe
public void onHitsplatApplied(final HitsplatApplied event) { public void onHitsplatApplied(HitsplatApplied event)
if (this.config.showDamageCounter()) { {
if (!(event.getActor() == this.client.getLocalPlayer() | event.getActor() == this.client.getLocalPlayer().getInteracting())) { if (config.showDamageCounter())
{
if (!(event.getActor() == client.getLocalPlayer() |
event.getActor() == client.getLocalPlayer().getInteracting()))
{
return; return;
} }
if (this.isAttackingPlayer(this.client) || this.inCombat) { if (isAttackingPlayer(client) || inCombat)
this.inCombat = true; {
if (event.getActor() == this.client.getLocalPlayer()) { inCombat = true;
this.damageTaken += event.getHitsplat().getAmount();
if (event.getActor() == client.getLocalPlayer())
{
damageTaken += event.getHitsplat().getAmount();
} }
if (event.getActor() == this.client.getLocalPlayer().getInteracting()) { if (event.getActor() == client.getLocalPlayer().getInteracting())
this.damageDone += event.getHitsplat().getAmount(); {
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 @Subscribe
public void onItemContainerChanged(final ItemContainerChanged event) { public void onItemContainerChanged(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 (config.gloryWarning() && event.getItemContainer().equals(InventoryID.EQUIPMENT))
if (amuletID == 1704) { {
this.displayGloryOverlay = true; final int amuletID = ObjectUtils.defaultIfNull(client.getLocalPlayer()
.getPlayerComposition().getEquipmentId(KitType.AMULET), 0);
if (amuletID == ItemID.AMULET_OF_GLORY)
{
displayGloryOverlay = true;
} }
else { else
this.displayGloryOverlay = false; {
displayGloryOverlay = false;
} }
} }
else { else
this.displayGloryOverlay = false; {
displayGloryOverlay = false;
} }
} }
@Subscribe @Subscribe
public void onExperienceChanged(final ExperienceChanged event) { public void onExperienceChanged(ExperienceChanged event)
{
final Skill skill = event.getSkill(); final Skill skill = event.getSkill();
final Player player = this.client.getLocalPlayer(); final Player player = client.getLocalPlayer();
if (skill.equals(Skill.HITPOINTS) && player.getInteracting() instanceof Player) { if (skill.equals(Skill.HITPOINTS))
this.lastXP = this.client.getSkillExperience(skill); {
if (player.getInteracting() instanceof Player)
{
//lient.getLogger().info(String.valueOf(Math.round((client.getSkillExperience(skill) - lastXP) / 1.33)) + 2);
lastXP = client.getSkillExperience(skill);
}
} }
} }
@Subscribe @Subscribe
public void onMenuOptionClicked(final MenuOptionClicked event) { public void onMenuOptionClicked(MenuOptionClicked event)
if (this.config.showDamageCounter() && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER)) { {
this.inCombat = true; if (config.showDamageCounter() && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER))
{
inCombat = true;
} }
} }
@Subscribe @Subscribe
public void onVarbitChanged(final VarbitChanged event) { public void onVarbitChanged(VarbitChanged event)
if (this.config.showDamageCounter() && this.client.getVar(VarPlayer.ATTACKING_PLAYER) == -1 && this.inCombat) { {
this.tickCountdown = 10; if (config.showDamageCounter())
} {
if (this.config.protectItemWarning()) { if (client.getVar(VarPlayer.ATTACKING_PLAYER) == -1)
try { {
if (this.client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL) { if (inCombat)
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; //damageTaken = 0;
} //damageDone = 0;
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) { tickCountdown = 10;
this.enableOverlay = false;
} }
} }
else { }
this.enableOverlay = false;
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;
} }
} }
catch (NullPointerException ex) {} else
{
enableOverlay = false;
}
}
catch (NullPointerException e)
{
}
} }
} }
@Subscribe @Subscribe
public void onGameTick(final GameTick event) { public void onGameTick(GameTick event)
if (this.tickCountdown > 0 && this.tickCountdown < 11) { {
--this.tickCountdown;
if (this.tickCountdown == 1 && !this.isAttackingPlayer(this.client)) { if (tickCountdown > 0 && tickCountdown < 11)
this.inCombat = false; {
this.damageDone = 0; tickCountdown--;
this.damageTaken = 0; if (tickCountdown == 1)
{
if (!isAttackingPlayer(client))
{
inCombat = false;
damageDone = 0;
damageTaken = 0;
return; 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; 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 { else
this.displaySmiteOverlay = false; {
displaySmiteOverlay = false;
} }
} }
else { else
this.displaySmiteOverlay = false; {
displaySmiteOverlay = false;
} }
} }
public boolean isAttackingPlayer(@NotNull final Client c) { public boolean isAttackingPlayer(@NotNull Client c)
if (this.client.getVar(Varbits.IN_WILDERNESS) == 1 && this.client.getLocalPlayer().getInteracting() != null) { {
if (client.getVar(Varbits.IN_WILDERNESS) == 1 && client.getLocalPlayer().getInteracting() != null)
{
return true; return true;
} }
final int varp = c.getVar(VarPlayer.ATTACKING_PLAYER); int varp = c.getVar(VarPlayer.ATTACKING_PLAYER);
return varp != -1; return varp != -1;
} }
public boolean isDisplaySmiteOverlay() {
return this.displaySmiteOverlay;
}
public boolean isDisplayGloryOverlay() {
return this.displayGloryOverlay;
}
} }

View File

@@ -1,42 +1,57 @@
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 Client client;
private final WhaleWatchersConfig config; private final WhaleWatchersConfig config;
private WhaleWatchersPlugin plugin; private WhaleWatchersPlugin plugin;
@Inject @Inject
public WhaleWatchersProtOverlay(final WhaleWatchersConfig config, final Client client, final WhaleWatchersPlugin plugin) { public WhaleWatchersProtOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin)
{
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.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
} }
@Override @Override
public Dimension render(final Graphics2D graphics) { public Dimension render(Graphics2D graphics)
if (this.plugin.enableOverlay && this.config.protectItemWarning()) { {
final Rectangle rectangle = new Rectangle(); if (plugin.enableOverlay && config.protectItemWarning())
rectangle.setBounds(this.client.getCanvas().getBounds()); {
rectangle.setLocation(this.client.getCanvas().getLocation()); Rectangle rectangle = new Rectangle();
final Stroke oldStroke = graphics.getStroke(); rectangle.setBounds(client.getCanvas().getBounds());
graphics.setStroke(new BasicStroke(10.0f)); rectangle.setLocation(client.getCanvas().getLocation());
Stroke oldStroke = graphics.getStroke();
graphics.setStroke(new BasicStroke(10));
graphics.setColor(Color.RED); graphics.setColor(Color.RED);
graphics.draw(rectangle); graphics.draw(rectangle);
final Font font = FontManager.getRunescapeBoldFont().deriveFont(1, 72.0f); Font font = FontManager.getRunescapeBoldFont().deriveFont(Font.BOLD, 72);
graphics.setFont(font); graphics.setFont(font);
OverlayUtil.renderTextLocation(graphics, new Point((int)rectangle.getCenterX() - 50, font.getSize()), "Protect item prayer disabled!!!", Color.red); OverlayUtil.renderTextLocation(graphics, new Point((int) rectangle.getCenterX() - 50, font.getSize()), "Protect item prayer disabled!!!", Color.red);
graphics.setStroke(oldStroke); graphics.setStroke(oldStroke);
} }
return null; return null;

View File

@@ -1,10 +1,16 @@
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
{ {
@@ -12,28 +18,42 @@ public class WhaleWatchersSmiteableOverlay extends Overlay
private WhaleWatchersPlugin plugin; private WhaleWatchersPlugin plugin;
private PanelComponent panelComponent; private PanelComponent panelComponent;
@Inject @Inject
public WhaleWatchersSmiteableOverlay(final WhaleWatchersPlugin plugin) { public WhaleWatchersSmiteableOverlay( WhaleWatchersPlugin plugin)
{
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.BOTTOM_RIGHT); setPosition(OverlayPosition.BOTTOM_RIGHT);
this.panelComponent = new PanelComponent();
panelComponent = new PanelComponent();
} }
@Override @Override
public Dimension render(final Graphics2D graphics) { public Dimension render(Graphics2D graphics)
final String subText = "You could be smited in 1 tick"; {
this.panelComponent.getChildren().clear(); String subText = "You could be smited in 1 tick";
if (this.plugin.isDisplaySmiteOverlay()) { panelComponent.getChildren().clear();
this.panelComponent.setBackgroundColor(Color.WHITE); if (plugin.isDisplaySmiteOverlay())
this.panelComponent.getChildren().add(TitleComponent.builder().text("LOW PRAYER WARNING").color(Color.BLACK).build()); {
this.panelComponent.getChildren().add(TitleComponent.builder().text(subText).color(Color.BLACK).build()); panelComponent.setBackgroundColor(Color.WHITE);
this.panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(subText) + 20, 0)); panelComponent.getChildren().add(TitleComponent.builder()
.text("LOW PRAYER WARNING")
.color(Color.BLACK)
.build());
panelComponent.getChildren().add(TitleComponent.builder()
.text(subText)
.color(Color.BLACK)
.build());
panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(subText)
+ 20 , 0));
} }
else { else
this.panelComponent.getChildren().clear(); {
panelComponent.getChildren().clear();
} }
return this.panelComponent.render(graphics); return panelComponent.render(graphics);
} }
} }

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);
}
});
}
}