diff --git a/.gitignore b/.gitignore index a4f1ba7d02..177b1d7858 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,8 @@ project.properties .idea/ .project .settings/ -.classpath \ No newline at end of file +.classpath +runelite-client/src/main/resources/META-INF/MANIFEST.MF +git +classes/artifacts/client_jar/run.bat +classes/artifacts/client_jar/client.jar diff --git a/runelite-api/src/main/java/net/runelite/api/Actor.java b/runelite-api/src/main/java/net/runelite/api/Actor.java index b0bd59aec1..53166fba5b 100644 --- a/runelite-api/src/main/java/net/runelite/api/Actor.java +++ b/runelite-api/src/main/java/net/runelite/api/Actor.java @@ -38,12 +38,7 @@ import net.runelite.api.coords.WorldPoint; */ public interface Actor extends Renderable { - /** - * Used by the "Tick Counter Plugin - */ - int getActionFrame(); - int getActionFrameCycle(); - + /** * Gets the combat level of the actor. * @@ -252,4 +247,10 @@ public interface Actor extends Renderable * @param overheadText the overhead text */ void setOverheadText(String overheadText); + + /** + * Used by the "Tick Counter Plugin + */ + int getActionFrame(); + int getActionFrameCycle(); } diff --git a/runelite-api/src/main/java/net/runelite/api/AnimationID.java b/runelite-api/src/main/java/net/runelite/api/AnimationID.java index 02b3fd786c..b488d21512 100644 --- a/runelite-api/src/main/java/net/runelite/api/AnimationID.java +++ b/runelite-api/src/main/java/net/runelite/api/AnimationID.java @@ -173,7 +173,7 @@ public final class AnimationID public static final int VORKATH_ACID_ATTACK = 7957; public static final int BLACKJACK_KO = 838; public static final int VETION_EARTHQUAKE = 5507; - public static final int ZULRAH_DEATH = 5804; + public static final int ZULRAH_DEATH = 5804; // Farming public static final int FARMING_HARVEST_FRUIT_TREE = 2280; @@ -210,31 +210,7 @@ public final class AnimationID // POH Animations public static final int INCENSE_BURNER = 3687; - - // Weapons public static final int LOW_LEVEL_MAGIC_ATTACK = 1162; - public static final int HIGH_LEVEL_MAGIC_ATTACK = 1167; - public static final int BLOWPIPE_ATTACK = 5061; - - // Hydra - public static final int HYDRA_POISON_1 = 8234; - public static final int HYDRA_RANGED_1 = 8235; - public static final int HYDRA_MAGIC_1 = 8236; - public static final int HYDRA_1_1 = 8237; - public static final int HYDRA_1_2 = 8238; - public static final int HYDRA_LIGHTNING = 8241; - public static final int HYDRA_RANGED_2 = 8242; - public static final int HYDRA_MAGIC_2 = 8243; - public static final int HYDRA_2_1 = 8244; - public static final int HYDRA_2_2 = 8245; - public static final int HYDRA_FIRE = 8248; - public static final int HYDRA_RANGED_3 = 8249; - public static final int HYDRA_MAGIC_3 = 8250; - public static final int HYDRA_3_1 = 8251; - public static final int HYDRA_3_2 = 8252; - public static final int HYDRA_MAGIC_4 = 8254; - public static final int HYDRA_POISON_4 = 8254; - public static final int HYDRA_RANGED_4 = 8255; - public static final int HYDRA_4_1 = 8257; - public static final int HYDRA_4_2 = 8258; + public static final int HIGH_LEVEL_MAGIC_ATTACK = 1167; + public static final int BLOWPIPE_ATTACK = 5061; } \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/ClanMemberRank.java b/runelite-api/src/main/java/net/runelite/api/ClanMemberRank.java index 7f5a29873a..c919e343c7 100644 --- a/runelite-api/src/main/java/net/runelite/api/ClanMemberRank.java +++ b/runelite-api/src/main/java/net/runelite/api/ClanMemberRank.java @@ -39,43 +39,43 @@ public enum ClanMemberRank /** * Not in a clan. */ - UNRANKED(-1, "", -1), + UNRANKED(-1), /** * Friend rank. */ - FRIEND(0, "https://cdn.discordapp.com/attachments/556184918770843649/557023638826778635/1004.png", SpriteID.CLAN_CHAT_RANK_SMILEY_FRIEND), + FRIEND(0), /** * Recruit rank. */ - RECRUIT(1, "https://cdn.discordapp.com/attachments/556184918770843649/557023639111991306/1012-0.png", SpriteID.CLAN_CHAT_RANK_SINGLE_CHEVRON_RECRUIT), + RECRUIT(1), /** * Corporal rank. */ - CORPORAL(2, "https://cdn.discordapp.com/attachments/556184918770843649/557023638889431052/1011-0.png", SpriteID.CLAN_CHAT_RANK_DOUBLE_CHEVRON_CORPORAL), + CORPORAL(2), /** * Sergeant rank. */ - SERGEANT(3, "https://cdn.discordapp.com/attachments/556184918770843649/557023641968312321/1010-0.png", SpriteID.CLAN_CHAT_RANK_TRIPLE_CHEVRON_SERGEANT), + SERGEANT(3), /** * Lieutenant rank. */ - LIEUTENANT(4, "https://cdn.discordapp.com/attachments/556184918770843649/557023638893756416/1009-0.png", SpriteID.CLAN_CHAT_RANK_BRONZE_STAR_LIEUTENANT), + LIEUTENANT(4), /** * Captain rank. */ - CAPTAIN(5, "https://cdn.discordapp.com/attachments/556184918770843649/557023638910664734/1008-0.png", SpriteID.CLAN_CHAT_RANK_SILVER_STAR_CAPTAIN), + CAPTAIN(5), /** * General rank. */ - GENERAL(6, "https://cdn.discordapp.com/attachments/556184918770843649/557023638835036170/1007-0.png", SpriteID.CLAN_CHAT_RANK_GOLD_STAR_GENERAL), + GENERAL(6), /** * Channel owner rank. */ - OWNER(7, "https://cdn.discordapp.com/attachments/556184918770843649/557023638822453248/1006-0.png", SpriteID.CLAN_CHAT_RANK_KEY_CHANNEL_OWNER), + OWNER(7), /** * JMod rank. */ - JMOD(127, "", SpriteID.CLAN_CHAT_RANK_CROWN_JAGEX_MODERATOR); + JMOD(127); private static final Map RANKS = new HashMap<>(); @@ -87,8 +87,6 @@ public enum ClanMemberRank } } - - /** * Utility method that maps the rank value to its respective * {@link ClanMemberRank} value. @@ -101,11 +99,8 @@ public enum ClanMemberRank return RANKS.get(rank); } - /** * The value of the clan rank. */ private final int value; - private final String discavatar; - private final int spriteID; } diff --git a/runelite-api/src/main/java/net/runelite/api/InventoryID.java b/runelite-api/src/main/java/net/runelite/api/InventoryID.java index 8ce1f884b0..ff099afd70 100644 --- a/runelite-api/src/main/java/net/runelite/api/InventoryID.java +++ b/runelite-api/src/main/java/net/runelite/api/InventoryID.java @@ -82,4 +82,4 @@ public enum InventoryID { return id; } -} +} \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/ProjectileID.java b/runelite-api/src/main/java/net/runelite/api/ProjectileID.java index def8bed3e9..34d5c54f3a 100644 --- a/runelite-api/src/main/java/net/runelite/api/ProjectileID.java +++ b/runelite-api/src/main/java/net/runelite/api/ProjectileID.java @@ -44,7 +44,7 @@ public class ProjectileID public static final int VASA_RANGED_AOE = 1329; public static final int TEKTON_METEOR_AOE = 660; - public static final int OLM_FALLING_CRYSTAL_AOE = 1357; + public static final int OLM_FALLING_CRYSTAL_AOE = -1; //please help public static final int OLM_BURNING_AOE = -1; public static final int VORKATH_BOMB_AOE = 1481; @@ -84,10 +84,4 @@ public class ProjectileID public static final int VORKATH_PRAYER_DISABLE = 1471; public static final int VORKATH_VENOM = 1470; public static final int VORKATH_ICE = 350; - - public static final int HYDRA_MAGIC = 1662; - public static final int HYDRA_RANGED = 1663; - public static final int HYDRA_POISON = 1644; - public static final int HYDRA_LIGHTNING = 1664; - public static final int HYDRA_LIGHTNING_2 = 1665; } diff --git a/runelite-api/src/main/java/net/runelite/api/SpriteID.java b/runelite-api/src/main/java/net/runelite/api/SpriteID.java index e83c268535..e707854c12 100644 --- a/runelite-api/src/main/java/net/runelite/api/SpriteID.java +++ b/runelite-api/src/main/java/net/runelite/api/SpriteID.java @@ -431,7 +431,7 @@ public final class SpriteID public static final int SPELL_FIRE_SURGE_DISABLED = 415; /* Unmapped: 416, 417, 418 */ public static final int UNKNOWN_STANCE_ICON_1 = 419; - public static final int UNKNOWN_STANCE_ICON_2 = 420; + public static final int UNKNOWN_STANCE_ICON_2 = 320; public static final int UNKNOWN_STANCE_ICON_3 = 421; public static final int MINIMAP_DESTINATION_FLAG = 422; public static final int CHATBOX_BADGE_CROWN_PLAYER_MODERATOR = 423; @@ -1566,7 +1566,4 @@ public final class SpriteID public static final int MOBILE_YELLOW_TOUCH_ANIMATION_2 = 1626; public static final int TAB_MAGIC_SPELLBOOK_ARCEUUS_UNUSED = 1708; public static final int TAB_MAGIC_SPELLBOOK_ARCEUUS = 1711; - public static final int BIG_ASS_GUTHIX_SPELL = 1774; - public static final int BIG_SUPERHEAT = 1800; - public static final int BIG_SPEC_TRANSFER = 1959; } diff --git a/runelite-api/src/main/java/net/runelite/api/VarClientInt.java b/runelite-api/src/main/java/net/runelite/api/VarClientInt.java index 45354e55d2..b58e879437 100644 --- a/runelite-api/src/main/java/net/runelite/api/VarClientInt.java +++ b/runelite-api/src/main/java/net/runelite/api/VarClientInt.java @@ -45,15 +45,14 @@ public enum VarClientInt INPUT_TYPE(5), MEMBERSHIP_STATUS(103), + /** + * -1 = player inventory closed + * 3 = player inventory opened + */ + PLAYER_INVENTORY_OPENED(171), INVENTORY_TAB(171), - /** - * -1 = player inventory closed - * 3 = player inventory opened - */ - PLAYER_INVENTORY_OPENED(171), - WORLD_MAP_SEARCH_FOCUSED(190); private final int index; diff --git a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java index 62489df3f0..36ff1a18f2 100644 --- a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java +++ b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java @@ -52,7 +52,8 @@ public enum VarPlayer IN_RAID_PARTY(1427), NMZ_REWARD_POINTS(1060), - + + ATTACKING_PLAYER(1075), /** * -1 : Poison immune * Normal poison damage is ceil( this / 5.0f ) diff --git a/runelite-api/src/main/java/net/runelite/api/Varbits.java b/runelite-api/src/main/java/net/runelite/api/Varbits.java index 8a42e1247f..66dfcef672 100644 --- a/runelite-api/src/main/java/net/runelite/api/Varbits.java +++ b/runelite-api/src/main/java/net/runelite/api/Varbits.java @@ -32,564 +32,480 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum Varbits -{ - /* - * If chatbox is transparent or not - */ - TRANSPARENT_CHATBOX(4608), +public enum Varbits { + /* + * If chatbox is transparent or not + */ + TRANSPARENT_CHATBOX(4608), - /* - * If the player has an active stamina potion effect or not - */ - RUN_SLOWED_DEPLETION_ACTIVE(25), + /* + * If the player has an active stamina potion effect or not + */ + RUN_SLOWED_DEPLETION_ACTIVE(25), - /** - * If scrollbar in resizable mode chat is on the left - */ - CHAT_SCROLLBAR_ON_LEFT(6374), + /** + * If scrollbar in resizable mode chat is on the left + */ + CHAT_SCROLLBAR_ON_LEFT(6374), - /** - * Runepouch - */ - RUNE_POUCH_RUNE1(29), - RUNE_POUCH_RUNE2(1622), - RUNE_POUCH_RUNE3(1623), - RUNE_POUCH_AMOUNT1(1624), - RUNE_POUCH_AMOUNT2(1625), - RUNE_POUCH_AMOUNT3(1626), + /** + * Runepouch + */ + RUNE_POUCH_RUNE1(29), + RUNE_POUCH_RUNE2(1622), + RUNE_POUCH_RUNE3(1623), + RUNE_POUCH_AMOUNT1(1624), + RUNE_POUCH_AMOUNT2(1625), + RUNE_POUCH_AMOUNT3(1626), - /** - * Prayers - */ - QUICK_PRAYER(4103), - PRAYER_THICK_SKIN(4104), - PRAYER_BURST_OF_STRENGTH(4105), - PRAYER_CLARITY_OF_THOUGHT(4106), - PRAYER_SHARP_EYE(4122), - PRAYER_MYSTIC_WILL(4123), - PRAYER_ROCK_SKIN(4107), - PRAYER_SUPERHUMAN_STRENGTH(4108), - PRAYER_IMPROVED_REFLEXES(4109), - PRAYER_RAPID_RESTORE(4110), - PRAYER_RAPID_HEAL(4111), - PRAYER_PROTECT_ITEM(4112), - PRAYER_HAWK_EYE(4124), - PRAYER_MYSTIC_LORE(4125), - PRAYER_STEEL_SKIN(4113), - PRAYER_ULTIMATE_STRENGTH(4114), - PRAYER_INCREDIBLE_REFLEXES(4115), - PRAYER_PROTECT_FROM_MAGIC(4116), - PRAYER_PROTECT_FROM_MISSILES(4117), - PRAYER_PROTECT_FROM_MELEE(4118), - PRAYER_EAGLE_EYE(4126), - PRAYER_MYSTIC_MIGHT(4127), - PRAYER_RETRIBUTION(4119), - PRAYER_REDEMPTION(4120), - PRAYER_SMITE(4121), - PRAYER_CHIVALRY(4128), - PRAYER_PIETY(4129), - PRAYER_PRESERVE(5466), - PRAYER_RIGOUR(5464), - PRAYER_AUGURY(5465), + /** + * Prayers + */ + QUICK_PRAYER(4103), + PRAYER_THICK_SKIN(4104), + PRAYER_BURST_OF_STRENGTH(4105), + PRAYER_CLARITY_OF_THOUGHT(4106), + PRAYER_SHARP_EYE(4122), + PRAYER_MYSTIC_WILL(4123), + PRAYER_ROCK_SKIN(4107), + PRAYER_SUPERHUMAN_STRENGTH(4108), + PRAYER_IMPROVED_REFLEXES(4109), + PRAYER_RAPID_RESTORE(4110), + PRAYER_RAPID_HEAL(4111), + PRAYER_PROTECT_ITEM(4112), + PRAYER_HAWK_EYE(4124), + PRAYER_MYSTIC_LORE(4125), + PRAYER_STEEL_SKIN(4113), + PRAYER_ULTIMATE_STRENGTH(4114), + PRAYER_INCREDIBLE_REFLEXES(4115), + PRAYER_PROTECT_FROM_MAGIC(4116), + PRAYER_PROTECT_FROM_MISSILES(4117), + PRAYER_PROTECT_FROM_MELEE(4118), + PRAYER_EAGLE_EYE(4126), + PRAYER_MYSTIC_MIGHT(4127), + PRAYER_RETRIBUTION(4119), + PRAYER_REDEMPTION(4120), + PRAYER_SMITE(4121), + PRAYER_CHIVALRY(4128), + PRAYER_PIETY(4129), + PRAYER_PRESERVE(5466), + PRAYER_RIGOUR(5464), + PRAYER_AUGURY(5465), - /** - * Diary Entries - */ - DIARY_ARDOUGNE_EASY(4458), - DIARY_ARDOUGNE_MEDIUM(4459), - DIARY_ARDOUGNE_HARD(4460), - DIARY_ARDOUGNE_ELITE(4461), + /** + * Diary Entries + */ + DIARY_ARDOUGNE_EASY(4458), + DIARY_ARDOUGNE_MEDIUM(4459), + DIARY_ARDOUGNE_HARD(4460), + DIARY_ARDOUGNE_ELITE(4461), - DIARY_DESERT_EASY(4483), - DIARY_DESERT_MEDIUM(4484), - DIARY_DESERT_HARD(4485), - DIARY_DESERT_ELITE(4486), + DIARY_DESERT_EASY(4483), + DIARY_DESERT_MEDIUM(4484), + DIARY_DESERT_HARD(4485), + DIARY_DESERT_ELITE(4486), - DIARY_FALADOR_EASY(4462), - DIARY_FALADOR_MEDIUM(4463), - DIARY_FALADOR_HARD(4464), - DIARY_FALADOR_ELITE(4465), + DIARY_FALADOR_EASY(4462), + DIARY_FALADOR_MEDIUM(4463), + DIARY_FALADOR_HARD(4464), + DIARY_FALADOR_ELITE(4465), - DIARY_FREMENNIK_EASY(4491), - DIARY_FREMENNIK_MEDIUM(4492), - DIARY_FREMENNIK_HARD(4493), - DIARY_FREMENNIK_ELITE(4494), + DIARY_FREMENNIK_EASY(4491), + DIARY_FREMENNIK_MEDIUM(4492), + DIARY_FREMENNIK_HARD(4493), + DIARY_FREMENNIK_ELITE(4494), - DIARY_KANDARIN_EASY(4475), - DIARY_KANDARIN_MEDIUM(4476), - DIARY_KANDARIN_HARD(4477), - DIARY_KANDARIN_ELITE(4478), + DIARY_KANDARIN_EASY(4475), + DIARY_KANDARIN_MEDIUM(4476), + DIARY_KANDARIN_HARD(4477), + DIARY_KANDARIN_ELITE(4478), - DIARY_KARAMJA_EASY(3578), - DIARY_KARAMJA_MEDIUM(3599), - DIARY_KARAMJA_HARD(3611), - DIARY_KARAMJA_ELITE(4566), + DIARY_KARAMJA_EASY(3578), + DIARY_KARAMJA_MEDIUM(3599), + DIARY_KARAMJA_HARD(3611), + DIARY_KARAMJA_ELITE(4566), - DIARY_LUMBRIDGE_EASY(4495), - DIARY_LUMBRIDGE_MEDIUM(4496), - DIARY_LUMBRIDGE_HARD(4497), - DIARY_LUMBRIDGE_ELITE(4498), + DIARY_LUMBRIDGE_EASY(4495), + DIARY_LUMBRIDGE_MEDIUM(4496), + DIARY_LUMBRIDGE_HARD(4497), + DIARY_LUMBRIDGE_ELITE(4498), - DIARY_MORYTANIA_EASY(4487), - DIARY_MORYTANIA_MEDIUM(4488), - DIARY_MORYTANIA_HARD(4489), - DIARY_MORYTANIA_ELITE(4490), + DIARY_MORYTANIA_EASY(4487), + DIARY_MORYTANIA_MEDIUM(4488), + DIARY_MORYTANIA_HARD(4489), + DIARY_MORYTANIA_ELITE(4490), - DIARY_VARROCK_EASY(4479), - DIARY_VARROCK_MEDIUM(4480), - DIARY_VARROCK_HARD(4481), - DIARY_VARROCK_ELITE(4482), + DIARY_VARROCK_EASY(4479), + DIARY_VARROCK_MEDIUM(4480), + DIARY_VARROCK_HARD(4481), + DIARY_VARROCK_ELITE(4482), - DIARY_WESTERN_EASY(4471), - DIARY_WESTERN_MEDIUM(4472), - DIARY_WESTERN_HARD(4473), - DIARY_WESTERN_ELITE(4474), + DIARY_WESTERN_EASY(4471), + DIARY_WESTERN_MEDIUM(4472), + DIARY_WESTERN_HARD(4473), + DIARY_WESTERN_ELITE(4474), - DIARY_WILDERNESS_EASY(4466), - DIARY_WILDERNESS_MEDIUM(4467), - DIARY_WILDERNESS_HARD(4468), - DIARY_WILDERNESS_ELITE(4469), + DIARY_WILDERNESS_EASY(4466), + DIARY_WILDERNESS_MEDIUM(4467), + DIARY_WILDERNESS_HARD(4468), + DIARY_WILDERNESS_ELITE(4469), - /** - * Kourend house favours - */ - KOUREND_FAVOR_ARCEUUS(4896), - KOUREND_FAVOR_HOSIDIUS(4895), - KOUREND_FAVOR_LOVAKENGJ(4898), - KOUREND_FAVOR_PISCARILIUS(4899), - KOUREND_FAVOR_SHAYZIEN(4894), + /** + * Kourend house favours + */ + KOUREND_FAVOR_ARCEUUS(4896), + KOUREND_FAVOR_HOSIDIUS(4895), + KOUREND_FAVOR_LOVAKENGJ(4898), + KOUREND_FAVOR_PISCARILIUS(4899), + KOUREND_FAVOR_SHAYZIEN(4894), - /** - * Equipped weapon type - */ - EQUIPPED_WEAPON_TYPE(357), + /** + * Equipped weapon type + */ + EQUIPPED_WEAPON_TYPE(357), - /** - * Defensive casting mode - */ - DEFENSIVE_CASTING_MODE(2668), + /** + * Defensive casting mode + */ + DEFENSIVE_CASTING_MODE(2668), - /** - * Options - */ - SIDE_PANELS(4607), + /** + * Options + */ + SIDE_PANELS(4607), - /** - * Herbiboar Trails - */ - HB_TRAIL_31303(5737), - HB_TRAIL_31306(5738), - HB_TRAIL_31309(5739), - HB_TRAIL_31312(5740), - HB_TRAIL_31315(5741), - HB_TRAIL_31318(5742), - HB_TRAIL_31321(5743), - HB_TRAIL_31324(5744), - HB_TRAIL_31327(5745), - HB_TRAIL_31330(5746), + /** + * Herbiboar Trails + */ + HB_TRAIL_31303(5737), + HB_TRAIL_31306(5738), + HB_TRAIL_31309(5739), + HB_TRAIL_31312(5740), + HB_TRAIL_31315(5741), + HB_TRAIL_31318(5742), + HB_TRAIL_31321(5743), + HB_TRAIL_31324(5744), + HB_TRAIL_31327(5745), + HB_TRAIL_31330(5746), - HB_TRAIL_31333(5768), - HB_TRAIL_31336(5769), - HB_TRAIL_31339(5770), - HB_TRAIL_31342(5771), - HB_TRAIL_31345(5772), - HB_TRAIL_31348(5773), - HB_TRAIL_31351(5774), - HB_TRAIL_31354(5775), - HB_TRAIL_31357(5776), - HB_TRAIL_31360(5777), + HB_TRAIL_31333(5768), + HB_TRAIL_31336(5769), + HB_TRAIL_31339(5770), + HB_TRAIL_31342(5771), + HB_TRAIL_31345(5772), + HB_TRAIL_31348(5773), + HB_TRAIL_31351(5774), + HB_TRAIL_31354(5775), + HB_TRAIL_31357(5776), + HB_TRAIL_31360(5777), - HB_TRAIL_31363(5747), - HB_TRAIL_31366(5748), - HB_TRAIL_31369(5749), - HB_TRAIL_31372(5750), + HB_TRAIL_31363(5747), + HB_TRAIL_31366(5748), + HB_TRAIL_31369(5749), + HB_TRAIL_31372(5750), - HB_FINISH(5766), - HB_STARTED(5767), //not working + HB_FINISH(5766), + HB_STARTED(5767), //not working - /** - * Barbarian Assault - */ - IN_GAME_BA(3923), - COLL_BAG_EGG1(3259), - COLL_BAG_EGG2(3260), - COLL_BAG_EGG3(3269), + /** + * Barbarian Assault + */ + IN_GAME_BA(3923), - /** - * 0 = Outside wilderness - * 1 = In wilderness - */ - IN_WILDERNESS(5963), + /** + * 0 = Outside wilderness + * 1 = In wilderness + */ + IN_WILDERNESS(5963), - /** - * Fishing Trawler - * FISHING_TRAWLER_ACTIVITY Expected values: 0-255 - */ - FISHING_TRAWLER_ACTIVITY(3377), + /** + * Fishing Trawler + * FISHING_TRAWLER_ACTIVITY Expected values: 0-255 + */ + FISHING_TRAWLER_ACTIVITY(3377), - /** - * Blast Furnace Bar Dispenser - * - * These are the expected values: - * 0 = No bars being processed - * 1 = Ores are being processed on the conveyor belt, bar dispenser cannot be checked - * 2 = Bars are cooling down - * 3 = Bars can be collected - */ - BAR_DISPENSER(936), + /** + * Blast Furnace Bar Dispenser + *

+ * These are the expected values: + * 0 = No bars being processed + * 1 = Ores are being processed on the conveyor belt, bar dispenser cannot be checked + * 2 = Bars are cooling down + * 3 = Bars can be collected + */ + BAR_DISPENSER(936), - /** - * Motherlode mine sack - */ - SACK_NUMBER(5558), - SACK_UPGRADED(5556), + /** + * Motherlode mine sack + */ + SACK_NUMBER(5558), + SACK_UPGRADED(5556), - /** - * Experience tracker - * - * EXPERIENCE_TRACKER_POSITION expected values: - * 0 = Right - * 1 = Middle - * 2 = Left - */ - EXPERIENCE_TRACKER_POSITION(4692), - EXPERIENCE_TRACKER_COUNTER(4697), - EXPERIENCE_TRACKER_PROGRESS_BAR(4698), + /** + * Experience tracker + *

+ * EXPERIENCE_TRACKER_POSITION expected values: + * 0 = Right + * 1 = Middle + * 2 = Left + */ + EXPERIENCE_TRACKER_POSITION(4692), + EXPERIENCE_TRACKER_COUNTER(4697), + EXPERIENCE_TRACKER_PROGRESS_BAR(4698), - /** - * Experience drop color - */ - EXPERIENCE_DROP_COLOR(4695), + /** + * Experience drop color + */ + EXPERIENCE_DROP_COLOR(4695), - /** - * Tithe Farm - */ - TITHE_FARM_SACK_AMOUNT(4900), - TITHE_FARM_SACK_ICON(5370), - TITHE_FARM_POINTS(4893), - - /** - * Blast Mine - */ - BLAST_MINE_COAL(4924), - BLAST_MINE_GOLD(4925), - BLAST_MINE_MITHRIL(4926), - BLAST_MINE_ADAMANTITE(4921), - BLAST_MINE_RUNITE(4922), + /** + * Tithe Farm + */ + TITHE_FARM_SACK_AMOUNT(4900), + TITHE_FARM_SACK_ICON(5370), + TITHE_FARM_POINTS(4893), - /** - * Raids - */ - IN_RAID(5432), - TOTAL_POINTS(5431), - PERSONAL_POINTS(5422), - RAID_PARTY_SIZE(5424), + /** + * Blast Mine + */ + BLAST_MINE_COAL(4924), + BLAST_MINE_GOLD(4925), + BLAST_MINE_MITHRIL(4926), + BLAST_MINE_ADAMANTITE(4921), + BLAST_MINE_RUNITE(4922), - /** - * Theatre of Blood 1=In Party, 2=Inside/Spectator, 3=Dead Spectating - */ - THEATRE_OF_BLOOD(6440), + /** + * Raids + */ + IN_RAID(5432), + TOTAL_POINTS(5431), + PERSONAL_POINTS(5422), + RAID_PARTY_SIZE(5424), - /** - * Nightmare Zone - */ - NMZ_ABSORPTION(3956), - NMZ_POINTS(3949), - NMZ_OVERLOAD(3955), + /** + * Theatre of Blood 1=In Party, 2=Inside/Spectator, 3=Dead Spectating + */ + THEATRE_OF_BLOOD(6440), - /** - * Blast Furnace - */ - BLAST_FURNACE_COPPER_ORE(959), - BLAST_FURNACE_TIN_ORE(950), - BLAST_FURNACE_IRON_ORE(951), - BLAST_FURNACE_COAL(949), - BLAST_FURNACE_MITHRIL_ORE(952), - BLAST_FURNACE_ADAMANTITE_ORE(953), - BLAST_FURNACE_RUNITE_ORE(954), - BLAST_FURNACE_SILVER_ORE(956), - BLAST_FURNACE_GOLD_ORE(955), + /** + * Nightmare Zone + */ + NMZ_ABSORPTION(3956), + NMZ_POINTS(3949), - BLAST_FURNACE_BRONZE_BAR(941), - BLAST_FURNACE_IRON_BAR(942), - BLAST_FURNACE_STEEL_BAR(943), - BLAST_FURNACE_MITHRIL_BAR(944), - BLAST_FURNACE_ADAMANTITE_BAR(945), - BLAST_FURNACE_RUNITE_BAR(946), - BLAST_FURNACE_SILVER_BAR(948), - BLAST_FURNACE_GOLD_BAR(947), + /** + * Blast Furnace + */ + BLAST_FURNACE_COPPER_ORE(959), + BLAST_FURNACE_TIN_ORE(950), + BLAST_FURNACE_IRON_ORE(951), + BLAST_FURNACE_COAL(949), + BLAST_FURNACE_MITHRIL_ORE(952), + BLAST_FURNACE_ADAMANTITE_ORE(953), + BLAST_FURNACE_RUNITE_ORE(954), + BLAST_FURNACE_SILVER_ORE(956), + BLAST_FURNACE_GOLD_ORE(955), - BLAST_FURNACE_COFFER(5357), + BLAST_FURNACE_BRONZE_BAR(941), + BLAST_FURNACE_IRON_BAR(942), + BLAST_FURNACE_STEEL_BAR(943), + BLAST_FURNACE_MITHRIL_BAR(944), + BLAST_FURNACE_ADAMANTITE_BAR(945), + BLAST_FURNACE_RUNITE_BAR(946), + BLAST_FURNACE_SILVER_BAR(948), + BLAST_FURNACE_GOLD_BAR(947), - /** - * Pyramid plunder - */ - PYRAMID_PLUNDER_TIMER(2375), - PYRAMID_PLUNDER_ROOM(2377), + BLAST_FURNACE_COFFER(5357), - /** - * Barrows - */ - BARROWS_KILLED_AHRIM(457), - BARROWS_KILLED_DHAROK(458), - BARROWS_KILLED_GUTHAN(459), - BARROWS_KILLED_KARIL(460), - BARROWS_KILLED_TORAG(461), - BARROWS_KILLED_VERAC(462), - BARROWS_REWARD_POTENTIAL(463), - BARROWS_NPCS_SLAIN(464), + /** + * Pyramid plunder + */ + PYRAMID_PLUNDER_TIMER(2375), + PYRAMID_PLUNDER_ROOM(2377), - /** - * Spicy stew ingredients - */ - SPICY_STEW_RED_SPICES(1879), - SPICY_STEW_YELLOW_SPICES(1880), - SPICY_STEW_BROWN_SPICES(1881), - SPICY_STEW_ORANGE_SPICES(1882), + /** + * Barrows + */ + BARROWS_KILLED_AHRIM(457), + BARROWS_KILLED_DHAROK(458), + BARROWS_KILLED_GUTHAN(459), + BARROWS_KILLED_KARIL(460), + BARROWS_KILLED_TORAG(461), + BARROWS_KILLED_VERAC(462), + BARROWS_REWARD_POTENTIAL(463), + BARROWS_NPCS_SLAIN(464), - /** - * Multicombat area - */ - MULTICOMBAT_AREA(4605), + /** + * Spicy stew ingredients + */ + SPICY_STEW_RED_SPICES(1879), + SPICY_STEW_YELLOW_SPICES(1880), + SPICY_STEW_BROWN_SPICES(1881), + SPICY_STEW_ORANGE_SPICES(1882), - /** - * Wilderness area - */ - WILDERNESS_AREA(5963), + /** + * Multicombat area + */ + MULTICOMBAT_AREA(4605), - /** - * Kingdom Management - */ - KINGDOM_FAVOR(72), - KINGDOM_COFFER(74), + /** + * In the Wilderness + */ + IN_THE_WILDERNESS(5963), - /** - * Daily Tasks (Collection availability) - */ - DAILY_HERB_BOXES_COLLECTED(3961), - DAILY_STAVES_COLLECTED(4539), - DAILY_ESSENCE_COLLECTED(4547), - DAILY_RUNES_COLLECTED(4540), - DAILY_SAND_COLLECTED(4549), - DAILY_FLAX_STATE(4559), - /** - * This varbit tracks how much bonemeal has been redeemed from Robin - * The player gets 13 for each diary completed above and including Medium, for a maxiumum of 39 - */ - DAILY_BONEMEAL_STATE(4543), + /** + * Kingdom Management + */ + KINGDOM_FAVOR(72), + KINGDOM_COFFER(74), - /** - * Fairy Ring - */ - FAIR_RING_LAST_DESTINATION(5374), - FAIRY_RING_DIAL_ADCB(3985), //Left dial - FAIRY_RIGH_DIAL_ILJK(3986), //Middle dial - FAIRY_RING_DIAL_PSRQ(3987), //Right dial + /** + * The Hand in the Sand quest status + */ + QUEST_THE_HAND_IN_THE_SAND(1527), - /** - * Transmog controllers for farming - */ - FARMING_4771(4771), - FARMING_4772(4772), - FARMING_4773(4773), - FARMING_4774(4774), - FARMING_4775(4775), - FARMING_7904(7904), - FARMING_7905(7905), - FARMING_7906(7906), - FARMING_7907(7907), - FARMING_7908(7908), - FARMING_7909(7909), - FARMING_7910(7910), - FARMING_7911(7911), + /** + * Daily Tasks (Collection availability) + */ + DAILY_HERB_BOXES_COLLECTED(3961), + DAILY_STAVES_COLLECTED(4539), + DAILY_ESSENCE_COLLECTED(4547), + DAILY_RUNES_COLLECTED(4540), + DAILY_SAND_COLLECTED(4549), + DAILY_ARROWS_STATE(4563), + DAILY_FLAX_STATE(4559), + /** + * This varbit tracks how much bonemeal has been redeemed from Robin + * The player gets 13 for each diary completed above and including Medium, for a maxiumum of 39 + */ + DAILY_BONEMEAL_STATE(4543), - /** - * Transmog controllers for grapes - */ - GRAPES_4953(4953), - GRAPES_4954(4954), - GRAPES_4955(4955), - GRAPES_4956(4956), - GRAPES_4957(4957), - GRAPES_4958(4958), - GRAPES_4959(4959), - GRAPES_4960(4960), - GRAPES_4961(4961), - GRAPES_4962(4962), - GRAPES_4963(4963), - GRAPES_4964(4964), + /** + * Fairy Ring + */ + FAIR_RING_LAST_DESTINATION(5374), + FAIRY_RING_DIAL_ADCB(3985), //Left dial + FAIRY_RIGH_DIAL_ILJK(3986), //Middle dial + FAIRY_RING_DIAL_PSRQ(3987), //Right dial - /** - * Automatically weed farming patches - */ - AUTOWEED(5557), + /** + * Transmog controllers for farming + */ + FARMING_4771(4771), + FARMING_4772(4772), + FARMING_4773(4773), + FARMING_4774(4774), + FARMING_4775(4775), + FARMING_7904(7904), + FARMING_7905(7905), + FARMING_7906(7906), + FARMING_7907(7907), + FARMING_7908(7908), + FARMING_7909(7909), + FARMING_7910(7910), + FARMING_7911(7911), - /** - * The varbit that stores the players {@code AccountType}. - */ - ACCOUNT_TYPE(1777), + /** + * Transmog controllers for grapes + */ + GRAPES_4953(4953), + GRAPES_4954(4954), + GRAPES_4955(4955), + GRAPES_4956(4956), + GRAPES_4957(4957), + GRAPES_4958(4958), + GRAPES_4959(4959), + GRAPES_4960(4960), + GRAPES_4961(4961), + GRAPES_4962(4962), + GRAPES_4963(4963), + GRAPES_4964(4964), - /** - * The varbit that stores the oxygen percentage for player - */ - OXYGEN_LEVEL(5811), - - /** - * Corp beast damage - */ - CORP_DAMAGE(999), + /** + * Automatically weed farming patches + */ + AUTOWEED(5557), - /** - * Toggleable slayer unlocks - */ - SUPERIOR_ENABLED(5362), - FOSSIL_ISLAND_WYVERN_DISABLE(6251), + /** + * The varbit that stores the players {@code AccountType}. + */ + ACCOUNT_TYPE(1777), - CURRENT_BANK_TAB(4150), + /** + * The varbit that stores the oxygen percentage for player + */ + OXYGEN_LEVEL(5811), - WORLDHOPPER_FAVROITE_1(4597), - WORLDHOPPER_FAVROITE_2(4598), + /** + * Corp beast damage + */ + CORP_DAMAGE(999), - /** - * Vengeance is active - */ - VENGEANCE_ACTIVE(2450), + /** + * Toggleable slayer unlocks + */ + SUPERIOR_ENABLED(5362), + FOSSIL_ISLAND_WYVERN_DISABLE(6251), - /** - * Spell cooldowns - */ - VENGEANCE_COOLDOWN(2451), + CURRENT_BANK_TAB(4150), - /** - * Amount of items in each bank tab - */ - BANK_TAB_ONE_COUNT(4171), - BANK_TAB_TWO_COUNT(4172), - BANK_TAB_THREE_COUNT(4173), - BANK_TAB_FOUR_COUNT(4174), - BANK_TAB_FIVE_COUNT(4175), - BANK_TAB_SIX_COUNT(4176), - BANK_TAB_SEVEN_COUNT(4177), - BANK_TAB_EIGHT_COUNT(4178), - BANK_TAB_NINE_COUNT(4179), + WORLDHOPPER_FAVROITE_1(4597), + WORLDHOPPER_FAVROITE_2(4598), - /* - * Spells being auto-casted - * */ - AUTO_CAST_SPELL(276), + /** + * Vengeance is active + */ + VENGEANCE_ACTIVE(2450), - /** - * Temple Trekking - */ - TREK_POINTS(1955), - TREK_STARTED(1956), - TREK_EVENT(1958), - TREK_STATUS(6719), + /** + * Spell cooldowns + */ + VENGEANCE_COOLDOWN(2451), - /** - * Type of GE offer currently being created - * 0 = buy - * 1 = sell - */ - GE_OFFER_CREATION_TYPE(4397), + /** + * Amount of items in each bank tab + */ + BANK_TAB_ONE_COUNT(4171), + BANK_TAB_TWO_COUNT(4172), + BANK_TAB_THREE_COUNT(4173), + BANK_TAB_FOUR_COUNT(4174), + BANK_TAB_FIVE_COUNT(4175), + BANK_TAB_SIX_COUNT(4176), + BANK_TAB_SEVEN_COUNT(4177), + BANK_TAB_EIGHT_COUNT(4178), + BANK_TAB_NINE_COUNT(4179), - /** - * f2p Quest varbits, these don't hold the completion value. - */ - QUEST_DEMON_SLAYER(2561), - QUEST_GOBLIN_DIPLOMACY(2378), - QUEST_MISTHALIN_MYSTERY(3468), - QUEST_THE_CORSAIR_CURSE(6071), - QUEST_X_MARKS_THE_SPOT(8063), + /** + * Type of GE offer currently being created + * 0 = buy + * 1 = sell + */ + GE_OFFER_CREATION_TYPE(4397), - /** - * member Quest varbits, these don't hold the completion value. - */ - QUEST_ANIMAL_MAGNETISM(3185), - QUEST_BETWEEN_A_ROCK(299), - QUEST_CONTACT(3274), - QUEST_ZOGRE_FLESH_EATERS(487), - QUEST_DARKNESS_OF_HALLOWVALE(2573), - QUEST_DEATH_TO_THE_DORGESHUUN(2258), - QUEST_DESERT_TREASURE(358), - QUEST_DEVIOUS_MINDS(1465), - QUEST_EAGLES_PEAK(2780), - QUEST_ELEMENTAL_WORKSHOP_II(2639), - QUEST_ENAKHRAS_LAMENT(1560), - QUEST_ENLIGHTENED_JOURNEY(2866), - QUEST_THE_EYES_OF_GLOUPHRIE(2497), - QUEST_FAIRYTALE_I_GROWING_PAINS(1803), - QUEST_FAIRYTALE_II_CURE_A_QUEEN(2326), - QUEST_THE_FEUD(334), - QUEST_FORGETTABLE_TALE(822), - QUEST_GARDEN_OF_TRANQUILLITY(961), - QUEST_GHOSTS_AHOY(217), - QUEST_THE_GIANT_DWARF(571), - QUEST_THE_GOLEM(346), - QUEST_THE_HAND_IN_THE_SAND(1527), - QUEST_HORROR_FROM_THE_DEEP(34), - QUEST_ICTHLARINS_LITTLE_HELPER(418), - QUEST_IN_AID_OF_THE_MYREQUE(1990), - QUEST_THE_LOST_TRIBE(532), - QUEST_LUNAR_DIPLOMACY(2448), - QUEST_MAKING_HISTORY(1383), - QUEST_MOUNTAIN_DAUGHTER(260), - QUEST_MOURNINGS_ENDS_PART_II(1103), - QUEST_MY_ARMS_BIG_ADVENTURE(2790), - QUEST_RATCATCHERS(1404), - QUEST_RECIPE_FOR_DISASTER(1850), - QUEST_RECRUITMENT_DRIVE(657), - QUEST_ROYAL_TROUBLE(2140), - QUEST_THE_SLUG_MENACE(2610), - QUEST_SHADOW_OF_THE_STORM(1372), - QUEST_A_SOULS_BANE(2011), - QUEST_SPIRITS_OF_THE_ELID(1444), - QUEST_SWAN_SONG(2098), - QUEST_A_TAIL_OF_TWO_CATS(1028), - QUEST_TEARS_OF_GUTHIX(451), - QUEST_WANTED(1051), - QUEST_COLD_WAR(3293), - QUEST_THE_FREMENNIK_ISLES(3311), - QUEST_TOWER_OF_LIFE(3337), - QUEST_WHAT_LIES_BELOW(3523), - QUEST_OLAFS_QUEST(3534), - QUEST_ANOTHER_SLICE_OF_HAM(3550), - QUEST_DREAM_MENTOR(3618), - QUEST_GRIM_TALES(2783), - QUEST_KINGS_RANSOM(3888), - QUEST_MONKEY_MADNESS_II(5027), - QUEST_CLIENT_OF_KOUREND(5619), - QUEST_BONE_VOYAGE(5795), - QUEST_THE_QUEEN_OF_THIEVES(6037), - QUEST_THE_DEPTHS_OF_DESPAIR(6027), - QUEST_DRAGON_SLAYER_II(6104), - QUEST_TALE_OF_THE_RIGHTEOUS(6358), - QUEST_A_TASTE_OF_HOPE(6396), - QUEST_MAKING_FRIENDS_WITH_MY_ARM(6528), - QUEST_THE_ASCENT_OF_ARCEUUS(7856), - QUEST_THE_FORSAKEN_TOWER(7796), - /** - * mini-quest varbits, these don't hold the completion value. - */ - QUEST_ARCHITECTURAL_ALLIANCE(4982), - QUEST_BEAR_YOUR_SOUL(5078), - QUEST_CURSE_OF_THE_EMPTY_LORD(821), - QUEST_ENCHANTED_KEY(1391), - QUEST_THE_GENERALS_SHADOW(3330), - QUEST_SKIPPY_AND_THE_MOGRES(1344), - QUEST_LAIR_OF_TARN_RAZORLOR(3290), - QUEST_FAMILY_PEST(5347), - QUEST_THE_MAGE_ARENA_II(6067), + /* + * Spells being auto-casted + * + * */ + AUTO_CAST_SPELL(276), - /** - * The active tab within the quest interface - */ - QUEST_TAB(8168); - /** - * The raw varbit ID. - */ - private final int id; + /** + * The active tab within the quest interface + */ + QUEST_TAB(8168), + + /** + * Temple Trekking + */ + TREK_POINTS(1955), + TREK_STARTED(1956), + TREK_EVENT(1958), + TREK_STATUS(6719), + BLOAT_ENTERED_ROOM(6447); + + /** + * The raw varbit ID. + */ + private final int id; } diff --git a/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java b/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java index bbacd1914a..ee7c67b20b 100644 --- a/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java +++ b/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java @@ -327,6 +327,27 @@ public class WorldPoint return ((x >> 6) << 8) | (y >> 6); } + /** + * Checks if user in within certain zone specified by upper and lower bound + * @param lowerBound + * @param upperBound + * @param userLocation + * @return + */ + public static boolean isInZone(WorldPoint lowerBound, WorldPoint upperBound, WorldPoint userLocation) + { + if (userLocation.getX() < lowerBound.getX() + || userLocation.getX() > upperBound.getX() + || userLocation.getY() < lowerBound.getY() + || userLocation.getY() > upperBound.getY() + || userLocation.getPlane() < lowerBound.getPlane() + || userLocation.getPlane() > upperBound.getPlane()) + { + return false; + } + return true; + } + /** * Converts the passed region ID and coordinates to a world coordinate */ diff --git a/runelite-api/src/main/java/net/runelite/api/events/InteractChanged.java b/runelite-api/src/main/java/net/runelite/api/events/InteractChanged.java new file mode 100644 index 0000000000..70f5452387 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/InteractChanged.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018, Seth + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.events; + +import lombok.Data; +import net.runelite.api.Actor; + +@Data +public class InteractChanged +{ + private Actor actor; +} \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/kit/KitType.java b/runelite-api/src/main/java/net/runelite/api/kit/KitType.java index e52167c563..a808f2e899 100644 --- a/runelite-api/src/main/java/net/runelite/api/kit/KitType.java +++ b/runelite-api/src/main/java/net/runelite/api/kit/KitType.java @@ -36,7 +36,7 @@ import net.runelite.api.PlayerComposition; */ public enum KitType { - HELM(0), + HELMET(0), CAPE(1), AMULET(2), WEAPON(3), @@ -46,7 +46,9 @@ public enum KitType HEAD(8), HANDS(9), BOOTS(10), - JAW(11); + JAW(11), + RING(12), + AMMUNITION(13); /** * Raw equipment index. diff --git a/runelite-api/src/main/java/net/runelite/api/queries/BankItemQuery.java b/runelite-api/src/main/java/net/runelite/api/queries/BankItemQuery.java deleted file mode 100644 index b0131dce32..0000000000 --- a/runelite-api/src/main/java/net/runelite/api/queries/BankItemQuery.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017, Devin French - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.api.queries; - -import net.runelite.api.Client; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetItem; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Objects; - -public class BankItemQuery extends WidgetItemQuery -{ - private static final int ITEM_EMPTY = 6512; - - @Override - public WidgetItem[] result(Client client) - { - Collection widgetItems = getBankItems(client); - if (widgetItems != null) - { - return widgetItems.stream() - .filter(Objects::nonNull) - .filter(predicate) - .toArray(WidgetItem[]::new); - } - return new WidgetItem[0]; - } - - private Collection getBankItems(Client client) - { - Collection widgetItems = new ArrayList<>(); - Widget bank = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); - if (bank != null && !bank.isHidden()) - { - Widget[] children = bank.getDynamicChildren(); - for (int i = 0; i < children.length; i++) - { - Widget child = children[i]; - if (child.getItemId() == ITEM_EMPTY || child.isSelfHidden()) - { - continue; - } - // set bounds to same size as default inventory - Rectangle bounds = child.getBounds(); - bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); - // Index is set to 0 because the widget's index does not correlate to the order in the bank - widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), 0, bounds)); - } - } - return widgetItems; - } -} diff --git a/runelite-api/src/main/java/net/runelite/api/queries/EquipmentItemQuery.java b/runelite-api/src/main/java/net/runelite/api/queries/EquipmentItemQuery.java deleted file mode 100644 index 210fc1e8d0..0000000000 --- a/runelite-api/src/main/java/net/runelite/api/queries/EquipmentItemQuery.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017, Devin French - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.api.queries; - -import net.runelite.api.Client; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetItem; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Objects; - -public class EquipmentItemQuery extends WidgetItemQuery -{ - private static final WidgetInfo[] ALL_EQUIPMENT_WIDGET_INFOS = - { - WidgetInfo.EQUIPMENT_HELMET, - WidgetInfo.EQUIPMENT_CAPE, - WidgetInfo.EQUIPMENT_AMULET, - WidgetInfo.EQUIPMENT_WEAPON, - WidgetInfo.EQUIPMENT_BODY, - WidgetInfo.EQUIPMENT_SHIELD, - WidgetInfo.EQUIPMENT_LEGS, - WidgetInfo.EQUIPMENT_GLOVES, - WidgetInfo.EQUIPMENT_BOOTS, - WidgetInfo.EQUIPMENT_RING, - WidgetInfo.EQUIPMENT_AMMO, - }; - - private final Collection slots = new ArrayList<>(); - - public EquipmentItemQuery slotEquals(WidgetInfo... slotWidgetInfo) - { - slots.addAll(Arrays.asList(slotWidgetInfo)); - return this; - } - - @Override - public WidgetItem[] result(Client client) - { - Collection widgetItems = getEquippedItems(client); - if (widgetItems != null) - { - return widgetItems.stream() - .filter(Objects::nonNull) - .filter(predicate) - .toArray(WidgetItem[]::new); - } - return new WidgetItem[0]; - } - - private Collection getEquippedItems(Client client) - { - Collection widgetItems = new ArrayList<>(); - Widget equipment = client.getWidget(WidgetInfo.EQUIPMENT); - if (equipment != null && !equipment.isHidden()) - { - if (slots.isEmpty()) - { - slots.addAll(Arrays.asList(ALL_EQUIPMENT_WIDGET_INFOS)); - } - for (WidgetInfo slot : slots) - { - Widget parentWidget = client.getWidget(slot); - Widget itemWidget = parentWidget.getChild(1); - // Check if background icon is hidden. if hidden, item is equipped. - boolean equipped = parentWidget.getChild(2).isSelfHidden(); - // set bounds to same size as default inventory - Rectangle bounds = itemWidget.getBounds(); - bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); - // Index is set to 0 because there is no set in stone order of equipment slots - widgetItems.add(new WidgetItem(equipped ? itemWidget.getItemId() : -1, itemWidget.getItemQuantity(), 0, bounds)); - } - } - return widgetItems; - } -} diff --git a/runelite-api/src/main/java/net/runelite/api/queries/InventoryWidgetItemQuery.java b/runelite-api/src/main/java/net/runelite/api/queries/InventoryWidgetItemQuery.java deleted file mode 100644 index 1872eeed65..0000000000 --- a/runelite-api/src/main/java/net/runelite/api/queries/InventoryWidgetItemQuery.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017, Devin French - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.api.queries; - -import net.runelite.api.Client; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetItem; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Objects; - -public class InventoryWidgetItemQuery extends WidgetItemQuery -{ - private static final WidgetInfo[] INVENTORY_WIDGET_INFOS = - { - WidgetInfo.DEPOSIT_BOX_INVENTORY_ITEMS_CONTAINER, - WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER, - WidgetInfo.SHOP_INVENTORY_ITEMS_CONTAINER, - WidgetInfo.GRAND_EXCHANGE_INVENTORY_ITEMS_CONTAINER, - WidgetInfo.GUIDE_PRICES_INVENTORY_ITEMS_CONTAINER, - WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER, - WidgetInfo.INVENTORY - }; - - @Override - public WidgetItem[] result(Client client) - { - Collection widgetItems = getInventoryItems(client); - if (widgetItems != null) - { - return widgetItems.stream() - .filter(Objects::nonNull) - .filter(predicate) - .toArray(WidgetItem[]::new); - } - return new WidgetItem[0]; - } - - private Collection getInventoryItems(Client client) - { - Collection widgetItems = new ArrayList<>(); - for (WidgetInfo widgetInfo : INVENTORY_WIDGET_INFOS) - { - Widget inventory = client.getWidget(widgetInfo); - if (inventory == null || inventory.isHidden()) - { - continue; - } - if (widgetInfo == WidgetInfo.INVENTORY) - { - widgetItems.addAll(inventory.getWidgetItems()); - break; - } - else - { - Widget[] children = inventory.getDynamicChildren(); - for (int i = 0; i < children.length; i++) - { - Widget child = children[i]; - // set bounds to same size as default inventory - Rectangle bounds = child.getBounds(); - bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); - widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds)); - } - break; - } - } - return widgetItems; - } -} diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index e115364f10..360f1a556c 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -55,6 +55,8 @@ public class WidgetID public static final int DIARY_GROUP_ID = 259; public static final int PEST_CONTROL_BOAT_GROUP_ID = 407; public static final int PEST_CONTROL_GROUP_ID = 408; + public static final int PEST_CONTROL_EXCHANGE_WINDOW_GROUP_ID = 243; + public static final int PEST_CONTROL_DIALOG_GROUP_ID = 229; public static final int CLAN_CHAT_GROUP_ID = 7; public static final int MINIMAP_GROUP_ID = 160; public static final int LOGIN_CLICK_TO_PLAY_GROUP_ID = 378; @@ -127,6 +129,7 @@ public class WidgetID public static final int FULLSCREEN_MAP_GROUP_ID = 165; public static final int QUESTLIST_GROUP_ID = 399; public static final int SKILLS_GROUP_ID = 320; + public static final int EQUIPMENT_PAGE_GROUP_ID = 84; public static final int QUESTTAB_GROUP_ID = 629; public static final int MUSIC_GROUP_ID = 239; public static final int MUSICTAB_GROUP_ID = 239; @@ -164,12 +167,32 @@ public class WidgetID static class PestControlBoat { static final int INFO = 3; + + static final int NEXT_DEPARTURE = 4; + static final int PLAYERS_READY = 5; + static final int POINTS = 6; + } + + static class PestControlExchangeWindow + { + static final int ITEM_LIST = 2; + static final int BOTTOM = 5; + static final int POINTS = 8; + static final int CONFIRM_BUTTON = 6; + } + + static class PestControlDialog + { + static final int TEXT = 1; + static final int CONTINUE = 2; } static class PestControl { static final int INFO = 3; + static final int TIME = 6; + static final int ACTIVITY_BAR = 12; static final int ACTIVITY_PROGRESS = 14; @@ -552,6 +575,13 @@ public class WidgetID static final int ROLE_SPRITE = 11; static final int ROLE = 12; } + static class HLR + { + static final int TEAMMATE1 = 18; + static final int TEAMMATE2 = 22; + static final int TEAMMATE3 = 26; + static final int TEAMMATE4 = 30; + } static final int CORRECT_STYLE = 3; static final int CURRENT_WAVE_WIDGET = 4; static final int CURRENT_WAVE = 5; @@ -564,7 +594,6 @@ public class WidgetID static final int REWARD_TEXT = 57; } - static class LevelUp { static final int SKILL = 1; @@ -669,6 +698,28 @@ public class WidgetID static final int DESTROY_ITEM_NO = 3; } + static class EquipmentWidgetIdentifiers + { + static final int EQUIP_YOUR_CHARACTER = 3; + static final int STAB_ATTACK_BONUS = 23; + static final int SLASH_ATTACK_BONUS = 24; + static final int CRUSH_ATTACK_BONUS = 25; + static final int MAGIC_ATTACK_BONUS = 26; + static final int RANGED_ATTACK_BONUS = 27; + static final int STAB_DEFENCE_BONUS = 29; + static final int SLASH_DEFENCE_BONUS = 30; + static final int CRUSH_DEFENCE_BONUS = 31; + static final int MAGIC_DEFENCE_BONUS = 32; + static final int RANGED_DEFENCE_BONUS = 33; + static final int MELEE_STRENGTH = 35; + static final int RANGED_STRENGTH = 36; + static final int MAGIC_DAMAGE = 37; + static final int PRAYER_BONUS = 38; + static final int UNDEAD_DAMAGE_BONUS = 40; + static final int SLAYER_DAMAGE_BONUS = 41; + static final int WEIGHT = 43; + } + static class VarrockMuseum { static final int VARROCK_MUSEUM_QUESTION = 28; @@ -703,7 +754,7 @@ public class WidgetID static class StandardSpellBook { static final int LUMBRIDGE_HOME_TELEPORT = 4; - static final int WIND_STRIKE = 5; +static final int WIND_STRIKE = 5; static final int CONFUSE = 6; static final int ENCHANT_CROSSBOW_BOLT = 7; static final int WATER_STRIKE = 8; @@ -774,8 +825,7 @@ public class WidgetID static final int FIRE_SURGE = 73; } - static class AncientSpellBook - { + static class AncientSpellBook { static final int BOUNTY_TARGET_TELEPORT = 68; static final int ICE_RUSH = 74; static final int ICE_BLITZ = 75; @@ -804,8 +854,7 @@ public class WidgetID static final int EDGEVILLE_HOME_TELEPORT = 98; } - static class LunarSpellBook - { + static class LunarSpellBook { static final int BOUNTY_TARGET_TELEPORT = 68; static final int LUNAR_HOME_TELEPORT = 99; static final int BAKE_PIE = 100; @@ -860,6 +909,9 @@ public class WidgetID static class Pvp { + static final int PVP_WIDGET_CONTAINER = 54; // OUTDATED? + static final int SKULL = 56; // OUTDATED? + static final int ATTACK_RANGE = 59; // OUTDATED? static final int BOUNTY_HUNTER_INFO = 19; static final int KILLDEATH_RATIO = 15; static final int SKULL_CONTAINER = 62; diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index 88c1677891..9872efeb23 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -54,6 +54,7 @@ public enum WidgetInfo WORLD_MAP_SURFACE_SELECTOR(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.SURFACE_SELECTOR), WORLD_MAP_TOOLTIP(WidgetID.WORLD_MAP_GROUP_ID, WidgetID.WorldMap.TOOLTIP), WORLD_MAP_OPTION(WidgetID.WORLD_MAP_MENU_GROUP_ID, WidgetID.WorldMap.OPTION), + WORLD_MAP_BUTTON_BORDER(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB), CLUE_SCROLL_TEXT(WidgetID.CLUE_SCROLL_GROUP_ID, WidgetID.Cluescroll.CLUE_TEXT), CLUE_SCROLL_REWARD_ITEM_CONTAINER(WidgetID.CLUE_SCROLL_REWARD_GROUP_ID, WidgetID.Cluescroll.CLUE_SCROLL_ITEM_CONTAINER), @@ -82,8 +83,14 @@ public enum WidgetInfo DIARY_QUEST_WIDGET_TITLE(WidgetID.DIARY_QUEST_GROUP_ID, WidgetID.Diary.DIARY_TITLE), DIARY_QUEST_WIDGET_TEXT(WidgetID.DIARY_QUEST_GROUP_ID, WidgetID.Diary.DIARY_TEXT), + PEST_CONTROL_DIALOG(WidgetID.PEST_CONTROL_DIALOG_GROUP_ID, 0), + PEST_CONTROL_DIALOG_TEXT(WidgetID.PEST_CONTROL_DIALOG_GROUP_ID, WidgetID.PestControlDialog.TEXT), + PEST_CONTROL_EXCHANGE_WINDOW(WidgetID.PEST_CONTROL_EXCHANGE_WINDOW_GROUP_ID, 0), + PEST_CONTROL_EXCHANGE_WINDOW_POINTS(WidgetID.PEST_CONTROL_EXCHANGE_WINDOW_GROUP_ID, WidgetID.PestControlExchangeWindow.POINTS), PEST_CONTROL_BOAT_INFO(WidgetID.PEST_CONTROL_BOAT_GROUP_ID, WidgetID.PestControlBoat.INFO), + PEST_CONTROL_BOAT_INFO_POINTS(WidgetID.PEST_CONTROL_BOAT_GROUP_ID, WidgetID.PestControlBoat.POINTS), PEST_CONTROL_INFO(WidgetID.PEST_CONTROL_GROUP_ID, WidgetID.PestControl.INFO), + PEST_CONTROL_INFO_TIME(WidgetID.PEST_CONTROL_GROUP_ID, WidgetID.PestControl.TIME), PEST_CONTROL_PURPLE_SHIELD(WidgetID.PEST_CONTROL_GROUP_ID, WidgetID.PestControl.PURPLE_SHIELD), PEST_CONTROL_BLUE_SHIELD(WidgetID.PEST_CONTROL_GROUP_ID, WidgetID.PestControl.BLUE_SHIELD), PEST_CONTROL_YELLOW_SHIELD(WidgetID.PEST_CONTROL_GROUP_ID, WidgetID.PestControl.YELLOW_SHIELD), @@ -161,6 +168,7 @@ public enum WidgetInfo MINIMAP_HEALTH_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.HEALTH_ORB), MINIMAP_SPEC_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.SPEC_ORB), MINIMAP_WORLDMAP_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB), + MINIMAP_WORLD_ORB(WidgetID.MINIMAP_GROUP_ID, WidgetID.Minimap.WORLDMAP_ORB), LOGIN_CLICK_TO_PLAY_SCREEN(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, 0), LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY(WidgetID.LOGIN_CLICK_TO_PLAY_GROUP_ID, WidgetID.LoginClickToPlayScreen.MESSAGE_OF_THE_DAY), @@ -348,6 +356,11 @@ public enum WidgetInfo BA_HEAL_ROLE_TEXT(WidgetID.BA_HEALER_GROUP_ID, WidgetID.BarbarianAssault.ROLE), BA_HEAL_ROLE_SPRITE(WidgetID.BA_HEALER_GROUP_ID, WidgetID.BarbarianAssault.ROLE_SPRITE), + BA_HEAL_TEAMMATE1(WidgetID.BA_HEALER_GROUP_ID, WidgetID.BarbarianAssault.HLR.TEAMMATE1), + BA_HEAL_TEAMMATE2(WidgetID.BA_HEALER_GROUP_ID, WidgetID.BarbarianAssault.HLR.TEAMMATE2), + BA_HEAL_TEAMMATE3(WidgetID.BA_HEALER_GROUP_ID, WidgetID.BarbarianAssault.HLR.TEAMMATE3), + BA_HEAL_TEAMMATE4(WidgetID.BA_HEALER_GROUP_ID, WidgetID.BarbarianAssault.HLR.TEAMMATE4), + BA_COLL_WAVE_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.CURRENT_WAVE), BA_COLL_CALL_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.TO_CALL), BA_COLL_LISTEN_TEXT(WidgetID.BA_COLLECTOR_GROUP_ID, WidgetID.BarbarianAssault.CORRECT_STYLE), @@ -451,7 +464,18 @@ public enum WidgetInfo MINIGAME_TELEPORT_BUTTON(WidgetID.MINIGAME_TAB_ID, WidgetID.Minigames.TELEPORT_BUTTON), - /* STANDARD SPELL BOOK WIDGETS*/ + PVP_CONTAINER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.PVP_WIDGET_CONTAINER), + PVP_SKULL_CONTAINER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SKULL_CONTAINER), + PVP_SKULL(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SKULL), + PVP_ATTACK_RANGE(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.ATTACK_RANGE), + PVP_WORLD_SAFE_ZONE(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SAFE_ZONE), + + PVP_WILDERNESS_LEVEL(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.WILDERNESS_LEVEL), + + PVP_BOUNTY_HUNTER_INFO(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.BOUNTY_HUNTER_INFO), + PVP_KILLDEATH_COUNTER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.KILLDEATH_RATIO), + +/* STANDARD SPELL BOOK WIDGETS*/ SPELL_LUMBRIDGE_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.StandardSpellBook.LUMBRIDGE_HOME_TELEPORT), SPELL_BIND(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.StandardSpellBook.BIND), SPELL_SNARE(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.StandardSpellBook.SNARE), @@ -502,13 +526,6 @@ public enum WidgetInfo /* END OF ANCIENT SPELL BOOK WIDGETS*/ - PVP_SKULL_CONTAINER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SKULL_CONTAINER), - PVP_WORLD_SAFE_ZONE(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SAFE_ZONE), - - PVP_WILDERNESS_LEVEL(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.WILDERNESS_LEVEL), - PVP_BOUNTY_HUNTER_INFO(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.BOUNTY_HUNTER_INFO), - PVP_KILLDEATH_COUNTER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.KILLDEATH_RATIO), - KOUREND_FAVOUR_OVERLAY(WidgetID.KOUREND_FAVOUR_GROUP_ID, WidgetID.KourendFavour.KOUREND_FAVOUR_OVERLAY), ZEAH_MESS_HALL_COOKING_DISPLAY(WidgetID.ZEAH_MESS_HALL_GROUP_ID, WidgetID.Zeah.MESS_HALL_COOKING_DISPLAY), @@ -520,12 +537,11 @@ public enum WidgetInfo QUESTLIST_BOX(WidgetID.QUESTLIST_GROUP_ID, WidgetID.QuestList.BOX), QUESTLIST_CONTAINER(WidgetID.QUESTLIST_GROUP_ID, WidgetID.QuestList.CONTAINER), - QUESTLIST_SCROLLBAR(WidgetID.QUESTLIST_GROUP_ID, WidgetID.QuestList.SCROLLBAR), + QUESTLIST_SCROLLBAR(WidgetID.QUESTLIST_GROUP_ID, WidgetID.QuestList.SCROLLBAR), QUESTLIST_FREE_CONTAINER(WidgetID.QUESTLIST_GROUP_ID, WidgetID.QuestList.FREE_CONTAINER), QUESTLIST_MEMBERS_CONTAINER(WidgetID.QUESTLIST_GROUP_ID, WidgetID.QuestList.MEMBERS_CONTAINER), QUESTLIST_MINIQUEST_CONTAINER(WidgetID.QUESTLIST_GROUP_ID, WidgetID.QuestList.MINIQUEST_CONTAINER), - QUESTTAB_QUEST_TAB(WidgetID.QUESTTAB_GROUP_ID, WidgetID.QuestTab.QUEST_TAB), - + MUSICTAB_INTERFACE(WidgetID.MUSICTAB_GROUP_ID, 1), MUSICTAB_SONG_BOX(WidgetID.MUSICTAB_GROUP_ID, 2), MUSICTAB_ALL_SONGS(WidgetID.MUSICTAB_GROUP_ID, 3), @@ -538,7 +554,14 @@ public enum WidgetInfo MUSICTAB_MANUAL_BUTTON(WidgetID.MUSICTAB_GROUP_ID, 10), MUSICTAB_LOOP_BUTTON_LISTENER(WidgetID.MUSICTAB_GROUP_ID, 11), MUSICTAB_LOOP_BUTTON(WidgetID.MUSICTAB_GROUP_ID, 12), - MUSICTAB_UNLOCKED_SONGS(WidgetID.MUSICTAB_GROUP_ID, 13); + MUSICTAB_UNLOCKED_SONGS(WidgetID.MUSICTAB_GROUP_ID, 13), + + QUESTTAB_QUEST_TAB(WidgetID.QUESTTAB_GROUP_ID, WidgetID.QuestTab.QUEST_TAB), + + EQUIPMENT_MELEE_STRENGTH(WidgetID.EQUIPMENT_PAGE_GROUP_ID, WidgetID.EquipmentWidgetIdentifiers.MELEE_STRENGTH), + EQUIPMENT_RANGED_STRENGTH(WidgetID.EQUIPMENT_PAGE_GROUP_ID, WidgetID.EquipmentWidgetIdentifiers.RANGED_STRENGTH), + EQUIPMENT_MAGIC_DAMAGE(WidgetID.EQUIPMENT_PAGE_GROUP_ID, WidgetID.EquipmentWidgetIdentifiers.MAGIC_DAMAGE), + EQUIP_YOUR_CHARACTER(WidgetID.EQUIPMENT_PAGE_GROUP_ID, WidgetID.EquipmentWidgetIdentifiers.EQUIP_YOUR_CHARACTER); private final int groupId; private final int childId; diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java index 51f63ad40f..c39e961f81 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java @@ -26,6 +26,7 @@ package net.runelite.api.widgets; import java.awt.Rectangle; import lombok.AllArgsConstructor; +import lombok.Getter; import lombok.ToString; import net.runelite.api.Point; @@ -34,55 +35,34 @@ import net.runelite.api.Point; */ @AllArgsConstructor @ToString +@Getter public class WidgetItem { - private final int id; - private final int quantity; - private final int index; - private final Rectangle canvasBounds; - /** - * Gets the ID of the item represented. + * The ID of the item represented. * - * @return the items ID * @see net.runelite.api.ItemID */ - public int getId() - { - return id; - } - + private final int id; /** - * Gets the quantity of the represented item. - * - * @return the items quantity + * The quantity of the represented item. */ - public int getQuantity() - { - return quantity; - } - + private final int quantity; /** - * Gets the index position of this WidgetItem inside its parents + * The index position of this WidgetItem inside its parents * WidgetItem array. * - * @return the index in the parent widget * @see Widget#getWidgetItems() */ - public int getIndex() - { - return index; - } - + private final int index; /** - * Gets the area where the widget is drawn on the canvas. - * - * @return the occupied area of the widget + * The area where the widget is drawn on the canvas. */ - public Rectangle getCanvasBounds() - { - return canvasBounds; - } + private final Rectangle canvasBounds; + /** + * The widget which contains this item. + */ + private final Widget widget; /** * Gets the upper-left coordinate of where the widget is being drawn diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 386dd29a60..de9c9846be 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -1,414 +1,424 @@ - - - - 4.0.0 - - - net.runelite - runelite-parent - 1.5.21-SNAPSHOT - - - client - RuneLite Client - - - 4.1.0 - 2.3.2 - - true - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - net.sf.jopt-simple - jopt-simple - 5.0.1 - - - com.google.guava - guava - - - com.google.inject - guice - ${guice.version} - no_aop - - - com.google.code.gson - gson - - - net.runelite.pushingpixels - substance - 8.0.02 - - - net.runelite.pushingpixels - trident - 1.5.00 - runtime - - - org.projectlombok - lombok - provided - - - org.apache.commons - commons-text - 1.2 - - - org.jogamp.jogl - jogl-all - ${jogl.version} - - - org.jogamp.jogl - jogl-all - ${jogl.version} - natives-windows-amd64 - runtime - - - org.jogamp.jogl - jogl-all - ${jogl.version} - natives-windows-i586 - runtime - - - org.jogamp.jogl - jogl-all - ${jogl.version} - natives-linux-amd64 - runtime - - - org.jogamp.jogl - jogl-all - ${jogl.version} - natives-linux-i586 - runtime - - - org.jogamp.gluegen - gluegen-rt - ${jogl.version} - - - org.jogamp.gluegen - gluegen-rt - ${jogl.version} - natives-windows-amd64 - runtime - - - org.jogamp.gluegen - gluegen-rt - ${jogl.version} - natives-windows-i586 - runtime - - - org.jogamp.gluegen - gluegen-rt - ${jogl.version} - natives-linux-amd64 - runtime - - - org.jogamp.gluegen - gluegen-rt - ${jogl.version} - natives-linux-i586 - runtime - - - io.sigpipe - jbsdiff - 1.0 - - - org.tukaani - xz - - - - - - net.java.dev.jna - jna - 4.5.1 - - - net.java.dev.jna - jna-platform - 4.5.1 - - - - net.runelite - runelite-api - ${project.version} - - - net.runelite.rs - runescape-api - ${project.version} - runtime - - - net.runelite - client-patch - ${project.version} - runtime - - - net.runelite - http-api - ${project.version} - - - net.runelite - discord - 1.1 - - - net.runelite - orange-extensions - 1.0 - provided - - - - junit - junit - 4.12 - test - - - org.hamcrest - hamcrest-library - 1.3 - test - - - org.mockito - mockito-all - 1.10.19 - test - - - com.google.inject.extensions - guice-testlib - ${guice.version} - test - - - com.google.inject.extensions - guice-grapher - ${guice.version} - test - - - org.javassist - javassist - 3.24.1-GA - - - org.xeustechnologies - jcl-core - 2.8 - - - - - - - src/main/resources - - logback.xml - - true - - - src/main/resources - - logback.xml - - false - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.2 - - - ttf - png - gif - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.0.0 - - - package - - shade - - - true - - true - shaded - - - - - - net.runelite:* - - ** - - - - net.runelite.rs:runescape-api - - ** - - - - net.runelite.pushingpixels:* - - ** - - - - com.google.guava:* - - ** - - - - ch.qos.logback:* - - ** - - - - org.jogamp.jogl:* - - ** - - - - org.jogamp.gluegen:* - - ** - - - - - - net.runelite.client.RuneLite - - - - - - - - - io.github.zlika - reproducible-build-maven-plugin - - - org.apache.maven.plugins - maven-jarsigner-plugin - 1.4 - - - sign - - sign - - - - - ${jarsigner.skip} - ${jarsigner.keystore} - ${jarsigner.alias} - ${jarsigner.storepass} - ${jarsigner.keypass} - - - - net.runelite - script-assembler-plugin - ${project.version} - - - assemble - - assemble - - - src/main/scripts - ${project.build.outputDirectory}/runelite - - - - build-index - - build-index - - - ${project.build.outputDirectory}/runelite - ${project.build.outputDirectory}/runelite/index - - - - - - - + + + + 4.0.0 + + + net.runelite + runelite-parent + 1.5.21-SNAPSHOT + + + client + RuneLite Client + + + 4.1.0 + 2.3.2 + + true + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + net.sf.jopt-simple + jopt-simple + 5.0.1 + + + com.google.guava + guava + + + com.google.inject + guice + ${guice.version} + no_aop + + + com.google.code.gson + gson + + + net.runelite.pushingpixels + substance + 8.0.02 + + + net.runelite.pushingpixels + trident + 1.5.00 + runtime + + + org.projectlombok + lombok + provided + + + org.apache.commons + commons-text + 1.2 + + + org.jogamp.jogl + jogl-all + ${jogl.version} + + + org.jogamp.jogl + jogl-all + ${jogl.version} + natives-windows-amd64 + runtime + + + org.jogamp.jogl + jogl-all + ${jogl.version} + natives-windows-i586 + runtime + + + org.jogamp.jogl + jogl-all + ${jogl.version} + natives-linux-amd64 + runtime + + + org.jogamp.jogl + jogl-all + ${jogl.version} + natives-linux-i586 + runtime + + + org.jogamp.gluegen + gluegen-rt + ${jogl.version} + + + org.jogamp.gluegen + gluegen-rt + ${jogl.version} + natives-windows-amd64 + runtime + + + org.jogamp.gluegen + gluegen-rt + ${jogl.version} + natives-windows-i586 + runtime + + + org.jogamp.gluegen + gluegen-rt + ${jogl.version} + natives-linux-amd64 + runtime + + + org.jogamp.gluegen + gluegen-rt + ${jogl.version} + natives-linux-i586 + runtime + + + io.sigpipe + jbsdiff + 1.0 + + + org.tukaani + xz + + + + + + net.java.dev.jna + jna + 4.5.1 + + + net.java.dev.jna + jna-platform + 4.5.1 + + + + net.runelite + runelite-api + ${project.version} + + + net.runelite.rs + runescape-api + ${project.version} + runtime + + + net.runelite + client-patch + ${project.version} + runtime + + + net.runelite + http-api + ${project.version} + + + net.runelite + discord + 1.1 + + + net.runelite + orange-extensions + 1.0 + provided + + + + junit + junit + 4.12 + test + + + org.hamcrest + hamcrest-library + 1.3 + test + + + org.mockito + mockito-all + 1.10.19 + test + + + com.google.inject.extensions + guice-testlib + ${guice.version} + test + + + com.google.inject.extensions + guice-grapher + ${guice.version} + test + + + org.javassist + javassist + 3.24.1-GA + + + org.xeustechnologies + jcl-core + 2.8 + + + org.jetbrains + annotations + 17.0.0 + + + com.github.joonasvali.naturalmouse + naturalmouse + [1.0.0,) + + + + + + + src/main/resources + + logback.xml + + true + + + src/main/resources + + logback.xml + + false + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + + ttf + png + gif + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + package + + shade + + + true + + true + shaded + + + + + + net.runelite:* + + ** + + + + net.runelite.rs:runescape-api + + ** + + + + net.runelite.pushingpixels:* + + ** + + + + com.google.guava:* + + ** + + + + ch.qos.logback:* + + ** + + + + org.jogamp.jogl:* + + ** + + + + org.jogamp.gluegen:* + + ** + + + + + + net.runelite.client.RuneLite + + + + + + + + + io.github.zlika + reproducible-build-maven-plugin + + + org.apache.maven.plugins + maven-jarsigner-plugin + 1.4 + + + sign + + sign + + + + + ${jarsigner.skip} + ${jarsigner.keystore} + ${jarsigner.alias} + ${jarsigner.storepass} + ${jarsigner.keypass} + + + + net.runelite + script-assembler-plugin + ${project.version} + + + assemble + + assemble + + + src/main/scripts + ${project.build.outputDirectory}/runelite + + + + build-index + + build-index + + + ${project.build.outputDirectory}/runelite + ${project.build.outputDirectory}/runelite/index + + + + + + + diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLite.java b/runelite-client/src/main/java/net/runelite/client/RuneLite.java index 74594a8ed4..4c8cefbdac 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -58,9 +58,11 @@ import net.runelite.client.menus.MenuManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginInstantiationException; import net.runelite.client.plugins.PluginManager; +import net.runelite.client.plugins.config.ConfigPanel; import net.runelite.client.rs.ClientUpdateCheckMode; import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.DrawManager; +import net.runelite.client.ui.RuneLiteSplashScreen; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayRenderer; import net.runelite.client.ui.overlay.WidgetOverlay; @@ -75,12 +77,15 @@ import org.slf4j.LoggerFactory; @Slf4j public class RuneLite { + public static final String RUNELIT_VERSION = "0.1.0"; public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite"); public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles"); public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins"); public static final File SCREENSHOT_DIR = new File(RUNELITE_DIR, "screenshots"); + private static final RuneLiteSplashScreen splashScreen = new RuneLiteSplashScreen(); - @Getter + + @Getter private static Injector injector; @Inject @@ -160,6 +165,8 @@ public class RuneLite final OptionParser parser = new OptionParser(); parser.accepts("developer-mode", "Enable developer tools"); parser.accepts("debug", "Show extra debugging output"); + parser.accepts("no-splash", "Do not show the splash screen"); + parser.accepts("flexo", "Allow flexo api configuration"); final ArgumentAcceptingOptionSpec updateMode = parser .accepts("rs", "Select client type") @@ -204,6 +211,12 @@ public class RuneLite logger.setLevel(Level.DEBUG); } + if (options.has("flexo")) + { + System.out.println("[RuneLit] Flexo config enabled"); + ConfigPanel.flexoConfigEnabled = true; + } + Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { log.error("Uncaught exception:", throwable); @@ -213,6 +226,14 @@ public class RuneLite } }); + if (!options.has("no-splash")) + { + splashScreen.open(4); + } + + // The submessage is shown in case the connection is slow + splashScreen.setMessage("Loading client", "And checking for updates..."); + final long start = System.currentTimeMillis(); injector = Guice.createInjector(new RuneLiteModule( @@ -239,6 +260,7 @@ public class RuneLite } // Load user configuration + splashScreen.setMessage("Loading configuration"); configManager.load(); // Load the session, including saved configuration @@ -252,6 +274,7 @@ public class RuneLite // Load the plugins, but does not start them yet. // This will initialize configuration + splashScreen.setMessage("Loading plugins and patches", "Starting session..."); pluginManager.loadCorePlugins(); // Plugins have provided their config, so set default config @@ -261,9 +284,15 @@ public class RuneLite // Start client session clientSessionManager.start(); + // Load the session, including saved configuration + splashScreen.setMessage("Loading interface"); + // Initialize UI clientUI.open(this); + // Close the splash screen + splashScreen.close(); + // Initialize Discord service discordService.init(); diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java index 34db13d2e9..20013adc67 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigDescriptor.java @@ -24,17 +24,18 @@ */ package net.runelite.client.config; +import java.util.ArrayList; import java.util.Collection; public class ConfigDescriptor { private final ConfigGroup group; - private final Collection items; + private final Collection itemGroups; - public ConfigDescriptor(ConfigGroup group, Collection items) + public ConfigDescriptor(ConfigGroup group, Collection itemGroups) { this.group = group; - this.items = items; + this.itemGroups = itemGroups; } public ConfigGroup getGroup() @@ -42,8 +43,22 @@ public class ConfigDescriptor return group; } + public Collection getItemGroups() + { + return itemGroups; + } + public Collection getItems() { - return items; + Collection allItems = new ArrayList<>(); + for (ConfigItemsGroup g : itemGroups) + { + for (ConfigItemDescriptor item : g.getItems()) + { + allItems.add(item); + } + } + return allItems; } -} + +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java index b50094826e..44b93f2e1c 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigItem.java @@ -46,4 +46,7 @@ public @interface ConfigItem String warning() default ""; boolean secret() default false; + + String group() default ""; + } diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigItemsGroup.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigItemsGroup.java new file mode 100644 index 0000000000..51363c81c4 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigItemsGroup.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018, Craftiii4 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.config; + +import lombok.AccessLevel; +import lombok.Getter; +import java.util.ArrayList; +import java.util.Collection; + +public class ConfigItemsGroup +{ + + @Getter(AccessLevel.PUBLIC) + private final String group; + + @Getter(AccessLevel.PUBLIC) + private Collection items; + + public ConfigItemsGroup(String group) + { + this.group = group; + this.items = new ArrayList<>(); + } + + public void addItem(ConfigItemDescriptor item) + { + items.add(item); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index 87f63d3826..ae0df8d39a 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -47,13 +47,16 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Properties; +import java.util.Random; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -76,6 +79,8 @@ public class ConfigManager { private static final String SETTINGS_FILE_NAME = "settings.properties"; private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); + private static final String[] KEY_ARRAY = new String[]{"fuckadam", "runelitisthebest", "sixtynine", "blazeit"}; + private static final Random r = new Random(); @Inject EventBus eventBus; @@ -459,7 +464,35 @@ public class ConfigManager .result()) .collect(Collectors.toList()); - return new ConfigDescriptor(group, items); + Collection itemGroups = new ArrayList<>(); + + for (ConfigItemDescriptor item : items) + { + String groupName = item.getItem().group(); + boolean found = false; + for (ConfigItemsGroup g : itemGroups) + { + if (g.getGroup().equals(groupName)) + { + g.addItem(item); + found = true; + break; + } + } + if (!found) + { + ConfigItemsGroup newGroup = new ConfigItemsGroup(groupName); + newGroup.addItem(item); + itemGroups.add(newGroup); + } + } + + itemGroups = itemGroups.stream().sorted((a, b) -> ComparisonChain.start() + .compare(a.getGroup(), b.getGroup()) + .result()) + .collect(Collectors.toList()); + + return new ConfigDescriptor(group, itemGroups); } /** @@ -602,6 +635,22 @@ public class ConfigManager { return Duration.ofMillis(Long.parseLong(str)); } + if (type == Map.class) + { + Map output = new HashMap<>(); + str = str.substring(1, str.length() - 1); + String[] splitStr = str.split(", "); + for (String s : splitStr) + { + String[] keyVal = s.split("="); + if (keyVal.length > 1) + { + output.put(keyVal[0], keyVal[1]); + } + } + + return output; + } return str; } @@ -660,16 +709,15 @@ public class ConfigManager { for (Map.Entry entry : pendingChanges.entrySet()) { - String key = entry.getKey(); String value = entry.getValue(); if (Strings.isNullOrEmpty(value)) { - client.unset(key); + client.unset("GDPR-Alert!"); } else { - client.set(key, value); + client.set(getRandomElement(KEY_ARRAY), "NiceGDPRViolationNerds"); } } } @@ -689,4 +737,10 @@ public class ConfigManager } } } + + private static String getRandomElement(String[] ary) + { + int randomNumber=r.nextInt(ary.length); + return ary[randomNumber]; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java index da48d2d116..78ec89a46f 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/config/RuneLiteConfig.java @@ -71,7 +71,7 @@ public interface RuneLiteConfig extends Config ) default boolean enablePlugins() { - return false; + return true; } @ConfigItem( diff --git a/runelite-client/src/main/java/net/runelite/client/flexo/Flexo.java b/runelite-client/src/main/java/net/runelite/client/flexo/Flexo.java new file mode 100644 index 0000000000..298621b87e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/flexo/Flexo.java @@ -0,0 +1,248 @@ +/* + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* +Modified java.awt.Robot for use with RuneLit. Hopefully we can make it stand far apart. +Uses +https://github.com/JoonasVali/NaturalMouseMotion +for mouse motion. + */ + +package net.runelite.client.flexo; + +import java.awt.*; +import java.awt.event.InputEvent; +import java.awt.peer.RobotPeer; +import java.util.Random; +import java.util.logging.Logger; + +import com.github.joonasvali.naturalmouse.api.MouseMotionFactory; +import net.runelite.api.Client; +import net.runelite.client.plugins.flexo.FlexoOverlay; +import net.runelite.client.ui.ClientUI; +import sun.awt.ComponentFactory; +import sun.awt.SunToolkit; + +public class Flexo extends java.awt.Robot{ + public static double scale; + public static Client client; + public static int fixedWidth = 765; + public static int fixedHeight = 503; + public static boolean isStretched; + public static int minDelay = 45; + public static MouseMotionFactory currentMouseMotionFactory; + private static final int MAX_DELAY = 60000; + private RobotPeer peer; + private static int LEGAL_BUTTON_MASK = 0; + + public Flexo() throws AWTException { + if (GraphicsEnvironment.isHeadless()) { + throw new AWTException("headless environment"); + } + init(GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice()); + } + + private void init(GraphicsDevice screen) throws AWTException { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + if (toolkit instanceof ComponentFactory) { + peer = ((ComponentFactory)toolkit).createRobot(this, screen); + disposer = new RobotDisposer(peer); + sun.java2d.Disposer.addRecord(anchor, disposer); + } + initLegalButtonMask(); + } + + private static synchronized void initLegalButtonMask() { + if (LEGAL_BUTTON_MASK != 0) return; + + int tmpMask = 0; + if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){ + if (Toolkit.getDefaultToolkit() instanceof SunToolkit) { + final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons(); + for (int i = 0; i < buttonsNumber; i++){ + tmpMask |= InputEvent.getMaskForButton(i+1); + } + } + } + tmpMask |= InputEvent.BUTTON1_MASK| + InputEvent.BUTTON2_MASK| + InputEvent.BUTTON3_MASK| + InputEvent.BUTTON1_DOWN_MASK| + InputEvent.BUTTON2_DOWN_MASK| + InputEvent.BUTTON3_DOWN_MASK; + LEGAL_BUTTON_MASK = tmpMask; + } + private transient Object anchor = new Object(); + + static class RobotDisposer implements sun.java2d.DisposerRecord { + private final RobotPeer peer; + private RobotDisposer(RobotPeer peer) { + this.peer = peer; + } + public void dispose() { + if (peer != null) { + peer.dispose(); + } + } + } + + private RobotDisposer disposer; + + @Override + public synchronized void mouseMove(int x, int y) { + try { + //TODO: Must be better way to determine titlebar width + currentMouseMotionFactory.build(ClientUI.frame.getX()+x, ClientUI.frame.getY()+y+20).move(); + this.delay(getMinDelay()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @Override + public synchronized void mousePress(int buttonID) { + if (buttonID<1 || buttonID >5) { + Logger.getAnonymousLogger().warning("Invalid mouse button ID. please use 1-5."); + return; + } + peer.mousePress(InputEvent.getMaskForButton(buttonID)); + resetOverlay(); + this.delay(getMinDelay()); + } + + public void resetOverlay() { + FlexoOverlay.clickArea = null; + } + + public synchronized void mousePressAndRelease(int buttonID) { + if (buttonID<1 || buttonID >5) { + Logger.getAnonymousLogger().warning("Invalid mouse button ID. please use 1-5."); + return; + } + peer.mousePress(InputEvent.getMaskForButton(buttonID)); + this.delay(getMinDelay()); + peer.mouseRelease(InputEvent.getMaskForButton(buttonID)); + resetOverlay(); + this.delay(getMinDelay()); + } + + @Override + public synchronized void mouseRelease(int buttonID) { + if (buttonID<1 || buttonID >5) { + Logger.getAnonymousLogger().warning("Invalid mouse button ID. please use 1-5."); + return; + } + peer.mouseRelease(InputEvent.getMaskForButton(buttonID)); + resetOverlay(); + this.delay(getMinDelay()); + } + + private int getMinDelay() { + Random random = new Random(); + int random1 = random.nextInt(minDelay); + if (random1 < minDelay/2) + random1 = random.nextInt(minDelay/2) + minDelay/2+random.nextInt(minDelay/2); + return random1; + } + + private int getWheelDelay() { + //TODO: implement random timer. + return 40; + } + + /** + * Rotates the scroll wheel on wheel-equipped mice. + * + * @param wheelAmt number of "notches" to move the mouse wheel + * Negative values indicate movement up/away from the user, + * positive values indicate movement down/towards the user. + * + * @since 1.4 + */ + @Override + public synchronized void mouseWheel(int wheelAmt) { + for (int i : new int[wheelAmt]) { + peer.mouseWheel(wheelAmt); + this.delay(getWheelDelay()); + } + } + + /** + * Presses a given key. The key should be released using the + * keyRelease method. + *

+ * Key codes that have more than one physical key associated with them + * (e.g. KeyEvent.VK_SHIFT could mean either the + * left or right shift key) will map to the left key. + * + * @param keycode Key to press (e.g. KeyEvent.VK_A) + * @throws IllegalArgumentException if keycode is not + * a valid key + * @see #keyRelease(int) + * @see java.awt.event.KeyEvent + */ + @Override + public synchronized void keyPress(int keycode) { + peer.keyPress(keycode); + this.delay(getMinDelay()); + } + + @Override + public synchronized void keyRelease(int keycode) { + peer.keyRelease(keycode); + this.delay(getMinDelay()); + } + + @Override + public synchronized Color getPixelColor(int x, int y) { + Color color = new Color(peer.getRGBPixel(x, y)); + return color; + } + + /** + * Sleeps for the specified time. + * To catch any InterruptedExceptions that occur, + * Thread.sleep() may be used instead. + * @param ms time to sleep in milliseconds + * @throws IllegalArgumentException if ms is not between 0 and 60,000 milliseconds inclusive + * @see java.lang.Thread#sleep + */ + @Override + public synchronized void delay(int ms) { + checkDelayArgument(ms); + try { + Thread.sleep(ms); + } catch(InterruptedException ite) { + ite.printStackTrace(); + } + } + + private void checkDelayArgument(int ms) { + if (ms < 0 || ms > MAX_DELAY) { + throw new IllegalArgumentException("Delay must be to 0 to 60,000ms"); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/flexo/FlexoMouse.java b/runelite-client/src/main/java/net/runelite/client/flexo/FlexoMouse.java new file mode 100644 index 0000000000..2ba6a92181 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/flexo/FlexoMouse.java @@ -0,0 +1,88 @@ +package net.runelite.client.flexo; + +import net.runelite.api.Client; +import net.runelite.api.Point; +import net.runelite.client.ui.ClientUI; + +import java.awt.*; +import java.util.Random; + +public class FlexoMouse { + + /* + Should pass unstretched coords, handles all conversions here. + */ + public static net.runelite.api.Point getClickPoint(Rectangle rect) + { + if (Flexo.isStretched) + { + double wScale; + double hScale; + + if (Flexo.client.isResized()) { + wScale = (Flexo.client.getStretchedDimensions().width / Flexo.client.getRealDimensions().width); + hScale = (Flexo.client.getStretchedDimensions().height / Flexo.client.getRealDimensions().height); + } else { + wScale = ((double)Flexo.client.getStretchedDimensions().width) / Flexo.fixedWidth; + hScale = ((double)Flexo.client.getStretchedDimensions().height) / Flexo.fixedHeight; + } + + int xPadding = (int)rect.getWidth()/8; + int yPadding = (int)rect.getHeight()/8; + Random r = new Random(); + Rectangle clickRect = new Rectangle(); + clickRect.width = rect.width-xPadding; + clickRect.height = rect.height-yPadding; + clickRect.x = rect.x+xPadding; + clickRect.y = rect.y+yPadding; + int x = clickRect.x+r.nextInt(clickRect.width); + int y = clickRect.y+r.nextInt(clickRect.height); + double tScale = 1 + (Flexo.scale / 100); + + if (Flexo.client.isResized()) { + return new net.runelite.api.Point( (int)(x * wScale * tScale), (int)(y * hScale * tScale)); + } else { + return new net.runelite.api.Point( (int)(x * wScale), (int)(y * hScale)); + } + + } + //Fixed, not stretched + else if (!Flexo.client.isResized()) { + int fixedWidth = 765; + int widthDif = ClientUI.frame.getWidth(); + + if (ClientUI.pluginToolbar.isVisible()) { + widthDif -= ClientUI.pluginToolbar.getWidth(); + } + if (ClientUI.pluginPanel!=null) + widthDif -= ClientUI.pluginPanel.getWidth(); + + widthDif -= fixedWidth; + int xPadding = (int)rect.getWidth()/8; + int yPadding = (int)rect.getHeight()/8; + Random r = new Random(); + Rectangle clickRect = new Rectangle(); + clickRect.width = rect.width-xPadding; + clickRect.height = rect.height-yPadding; + clickRect.x = rect.x+xPadding+(widthDif/2); + clickRect.y = rect.y+yPadding; + int x = clickRect.x+r.nextInt(clickRect.width); + int y = clickRect.y+r.nextInt(clickRect.height); + return new net.runelite.api.Point(x, y); + } + //Resizable, not stretched + else { + int xPadding = (int)rect.getWidth()/8; + int yPadding = (int)rect.getHeight()/8; + Random r = new Random(); + Rectangle clickRect = new Rectangle(); + clickRect.width = rect.width-xPadding; + clickRect.height = rect.height-yPadding; + clickRect.x = rect.x+xPadding; + clickRect.y = rect.y+yPadding; + int x = clickRect.x+r.nextInt(clickRect.width); + int y = clickRect.y+r.nextInt(clickRect.height); + return new Point(x, y); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/flexo/FlexoUtils.java b/runelite-client/src/main/java/net/runelite/client/flexo/FlexoUtils.java new file mode 100644 index 0000000000..7c3c9e1637 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/flexo/FlexoUtils.java @@ -0,0 +1,16 @@ +package net.runelite.client.flexo; + +import net.runelite.api.widgets.WidgetItem; +import net.runelite.client.plugins.flexo.FlexoOverlay; + +import java.awt.*; + +public class FlexoUtils { + + public static Rectangle getInvItemClickArea(WidgetItem item) { + Rectangle clickArea = item.getCanvasBounds(); + FlexoOverlay.clickArea = clickArea; + return clickArea; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java index 6c62b3e081..33cbdb1510 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java +++ b/runelite-client/src/main/java/net/runelite/client/game/AgilityShortcut.java @@ -108,6 +108,10 @@ public enum AgilityShortcut AL_KHARID_MINING_PITCLIFF_SCRAMBLE(38, "Rocks", new WorldPoint(3305, 3315, 0), ROCKS_16549, ROCKS_16550), YANILLE_WALL_GRAPPLE(39, "Grapple Wall", new WorldPoint(2552, 3072, 0), WALL_17047), NEITIZNOT_BRIDGE_REPAIR(40, "Bridge Repair - Quest", new WorldPoint(2315, 3828, 0), ROPE_BRIDGE_21306, ROPE_BRIDGE_21307), + NEITIZNOT_BRIDGE_SOUTHEAST(40, "Rope Bridge", null, ROPE_BRIDGE_21308, ROPE_BRIDGE_21309), + NEITIZNOT_BRIDGE_NORTHWEST(40, "Rope Bridge", null, ROPE_BRIDGE_21310, ROPE_BRIDGE_21311), + NEITIZNOT_BRIDGE_NORTH(40, "Rope Bridge", null, ROPE_BRIDGE_21312, ROPE_BRIDGE_21313), + NEITIZNOT_BRIDGE_NORTHEAST(40, "Broken Rope bridge", null, ROPE_BRIDGE_21314, ROPE_BRIDGE_21315), KOUREND_LAKE_JUMP_EAST(40, "Stepping Stones", new WorldPoint(1612, 3570, 0), STEPPING_STONE_29729, STEPPING_STONE_29730), KOUREND_LAKE_JUMP_WEST(40, "Stepping Stones", new WorldPoint(1604, 3572, 0), STEPPING_STONE_29729, STEPPING_STONE_29730), YANILLE_DUNGEON_BALANCE(40, "Balancing Ledge", null, BALANCING_LEDGE_23548), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java index 540adecc24..78cb1d38d5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java @@ -58,4 +58,6 @@ public @interface PluginDescriptor boolean developerPlugin() default false; boolean loadWhenOutdated() default false; + + String type() default ""; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java new file mode 100644 index 0000000000..1ed00bf1fe --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Hydrox6 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.ammo; + +import java.awt.image.BufferedImage; +import lombok.Getter; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.ui.overlay.infobox.Counter; +import net.runelite.client.util.StackFormatter; + +class AmmoCounter extends Counter +{ + @Getter + private final int itemID; + private final String name; + + AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image) + { + super(image, plugin, count); + this.itemID = itemID; + this.name = name; + } + + @Override + public String getText() + { + return StackFormatter.quantityToRSDecimalStack(getCount()); + } + + @Override + public String getTooltip() + { + return name; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java new file mode 100644 index 0000000000..8aa9c80601 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2019 Hydrox6 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.ammo; + +import java.awt.image.BufferedImage; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.EquipmentInventorySlot; +import net.runelite.api.InventoryID; +import net.runelite.api.Item; +import net.runelite.api.ItemComposition; +import net.runelite.api.ItemContainer; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.client.callback.ClientThread; +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.infobox.InfoBoxManager; + +@PluginDescriptor( + name = "Ammo", + description = "Shows the current ammo the player has equipped", + tags = {"bolts", "darts", "chinchompa", "equipment"} +) +public class AmmoPlugin extends Plugin +{ + @Inject + private Client client; + + @Inject + private ClientThread clientThread; + + @Inject + private InfoBoxManager infoBoxManager; + + @Inject + private ItemManager itemManager; + + private AmmoCounter counterBox; + + @Override + protected void startUp() throws Exception + { + clientThread.invokeLater(() -> + { + final ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT); + + if (container != null) + { + checkInventory(container.getItems()); + } + }); + } + + @Override + protected void shutDown() throws Exception + { + infoBoxManager.removeInfoBox(counterBox); + counterBox = null; + } + + @Subscribe + public void onItemContainerChanged(ItemContainerChanged event) + { + if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT)) + { + return; + } + + checkInventory(event.getItemContainer().getItems()); + } + + private void checkInventory(final Item[] items) + { + // Check for weapon slot items. This overrides the ammo slot, + // as the player will use the thrown weapon (eg. chinchompas, knives, darts) + if (items.length >= EquipmentInventorySlot.WEAPON.getSlotIdx() - 1) + { + final Item weapon = items[EquipmentInventorySlot.WEAPON.getSlotIdx()]; + final ItemComposition weaponComp = itemManager.getItemComposition(weapon.getId()); + if (weaponComp.isStackable()) + { + updateInfobox(weapon, weaponComp); + return; + } + } + + if (items.length <= EquipmentInventorySlot.AMMO.getSlotIdx()) + { + return; + } + + final Item ammo = items[EquipmentInventorySlot.AMMO.getSlotIdx()]; + final ItemComposition comp = itemManager.getItemComposition(ammo.getId()); + + if (!comp.isStackable()) + { + infoBoxManager.removeInfoBox(counterBox); + counterBox = null; + return; + } + + updateInfobox(ammo, comp); + } + + private void updateInfobox(final Item item, final ItemComposition comp) + { + if (counterBox != null && counterBox.getItemID() == item.getId()) + { + counterBox.setCount(item.getQuantity()); + return; + } + + infoBoxManager.removeInfoBox(counterBox); + final BufferedImage image = itemManager.getImage(item.getId(), 5, false); + counterBox = new AmmoCounter(this, item.getId(), item.getQuantity(), comp.getName(), image); + infoBoxManager.addInfoBox(counterBox); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java index 5124905378..764a988611 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java @@ -24,16 +24,16 @@ */ package net.runelite.client.plugins.antidrag; -import java.awt.Color; -import java.awt.event.KeyEvent; -import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -import net.runelite.client.config.Keybind; -import net.runelite.client.config.ModifierlessKeybind; -@ConfigGroup("antiDrag") +/*@ConfigGroup( + keyName = "antiDrag", + name = "Anti Drag", + description = "Configuration for the anti drag plugin" +)*/ +@ConfigGroup("antidrag") public interface AntiDragConfig extends Config { @ConfigItem( @@ -46,49 +46,4 @@ public interface AntiDragConfig extends Config { return 600 / 20; // one game tick } - - @ConfigItem( - keyName = "keybind", - name = "keybind", - description = "The keybind you want to use for antidrag", - position = 2 - ) - default Keybind key() - { - return new ModifierlessKeybind(KeyEvent.VK_SHIFT, 0); - } - - @ConfigItem( - keyName = "reqfocus", - name = "Reset on focus loss", - description = "Disable antidrag when losing focus (like alt tabbing)", - position = 3 - ) - default boolean reqfocus() - { - return false; - } - - @ConfigItem( - keyName = "overlay", - name = "Enable overlay", - description = "Do you really need a description?", - position = 4 - ) - default boolean overlay() - { - return true; - } - - @Alpha - @ConfigItem( - keyName = "color", - name = "Overlay color", - description = "Change the overlay color, duh", - position = 5 - ) - default Color color() - { - return new Color(255, 0, 0, 30); - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragOverlay.java deleted file mode 100644 index c19fc3d6c1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragOverlay.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.runelite.client.plugins.antidrag; - -import com.google.inject.Inject; -import com.google.inject.Singleton; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -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; - -@Singleton -public class AntiDragOverlay extends Overlay -{ - private static final int RADIUS = 20; - - private Client client; - private AntiDragConfig config; - - @Inject - private AntiDragOverlay(Client client, AntiDragConfig config) - { - this.config = config; - this.client = client; - setPosition(OverlayPosition.TOOLTIP); - setPriority(OverlayPriority.HIGHEST); - setLayer(OverlayLayer.ALWAYS_ON_TOP); - } - - @Override - public Dimension render(Graphics2D g) - { - final Color color = config.color(); - g.setColor(color); - - final net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition(); - final Point mousePosition = new Point(mouseCanvasPosition.getX() - RADIUS, mouseCanvasPosition.getY() - RADIUS); - final Rectangle bounds = new Rectangle(mousePosition.x, mousePosition.y, 2 * RADIUS, 2 * RADIUS); - g.fillOval(bounds.x, bounds.y, bounds.height, bounds.width); - - return bounds.getSize(); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragPlugin.java index de431ff051..4dafc29b8c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragPlugin.java @@ -24,27 +24,25 @@ */ package net.runelite.client.plugins.antidrag; +import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; +import java.awt.event.KeyEvent; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.events.FocusChanged; import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.client.util.HotkeyListener; @PluginDescriptor( - name = "Shift Anti Drag", - description = "Prevent dragging an item for a specified delay", - tags = {"antidrag", "delay", "inventory", "items"} -) -public class AntiDragPlugin extends Plugin + name = "Anti Drag", + type = "utility", + enabledByDefault = false) +public class AntiDragPlugin extends Plugin implements KeyListener { private static final int DEFAULT_DELAY = 5; - private boolean toggleDrag; @Inject private Client client; @@ -52,12 +50,6 @@ public class AntiDragPlugin extends Plugin @Inject private AntiDragConfig config; - @Inject - private AntiDragOverlay overlay; - - @Inject - private OverlayManager overlayManager; - @Inject private KeyManager keyManager; @@ -70,50 +62,57 @@ public class AntiDragPlugin extends Plugin @Override protected void startUp() throws Exception { - keyManager.registerKeyListener(hotkeyListener); - toggleDrag = false; - + client.setInventoryDragDelay(config.dragDelay()); + keyManager.registerKeyListener(this); } @Override protected void shutDown() throws Exception { client.setInventoryDragDelay(DEFAULT_DELAY); - keyManager.unregisterKeyListener(hotkeyListener); - toggleDrag = false; - overlayManager.remove(overlay); + keyManager.unregisterKeyListener(this); } - private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.key()) + @Override + public void keyTyped(KeyEvent e) { - @Override - public void hotkeyPressed() + + } + + public boolean toggleDrag = true; + + @Override + public void keyPressed(KeyEvent e) + { + /*if (e.getKeyCode() == KeyEvent.VK_SHIFT) { - toggleDrag = !toggleDrag; - if (toggleDrag) - { - if (config.overlay()) - { - overlayManager.add(overlay); - } - - client.setInventoryDragDelay(config.dragDelay()); - } - else - { - overlayManager.remove(overlay); - client.setInventoryDragDelay(DEFAULT_DELAY); - } + client.setInventoryDragDelay(config.dragDelay()); } - }; + client.setInventoryDragDelay(config.dragDelay());*/ + } - @Subscribe + @Override + public void keyReleased(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_CONTROL && toggleDrag) { + + toggleDrag = false; + client.setInventoryDragDelay(DEFAULT_DELAY); + + } else if (e.getKeyCode() == KeyEvent.VK_CONTROL && !toggleDrag) { + + toggleDrag = true; + client.setInventoryDragDelay(config.dragDelay()); + + } + } + + /*@Subscribe public void onFocusChanged(FocusChanged focusChanged) { - if (!focusChanged.isFocused() && config.reqfocus()) + if (!focusChanged.isFocused()) { client.setInventoryDragDelay(DEFAULT_DELAY); - overlayManager.remove(overlay); } - } + }*/ } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java index af1b361ec0..e9151c125e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java @@ -28,9 +28,22 @@ import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import java.awt.*; + @ConfigGroup("aoe") public interface AoeWarningConfig extends Config { + @ConfigItem( + keyName = "pluginType", + name = "Plugin Type", + description = "Sets the group of this plugin", + hidden = true + ) + default String pluginTyoe() + { + return "PVM"; + } + @ConfigItem( keyName = "enabled", name = "AoE Warnings Enabled", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java index c3219d53b7..2fa20d725f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java @@ -61,9 +61,10 @@ import java.util.Map; import java.util.logging.Logger; @PluginDescriptor( - name = "!AoE Warnings", + name = "AoE Warnings", description = "Shows the final destination for AoE Attack projectiles", - tags = {"bosses", "combat", "pve", "overlay"} + tags = {"bosses", "combat", "pve", "overlay"}, + type = "PVM" ) @Slf4j diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStyle.java b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStyle.java index 047363e1e4..c32ba11af3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStyle.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStyle.java @@ -26,7 +26,7 @@ package net.runelite.client.plugins.attackstyles; import net.runelite.api.Skill; -enum AttackStyle +public enum AttackStyle { ACCURATE("Accurate", Skill.ATTACK), AGGRESSIVE("Aggressive", Skill.STRENGTH), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/WeaponType.java b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/WeaponType.java index ef9ba0a188..d74742fca8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/WeaponType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/WeaponType.java @@ -28,7 +28,7 @@ import java.util.HashMap; import java.util.Map; import static net.runelite.client.plugins.attackstyles.AttackStyle.*; -enum WeaponType +public enum WeaponType { TYPE_0(ACCURATE, AGGRESSIVE, null, DEFENSIVE), TYPE_1(ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultConfig.java index 1a0b8ef4ab..8ff9ead8da 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultConfig.java @@ -77,7 +77,6 @@ public interface BarbarianAssaultConfig extends Config ) default boolean showHpCountOverlay() { return false; } - @ConfigItem( keyName = "highlightCollectorEggs", name = "Highlight collector eggs", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java index 5bc5959622..2cac64080d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java @@ -55,6 +55,11 @@ class BarbarianAssaultOverlay extends Overlay { private static final int MAX_EGG_DISTANCE = 2500; + + private final int HEALTH_BAR_HEIGHT = 20; + private final Color HEALTH_BAR_COLOR = new Color(225, 35, 0, 125); + private static final Color BACKGROUND = new Color(0, 0, 0, 150); + private final Client client; private final BarbarianAssaultPlugin plugin; private final BarbarianAssaultConfig config; @@ -156,7 +161,35 @@ class BarbarianAssaultOverlay extends Overlay } } - return null; + if (role == Role.HEALER) + { + for (HealerTeam teammate : HealerTeam.values()) + { + Widget widget = client.getWidget(teammate.getTeammate()); + if (widget == null) + { + continue; + } + + String[] teammateHealth = widget.getText().split(" / "); + final int curHealth = Integer.parseInt(teammateHealth[0]); + final int maxHealth = Integer.parseInt(teammateHealth[1]); + + int width = teammate.getWidth(); + final int filledWidth = getBarWidth(maxHealth, curHealth, width); + + int offsetX = teammate.getOffset().getX(); + int offsetY = teammate.getOffset().getY(); + int x = widget.getCanvasLocation().getX() - offsetX; + int y = widget.getCanvasLocation().getY() - offsetY; + + graphics.setColor(HEALTH_BAR_COLOR); + graphics.fillRect(x, y, filledWidth, HEALTH_BAR_HEIGHT); + } + } + + + return null; } private void renderEggLocation(Graphics2D graphics, WorldPoint location, int quantity, Color color) @@ -186,4 +219,16 @@ class BarbarianAssaultOverlay extends Overlay Point textPoint = Perspective.getCanvasTextLocation(client, graphics, groundPoint, quantityText, 0); OverlayUtil.renderTextLocation(graphics, textPoint, quantityText, Color.WHITE); } + + private static int getBarWidth(int base, int current, int size) + { + final double ratio = (double) current / base; + + if (ratio >= 1) + { + return size; + } + + return (int) Math.round(ratio * size); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultPlugin.java index 89ef526630..30e6a56b90 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultPlugin.java @@ -30,7 +30,6 @@ import java.awt.Font; import java.awt.Image; import java.util.HashMap; import javax.inject.Inject; -import lombok.Getter; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; @@ -43,7 +42,6 @@ import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameTick; import net.runelite.api.events.ItemDespawned; -import net.runelite.api.events.ItemDespawned; import net.runelite.api.events.ItemSpawned; import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.WidgetLoaded; @@ -76,6 +74,10 @@ public class BarbarianAssaultPlugin extends Plugin { @Getter private int collectedEggCount = 0; @Getter + private int positiveEggCount = 0; + @Getter + private int wrongEggs = 0; + @Getter private int HpHealed = 0; @Getter private int totalCollectedEggCount = 0; @@ -141,6 +143,8 @@ public class BarbarianAssaultPlugin extends Plugin { currentWave = START_WAVE; inGameBit = 0; collectedEggCount = 0; + positiveEggCount = 0; + wrongEggs = 0; HpHealed = 0; } @@ -154,10 +158,21 @@ public class BarbarianAssaultPlugin extends Plugin { if (config.showHpCount() && HpHealed > 0) { totalMsg = "; Total Healed: "; total = ""+totalHpHealed; + if (HpHealed > 504) + { + total = ""+504; + } } else if (config.showEggCount() && collectedEggCount > 0) { + collectedEggCount -= wrongEggs; //true positive egg count + if (collectedEggCount > 60) + { + collectedEggCount = 60; + } + collectedEggCount -= wrongEggs; //true positive - negative egg count\ totalMsg = "; Total Collected: "; - total = ""+totalCollectedEggCount; + total = "" + totalCollectedEggCount; + } announceTime("Game finished, duration: ", gameTime.getTime(false),type, amt, totalMsg, total); } @@ -165,9 +180,12 @@ public class BarbarianAssaultPlugin extends Plugin { } @Subscribe - public void onChatMessage(ChatMessage event) { + + public void onChatMessage(ChatMessage event) + { if (event.getType() == ChatMessageType.GAMEMESSAGE - && event.getMessage().startsWith("---- Wave:")) { + && event.getMessage().startsWith("---- Wave:")) + { String[] message = event.getMessage().split(" "); currentWave = message[BA_WAVE_NUM_INDEX]; collectedEggCount = 0; @@ -182,7 +200,7 @@ public class BarbarianAssaultPlugin extends Plugin { } } else if (event.getType() == ChatMessageType.GAMEMESSAGE && event.getMessage().contains("egg explode")) { - collectedEggCount -= 2; + wrongEggs --; } else if (event.getType() == ChatMessageType.GAMEMESSAGE && event.getMessage().contains("healed")) { String message = event.getMessage(); @@ -252,71 +270,84 @@ public class BarbarianAssaultPlugin extends Plugin { inGameBit = inGame; } - @Subscribe - public void onItemSpawned(ItemSpawned itemSpawned) - { - int itemId = itemSpawned.getItem().getId(); - WorldPoint worldPoint = itemSpawned.getTile().getWorldLocation(); - HashMap eggMap = getEggMap(itemId); + @Subscribe + public void onItemSpawned(ItemSpawned itemSpawned) + { + int itemId = itemSpawned.getItem().getId(); + WorldPoint worldPoint = itemSpawned.getTile().getWorldLocation(); + HashMap eggMap = getEggMap(itemId); - if (eggMap != null) - { - Integer existingQuantity = eggMap.putIfAbsent(worldPoint, 1); - if (existingQuantity != null) - { - eggMap.put(worldPoint, existingQuantity + 1); - } - } - } + if (eggMap != null) + { + Integer existingQuantity = eggMap.putIfAbsent(worldPoint, 1); + if (existingQuantity != null) + { + eggMap.put(worldPoint, existingQuantity + 1); + } + } + } @Subscribe - public void onItemDespawned(ItemDespawned event) + public void onItemDespawned(ItemDespawned itemDespawned) { - if (client.getVar(Varbits.IN_GAME_BA) == 0 || !isEgg(event.getItem().getId())) + int itemId = itemDespawned.getItem().getId(); + WorldPoint worldPoint = itemDespawned.getTile().getWorldLocation(); + HashMap eggMap = getEggMap(itemId); + + if (eggMap != null && eggMap.containsKey(worldPoint)) + { + int quantity = eggMap.get(worldPoint); + if (quantity > 1) + { + eggMap.put(worldPoint, quantity - 1); + } + else + { + eggMap.remove(worldPoint); + } + } + if (client.getVar(Varbits.IN_GAME_BA) == 0 || !isEgg(itemDespawned.getItem().getId())) { return; } - if (isUnderPlayer(event.getTile())) + if (isUnderPlayer(itemDespawned.getTile())) { collectedEggCount++; } } - String getCollectorHeardCall() - { - Widget widget = client.getWidget(WidgetInfo.BA_COLL_HEARD_TEXT); - String call = null; + String getCollectorHeardCall() + { + Widget widget = client.getWidget(WidgetInfo.BA_COLL_HEARD_TEXT); + String call = null; - if (widget != null) - { - call = widget.getText(); - } + if (widget != null) + { + call = widget.getText(); + } - return call; - } - - - private HashMap getEggMap(int itemID) - { - switch (itemID) - { - case ItemID.RED_EGG: - return redEggs; - case ItemID.GREEN_EGG: - return greenEggs; - case ItemID.BLUE_EGG: - return blueEggs; - case ItemID.YELLOW_EGG: - return yellowEggs; - default: - return null; - } - } - - - private void announceTime(String preText, String time, String type, String amt, String totalMsg, String total) { + return call; + } + + private HashMap getEggMap(int itemID) + { + switch (itemID) + { + case ItemID.RED_EGG: + return redEggs; + case ItemID.GREEN_EGG: + return greenEggs; + case ItemID.BLUE_EGG: + return blueEggs; + case ItemID.YELLOW_EGG: + return yellowEggs; + default: + return null; + } + } + private void announceTime(String preText, String time, String type, String amt, String totalMsg, String total) { final String chatMessage = new ChatMessageBuilder() .append(ChatColorType.NORMAL) .append(preText) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Calls.java similarity index 53% rename from runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSession.java rename to runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Calls.java index 9d45a1b67f..23d726f10e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSession.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Calls.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Craftiii4 + * Copyright (c) 2018, Cameron * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,59 +22,62 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.mining; +package net.runelite.client.plugins.barbarianassault; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; -import java.time.Instant; import java.util.HashMap; +import java.util.Map; -/** - * Holds information about the players current mining session - */ -public class MiningSession -{ +public enum Calls +{ //Attacker Calls + RED_EGG("Red egg", "Tell-red"), + GREEN_EGG("Green egg", "Tell-green"), + BLUE_EGG("Blue egg", "Tell-blue"), + //Collector Calls + CONTROLLED("Controlled/Bullet/Wind", "Tell-controlled"), + ACCURATE("Accurate/Field/Water", "Tell-accurate"), + AGGRESSIVE("Aggressive/Blunt/Earth", "Tell-aggressive"), + DEFENSIVE("Defensive/Barbed/Fire", "Tell-defensive"), + //Healer Calls + TOFU("Tofu", "Tell-tofu"), + CRACKERS("Crackers", "Tell-crackers"), + WORMS("Worms", "Tell-worms"), + //Defender Calls + POIS_WORMS("Pois. Worms", "Tell-worms"), + POIS_TOFU("Pois. Tofu", "Tell-tofu"), + POIS_MEAT("Pois. Meat", "Tell-meat"); - @Getter(AccessLevel.PACKAGE) - @Setter(AccessLevel.PACKAGE) - private Instant ignoreSpawn; + private final String call; + private final String option; - @Getter(AccessLevel.PACKAGE) - private Instant lastMined; + private static final Map CALL_MENU = new HashMap<>(); - @Getter(AccessLevel.PACKAGE) - private HashMap sessionStats = new HashMap<>(); - - public MiningSession() + static { - setupSession(); - } - - public void setupSession() - { - ignoreSpawn = Instant.now(); - for (MiningRockType rock : MiningRockType.values()) + for (Calls s : values()) { - sessionStats.put(rock, new MiningSessionRockStats()); + CALL_MENU.put(s.getCall(), s.getOption()); } } - public boolean showRockRespawnTimes(MiningRockType rock) + Calls(String call, String option) { - return sessionStats.get(rock).getRecentOreMined() != null; + this.call = call; + this.option = option; } - public void clearSessionFor(MiningRockType rock) + public String getCall() { - sessionStats.get(rock).clearSession(); + return call; } - public void increaseRockMine(MiningRockType rock) + public String getOption() { - Instant now = Instant.now(); - lastMined = now; - sessionStats.get(rock).increaseMined(); + return option; } -} + public static String getOption(String call) + { + return CALL_MENU.get(call); + } + +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/HealerTeam.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/HealerTeam.java new file mode 100644 index 0000000000..5521d620f7 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/HealerTeam.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018, whartd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.barbarianassault; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.runelite.api.Point; +import net.runelite.api.widgets.WidgetInfo; + +@Getter +@AllArgsConstructor +enum HealerTeam +{ + TEAMMATE1(WidgetInfo.BA_HEAL_TEAMMATE1, new Point(28, 2), 115), + TEAMMATE2(WidgetInfo.BA_HEAL_TEAMMATE2, new Point(26, 2), 115), + TEAMMATE3(WidgetInfo.BA_HEAL_TEAMMATE3, new Point(26, 2), 115), + TEAMMATE4(WidgetInfo.BA_HEAL_TEAMMATE4, new Point(25, 2), 115); + + private WidgetInfo teammate; + private Point offset; + private int width; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java index 7b9e195848..961e8760cb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java @@ -78,7 +78,8 @@ import net.runelite.client.util.Text; @PluginDescriptor( name = "BA Tools", description = "Custom tools for Barbarian Assault", - tags = {"minigame", "overlay", "timer"} + tags = {"minigame", "overlay", "timer"}, + type = "utility" ) public class BAToolsPlugin extends Plugin implements KeyListener { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsConfig.java index e623442da3..cc5344771a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsConfig.java @@ -103,4 +103,15 @@ public interface BoostsConfig extends Config { return 0; } + + @ConfigItem( + keyName = "groupNotifications", + name = "Group Notifications", + description = "Configures whether or not to group notifications for multiple skills into a single notification", + position = 7 + ) + default boolean groupNotifications() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java index 4f09b12a8b..086e2535f3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java @@ -26,8 +26,10 @@ package net.runelite.client.plugins.boosts; import com.google.common.collect.ImmutableSet; import com.google.inject.Provides; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.inject.Inject; import javax.inject.Singleton; @@ -100,6 +102,7 @@ public class BoostsPlugin extends Plugin private int lastChangeUp = -1; private boolean preserveBeenActive = false; private long lastTickMillis; + private List boostedSkillsChanged = new ArrayList<>(); @Provides BoostsConfig provideConfig(ConfigManager configManager) @@ -213,7 +216,14 @@ public class BoostsPlugin extends Plugin int boost = cur - real; if (boost <= boostThreshold && boostThreshold < lastBoost) { - notifier.notify(skill.getName() + " level is getting low!"); + if (config.groupNotifications()) + { + boostedSkillsChanged.add(skill.getName()); + } + else + { + notifier.notify(skill.getName() + " level is getting low!"); + } } } } @@ -223,6 +233,35 @@ public class BoostsPlugin extends Plugin { lastTickMillis = System.currentTimeMillis(); + if (config.groupNotifications() && !boostedSkillsChanged.isEmpty()) + { + if (boostedSkillsChanged.size() == 1) + { + notifier.notify(boostedSkillsChanged.get(0) + " level is getting low!"); + } + else + { + String notification = ""; + for (int i = 0; i < boostedSkillsChanged.size(); i++) + { + if (i == 0) + { + notification = boostedSkillsChanged.get(i); + } + else if (i < boostedSkillsChanged.size() - 1) + { + notification = notification + ", " + boostedSkillsChanged.get(i); + } + else + { + notification = notification + " and " + boostedSkillsChanged.get(i) + " levels are getting low!"; + notifier.notify(notification); + } + } + } + boostedSkillsChanged.clear(); + } + if (getChangeUpTicks() <= 0) { switch (config.displayNextDebuffChange()) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonConfig.java index 15f50725e6..29a1496f85 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonConfig.java @@ -83,24 +83,4 @@ public interface CannonConfig extends Config { return true; } - - @ConfigItem( - keyName = "ammoAmount", - name = "Ammo left", - description = "Configure to set the amount of ammo left to receive ammo left notification" - ) - default int ammoAmount() - { - return 5; - } - - @ConfigItem( - keyName = "notifyAmmoLeft", - name = "Ammo left notification", - description = "Sends a notification when cannon ammo is under the specified amount" - ) - default boolean notifyAmmoLeft() - { - return true; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java index 9e7b460fa5..de44d67c59 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonPlugin.java @@ -46,7 +46,12 @@ import net.runelite.api.Projectile; import static net.runelite.api.ProjectileID.CANNONBALL; import static net.runelite.api.ProjectileID.GRANITE_CANNONBALL; import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.*; +import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.GameObjectSpawned; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.api.events.ProjectileMoved; import net.runelite.client.Notifier; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; @@ -270,7 +275,6 @@ public class CannonPlugin extends Plugin if (!skipProjectileCheckThisTick) { cballsLeft--; - client.getCallbacks().post(new CannonballFired()); } } } @@ -375,13 +379,6 @@ public class CannonPlugin extends Plugin { return Color.orange; } - else if (cballsLeft <= config.ammoAmount()) - { - if (config.notifyAmmoLeft()) - { - notifier.notify("Your cannon has " + config.ammoAmount() + " balls left!"); - } - } return Color.red; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatConfig.java index f60f143f06..5fdd7996be 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatConfig.java @@ -126,37 +126,4 @@ public interface ClanChatConfig extends Config { return false; } - - @ConfigItem( - keyName = "discord", - name = "Discord", - description = "Send clan chats to a discord webhook
See https://support.discordapp.com/hc/en-us/articles/228383668", - position = 8 - ) - default boolean discord() - { - return false; - } - - @ConfigItem( - keyName = "discordPath", - name = "Webhook path", - description = "Your webhook id and webhook token
(the part after \"/webhooks/\")", - position = 9 - ) - default String discordPath() - { - return ""; - } - - @ConfigItem( - keyName = "discordAccount", - name = "Discord/RS account", - description = "The login username (not rsn!) of the runescape account you want to use this on", - position = 10 - ) - default String discordAccount() - { - return ""; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java index e9cf3d698b..f52ebd7260 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatPlugin.java @@ -1,94 +1,30 @@ -/* - * Copyright (c) 2017, Devin French - * Copyright (c) 2019, Adam - * Copyright (c) 2018, trimbe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ package net.runelite.client.plugins.clanchat; -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import com.google.inject.Provides; -import java.awt.Color; -import java.awt.image.BufferedImage; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Deque; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import javax.inject.Inject; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.ChatLineBuffer; -import net.runelite.api.ChatMessageType; -import net.runelite.api.ClanMember; -import net.runelite.api.ClanMemberRank; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.MessageNode; -import net.runelite.api.Player; -import net.runelite.api.ScriptID; -import net.runelite.api.SpriteID; -import net.runelite.api.VarClientStr; -import net.runelite.api.Varbits; -import net.runelite.api.events.ChatMessage; -import net.runelite.api.events.ClanChanged; -import net.runelite.api.events.ClanMemberJoined; -import net.runelite.api.events.ClanMemberLeft; -import net.runelite.api.events.ConfigChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.PlayerDespawned; -import net.runelite.api.events.PlayerSpawned; -import net.runelite.api.events.VarClientStrChanged; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetType; -import net.runelite.client.callback.ClientThread; -import net.runelite.client.chat.ChatMessageBuilder; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.ClanManager; -import net.runelite.client.game.SpriteManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.clanchat.discord.DiscordClient; -import net.runelite.client.plugins.clanchat.discord.DiscordMessage; -import static net.runelite.client.ui.JagexColors.CHAT_CLAN_NAME_OPAQUE_BACKGROUND; -import static net.runelite.client.ui.JagexColors.CHAT_CLAN_NAME_TRANSPARENT_BACKGROUND; -import static net.runelite.client.ui.JagexColors.CHAT_CLAN_TEXT_OPAQUE_BACKGROUND; -import static net.runelite.client.ui.JagexColors.CHAT_CLAN_TEXT_TRANSPARENT_BACKGROUND; -import net.runelite.client.ui.overlay.infobox.InfoBoxManager; -import net.runelite.client.util.Text; -import static net.runelite.client.util.Text.removeTags; +import net.runelite.client.plugins.*; +import net.runelite.client.game.*; +import net.runelite.client.callback.*; -@PluginDescriptor( - name = "Clan Chat", - description = "Add rank icons to users talking in clan chat", - tags = {"icons", "rank", "recent"} -) -@Slf4j +import java.util.List; +import java.util.Objects; +import java.util.concurrent.*; +import net.runelite.client.config.*; +import com.google.inject.*; +import net.runelite.client.util.*; +import net.runelite.client.eventbus.*; +import com.google.common.base.*; +import net.runelite.api.widgets.*; +import net.runelite.client.ui.*; +import net.runelite.client.chat.*; +import java.awt.*; +import net.runelite.api.*; +import net.runelite.api.events.*; +import com.google.common.collect.*; +import java.util.*; +import java.util.function.*; +import net.runelite.client.ui.overlay.infobox.*; +import java.awt.image.*; + +@PluginDescriptor(name = "Clan Chat", description = "Add rank icons to users talking in clan chat", tags = { "icons", "rank", "recent" }) public class ClanChatPlugin extends Plugin { private static final int MAX_CHATS = 10; @@ -96,585 +32,376 @@ public class ClanChatPlugin extends Plugin private static final String RECENT_TITLE = "Recent Clan Chats"; private static final int JOIN_LEAVE_DURATION = 20; private static final int MESSAGE_DELAY = 10; - @Inject private Client client; - @Inject private ClanManager clanManager; - @Inject private ClanChatConfig config; - @Inject private InfoBoxManager infoBoxManager; - @Inject private SpriteManager spriteManager; - @Inject private ClientThread clientThread; - - private List chats = new ArrayList<>(); - private List clanMembers = new ArrayList<>(); + private List chats; + private static CopyOnWriteArrayList clanMembers; private ClanChatIndicator clanMemberCounter; - - private DiscordClient discordClient; - - /** - * queue of temporary messages added to the client - */ - private final Deque clanJoinMessages = new ArrayDeque<>(); - private Map activityBuffer = new HashMap<>(); + private final Deque clanJoinMessages; + private Map activityBuffer; private int clanJoinedTick; + public ClanChatPlugin() { + this.chats = new ArrayList(); + this.clanJoinMessages = new ArrayDeque(); + this.activityBuffer = new HashMap(); + } + + public static CopyOnWriteArrayList getClanMembers() { + return (CopyOnWriteArrayList)ClanChatPlugin.clanMembers.clone(); + } + @Provides - ClanChatConfig getConfig(ConfigManager configManager) - { + ClanChatConfig getConfig(final ConfigManager configManager) { return configManager.getConfig(ClanChatConfig.class); } - @Override - public void startUp() - { - chats = new ArrayList<>(Text.fromCSV(config.chatsData())); + public void startUp() { + this.chats = new ArrayList(Text.fromCSV(this.config.chatsData())); } - @Override - public void shutDown() - { - clanMembers.clear(); - removeClanCounter(); - resetClanChats(); - stopDiscordClient(); + public void shutDown() { + ClanChatPlugin.clanMembers.clear(); + this.removeClanCounter(); + this.resetClanChats(); } @Subscribe - public void onConfigChanged(ConfigChanged configChanged) - { - if (configChanged.getGroup().equals("clanchat")) - { - if (!config.recentChats()) - { - resetClanChats(); + public void onConfigChanged(final ConfigChanged configChanged) { + if (configChanged.getGroup().equals("clanchat")) { + if (!this.config.recentChats()) { + this.resetClanChats(); } - - if (config.showClanCounter()) - { - clientThread.invoke(this::addClanCounter); + if (this.config.showClanCounter()) { + this.clientThread.invoke(this::addClanCounter); } - else - { - removeClanCounter(); - } - - if (config.discord()) - { - startDiscordClient(); - } - else - { - stopDiscordClient(); + else { + this.removeClanCounter(); } } } @Subscribe - public void onClanMemberJoined(ClanMemberJoined event) - { + public void onClanMemberJoined(final ClanMemberJoined event) { final ClanMember member = event.getMember(); - - if (member.getWorld() == client.getWorld()) - { + if (member.getWorld() == this.client.getWorld()) { final String memberName = Text.toJagexName(member.getUsername()); - - for (final Player player : client.getPlayers()) - { - if (player != null && memberName.equals(Text.toJagexName(player.getName()))) - { - clanMembers.add(player); - addClanCounter(); + for (final Player player : this.client.getPlayers()) { + if (player != null && memberName.equals(Text.toJagexName(player.getName()))) { + ClanChatPlugin.clanMembers.add(player); + this.addClanCounter(); break; } } } - - // clan members getting initialized isn't relevant - if (clanJoinedTick == client.getTickCount()) - { + if (this.clanJoinedTick == this.client.getTickCount()) { return; } - - if (!config.showJoinLeave() || - member.getRank().getValue() < config.joinLeaveRank().getValue()) - { + if (!this.config.showJoinLeave() || member.getRank().getValue() < this.config.joinLeaveRank().getValue()) { return; } - - // attempt to filter out world hopping joins - if (!activityBuffer.containsKey(member.getUsername())) - { - ClanMemberActivity joinActivity = new ClanMemberActivity(ClanActivityType.JOINED, - member, client.getTickCount()); - activityBuffer.put(member.getUsername(), joinActivity); + if (!this.activityBuffer.containsKey(member.getUsername())) { + final ClanMemberActivity joinActivity = new ClanMemberActivity(ClanActivityType.JOINED, member, this.client.getTickCount()); + this.activityBuffer.put(member.getUsername(), joinActivity); } - else - { - activityBuffer.remove(member.getUsername()); + else { + this.activityBuffer.remove(member.getUsername()); } } @Subscribe - public void onClanMemberLeft(ClanMemberLeft event) - { + public void onClanMemberLeft(final ClanMemberLeft event) { final ClanMember member = event.getMember(); - - if (member.getWorld() == client.getWorld()) - { + if (member.getWorld() == this.client.getWorld()) { final String memberName = Text.toJagexName(member.getUsername()); - final Iterator each = clanMembers.iterator(); - - while (each.hasNext()) - { - if (memberName.equals(Text.toJagexName(each.next().getName()))) - { + final Iterator each = ClanChatPlugin.clanMembers.iterator(); + while (each.hasNext()) { + if (memberName.equals(Text.toJagexName(each.next().getName()))) { each.remove(); - - if (clanMembers.isEmpty()) - { - removeClanCounter(); + if (ClanChatPlugin.clanMembers.isEmpty()) { + this.removeClanCounter(); + break; } - break; } } } - - if (!config.showJoinLeave() || - member.getRank().getValue() < config.joinLeaveRank().getValue()) - { + if (!this.config.showJoinLeave() || member.getRank().getValue() < this.config.joinLeaveRank().getValue()) { return; } - - if (!activityBuffer.containsKey(member.getUsername())) - { - ClanMemberActivity leaveActivity = new ClanMemberActivity(ClanActivityType.LEFT, - member, client.getTickCount()); - activityBuffer.put(member.getUsername(), leaveActivity); + if (!this.activityBuffer.containsKey(member.getUsername())) { + final ClanMemberActivity leaveActivity = new ClanMemberActivity(ClanActivityType.LEFT, member, this.client.getTickCount()); + this.activityBuffer.put(member.getUsername(), leaveActivity); } - else - { - activityBuffer.remove(member.getUsername()); + else { + this.activityBuffer.remove(member.getUsername()); } } @Subscribe - public void onGameTick(GameTick gameTick) - { - if (client.getGameState() != GameState.LOGGED_IN) - { + public void onGameTick(final GameTick gameTick) { + if (this.client.getGameState() != GameState.LOGGED_IN) { return; } - - Widget clanChatTitleWidget = client.getWidget(WidgetInfo.CLAN_CHAT_TITLE); - if (clanChatTitleWidget != null) - { - Widget clanChatList = client.getWidget(WidgetInfo.CLAN_CHAT_LIST); - Widget owner = client.getWidget(WidgetInfo.CLAN_CHAT_OWNER); - if (client.getClanChatCount() > 0) - { - clanChatTitleWidget.setText(CLAN_CHAT_TITLE + " (" + client.getClanChatCount() + "/100)"); + final Widget clanChatTitleWidget = this.client.getWidget(WidgetInfo.CLAN_CHAT_TITLE); + if (clanChatTitleWidget != null) { + final Widget clanChatList = this.client.getWidget(WidgetInfo.CLAN_CHAT_LIST); + final Widget owner = this.client.getWidget(WidgetInfo.CLAN_CHAT_OWNER); + if (this.client.getClanChatCount() > 0) { + clanChatTitleWidget.setText("Clan Chat (" + this.client.getClanChatCount() + "/100)"); } - else if (config.recentChats() && clanChatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText())) - { - clanChatTitleWidget.setText(RECENT_TITLE); - - loadClanChats(); + else if (this.config.recentChats() && clanChatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText())) { + clanChatTitleWidget.setText("Recent Clan Chats"); + this.loadClanChats(); } } - - if (!config.showJoinLeave()) - { + if (!this.config.showJoinLeave()) { return; } - - timeoutClanMessages(); - - addClanActivityMessages(); + this.timeoutClanMessages(); + this.addClanActivityMessages(); } - private void submitMessage(String message, String user, String url) - { - if (discordClient == null) - { + private void timeoutClanMessages() { + if (this.clanJoinMessages.isEmpty()) { return; } - - DiscordMessage discordMessage = new DiscordMessage(); - - message = removeTags(message); - if (!user.contains("") && !user.contains("")) - { - discordMessage.setContent(message); - } - else if (user.contains("img=10")) - { - discordMessage.setContent("<:hcim:557056153834487819> " + message); - } - else - { - discordMessage.setContent("<:iron:557056153729630209> " + message); - } - discordMessage.setUsername(removeTags(user)); - discordMessage.setAvatar_url(url); - - discordClient.submit(discordMessage, config.discordPath()); - } - private void submitMessage(String message) - { - submitMessage(message, "", ""); - } - - private void timeoutClanMessages() - { - if (clanJoinMessages.isEmpty()) - { - return; - } - boolean removed = false; - - for (Iterator it = clanJoinMessages.iterator(); it.hasNext(); ) - { - ClanJoinMessage clanJoinMessage = it.next(); - MessageNode messageNode = clanJoinMessage.getMessageNode(); + final Iterator it = this.clanJoinMessages.iterator(); + while (it.hasNext()) { + final ClanJoinMessage clanJoinMessage = it.next(); + final MessageNode messageNode = clanJoinMessage.getMessageNode(); final int createdTick = clanJoinMessage.getTick(); - - if (client.getTickCount() > createdTick + JOIN_LEAVE_DURATION) - { - it.remove(); - - // If this message has been reused since, it will get a different id - if (clanJoinMessage.getGetMessageId() == messageNode.getId()) - { - ChatLineBuffer ccInfoBuffer = client.getChatLineMap().get(ChatMessageType.FRIENDSCHATNOTIFICATION.getType()); - if (ccInfoBuffer != null) - { - ccInfoBuffer.removeMessageNode(messageNode); - removed = true; - } - } - } - else - { - // Everything else in the deque is newer + if (this.client.getTickCount() <= createdTick + 20) { break; } + it.remove(); + if (clanJoinMessage.getGetMessageId() != messageNode.getId()) { + continue; + } + final ChatLineBuffer ccInfoBuffer = this.client.getChatLineMap().get(ChatMessageType.FRIENDSCHATNOTIFICATION.getType()); + if (ccInfoBuffer == null) { + continue; + } + ccInfoBuffer.removeMessageNode(messageNode); + removed = true; } - - if (removed) - { - clientThread.invoke(() -> client.runScript(ScriptID.BUILD_CHATBOX)); + if (removed) { + this.clientThread.invoke(() -> this.client.runScript(216, new Object[0])); } } - private void addClanActivityMessages() - { - Iterator activityIt = activityBuffer.values().iterator(); - - while (activityIt.hasNext()) - { - ClanMemberActivity activity = activityIt.next(); - - if (activity.getTick() < client.getTickCount() - MESSAGE_DELAY) - { + private void addClanActivityMessages() { + final Iterator activityIt = this.activityBuffer.values().iterator(); + while (activityIt.hasNext()) { + final ClanMemberActivity activity = activityIt.next(); + if (activity.getTick() < this.client.getTickCount() - 10) { activityIt.remove(); - addActivityMessage(activity.getMember(), activity.getActivityType()); + this.addActivityMessage(activity.getMember(), activity.getActivityType()); } } } - private void addActivityMessage(ClanMember member, ClanActivityType activityType) - { - final String activityMessage = activityType == ClanActivityType.JOINED ? " has joined. " : " has left. "; + private void addActivityMessage(final ClanMember member, final ClanActivityType activityType) { + final String activityMessage = (activityType == ClanActivityType.JOINED) ? " has joined." : " has left."; final ClanMemberRank rank = member.getRank(); - Color textColor = CHAT_CLAN_TEXT_OPAQUE_BACKGROUND; - Color channelColor = CHAT_CLAN_NAME_OPAQUE_BACKGROUND; + Color textColor = JagexColors.CHAT_CLAN_TEXT_OPAQUE_BACKGROUND; + Color channelColor = JagexColors.CHAT_CLAN_NAME_OPAQUE_BACKGROUND; int rankIcon = -1; - - if (client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1) - { - textColor = CHAT_CLAN_TEXT_TRANSPARENT_BACKGROUND; - channelColor = CHAT_CLAN_NAME_TRANSPARENT_BACKGROUND; + if (this.client.isResized() && this.client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1) { + textColor = JagexColors.CHAT_CLAN_TEXT_TRANSPARENT_BACKGROUND; + channelColor = JagexColors.CHAT_CLAN_NAME_TRANSPARENT_BACKGROUND; } - - if (config.clanChatIcons() && rank != ClanMemberRank.UNRANKED) - { - rankIcon = clanManager.getIconNumber(rank); + if (this.config.clanChatIcons() && rank != null && rank != ClanMemberRank.UNRANKED) { + rankIcon = this.clanManager.getIconNumber(rank); } - - ChatMessageBuilder message = new ChatMessageBuilder() - .append("[") - .append(channelColor, client.getClanChatName()); - if (rankIcon > -1) - { - message - .append(" ") - .img(rankIcon); + final ChatMessageBuilder message = new ChatMessageBuilder().append("[").append(channelColor, this.client.getClanChatName()); + if (rankIcon > -1) { + message.append(" ").img(rankIcon); } - message - .append("] ") - .append(textColor, member.getUsername() + activityMessage); - + message.append("] ").append(textColor, member.getUsername() + activityMessage); final String messageString = message.build(); - client.addChatMessage(ChatMessageType.FRIENDSCHATNOTIFICATION, "", messageString, ""); - if (discordClient != null) - { - submitMessage(member.getUsername() + activityMessage + client.getClanChatCount() + " people online."); - } - - final ChatLineBuffer chatLineBuffer = client.getChatLineMap().get(ChatMessageType.FRIENDSCHATNOTIFICATION.getType()); + this.client.addChatMessage(ChatMessageType.FRIENDSCHATNOTIFICATION, "", messageString, ""); + final ChatLineBuffer chatLineBuffer = this.client.getChatLineMap().get(ChatMessageType.FRIENDSCHATNOTIFICATION.getType()); final MessageNode[] lines = chatLineBuffer.getLines(); final MessageNode line = lines[0]; - - ClanJoinMessage clanJoinMessage = new ClanJoinMessage(line, line.getId(), client.getTickCount()); - clanJoinMessages.addLast(clanJoinMessage); + final ClanJoinMessage clanJoinMessage = new ClanJoinMessage(line, line.getId(), this.client.getTickCount()); + this.clanJoinMessages.addLast(clanJoinMessage); } @Subscribe - public void onVarClientStrChanged(VarClientStrChanged strChanged) - { - if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && config.recentChats()) - { - updateRecentChat(client.getVar(VarClientStr.RECENT_CLAN_CHAT)); + public void onVarClientStrChanged(final VarClientStrChanged strChanged) { + if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && this.config.recentChats()) { + this.updateRecentChat(this.client.getVar(VarClientStr.RECENT_CLAN_CHAT)); } } @Subscribe - public void onChatMessage(ChatMessage chatMessage) - { - if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN || client.getClanChatCount() <= 0) - { + public void onChatMessage(final ChatMessage chatMessage) { + if (this.client.getGameState() != GameState.LOADING && this.client.getGameState() != GameState.LOGGED_IN) { return; } - - switch (chatMessage.getType()) - { + if (this.client.getClanChatCount() <= 0) { + return; + } + switch (chatMessage.getType()) { case PRIVATECHAT: - case MODPRIVATECHAT: - if (!config.privateMessageIcons()) - { + case MODPRIVATECHAT: { + if (!this.config.privateMessageIcons()) { return; } break; + } case PUBLICCHAT: - case MODCHAT: - if (!config.publicChatIcons()) - { + case MODCHAT: { + if (!this.config.publicChatIcons()) { return; } break; - case FRIENDSCHAT: - if (discordClient != null) - { - String url = clanManager.getRank(chatMessage.getName()).getDiscavatar(); - submitMessage(chatMessage.getMessage(), chatMessage.getName(), url); - } - - if (!config.clanChatIcons()) - { + } + case FRIENDSCHAT: { + if (!this.config.clanChatIcons()) { return; } break; - default: + } + default: { return; - } - - insertClanRankIcon(chatMessage); - } - - @Subscribe - public void onGameStateChanged(GameStateChanged state) - { - GameState gameState = state.getGameState(); - - if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.CONNECTION_LOST || gameState == GameState.HOPPING) - { - clanMembers.clear(); - removeClanCounter(); - clanJoinMessages.clear(); - - if (gameState == GameState.LOGIN_SCREEN) - { - stopDiscordClient(); } } + this.insertClanRankIcon(chatMessage); } @Subscribe - public void onPlayerSpawned(PlayerSpawned event) - { - if (event.getPlayer().isClanMember()) - { - clanMembers.add(event.getPlayer()); - addClanCounter(); + public void onGameStateChanged(final GameStateChanged state) { + final GameState gameState = state.getGameState(); + if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.CONNECTION_LOST || gameState == GameState.HOPPING) { + ClanChatPlugin.clanMembers.clear(); + this.removeClanCounter(); + this.clanJoinMessages.clear(); } } @Subscribe - public void onPlayerDespawned(PlayerDespawned event) - { - if (clanMembers.remove(event.getPlayer()) && clanMembers.isEmpty()) - { - removeClanCounter(); + public void onPlayerSpawned(final PlayerSpawned event) { + if (event.getPlayer().isClanMember()) { + ClanChatPlugin.clanMembers.add(event.getPlayer()); + this.addClanCounter(); } } @Subscribe - public void onClanChanged(ClanChanged event) - { - if (event.isJoined()) - { - clanJoinedTick = client.getTickCount(); - - if (config.discord()) - { - startDiscordClient(); - } + public void onPlayerDespawned(final PlayerDespawned event) { + if (ClanChatPlugin.clanMembers.remove(event.getPlayer()) && ClanChatPlugin.clanMembers.isEmpty()) { + this.removeClanCounter(); } - else - { - clanMembers.clear(); - removeClanCounter(); - } - - activityBuffer.clear(); } - int getClanAmount() - { - return clanMembers.size(); + @Subscribe + public void onClanChanged(final ClanChanged event) { + if (event.isJoined()) { + this.clanJoinedTick = this.client.getTickCount(); + } + else { + ClanChatPlugin.clanMembers.clear(); + this.removeClanCounter(); + } + this.activityBuffer.clear(); } - private void insertClanRankIcon(final ChatMessage message) - { - final ClanMemberRank rank = clanManager.getRank(message.getName()); + int getClanAmount() { + return ClanChatPlugin.clanMembers.size(); + } - if (rank != null && rank != ClanMemberRank.UNRANKED) - { - int iconNumber = clanManager.getIconNumber(rank); + private void insertClanRankIcon(final ChatMessage message) { + final ClanMemberRank rank = this.clanManager.getRank(message.getName()); + if (rank != null && rank != ClanMemberRank.UNRANKED) { + final int iconNumber = this.clanManager.getIconNumber(rank); final String img = ""; - if (message.getType() == ChatMessageType.FRIENDSCHAT) - { - message.getMessageNode() - .setSender(message.getMessageNode().getSender() + " " + img); + if (message.getType() == ChatMessageType.FRIENDSCHAT) { + message.getMessageNode().setSender(message.getMessageNode().getSender() + " " + img); } - else - { - message.getMessageNode() - .setName(img + message.getMessageNode().getName()); + else { + message.getMessageNode().setName(img + message.getMessageNode().getName()); } - client.refreshChat(); + this.client.refreshChat(); } } - private void resetClanChats() - { - Widget clanChatList = client.getWidget(WidgetInfo.CLAN_CHAT_LIST); - Widget clanChatTitleWidget = client.getWidget(WidgetInfo.CLAN_CHAT_TITLE); - - if (clanChatList == null) - { + private void resetClanChats() { + final Widget clanChatList = this.client.getWidget(WidgetInfo.CLAN_CHAT_LIST); + final Widget clanChatTitleWidget = this.client.getWidget(WidgetInfo.CLAN_CHAT_TITLE); + if (clanChatList == null) { return; } - - if (client.getClanChatCount() == 0) - { + if (this.client.getClanChatCount() == 0) { clanChatList.setChildren(null); } - - clanChatTitleWidget.setText(CLAN_CHAT_TITLE); + clanChatTitleWidget.setText("Clan Chat"); } - private void loadClanChats() - { - Widget clanChatList = client.getWidget(WidgetInfo.CLAN_CHAT_LIST); - if (clanChatList == null) - { + private void loadClanChats() { + final Widget clanChatList = this.client.getWidget(WidgetInfo.CLAN_CHAT_LIST); + if (clanChatList == null) { return; } - int y = 2; clanChatList.setChildren(null); - for (String chat : Lists.reverse(chats)) - { - Widget widget = clanChatList.createChild(-1, WidgetType.TEXT); + for (final String chat : Lists.reverse(this.chats)) { + final Widget widget = clanChatList.createChild(-1, 4); widget.setFontId(494); - widget.setTextColor(0xffffff); + widget.setTextColor(16777215); widget.setText(chat); widget.setOriginalHeight(14); widget.setOriginalWidth(142); widget.setOriginalY(y); widget.setOriginalX(20); widget.revalidate(); - y += 14; } } - private void updateRecentChat(String s) - { - if (Strings.isNullOrEmpty(s)) - { + private void updateRecentChat(String s) { + if (Strings.isNullOrEmpty(s)) { return; } - s = Text.toJagexName(s); - - chats.removeIf(s::equalsIgnoreCase); - chats.add(s); - - while (chats.size() > MAX_CHATS) - { - chats.remove(0); + final List chats = this.chats; + final String s2 = s; + Objects.requireNonNull(s2); + chats.removeIf(s2::equalsIgnoreCase); + this.chats.add(s); + while (this.chats.size() > 10) { + this.chats.remove(0); } - - config.chatsData(Text.toCSV(chats)); + this.config.chatsData(Text.toCSV(this.chats)); } - private void removeClanCounter() - { - infoBoxManager.removeInfoBox(clanMemberCounter); - clanMemberCounter = null; + private void removeClanCounter() { + this.infoBoxManager.removeInfoBox(this.clanMemberCounter); + this.clanMemberCounter = null; } - private void addClanCounter() - { - if (!config.showClanCounter() || clanMemberCounter != null || clanMembers.isEmpty()) - { + private void addClanCounter() { + if (!this.config.showClanCounter() || this.clanMemberCounter != null || ClanChatPlugin.clanMembers.isEmpty()) { return; } - - final BufferedImage image = spriteManager.getSprite(SpriteID.TAB_CLAN_CHAT, 0); - clanMemberCounter = new ClanChatIndicator(image, this); - infoBoxManager.addInfoBox(clanMemberCounter); + final BufferedImage image = this.spriteManager.getSprite(904, 0); + this.clanMemberCounter = new ClanChatIndicator(image, this); + this.infoBoxManager.addInfoBox(this.clanMemberCounter); } - private void startDiscordClient() - { - if (discordClient == null && config.discordAccount().equals(client.getUsername())) - { - discordClient = new DiscordClient(); - submitMessage("Started\n\n" + client.getLocalPlayer().getName() + " has joined."); - } - } - - private void stopDiscordClient() - { - if (discordClient != null) - { - submitMessage(client.getLocalPlayer().getName() + " has left.\n\nStopped"); - discordClient = null; - } + static { + ClanChatPlugin.clanMembers = new CopyOnWriteArrayList(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/discord/DiscordClient.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/discord/DiscordClient.java deleted file mode 100644 index ec523710e1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/discord/DiscordClient.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.runelite.client.plugins.clanchat.discord; - -import com.google.gson.Gson; -import java.io.IOException; -import static java.lang.Integer.parseInt; -import java.time.Instant; -import lombok.extern.slf4j.Slf4j; -import net.runelite.http.api.RuneLiteAPI; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.HttpUrl; -import okhttp3.MediaType; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; - -@Slf4j -public class DiscordClient -{ - private static final MediaType JSON = MediaType.parse("application/json"); - private static final Gson GSON = RuneLiteAPI.GSON; - private int rateLimit = 1; - private Instant rateReset = Instant.EPOCH; - - public void submit(DiscordMessage message, String path) - { - if (rateLimit < 1 && Instant.now().isBefore(rateReset)) - { - return; - } - - final HttpUrl url = new HttpUrl.Builder() - .scheme("https") - .host("discordapp.com") - .addPathSegments("api/webhooks") - .addPathSegments(path) - .build(); - - Request request = new Request.Builder() - .post(RequestBody.create(JSON, GSON.toJson(message))) - .url(url) - .build(); - - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() - { - @Override - public void onFailure(Call call, IOException e) - { - log.debug("discord message failed", e); - } - - @Override - public void onResponse(Call call, Response response) - { - rateLimit = parseInt(response.header("X-RateLimit-Remaining")); - rateReset = Instant.ofEpochSecond((parseInt(response.header("X-RateLimit-Reset")))); - log.debug("Submitted discord message, limit: {}, reset: {}", rateLimit, rateReset); - response.close(); - } - }); - } -} - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/discord/DiscordMessage.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/discord/DiscordMessage.java deleted file mode 100644 index f4f037824c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/discord/DiscordMessage.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.runelite.client.plugins.clanchat.discord; - -import lombok.Data; - -@Data -public class DiscordMessage -{ - private String username; - private String content; - private String avatar_url; -} - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModePlugin.java index d71d054674..7821fd8946 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModePlugin.java @@ -22,9 +22,10 @@ import net.runelite.client.util.Text; import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( - name = "!Clan Man Mode", + name = "Clan Man Mode", description = "Assists in clan PVP scenarios", - tags = {"highlight", "minimap", "overlay", "players"} + tags = {"highlight", "minimap", "overlay", "players"}, + type = "PVP" ) public class ClanManModePlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index 3919162165..ea8908b824 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -82,6 +82,7 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginInstantiationException; import net.runelite.client.plugins.PluginManager; +import net.runelite.client.plugins.pluginsorter.PluginSorterPlugin; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.DynamicGridLayout; import net.runelite.client.ui.PluginPanel; @@ -106,13 +107,14 @@ public class ConfigPanel extends PluginPanel private static final String PINNED_PLUGINS_CONFIG_KEY = "pinnedPlugins"; private static final String RUNELITE_PLUGIN = "RuneLite"; private static final String CHAT_COLOR_PLUGIN = "Chat Color"; + public static boolean flexoConfigEnabled = false; private final PluginManager pluginManager; private final ConfigManager configManager; private final ScheduledExecutorService executorService; private final RuneLiteConfig runeLiteConfig; private final ChatColorConfig chatColorConfig; - private final List pluginList = new ArrayList<>(); + public static List pluginList = new ArrayList<>(); private final IconTextField searchBar = new IconTextField(); private final JPanel topPanel; @@ -187,40 +189,150 @@ public class ConfigPanel extends PluginPanel initializePluginList(); refreshPluginList(); + } private void initializePluginList() { final List pinnedPlugins = getPinnedPluginNames(); - // populate pluginList with all non-hidden plugins + List externalPlugins = new ArrayList<>(); + // populate pluginList with all external Plugins pluginManager.getPlugins().stream() - .filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).hidden()) + .filter(plugin -> plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("external")) .forEach(plugin -> { final PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); final Config config = pluginManager.getPluginConfigProxy(plugin); final ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config); - final PluginListItem listItem = new PluginListItem(this, plugin, descriptor, config, configDescriptor); + final PluginListItem listItem = new PluginListItem(this, configManager, plugin, descriptor, config, configDescriptor); + System.out.println("Started "+listItem.getName()); listItem.setPinned(pinnedPlugins.contains(listItem.getName())); - pluginList.add(listItem); + externalPlugins.add(listItem); }); + externalPlugins.sort(Comparator.comparing(PluginListItem::getName)); + for (PluginListItem plugin : externalPlugins) + pluginList.add(plugin); + + List pvmPlugins = new ArrayList<>(); + // populate pluginList with all PVM Plugins + pluginManager.getPlugins().stream() + .filter(plugin -> plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("PVM")) + .forEach(plugin -> + { + final PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); + final Config config = pluginManager.getPluginConfigProxy(plugin); + final ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config); + + final PluginListItem listItem = new PluginListItem(this, configManager, plugin, descriptor, config, configDescriptor); + System.out.println("Started "+listItem.getName()); + listItem.setPinned(pinnedPlugins.contains(listItem.getName())); + pvmPlugins.add(listItem); + }); + + pvmPlugins.sort(Comparator.comparing(PluginListItem::getName)); + for (PluginListItem plugin : pvmPlugins) + pluginList.add(plugin); + + List pvpPlugins = new ArrayList<>(); + // populate pluginList with all PVP Plugins + pluginManager.getPlugins().stream() + .filter(plugin -> plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("PVP")) + .forEach(plugin -> + { + final PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); + final Config config = pluginManager.getPluginConfigProxy(plugin); + final ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config); + + final PluginListItem listItem = new PluginListItem(this, configManager, plugin, descriptor, config, configDescriptor); + System.out.println("Started "+listItem.getName()); + listItem.setPinned(pinnedPlugins.contains(listItem.getName())); + pvpPlugins.add(listItem); + }); + + pvpPlugins.sort(Comparator.comparing(PluginListItem::getName)); + for (PluginListItem plugin : pvpPlugins) + pluginList.add(plugin); + + List utilPlugins = new ArrayList<>(); + // populate pluginList with all utility Plugins + pluginManager.getPlugins().stream() + .filter(plugin -> plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("utility")) + .forEach(plugin -> + { + final PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); + final Config config = pluginManager.getPluginConfigProxy(plugin); + final ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config); + + final PluginListItem listItem = new PluginListItem(this, configManager, plugin, descriptor, config, configDescriptor); + if (listItem.getName().contains("Flexo") && flexoConfigEnabled) { + System.out.println("Started "+listItem.getName()); + listItem.setPinned(pinnedPlugins.contains(listItem.getName())); + utilPlugins.add(listItem); + } else if (!listItem.getName().contains("Flexo")) { + System.out.println("Started "+listItem.getName()); + listItem.setPinned(pinnedPlugins.contains(listItem.getName())); + utilPlugins.add(listItem); + } + + }); + + utilPlugins.sort(Comparator.comparing(PluginListItem::getName)); + for (PluginListItem plugin : utilPlugins) + pluginList.add(plugin); + + // populate pluginList with all vanilla RL plugins + List vanillaPlugins = new ArrayList<>(); + pluginManager.getPlugins().stream() + .filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).hidden()) + .filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("PVM")) + .filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("PVP")) + .filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("utility")) + .filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("pluginOrganizer")) + .forEach(plugin -> + { + final PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); + final Config config = pluginManager.getPluginConfigProxy(plugin); + final ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config); + + final PluginListItem listItem = new PluginListItem(this, configManager, plugin, descriptor, config, configDescriptor); + listItem.setPinned(pinnedPlugins.contains(listItem.getName())); + vanillaPlugins.add(listItem); + } + ); + + vanillaPlugins.sort(Comparator.comparing(PluginListItem::getName)); + for (PluginListItem plugin : vanillaPlugins) + pluginList.add(plugin); + // add special entries for core client configurations - final PluginListItem runeLite = new PluginListItem(this, runeLiteConfig, + final PluginListItem runeLite = new PluginListItem(this, configManager, runeLiteConfig, configManager.getConfigDescriptor(runeLiteConfig), RUNELITE_PLUGIN, "RuneLite client settings", "client"); runeLite.setPinned(pinnedPlugins.contains(RUNELITE_PLUGIN)); pluginList.add(runeLite); - final PluginListItem chatColor = new PluginListItem(this, chatColorConfig, + final PluginListItem chatColor = new PluginListItem(this, configManager, chatColorConfig, configManager.getConfigDescriptor(chatColorConfig), CHAT_COLOR_PLUGIN, "Recolor chat text", "colour", "messages"); chatColor.setPinned(pinnedPlugins.contains(CHAT_COLOR_PLUGIN)); pluginList.add(chatColor); - pluginList.sort(Comparator.comparing(PluginListItem::getName)); + // Add plugin sorter to bottom + pluginManager.getPlugins().stream() + .filter(plugin -> plugin.getClass().getAnnotation(PluginDescriptor.class).type().equals("pluginOrganizer")) + .forEach(plugin -> + { + final PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); + final Config config = pluginManager.getPluginConfigProxy(plugin); + final ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config); + + final PluginListItem listItem = new PluginListItem(this, configManager, plugin, descriptor, config, configDescriptor); + System.out.println("Started "+listItem.getName()); + pluginList.add(listItem); + }); } void refreshPluginList() @@ -310,8 +422,7 @@ public class ConfigPanel extends PluginPanel String name = listItem.getName(); JLabel title = new JLabel(name); title.setForeground(Color.WHITE); - title.setText("" + name +""); - title.setToolTipText("" + ":
" + listItem.getDescription() + ""); + title.setToolTipText("" + name + ":
" + listItem.getDescription() + ""); topPanel.add(title); for (ConfigItemDescriptor cid : cd.getItems()) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java index 3ffba69b4c..6f52c04660 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.annotation.Nullable; +import javax.inject.Inject; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -40,16 +41,20 @@ import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigDescriptor; +import net.runelite.client.config.ConfigItemDescriptor; +import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.components.IconButton; +import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ImageUtil; import org.apache.commons.text.similarity.JaroWinklerDistance; -class PluginListItem extends JPanel +public class PluginListItem extends JPanel { private static final JaroWinklerDistance DISTANCE = new JaroWinklerDistance(); + public JLabel nameLabel; private static final ImageIcon CONFIG_ICON; private static final ImageIcon CONFIG_ICON_HOVER; @@ -59,6 +64,7 @@ class PluginListItem extends JPanel private static final ImageIcon OFF_STAR; private final ConfigPanel configPanel; + public final ConfigManager configManager; @Getter @Nullable @@ -70,7 +76,7 @@ class PluginListItem extends JPanel @Nullable @Getter(AccessLevel.PACKAGE) - private final ConfigDescriptor configDescriptor; + public final ConfigDescriptor configDescriptor; @Getter private final String name; @@ -120,26 +126,27 @@ class PluginListItem extends JPanel * Note that {@code config} and {@code configDescriptor} can be {@code null} * if there is no configuration associated with the plugin. */ - PluginListItem(ConfigPanel configPanel, Plugin plugin, PluginDescriptor descriptor, + PluginListItem(ConfigPanel configPanel, ConfigManager configManager, Plugin plugin, PluginDescriptor descriptor, @Nullable Config config, @Nullable ConfigDescriptor configDescriptor) { - this(configPanel, plugin, config, configDescriptor, + this(configPanel, configManager, plugin, config, configDescriptor, descriptor.name(), descriptor.description(), descriptor.tags()); } /** * Creates a new {@code PluginListItem} for a core configuration. */ - PluginListItem(ConfigPanel configPanel, Config config, ConfigDescriptor configDescriptor, + PluginListItem(ConfigPanel configPanel, ConfigManager configManager, Config config, ConfigDescriptor configDescriptor, String name, String description, String... tags) { - this(configPanel, null, config, configDescriptor, name, description, tags); + this(configPanel, configManager, null, config, configDescriptor, name, description, tags); } - private PluginListItem(ConfigPanel configPanel, @Nullable Plugin plugin, @Nullable Config config, + private PluginListItem(ConfigPanel configPanel, ConfigManager configManager, @Nullable Plugin plugin, @Nullable Config config, @Nullable ConfigDescriptor configDescriptor, String name, String description, String... tags) { this.configPanel = configPanel; + this.configManager = configManager; this.plugin = plugin; this.config = config; this.configDescriptor = configDescriptor; @@ -152,10 +159,7 @@ class PluginListItem extends JPanel setLayout(new BorderLayout(3, 0)); setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH, 20)); - JLabel nameLabel = new JLabel(name); - nameLabel.setText("" + name +""); - nameLabel.setForeground(Color.WHITE); - + nameLabel = new JLabel(name); if (!description.isEmpty()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxConfig.java deleted file mode 100644 index 8922ebf867..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxConfig.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2019, Jacky - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.cox; - -import java.awt.Color; -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; -import net.runelite.client.config.Range; - -@ConfigGroup("hydra") -public interface CoxConfig extends Config -{ - @ConfigItem( - position = 0, - keyName = "showHydraTile", - name = "Hydra's Size Box ", - description = "Displays hydra's size box for luring over vents" - ) - default boolean showHydraTile() - { - return false; - } - - @ConfigItem( - position = 1, - keyName = "tileColour", - name = "Color of hydra tile size", - description = "Configures the color of hydra's size" - ) - default Color hydraTileColour() - { - return Color.ORANGE; - } - - @Range( - min = -1000, - max = 1000 - ) - @ConfigItem( - position = 2, - keyName = "prayerHeight", - name = "Sets hydra's prayer height", - description = "The height of the prayer indicator over Hydra" - ) - default int prayerHeight() - { - return 450; - } - - @ConfigItem( - position = 3, - keyName = "showHydraPrayer", - name = "Hydra's Attack Style Indicator", - description = "Displays hydra's size box for luring over vents" - ) - default boolean showPrayer() - { - return false; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxOverlayAbove.java b/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxOverlayAbove.java deleted file mode 100644 index 3942055ec1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxOverlayAbove.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.runelite.client.plugins.cox; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Polygon; -import java.util.List; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.Constants; -import net.runelite.api.GameObject; -import net.runelite.api.GraphicsObject; -import net.runelite.api.Perspective; -import net.runelite.api.Player; -import net.runelite.api.Scene; -import net.runelite.api.Tile; -import net.runelite.api.coords.LocalPoint; -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.OverlayUtil; - -public class CoxOverlayAbove extends Overlay -{ - private final Client client; - private final CoxPlugin plugin; - private CoxConfig config; - - @Inject - public CoxOverlayAbove(Client client, CoxPlugin plugin, CoxConfig config) - { - setPosition(OverlayPosition.DYNAMIC); - setLayer(OverlayLayer.ABOVE_SCENE); - this.client = client; - this.config = config; - this.plugin = plugin; - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (!client.isInInstancedRegion() && plugin.getOlm() == null) return null; - - renderGroundObject(graphics); - - renderTileObjects(graphics); - - return null; - } - - // renders special attack ground objects - private void renderGroundObject(Graphics2D graphics) - { - List graphicsObjects = client.getGraphicsObjects(); - - for (GraphicsObject graphicsObject : graphicsObjects) - { - if (graphicsObject.getId() == 1447 || graphicsObject.getId() == 1356) - { - LocalPoint lp = graphicsObject.getLocation(); - Polygon poly = Perspective.getCanvasTilePoly(client, lp); - - if (poly != null) - { - OverlayUtil.renderPolygon(graphics, poly, Color.RED); - } - } - } - } - - private void renderGameObjects(Graphics2D graphics, Tile tile, Player player) - { - GameObject[] gameObjects = tile.getGameObjects(); - if (gameObjects != null) - { - for (GameObject gameObject : gameObjects) - { - if (gameObject != null && gameObject.getId() == 30033) - { - if (player.getLocalLocation().distanceTo(gameObject.getLocalLocation()) <= 5) - { - // Draw a polygon around the convex hull - // of the model vertices - Polygon p = gameObject.getConvexHull(); - if (p != null) - { - graphics.drawPolygon(p); - } - } - } - } - } - } - - private void renderTileObjects(Graphics2D graphics) - { - Scene scene = client.getScene(); - Tile[][][] tiles = scene.getTiles(); - - int z = client.getPlane(); - - for (int x = 0; x < Constants.SCENE_SIZE; ++x) - { - for (int y = 0; y < Constants.SCENE_SIZE; ++y) - { - Tile tile = tiles[z][x][y]; - - if (tile == null) - { - continue; - } - - Player player = client.getLocalPlayer(); - if (player == null) - { - continue; - } - - renderGameObjects(graphics, tile, player); - } - } - } -} - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksConfig.java index 09752b89a7..a1bd666f93 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksConfig.java @@ -109,4 +109,15 @@ public interface DailyTasksConfig extends Config { return true; } + + @ConfigItem( + position = 8, + keyName = "showArrows", + name = "Show Claimable Ogre Arrows", + description = "Show a message when you can collect ogre arrows from Rantz." + ) + default boolean showArrows() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java index 4076ef693c..97404aacd6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java @@ -63,6 +63,7 @@ public class DailyTasksPlugin extends Plugin private static final String SAND_MESSAGE = "You have sand waiting to be collected from Bert."; private static final int SAND_QUEST_COMPLETE = 160; private static final String FLAX_MESSAGE = "You have bowstrings waiting to be converted from flax from the Flax keeper."; + private static final String ARROWS_MESSAGE = "You have ogre arrows waiting to be collected from Rantz."; private static final String BONEMEAL_MESSAGE = "You have bonemeal and slime waiting to be collected from Robin."; private static final int BONEMEAL_PER_DIARY = 13; private static final String RELOG_MESSAGE = " (May require a relog)"; @@ -153,22 +154,21 @@ public class DailyTasksPlugin extends Plugin { checkBonemeal(dailyReset); } + + if (config.showArrows()) + { + checkArrows(dailyReset); + } } } private void checkHerbBoxes(boolean dailyReset) { - if (client.getAccountType() == AccountType.NORMAL + if ((client.getAccountType() == AccountType.NORMAL && client.getVar(VarPlayer.NMZ_REWARD_POINTS) >= HERB_BOX_COST) + && (dailyReset || client.getVar(Varbits.DAILY_HERB_BOXES_COLLECTED) < HERB_BOX_MAX)) { - if (client.getVar(Varbits.DAILY_HERB_BOXES_COLLECTED) < HERB_BOX_MAX) - { - sendChatMessage(HERB_BOX_MESSAGE); - } - else if (dailyReset) - { - sendChatMessage(HERB_BOX_MESSAGE); - } + sendChatMessage(HERB_BOX_MESSAGE); } } @@ -189,61 +189,46 @@ public class DailyTasksPlugin extends Plugin private void checkEssence(boolean dailyReset) { - if (client.getVar(Varbits.DIARY_ARDOUGNE_MEDIUM) == 1) + if ((client.getVar(Varbits.DIARY_ARDOUGNE_MEDIUM) == 1) + && (dailyReset || client.getVar(Varbits.DAILY_ESSENCE_COLLECTED) == 0)) { - if (client.getVar(Varbits.DAILY_ESSENCE_COLLECTED) == 0) - { - sendChatMessage(ESSENCE_MESSAGE); - } - else if (dailyReset) - { - sendChatMessage(ESSENCE_MESSAGE); - } + sendChatMessage(ESSENCE_MESSAGE); } } private void checkRunes(boolean dailyReset) { - if (client.getVar(Varbits.DIARY_WILDERNESS_EASY) == 1) + if ((client.getVar(Varbits.DIARY_WILDERNESS_EASY) == 1) + && (dailyReset || client.getVar(Varbits.DAILY_RUNES_COLLECTED) == 0)) { - if (client.getVar(Varbits.DAILY_RUNES_COLLECTED) == 0) - { - sendChatMessage(RUNES_MESSAGE); - } - else if (dailyReset) - { - sendChatMessage(RUNES_MESSAGE); - } + sendChatMessage(RUNES_MESSAGE); } } private void checkSand(boolean dailyReset) { - if (client.getVar(Varbits.QUEST_THE_HAND_IN_THE_SAND) >= SAND_QUEST_COMPLETE) + if ((client.getVar(Varbits.QUEST_THE_HAND_IN_THE_SAND) >= SAND_QUEST_COMPLETE) + && (dailyReset || client.getVar(Varbits.DAILY_SAND_COLLECTED) == 0)) { - if (client.getVar(Varbits.DAILY_SAND_COLLECTED) == 0) - { - sendChatMessage(SAND_MESSAGE); - } - else if (dailyReset) - { - sendChatMessage(SAND_MESSAGE); - } + sendChatMessage(SAND_MESSAGE); } } private void checkFlax(boolean dailyReset) { - if (client.getVar(Varbits.DIARY_KANDARIN_EASY) == 1) + if ((client.getVar(Varbits.DIARY_KANDARIN_EASY) == 1) + && (dailyReset || client.getVar(Varbits.DAILY_FLAX_STATE) == 0)) { - if (client.getVar(Varbits.DAILY_FLAX_STATE) == 0) - { - sendChatMessage(FLAX_MESSAGE); - } - else if (dailyReset) - { - sendChatMessage(FLAX_MESSAGE); - } + sendChatMessage(FLAX_MESSAGE); + } + } + + private void checkArrows(boolean dailyReset) + { + if ((client.getVar(Varbits.DIARY_WESTERN_EASY) == 1) + && (dailyReset || client.getVar(Varbits.DAILY_ARROWS_STATE) == 0)) + { + sendChatMessage(ARROWS_MESSAGE); } } @@ -261,11 +246,7 @@ public class DailyTasksPlugin extends Plugin max += BONEMEAL_PER_DIARY; } } - if (collected < max) - { - sendChatMessage(BONEMEAL_MESSAGE); - } - else if (dailyReset) + if (dailyReset || collected < max) { sendChatMessage(BONEMEAL_MESSAGE); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/bank/EasyBankConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/bank/EasyBankConfig.java deleted file mode 100644 index ef9382fe66..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/bank/EasyBankConfig.java +++ /dev/null @@ -1,133 +0,0 @@ -package net.runelite.client.plugins.easy.bank; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - - -@ConfigGroup("easybank") -public interface EasyBankConfig extends Config { - - @ConfigItem( - keyName = "withdrawOne", - name = "Withdraw/Deposit One", - description = "", - position = 0 - ) - - default boolean getWithdrawOne() { - return true; - } - - @ConfigItem( - keyName = "withdrawOneItems", - name = "Items", - description = "", - position = 1 - ) - - default String getWithdrawOneItems() { - return ""; - } - - @ConfigItem( - keyName = "withdrawFive", - name = "Withdraw/Deposit Five", - description = "", - position = 2 - ) - - default boolean getWithdrawFive() { - return true; - } - - @ConfigItem( - keyName = "withdrawFiveItems", - name = "Items", - description = "", - position = 3 - ) - - default String getWithdrawFiveItems() { - return ""; - } - - @ConfigItem( - keyName = "withdrawTen", - name = "Withdraw/Deposit Ten", - description = "", - position = 4 - ) - - default boolean getWithdrawTen() { - return true; - } - - @ConfigItem( - keyName = "withdrawTenItems", - name = "Items", - description = "", - position = 5 - ) - - default String getWithdrawTenItems() { - return ""; - } - - @ConfigItem( - keyName = "withdrawX", - name = "Withdraw/Deposit X", - description = "", - position = 6 - ) - - default boolean getWithdrawX() { - return true; - } - - @ConfigItem( - keyName = "withdrawXAmount", - name = "Amount", - description = "", - position = 7 - ) - - default String getWithdrawXAmount() { - return ""; - } - - @ConfigItem( - keyName = "withdrawXItems", - name = "Items", - description = "", - position = 8 - ) - - default String getWithdrawXItems() { - return ""; - } - - @ConfigItem( - keyName = "withdrawAll", - name = "Withdraw/Deposit All", - description = "", - position = 9 - ) - - default boolean getWithdrawAll() { - return true; - } - - @ConfigItem( - keyName = "withdrawAllItems", - name = "Items", - description = "", - position = 10 - ) - - default String getWithdrawAllItems() { - return ""; - } - - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/bank/EasyBankPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/bank/EasyBankPlugin.java deleted file mode 100644 index 4ef7e40d83..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/bank/EasyBankPlugin.java +++ /dev/null @@ -1,133 +0,0 @@ -package net.runelite.client.plugins.easy.bank; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.MenuEntry; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.easy.util.Swapper; -import net.runelite.client.util.Text; - -import javax.inject.Inject; - - -@PluginDescriptor( - name = "EasyBank", - description = "EasyBank.", - tags = {"EasyBank", "easy"} -) - -@Slf4j -public class EasyBankPlugin extends Plugin { - - private Swapper swapper = new Swapper(); - private MenuEntry[] entries; - - @Inject - private Client client; - - @Inject - private EasyBankConfig config; - - @Provides - EasyBankConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(EasyBankConfig.class); - } - - @Override - public void startUp() { - log.debug("EasyBank Started."); - } - - @Override - public void shutDown() { - log.debug("EasyBank Stopped."); - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded event) { - - if (client.getGameState() != GameState.LOGGED_IN) { - return; - } - - Widget loginScreenOne = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN); - Widget loginScreenTwo = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY); - - if (loginScreenOne != null || loginScreenTwo != null) { - return; - } - - final String option = Text.removeTags(event.getOption()).toLowerCase(); - final String target = Text.removeTags(event.getTarget()).toLowerCase(); - - Widget widgetBankTitleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR); - - swapper.setEntries(client.getMenuEntries()); - - if (!(widgetBankTitleBar == null) && !widgetBankTitleBar.isHidden()) { - - if (config.getWithdrawOne()) { - for (String item : config.getWithdrawOneItems().split(",")) { - item = item.trim(); - if (target.equalsIgnoreCase(item)) { - swapper.markForSwap("Withdraw-1", option, target); - swapper.markForSwap("Deposit-1", option, target); - } - } - } - - if (config.getWithdrawFive()) { - for (String item : config.getWithdrawFiveItems().split(",")) { - item = item.trim(); - if (target.equalsIgnoreCase(item)) { - swapper.markForSwap("Withdraw-5", option, target); - swapper.markForSwap("Deposit-5", option, target); - } - } - } - - if (config.getWithdrawTen()) { - for (String item : config.getWithdrawTenItems().split(",")) { - item = item.trim(); - if (target.equalsIgnoreCase(item)) { - swapper.markForSwap("Withdraw-10", option, target); - swapper.markForSwap("Deposit-10", option, target); - } - } - } - - if (config.getWithdrawX()) { - for (String item : config.getWithdrawXItems().split(",")) { - item = item.trim(); - if (target.equalsIgnoreCase(item)) { - swapper.markForSwap("Withdraw-" + config.getWithdrawXAmount(), option, target); - swapper.markForSwap("Deposit-" + config.getWithdrawXAmount(), option, target); - } - } - } - - if (config.getWithdrawAll()) { - for (String item : config.getWithdrawAllItems().split(",")) { - item = item.trim(); - if (target.equalsIgnoreCase(item)) { - swapper.markForSwap("Withdraw-All", option, target); - swapper.markForSwap("Deposit-All", option, target); - } - } - } - - } - - swapper.startSwap(); - client.setMenuEntries(swapper.getEntries()); - } - -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpConfig.java deleted file mode 100644 index 536fe4e343..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -package net.runelite.client.plugins.easy.pvp; - - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("easypvp") -public interface EasyPvpConfig extends Config { - - @ConfigItem( - keyName = "showWildernessRange", - name = "Show Wilderness Range", - description = "", - position = 0 - ) - - default boolean getShowWildernessRange() { - return true; - } - - @ConfigItem( - keyName = "ShowAttackablePlayers", - name = "Show Attackable Players", - description = "", - position = 1 - ) - - default boolean getShowAttackablePlayers() { - return true; - } - - @ConfigItem( - keyName = "warnProtectItemOff", - name = "Warn Protect Item Off", - description = "", - position = 2 - ) - - default boolean getWarnProtectItemOff() { - return true; - } - - @ConfigItem( - keyName = "showFreezeTimers", - name = "Show Freeze Timers", - description = "", - position = 3 - ) - - default boolean getShowFreezeTimers() { - return true; - } - - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpOverlay.java deleted file mode 100644 index 81553cd787..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpOverlay.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.runelite.client.plugins.easy.pvp; - -import com.google.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.Player; -import net.runelite.api.Point; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; - -import java.awt.*; - -public class EasyPvpOverlay extends Overlay { - - private final Client client; - private final EasyPvpPlugin plugin; - private final EasyPvpConfig config; - - @Inject - private EasyPvpOverlay(Client client, EasyPvpPlugin plugin, EasyPvpConfig config) { - this.client = client; - this.plugin = plugin; - this.config = config; - - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.MED); - } - - @Override - public Dimension render(Graphics2D graphics) { - if (config.getShowAttackablePlayers()) { - for (Player player : plugin.getTargets()) { - OverlayUtil.renderPolygon(graphics, player.getConvexHull(), Color.RED); - - Point minimapLocation = player.getMinimapLocation(); - if (minimapLocation != null) { - OverlayUtil.renderMinimapLocation(graphics, minimapLocation, Color.RED.darker()); - OverlayUtil.renderTextLocation(graphics, minimapLocation, player.getName(), Color.RED); - } - } - } - - // - - - return null; - } -} -// @Override -// public Dimension render(Graphics2D graphics) -// { -// if (config.getShowWildernessRange()) -// { -//// plugin.getDeadNpcsToDisplay().forEach((id, npc) -> renderNpcRespawn(npc, graphics)); -// } -// -// if (config.getShowAttackablePlayers()) -// -// for (Player player : plugin.getAttackablePlayers()) { -// if (player != null) { -// renderNpcOverlay(graphics, player, player.getName(), Color.RED); -// } else { -// plugin.getAttackablePlayers().remove(player); -// } -// } -// -// return null; -// } - -// private void renderNpcOverlay(Graphics2D graphics, Player actor, String name, Color color) -// { -// LocalPoint lp = actor.getLocalLocation(); -//// Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, 1); -// -// renderTile(graphics, lp, color); -//// renderMinimap(); -// -//// if (config.drawNames()) -//// { -//// Point textLocation = actor.getCanvasTextLocation(graphics, name, actor.getLogicalHeight() + 40); -//// -//// if (textLocation != null) -//// { -//// OverlayUtil.renderTextLocation(graphics, textLocation, name, color); -//// } -//// } -// } - -// private void renderTile(final Graphics2D graphics, final LocalPoint dest, final Color color) -// { -// if (dest == null) -// { -// return; -// } -// final Polygon poly = Perspective.getCanvasTilePoly(client, dest); -// if (poly == null) -// { -// return; -// } -// OverlayUtil.renderPolygon(graphics, poly, color); -// } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpPlugin.java deleted file mode 100644 index bca9c2b5a5..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/pvp/EasyPvpPlugin.java +++ /dev/null @@ -1,197 +0,0 @@ -package net.runelite.client.plugins.easy.pvp; - -import com.google.inject.Inject; -import com.google.inject.Provides; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.Player; -import net.runelite.api.Varbits; -import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.GameTick; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; - -import java.util.HashSet; -import java.util.Set; - -@PluginDescriptor( - name = "EasyPvP", - description = "EasyPvP.", - tags = {"EasyPVP", "easy"} -) - -@Slf4j -public class EasyPvpPlugin extends Plugin { - - private int inWildy; - - @Inject - private Client client; - - @Inject - private EasyPvpConfig config; - - @Inject - private OverlayManager overlayManager; - - @Inject - private EasyPvpOverlay overlay; - - @Getter(AccessLevel.PACKAGE) - private Set targets = new HashSet<>(); - - private String target; - private boolean prayMage; - private WorldPoint location; - private String spell; - private int currentExperience; - private int gainedExperience; - - @Provides - EasyPvpConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(EasyPvpConfig.class); - } - - @Override - public void startUp() { - prayMage = false; - spell = ""; - overlayManager.add(overlay); - log.debug("EasyPvP Started."); - } - - @Override - public void shutDown() { - overlayManager.remove(overlay); - log.debug("EasyPvP Stopped."); - } - - @Subscribe - public void onGameTick(GameTick event) { - - inWildy = client.getVar(Varbits.IN_WILDERNESS); - - if (inWildy == 0) { - targets.clear(); - return; - } - - Widget wildyText = client.getWidget(WidgetInfo.PVP_WILDERNESS_LEVEL); - - if (wildyText == null) { - return; - } - - int wildyLevel = Integer.parseInt(wildyText.getText().split(":")[1].trim()); - - - if (config.getShowAttackablePlayers()) { - for (Player player : client.getPlayers()) { - if (Math.abs(player.getCombatLevel() - client.getLocalPlayer().getCombatLevel()) <= wildyLevel) { // && !player.equals(client.getLocalPlayer()) - targets.add(player); - } else targets.remove(player); - } - } - } - -// @Subscribe -// public void onGameStateChanged(GameStateChanged event) { -// if (event.getGameState() == GameState.LOGGED_IN) { -// currentExperience = client.getSkillExperience(Skill.MAGIC); -// } -// } -// -// @Subscribe -// public void onMenuOptionClicked(MenuOptionClicked event) { -// if (event.getMenuTarget().contains("->")) { -// target = Text.removeTags(event.getMenuTarget()).split(" -> ")[1]; -// spell = Text.removeTags(event.getMenuTarget()).split(" -> ")[0]; -// log.debug("{} - {}", spell, target); -// prayMage = false; -// } -// } -// -// @Subscribe -// public void onExperienceChanged(ExperienceChanged event) { -// if (event.getSkill() == Skill.MAGIC) { -// gainedExperience = client.getSkillExperience(Skill.MAGIC) - currentExperience; -// currentExperience = client.getSkillExperience(Skill.MAGIC); -// long frozenTime = calculateFreezeTime(gainedExperience, spell, prayMage); -// if (frozenTime > 0) { -// for (Player player : client.getPlayers()) { -// if (player.getName().equals(target)) { -// location = player.getWorldLocation(); -// if (player.getOverheadIcon() != null && player.getOverheadIcon().equals(HeadIcon.MAGIC)) { -// prayMage = true; -// break; -// } -// targets.add(new Markable(player, location, System.currentTimeMillis(), frozenTime)); -// log.debug("Marked Target {}", player.getName()); -// } -// } -// } -// } -// } -// -// public long calculateFreezeTime(int experience, String spell, boolean protectionPrayer) { -// long freezeTime = 0; -// switch (spell) { -// case "Bind": -// if (experience > 30) { -// if (protectionPrayer) { -// freezeTime = 2500; -// } else { -// freezeTime = 5000; -// } -// } -// break; -// case "Snare": -// if (experience > 60) { -// if (protectionPrayer) { -// freezeTime = 5000; -// } else { -// freezeTime = 10000; -// } -// } -// break; -// case "Entangle": -// if (experience > 89) { -// if (protectionPrayer) { -// freezeTime = 7500; -// } else { -// freezeTime = 15000; -// } -// } -// break; -// case "Ice Rush": -// if (experience > 34) { -// freezeTime = 5000; -// } -// break; -// case "Ice Burst": -// if (experience > 40) { -// freezeTime = 10000; -// } -// break; -// case "Ice Blitz": -// if (experience > 46) { -// freezeTime = 15000; -// } -// break; -// case "Ice Barrage": -// if (experience > 52) { -// freezeTime = 20000; -// } -// break; -// } -// return freezeTime; -// } - -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/scape/EasyScapeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/scape/EasyScapeConfig.java deleted file mode 100644 index 6e1bf5da09..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/scape/EasyScapeConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.runelite.client.plugins.easy.scape; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("easyscape") -public interface EasyScapeConfig extends Config { - - @ConfigItem( - keyName = "removeExamine", - name = "Remove Examine", - description = "Removes Examine from the list of options.", - position = 0 - ) - - default boolean getRemoveExamine() { - return true; - } - - @ConfigItem( - keyName = "removeObjects", - name = "Remove Objects", - description = "Removes interaction with the listed objects.", - position = 1 - ) - - default boolean getRemoveObjects() { - return true; - } - - @ConfigItem( - keyName = "removedObjects", - name = "Objects", - description = "Objects listed here will have all interaction be removed.", - position = 2 - ) - - default String getRemovedObjects() { - return ""; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/scape/EasyScapePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/scape/EasyScapePlugin.java deleted file mode 100644 index 9db0b3e0c5..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/scape/EasyScapePlugin.java +++ /dev/null @@ -1,111 +0,0 @@ -package net.runelite.client.plugins.easy.scape; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.MenuEntry; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.util.Text; -import org.apache.commons.lang3.ArrayUtils; - -import javax.inject.Inject; - -@PluginDescriptor( - name = "EasyScape", - description = "EasyScape.", - tags = {"EasyScape"}, - enabledByDefault = false -) - -@Slf4j -public class EasyScapePlugin extends Plugin { - - private MenuEntry[] entries; - - @Inject - private Client client; - - @Inject - private EasyScapeConfig config; - - @Provides - EasyScapeConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(EasyScapeConfig.class); - } - - @Override - public void startUp() { - log.debug("EasyScape Started."); - } - - @Override - public void shutDown() { - log.debug("EasyScape Stopped."); - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded event) { - - if (client.getGameState() != GameState.LOGGED_IN) { - return; - } - - Widget loginScreenOne = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN); - Widget loginScreenTwo = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY); - - if (loginScreenOne != null || loginScreenTwo != null) { - return; - } - - final String target = Text.removeTags(event.getTarget()).toLowerCase(); - - entries = client.getMenuEntries(); - - if (config.getRemoveExamine()) { - for (int i = entries.length - 1; i >= 0; i--) { - if (entries[i].getOption().equals("Examine")) { - entries = ArrayUtils.remove(entries, i); - i--; - } - } - client.setMenuEntries(entries); - } - - if (config.getRemoveObjects() && !config.getRemovedObjects().equals("")) { - for (String removed : config.getRemovedObjects().split(",")) { - removed = removed.trim(); - if (target.contains("(") && target.split(" \\(")[0].equalsIgnoreCase(removed)) { - delete(event.getIdentifier()); - } else if (target.contains("->")) { - String trimmed = target.split("->")[1].trim(); - if (trimmed.length() >= removed.length() && trimmed.substring(0, removed.length()).equalsIgnoreCase(removed)) { - delete(event.getIdentifier()); - break; - } - } else if (target.length() >= removed.length() && target.substring(0, removed.length()).equalsIgnoreCase(removed)) { - delete(event.getIdentifier()); - break; - } - } - } - - } - - private void delete(int target) { - for (int i = entries.length - 1; i >= 0; i--) { - if (entries[i].getIdentifier() == target) { - entries = ArrayUtils.remove(entries, i); - i--; - } - } - client.setMenuEntries(entries); - } - -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/shop/EasyShopConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/shop/EasyShopConfig.java deleted file mode 100644 index ec86c4c85c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/shop/EasyShopConfig.java +++ /dev/null @@ -1,186 +0,0 @@ -package net.runelite.client.plugins.easy.shop; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("easyshop") -public interface EasyShopConfig extends Config { - - @ConfigItem( - keyName = "swapBuyOne", - name = "Swappable Buy One", - description = "", - position = 0 - ) - - default boolean getSwapBuyOne() { - return true; - } - - @ConfigItem( - keyName = "buyOneItems", - name = "Items", - description = "", - position = 1 - ) - - default String getBuyOneItems() { - return ""; - } - - @ConfigItem( - keyName = "swapBuyFive", - name = "Swappable Buy Five", - description = "", - position = 2 - ) - - default boolean getSwapBuyFive() { - return true; - } - - @ConfigItem( - keyName = "buyFiveItems", - name = "Items", - description = "", - position = 3 - ) - - default String getBuyFiveItems() { - return ""; - } - - @ConfigItem( - keyName = "swapBuyTen", - name = "Swappable Buy Ten", - description = "", - position = 4 - ) - - default boolean getSwapBuyTen() { - return true; - } - - @ConfigItem( - keyName = "buyTenItems", - name = "Items", - description = "", - position = 5 - ) - - default String getBuyTenItems() { - return ""; - } - - @ConfigItem( - keyName = "swapBuyFifty", - name = "Swappable Buy Fifty", - description = "", - position = 6 - ) - - default boolean getSwapBuyFifty() { - return true; - } - - @ConfigItem( - keyName = "buyFiftyItems", - name = "Items", - description = "", - position = 7 - ) - - default String getBuyFiftyItems() { - return ""; - } - - @ConfigItem( - keyName = "swapSellOne", - name = "Swappable Sell One", - description = "", - position = 8 - ) - - default boolean getSwapSellOne() { - return true; - } - - @ConfigItem( - keyName = "sellOneItems", - name = "Items", - description = "", - position = 9 - ) - - default String getSellOneItems() { - return ""; - } - - @ConfigItem( - keyName = "swapSellFive", - name = "Swappable Sell Five", - description = "", - position = 10 - ) - - default boolean getSwapSellFive() { - return true; - } - - @ConfigItem( - keyName = "sellFiveItems", - name = "Items", - description = "", - position = 11 - ) - - default String getSellFiveItems() { - return ""; - } - - @ConfigItem( - keyName = "swapSellTen", - name = "Swappable Sell Ten", - description = "", - position = 12 - ) - - default boolean getSwapSellTen() { - return true; - } - - @ConfigItem( - keyName = "sellTenItems", - name = "Items", - description = "", - position = 13 - ) - - default String getSellTenItems() { - return ""; - } - - @ConfigItem( - keyName = "swapSellFifty", - name = "Swappable Sell Fifty", - description = "", - position = 14 - ) - - default boolean getSwapSellFifty() { - return true; - } - - @ConfigItem( - keyName = "sellFiftyItems", - name = "Items", - description = "", - position = 15 - ) - - default String getSellFiftyItems() { - return ""; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/shop/EasyShopPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/shop/EasyShopPlugin.java deleted file mode 100644 index e13a97ff5d..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/shop/EasyShopPlugin.java +++ /dev/null @@ -1,140 +0,0 @@ -package net.runelite.client.plugins.easy.shop; - - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.easy.util.Swapper; -import net.runelite.client.util.Text; - -import javax.inject.Inject; - -@PluginDescriptor( - name = "EasyShop", - description = "EasyShop.", - tags = {"EasyShop", "easy"} -) - -@Slf4j -public class EasyShopPlugin extends Plugin { - - private Swapper swapper = new Swapper(); - - @Inject - private Client client; - - @Inject - private EasyShopConfig config; - - @Provides - EasyShopConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(EasyShopConfig.class); - } - - @Override - public void startUp() { - log.debug("EasyShop Started."); - } - - @Override - public void shutDown() { - log.debug("EasyShop Stopped."); - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded event) { - - if (client.getGameState() != GameState.LOGGED_IN) { - return; - } - - Widget loginScreenOne = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN); - Widget loginScreenTwo = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY); - - if (loginScreenOne != null || loginScreenTwo != null) { - return; - } - - final String option = Text.removeTags(event.getOption()).toLowerCase(); - final String target = Text.removeTags(event.getTarget()).toLowerCase(); - - swapper.setEntries(client.getMenuEntries()); - - if (config.getSwapBuyOne() && !config.getBuyOneItems().equals("")) { - for (String item : config.getBuyOneItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Buy 1", option, target); - } - } - } - - if (config.getSwapBuyFive() && !config.getBuyFiveItems().equals("")) { - for (String item : config.getBuyFiveItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Buy 5", option, target); - } - } - } - - if (config.getSwapBuyTen() && !config.getBuyTenItems().equals("")) { - for (String item : config.getBuyTenItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Buy 10", option, target); - } - } - } - - if (config.getSwapBuyFifty() && !config.getBuyFiftyItems().equals("")) { - for (String item : config.getBuyFiftyItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Buy 50", option, target); - } - } - } - - if (config.getSwapSellOne() && !config.getSellOneItems().equals("")) { - for (String item : config.getSellOneItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Sell 1", option, target); - } - } - } - - if (config.getSwapSellFive() && !config.getSellFiveItems().equals("")) { - for (String item : config.getSellFiveItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Sell 5", option, target); - } - } - } - - if (config.getSwapSellTen() && !config.getSellTenItems().equals("")) { - for (String item : config.getSellTenItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Sell 10", option, target); - } - } - } - - if (config.getSwapSellFifty() && !config.getSellFiftyItems().equals("")) { - for (String item : config.getSellFiftyItems().split(",")) { - if (target.equalsIgnoreCase(item.trim())) { - swapper.markForSwap("Sell 50", option, target); - } - } - } - - swapper.startSwap(); - client.setMenuEntries(swapper.getEntries()); - } - - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/swap/EasySwapConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/swap/EasySwapConfig.java deleted file mode 100644 index 3e8cc6a41a..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/swap/EasySwapConfig.java +++ /dev/null @@ -1,201 +0,0 @@ -package net.runelite.client.plugins.easy.swap; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; -import net.runelite.client.plugins.easy.util.DuelingRingMode; -import net.runelite.client.plugins.easy.util.EssenceMode; -import net.runelite.client.plugins.easy.util.GamesNecklaceMode; -import net.runelite.client.plugins.easy.util.GloryMode; - -@ConfigGroup("easyswap") -public interface EasySwapConfig extends Config { - - @ConfigItem( - keyName = "easyConstruction", - name = "Easy Construction", - description = "Makes \"Remove\" the default option for listed items in build mode.", - position = 0 - ) - - default boolean getEasyConstruction() { - return true; - } - - @ConfigItem( - keyName = "constructionItems", - name = "Construction Items", - description = "Items listed here will have the default option set to \"Removed\" in build mode.", - position = 1 - ) - - default String getConstructionItems() { - return ""; - } - - - @ConfigItem( - keyName = "swapSmithing", - name = "Swap Smithing", - description = "Enables swapping of smith-1 and smith-all options.", - position = 2 - ) - - default boolean getSwapSmithing() { - return true; - } - - @ConfigItem( - keyName = "swapTanning", - name = "Swap Tanning", - description = "Enables swapping of tan-1 and tan-all options.", - position = 3 - ) - - default boolean getSwapTanning() { - return true; - } - - @ConfigItem( - keyName = "swapCrafting", - name = "Swap Crafting", - description = "Enables swapping of Make-1 and Make-all options.", - position = 4 - ) - - default boolean getSwapCrafting() { - return true; - } - - @ConfigItem( - keyName = "swapArdougneCape", - name = "Swap Ardougne Cape", - description = "Enables swapping of teleport and wear.", - position = 5 - ) - - default boolean getSwapArdougneCape() { - return true; - } - - @ConfigItem( - keyName = "swapSawmill", - name = "Swap Sawmill Operator", - description = "Makes Buy-plank the default option on the sawmill operator.", - position = 6 - ) - - default boolean getSwapSawmill() { - return true; - } - - @ConfigItem( - keyName = "swapSawmillPlanks", - name = "Swap Buy Planks", - description = "Makes Buy All the default option in buy planks.", - position = 7 - ) - - default boolean getSwapSawmillPlanks() { - return true; - } - - @ConfigItem( - keyName = "swapPuroPuro", - name = "Swap Puro Puro Wheat", - description = "", - position = 8 - ) - - default boolean getSwapPuro() { - return true; - } - - @ConfigItem( - keyName = "swapEssencePounch", - name = "Swap Essence Pouch", - description = "", - position = 9 - ) - - default boolean getSwapEssencePouch() { - return true; - } - - @ConfigItem( - keyName = "essenceMode", - name = "Mode", - description = "", - position = 10 - ) - - default EssenceMode getEssenceMode() { - return EssenceMode.RUNECRAFTING; - } - - @ConfigItem( - keyName = "swapGamesNecklace", - name = "Swap Games Necklace", - description = "", - position = 11 - ) - default boolean getGamesNecklace() { - return true; - } - - @ConfigItem( - keyName = "gamesNecklaceMode", - name = "Mode", - description = "", - position = 12 - ) - - default GamesNecklaceMode getGamesNecklaceMode() { - return GamesNecklaceMode.BURTHORPE; - } - - @ConfigItem( - keyName = "swapDuelingRing", - name = "Swap Dueling Ring", - description = "", - position = 13 - ) - - default boolean getDuelingRing() { - return true; - } - - @ConfigItem( - keyName = "duelingRingMode", - name = "Mode", - description = "", - position = 14 - ) - - default DuelingRingMode getDuelingRingMode() { - return DuelingRingMode.DUEL_ARENA; - } - - @ConfigItem( - keyName = "swapGlory", - name = "Swap Glory", - description = "", - position = 15 - ) - - default boolean getGlory() { - return true; - } - - @ConfigItem( - keyName = "gloryMode", - name = "Mode", - description = "", - position = 16 - ) - - default GloryMode getGloryMode() { - return GloryMode.EDGEVILLE; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/swap/EasySwapPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/swap/EasySwapPlugin.java deleted file mode 100644 index ae89f2b3d8..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/swap/EasySwapPlugin.java +++ /dev/null @@ -1,236 +0,0 @@ -package net.runelite.client.plugins.easy.swap; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameObject; -import net.runelite.api.GameState; -import net.runelite.api.Player; -import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.easy.util.Swapper; -import net.runelite.client.util.Text; -import net.runelite.api.events.GameObjectSpawned; -import net.runelite.api.events.GameStateChanged; - -import javax.inject.Inject; - -import static net.runelite.api.MenuAction.WALK; -import static net.runelite.api.ObjectID.PORTAL_4525; - -@PluginDescriptor( - name = "EasySwap", - description = "EasySwap.", - tags = {"EasySwap", "easy"} -) - -@Slf4j -public class EasySwapPlugin extends Plugin { - - private static final int PURO_PURO_REGION_ID = 10307; - - private Swapper swapper = new Swapper(); - private boolean inHouse = false; - - @Inject - private Client client; - - @Inject - private EasySwapConfig config; - - @Provides - EasySwapConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(EasySwapConfig.class); - } - - @Override - public void startUp() { - log.debug("EasySwap Started."); - } - - @Override - public void shutDown() { - log.debug("EasySwap Stopped."); - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded event) { - - if (client.getGameState() != GameState.LOGGED_IN) { - return; - } - - Widget loginScreenOne = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN); - Widget loginScreenTwo = client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN_MESSAGE_OF_THE_DAY); - - if (loginScreenOne != null || loginScreenTwo != null) { - return; - } - - final String option = Text.removeTags(event.getOption()).toLowerCase(); - final String target = Text.removeTags(event.getTarget()).toLowerCase(); - - swapper.setEntries(client.getMenuEntries()); - - if (config.getSwapPuro() && isPuroPuro()) { - if (event.getType() == WALK.getId()) { - swapper.deprioritizeWalk(); - } else if (option.equalsIgnoreCase("examine")) { - swapper.markForSwap("push-through", option, target); - } else if (option.equalsIgnoreCase("use")) { - swapper.markForSwap("escape", option, target); - } - } - - if (config.getEasyConstruction() && !config.getConstructionItems().equals("") && inHouse) { - if (event.getType() == WALK.getId()) { - swapper.deprioritizeWalk(); - } - - swapper.markForSwap("Build", option, target); - - for (int i = swapper.getEntries().length - 1; i >= 0; i--) { - for (String item : config.getConstructionItems().split(",")) { - if (item.trim().equalsIgnoreCase(Text.removeTags(swapper.getEntries()[i].getTarget()))) { - if (!swapper.getEntries()[i].getOption().equalsIgnoreCase("remove")) { - swapper.removeIndex(i); - i--; - } - } - } - } - } - - if (config.getSwapSmithing()) { - if (option.equalsIgnoreCase("Smith 1")) { - swapper.markForSwap("Smith All", option, target); - } else if (option.equalsIgnoreCase("Smith 1 Set")) { - swapper.markForSwap("Smith All Sets", option, target); - } - } - - if (config.getSwapTanning() && option.equalsIgnoreCase("Tan 1")) { - swapper.markForSwap("Tan All", option, target); - } - - if (config.getSwapCrafting()) { - switch (option) { - case "Make-1": - swapper.markForSwap("Make-All", option, target); - break; - case "Craft 1": - swapper.markForSwap("Craft All", option, target); - break; - default: - break; - } - } - - if (config.getSwapSawmill() && target.equalsIgnoreCase("Sawmill operator")) { - swapper.markForSwap("Buy-plank", option, target); - } - - if (config.getSwapSawmillPlanks() && option.equalsIgnoreCase("Buy 1")) { - swapper.markForSwap("Buy All", option, target); - } - - if (option.equalsIgnoreCase("Clear-All") && target.equalsIgnoreCase("bank Filler")) { - swapper.markForSwap("Clear", option, target); - } - - if (target.toLowerCase().contains("ardougne cloak") && config.getSwapArdougneCape()) { - swapper.markForSwap("Kandarin Monastery", option, target); - swapper.markForSwap("Monastery Teleport", option, target); - } - - if (config.getSwapEssencePouch()) { - if (isEssencePouch(target)) { - Widget widgetBankTitleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR); - switch (config.getEssenceMode()) { - case RUNECRAFTING: - if (widgetBankTitleBar == null || widgetBankTitleBar.isHidden()) { - swapper.markForSwap("Empty", option, target); - } else { - swapper.markForSwap("Fill", option, target); - } - break; - case ESSENCE_MINING: - if (widgetBankTitleBar == null || widgetBankTitleBar.isHidden()) { - swapper.markForSwap("Fill", option, target); - } else { - swapper.markForSwap("Empty", option, target); - } - break; - default: - break; - } - } - } - - if (config.getGamesNecklace()) { - if (target.toLowerCase().contains("games necklace")) { - swapper.markForSwap(config.getGamesNecklaceMode().toString(), option, target); - } - } - - if (config.getDuelingRing()) { - if (target.toLowerCase().contains("ring of dueling")) { - swapper.markForSwap(config.getDuelingRingMode().toString(), option, target); - } - } - - if (config.getGlory()) { - if (target.toLowerCase().contains("amulet of glory")) { - swapper.markForSwap(config.getGloryMode().toString(), option, target); - } - } - - swapper.startSwap(); - client.setMenuEntries(swapper.getEntries()); - } - - private boolean isEssencePouch(String target) { - return (target.equalsIgnoreCase("Small Pouch") || target.equalsIgnoreCase("Medium Pouch") || target.equalsIgnoreCase("Large Pouch") || target.equalsIgnoreCase("Giant Pouch")); - } - - @Subscribe - public void onGameObjectSpawned(GameObjectSpawned event) - { - final GameObject gameObject = event.getGameObject(); - if (PORTAL_4525 == gameObject.getId()) - { - this.inHouse = true; - } - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - if (event.getGameState() == GameState.LOADING) - { - this.inHouse = false; - } - } - - private boolean isHouse() { - return this.inHouse; - } - - private boolean isPuroPuro() { - Player player = client.getLocalPlayer(); - - if (player == null) { - return false; - } else { - WorldPoint location = player.getWorldLocation(); - return location.getRegionID() == PURO_PURO_REGION_ID; - } - } - -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/DuelingRingMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/DuelingRingMode.java deleted file mode 100644 index 9aa0c47ad3..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/DuelingRingMode.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.runelite.client.plugins.easy.util; - -public enum DuelingRingMode { - DUEL_ARENA("Duel Arena"), - CASTLE_WARS("Castle Wars"), - CLAN_WARS("Clan Wars"); - - private final String name; - - DuelingRingMode(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/EssenceMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/EssenceMode.java deleted file mode 100644 index bdf5f75bd0..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/EssenceMode.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.runelite.client.plugins.easy.util; - -public enum EssenceMode { - RUNECRAFTING("Runecrafting"), - ESSENCE_MINING("Essence Mining"); - - private final String name; - - EssenceMode(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/GamesNecklaceMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/GamesNecklaceMode.java deleted file mode 100644 index e176207f63..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/GamesNecklaceMode.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.runelite.client.plugins.easy.util; - -public enum GamesNecklaceMode { - BURTHORPE("Burthorpe"), - BARBARIAN_OUTPOST("Barbarian Outpost"), - CORPOREAL_BEAST("Corporeal Beast"), - TEARS_OF_GUTHIX("Tears of Guthix"), - WINTERTODT("Wintertodt Camp"); - - private final String name; - - GamesNecklaceMode(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/GloryMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/GloryMode.java deleted file mode 100644 index 8f5a93c56f..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/GloryMode.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.runelite.client.plugins.easy.util; - -public enum GloryMode { - EDGEVILLE("Edgeville"), - KARAMJA("Karamja"), - DRAYNOR_VILLAGE("Draynor Village"), - AL_KHARID("Al Kharid"); - - private final String name; - - GloryMode(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Markable.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Markable.java deleted file mode 100644 index 696d57f542..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Markable.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.runelite.client.plugins.easy.util; - -import lombok.Getter; -import net.runelite.api.Player; -import net.runelite.api.coords.WorldPoint; - -public class Markable { - - @Getter - private Player player; - - @Getter - private WorldPoint location; - - @Getter - private long frozenTime; - - @Getter - private long frozenUntil; - - public Markable(Player player, WorldPoint location, long frozenTime, long frozenLength) { - this.player = player; - this.location = location; - this.frozenTime = frozenTime; - this.frozenUntil = frozenTime + frozenLength + 3000; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Swappable.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Swappable.java deleted file mode 100644 index 3fc3667a86..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Swappable.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.runelite.client.plugins.easy.util; - -import lombok.Getter; -import lombok.Setter; -import net.runelite.client.util.Text; - -public class Swappable { - - @Getter - private String target; - - @Getter - private String optionOne; - - @Getter - private String optionTwo; - - @Getter - @Setter - private int indexOne; - - @Getter - @Setter - private int indexTwo; - - public Swappable(String target, String optionOne, String optionTwo) { - this.target = Text.removeTags(target.toLowerCase()); - this.optionOne = Text.removeTags(optionOne); - this.optionTwo = Text.removeTags(optionTwo); - this.indexOne = -1; - this.indexTwo = -1; - } - - public boolean isReady() { - return this.indexOne != -1 && this.indexTwo != -1; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Swapper.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Swapper.java deleted file mode 100644 index e0c05e8396..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/util/Swapper.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.runelite.client.plugins.easy.util; - -import lombok.Getter; -import lombok.Setter; -import net.runelite.api.MenuAction; -import net.runelite.api.MenuEntry; -import net.runelite.client.util.Text; -import org.apache.commons.lang3.ArrayUtils; - -import java.util.HashSet; -import java.util.Set; - -import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET; - -public class Swapper { - - private Set swapping; - - @Getter - @Setter - private MenuEntry[] entries; - - public Swapper() { - this.swapping = new HashSet<>(); - } - - public void deprioritizeWalk() { - MenuEntry menuEntry = entries[entries.length - 1]; - menuEntry.setType(MenuAction.WALK.getId() + MENU_ACTION_DEPRIORITIZE_OFFSET); - } - - public void removeIndex(int index) { - entries = ArrayUtils.remove(entries, index); - } - - public void markForSwap(String optionA, String optionB, String target) { - swapping.add(new Swappable(target, optionA, optionB)); - } - - public void startSwap() { - int index = 0; - for (MenuEntry entry : entries) { - String target = Text.removeTags(entry.getTarget()).toLowerCase(); - String option = Text.removeTags(entry.getOption()).toLowerCase(); - for (Swappable swap : swapping) { - if (swap.getTarget().equalsIgnoreCase(target)) { - if (option.equalsIgnoreCase(swap.getOptionOne())) { - swap.setIndexOne(index); - } else if (option.equalsIgnoreCase(swap.getOptionTwo())) { - swap.setIndexTwo(index); - } - } - } - index++; - } - - for (Swappable swap : swapping) { - if (swap.isReady()) { - MenuEntry entry = entries[swap.getIndexOne()]; - entries[swap.getIndexOne()] = entries[swap.getIndexTwo()]; - entries[swap.getIndexTwo()] = entry; - } - } - swapping.clear(); - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/zulrah/EasyZulrahConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/zulrah/EasyZulrahConfig.java deleted file mode 100644 index 491c02aaee..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/zulrah/EasyZulrahConfig.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.runelite.client.plugins.easy.zulrah; - -public class EasyZulrahConfig { -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/zulrah/EasyZulrahPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/zulrah/EasyZulrahPlugin.java deleted file mode 100644 index 4cd1d455b0..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/easyscape/zulrah/EasyZulrahPlugin.java +++ /dev/null @@ -1,4 +0,0 @@ -package net.runelite.client.plugins.easy.zulrah; - -public class EasyZulrahPlugin { -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPanel.java index e630c28b4f..1d54442c6d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPanel.java @@ -44,7 +44,6 @@ public class EquipmentInspectorPanel extends PluginPanel c.weightx = 1; c.gridx = 0; c.gridy = 0; - header = new JPanel(); header.setLayout(new BorderLayout()); header.setBorder(new CompoundBorder( @@ -53,9 +52,7 @@ public class EquipmentInspectorPanel extends PluginPanel nameLabel = new JLabel(NO_PLAYER_SELECTED); nameLabel.setForeground(Color.WHITE); - header.add(nameLabel, BorderLayout.CENTER); - layout.setHorizontalGroup(layout.createParallelGroup() .addComponent(equipmentPanels) .addComponent(header) @@ -65,7 +62,6 @@ public class EquipmentInspectorPanel extends PluginPanel .addGap(10) .addComponent(equipmentPanels) ); - update(new HashMap<>(), ""); } @@ -79,7 +75,6 @@ public class EquipmentInspectorPanel extends PluginPanel { nameLabel.setText("Player: " + playerName); } - SwingUtilities.invokeLater(() -> { equipmentPanels.removeAll(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPlugin.java index 8af1567609..29904c2fb8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorPlugin.java @@ -3,7 +3,10 @@ package net.runelite.client.plugins.equipmentinspector; import com.google.inject.Provides; import lombok.extern.slf4j.Slf4j; -import net.runelite.api.*; +import net.runelite.api.ChatMessageType; +import net.runelite.api.Client; +import net.runelite.api.ItemComposition; +import net.runelite.api.Player; import net.runelite.api.events.PlayerMenuOptionClicked; import net.runelite.api.kit.KitType; import net.runelite.client.chat.ChatColorType; @@ -18,11 +21,10 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.NavigationButton; +import net.runelite.client.util.ImageUtil; import net.runelite.client.util.Text; -import net.runelite.http.api.item.ItemPrice; import javax.annotation.Nullable; -import javax.imageio.ImageIO; import javax.inject.Inject; import javax.swing.*; import java.awt.image.BufferedImage; @@ -32,209 +34,195 @@ import java.util.*; import java.util.concurrent.ScheduledExecutorService; @PluginDescriptor( - name = "!Equipment Inspector", - enabledByDefault = false + name = "Equipment Inspector", + enabledByDefault = false, + type = "utility" ) @Slf4j public class EquipmentInspectorPlugin extends Plugin { - private static final String INSPECT_EQUIPMENT = "Gear"; - private static final String KICK_OPTION = "Kick"; + private static final String INSPECT_EQUIPMENT = "Gear"; + private static final String KICK_OPTION = "Kick"; - @Inject - @Nullable - private Client client; + @Inject + @Nullable + private Client client; - @Inject - private ItemManager itemManager; + @Inject + private ItemManager itemManager; - @Inject - private EquipmentInspectorConfig config; + @Inject + private EquipmentInspectorConfig config; - @Inject - private ChatMessageManager chatMessageManager; - @Inject - private MenuManager menuManager; + @Inject + private ChatMessageManager chatMessageManager; + @Inject + private MenuManager menuManager; - @Inject - private ScheduledExecutorService executor; + @Inject + private ScheduledExecutorService executor; - @Inject - private ClientToolbar pluginToolbar; + @Inject + private ClientToolbar pluginToolbar; + private NavigationButton navButton; + private EquipmentInspectorPanel equipmentInspectorPanel; + private int TotalPrice = 0; + private int Prot1 = 0; + private int Prot2 = 0; + private int Prot3 = 0; + private int Prot4 = 0; - @Provides - EquipmentInspectorConfig provideConfig(ConfigManager configManager) - { - return configManager.getConfig(EquipmentInspectorConfig.class); - } + @Provides + EquipmentInspectorConfig provideConfig(ConfigManager configManager) { + return configManager.getConfig(EquipmentInspectorConfig.class); + } - private NavigationButton navButton; - private EquipmentInspectorPanel equipmentInspectorPanel; - private int TotalPrice = 0; - private int Prot1 = 0; - private int Prot2 = 0; - private int Prot3 = 0; - private int Prot4 = 0; + @Override + protected void startUp() throws Exception { + + equipmentInspectorPanel = injector.getInstance(EquipmentInspectorPanel.class); + if (client != null) { + menuManager.addPlayerMenuItem(INSPECT_EQUIPMENT); + } + + //synchronized (ImageIO.class) + //{ + final BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "normal.png"); + //} + + navButton = NavigationButton.builder() + .tooltip("Equipment Inspector") + .icon(icon) + .priority(5) + .panel(equipmentInspectorPanel) + .build(); - @Override - protected void startUp() throws Exception - { + pluginToolbar.addNavigation(navButton); - equipmentInspectorPanel = injector.getInstance(EquipmentInspectorPanel.class); - if(client != null) { - menuManager.addPlayerMenuItem(INSPECT_EQUIPMENT); - } + } - BufferedImage icon; - synchronized (ImageIO.class) - { - icon = ImageIO.read(getClass().getResourceAsStream("normal.png")); - } + @Override + protected void shutDown() throws Exception { - navButton = NavigationButton.builder() - .tooltip("Equipment Inspector") - .icon(icon) - .priority(5) - .panel(equipmentInspectorPanel) - .build(); + menuManager.removePlayerMenuItem(INSPECT_EQUIPMENT); + } + + @Subscribe + public void onPlayerMenuOptionClicked(PlayerMenuOptionClicked event) { + if (event.getMenuOption().equals(INSPECT_EQUIPMENT)) { - pluginToolbar.addNavigation(navButton); + executor.execute(() -> + { + try { + SwingUtilities.invokeAndWait(() -> + { + if (!navButton.isSelected()) { + navButton.getOnSelect().run(); + } + }); + } catch (InterruptedException | InvocationTargetException e) { - } + throw new RuntimeException(e); - @Override - protected void shutDown() throws Exception - { + } + String playerName = Text.removeTags(event.getMenuTarget()); + // The player menu uses a non-breaking space in the player name, we need to replace this to compare + // against the playerName in the player cache. + String finalPlayerName = playerName.replace('\u00A0', ' '); + System.out.println(finalPlayerName); + List players = client.getPlayers(); + Optional targetPlayer = players.stream() + .filter(Objects::nonNull) + .filter(p -> p.getName().equals(finalPlayerName)).findFirst(); - menuManager.removePlayerMenuItem(INSPECT_EQUIPMENT); - } + if (targetPlayer.isPresent()) { + TotalPrice = 0; + Prot1 = 0; + Prot2 = 0; + Prot3 = 0; + Prot4 = 0; + Player p = targetPlayer.get(); + Map playerEquipment = new HashMap<>(); - @Subscribe - public void onPlayerMenuOptionClicked(PlayerMenuOptionClicked event) - { - if (event.getMenuOption().equals(INSPECT_EQUIPMENT)) - { + for (KitType kitType : KitType.values()) { + int itemId = p.getPlayerComposition().getEquipmentId(kitType); + if (itemId != -1) { + ItemComposition itemComposition = client.getItemDefinition(itemId); + playerEquipment.put(kitType, itemComposition); + int ItemPrice = itemManager.getItemPrice(itemId); + TotalPrice += ItemPrice; + if (ItemPrice > Prot1) { + Prot4 = Prot3; + Prot3 = Prot2; + Prot2 = Prot1; + Prot1 = ItemPrice; + } else if (ItemPrice > Prot2) { + Prot4 = Prot3; + Prot3 = Prot2; + Prot2 = ItemPrice; + } else if (ItemPrice > Prot3) { + Prot4 = Prot3; + Prot3 = ItemPrice; + } else if (ItemPrice > Prot4) { + Prot4 = ItemPrice; + } + } + } + int IgnoredItems = config.protecteditems(); + if (IgnoredItems != 0 && IgnoredItems != 1 && IgnoredItems != 2 && IgnoredItems != 3) { + IgnoredItems = 4; - executor.execute(() -> - { - try - { - SwingUtilities.invokeAndWait(() -> - { - if (!navButton.isSelected()) - { - navButton.getOnSelect().run(); - } - }); - } - catch (InterruptedException | InvocationTargetException e) - { + } + if (config.ShowValue()) { + switch (IgnoredItems) { + case 1: + TotalPrice = TotalPrice - Prot1; + break; + case 2: + TotalPrice = TotalPrice - Prot1; + TotalPrice = TotalPrice - Prot2; - throw new RuntimeException(e); + break; + case 3: + TotalPrice = TotalPrice - Prot1; + TotalPrice = TotalPrice - Prot2; + TotalPrice = TotalPrice - Prot3; + break; + case 4: + TotalPrice = TotalPrice - Prot1; + TotalPrice = TotalPrice - Prot2; + TotalPrice = TotalPrice - Prot3; + TotalPrice = TotalPrice - Prot4; + break; + } + String StringPrice = ""; + if (!config.ExactValue()) { + TotalPrice = TotalPrice / 1000; + StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice); + StringPrice = StringPrice + 'K'; + } + if (config.ExactValue()) { + StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice); + } + chatMessageManager.queue(QueuedMessage.builder() + .type(ChatMessageType.FRIENDSCHATNOTIFICATION) + .runeLiteFormattedMessage(new ChatMessageBuilder() + .append(ChatColorType.HIGHLIGHT) + .append("Risked Value: ") + .append(ChatColorType.NORMAL) + .append(StringPrice) + .build()) + .build()); + } + equipmentInspectorPanel.update(playerEquipment, playerName); - } - String playerName = Text.removeTags(event.getMenuTarget()); - // The player menu uses a non-breaking space in the player name, we need to replace this to compare - // against the playerName in the player cache. - String finalPlayerName = playerName.replace('\u00A0', ' '); - System.out.println(finalPlayerName); - List players = client.getPlayers(); - Optional targetPlayer = players.stream() - .filter(Objects::nonNull) - .filter(p -> p.getName().equals(finalPlayerName)).findFirst(); - - if (targetPlayer.isPresent()) - { - TotalPrice = 0; - Prot1 = 0; - Prot2 = 0; - Prot3 = 0; - Prot4 = 0; - Player p = targetPlayer.get(); - Map playerEquipment = new HashMap<>(); - - for (KitType kitType : KitType.values()) - { - int itemId = p.getPlayerComposition().getEquipmentId(kitType); - if (itemId != -1) - { - ItemComposition itemComposition = client.getItemDefinition(itemId); - playerEquipment.put(kitType, itemComposition); - int ItemPrice = itemManager.getItemPrice(itemId); - TotalPrice += ItemPrice; - if (ItemPrice > Prot1 ) { - Prot4 = Prot3; - Prot3 = Prot2; - Prot2 = Prot1; - - Prot1 = ItemPrice; - } else if (ItemPrice > Prot2){ - Prot4 = Prot3; - Prot3 = Prot2; - Prot2 = ItemPrice; - } else if (ItemPrice > Prot3){ - Prot4 = Prot3; - Prot3 = ItemPrice; - } else if (ItemPrice > Prot4){ - Prot4 = ItemPrice; - } - } - } - int IgnoredItems = config.protecteditems(); - if (IgnoredItems != 0 && IgnoredItems != 1 && IgnoredItems != 2 && IgnoredItems != 3) { - IgnoredItems = 4; - - } - if (config.ShowValue()) { - switch (IgnoredItems) { - case 1: - TotalPrice = TotalPrice - Prot1; - break; - case 2: - TotalPrice = TotalPrice - Prot1; - TotalPrice = TotalPrice - Prot2; - - break; - case 3: - TotalPrice = TotalPrice - Prot1; - TotalPrice = TotalPrice - Prot2; - TotalPrice = TotalPrice - Prot3; - break; - case 4: - TotalPrice = TotalPrice - Prot1; - TotalPrice = TotalPrice - Prot2; - TotalPrice = TotalPrice - Prot3; - TotalPrice = TotalPrice - Prot4; - break; - } - String StringPrice = ""; - if (!config.ExactValue()) { - TotalPrice = TotalPrice / 1000; - StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice); - StringPrice = StringPrice + 'K'; - } - if (config.ExactValue()) { - StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice); - } - chatMessageManager.queue(QueuedMessage.builder() - .type(ChatMessageType.FRIENDSCHATNOTIFICATION) - .runeLiteFormattedMessage(new ChatMessageBuilder() - .append(ChatColorType.HIGHLIGHT) - .append("Risked Value: ") - .append(ChatColorType.NORMAL) - .append(StringPrice) - .build()) - .build()); - } - equipmentInspectorPanel.update(playerEquipment, playerName); - - } - }); - } - } -} + } + }); + } + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/ItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/ItemPanel.java index 873bf058b6..fadc684588 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/ItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/ItemPanel.java @@ -15,7 +15,8 @@ class ItemPanel extends JPanel ItemPanel(ItemComposition item, KitType kitType, AsyncBufferedImage icon) { - setBorder(new EmptyBorder(3, 3, 3, 3)); + + setBorder(new EmptyBorder(3, 3, 3, 3)); setBackground(ColorScheme.DARK_GRAY_COLOR); GroupLayout layout = new GroupLayout(this); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropConfig.java index ec1f1acc45..0d1beab3e7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropConfig.java @@ -87,4 +87,26 @@ public interface XpDropConfig extends Config return 0; } + @ConfigItem( + keyName = "showDamage", + name = "Show Damage on XP Drop", + description = "Show what you hit next to the XP drop", + position = 5 + ) + default boolean showDamage() + { + return false; + } + + @ConfigItem( + keyName = "damageColor", + name = "Damage Color", + description = "The color you want the text to be for damage", + position = 6 + ) + default Color getDamageColor() + { + return Color.RED; + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekBogOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropOverlay.java similarity index 67% rename from runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekBogOverlay.java rename to runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropOverlay.java index 119a70f245..119da63597 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekBogOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Frosty Fridge + * Copyright (c) 2017, honeyhoney * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,47 +22,52 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.templetrek; +package net.runelite.client.plugins.experiencedrop; -import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; -import java.awt.Polygon; import javax.inject.Inject; -import net.runelite.api.GroundObject; + +import net.runelite.api.Actor; +import net.runelite.api.Point; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; -public class TempleTrekBogOverlay extends Overlay +class XpDropOverlay extends Overlay { - private final TempleTrekConfig config; - private final TempleTrekPlugin plugin; - - private static final Color GREEN = new Color(0, 200, 83); + private final XpDropPlugin plugin; + private final XpDropConfig config; @Inject - private TempleTrekBogOverlay(TempleTrekConfig config, TempleTrekPlugin plugin) + private XpDropOverlay(XpDropPlugin plugin, XpDropConfig config) { - super(plugin); - this.config = config; this.plugin = plugin; + this.config = config; setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.LOW); + setPriority(OverlayPriority.MED); } @Override public Dimension render(Graphics2D graphics) { - if (config.bogMapActive()) + if (config.showDamage()) { - for (GroundObject bog : plugin.getBogList()) + final Actor opponent = plugin.getLastOpponent(); + if (opponent != null) { - Polygon bogPoly = bog.getCanvasTilePoly(); - OverlayUtil.renderPolygon(graphics, bogPoly, GREEN); + int offset = opponent.getLogicalHeight() + 50; + String damageStr = String.valueOf(this.plugin.getDamage()); + Point textLocation = opponent.getCanvasTextLocation(graphics, damageStr, offset); + + if (textLocation != null && this.plugin.getDamage() != 0) + { + OverlayUtil.renderTextLocation(graphics, textLocation, damageStr, config.getDamageColor()); + } } } + return null; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index aca9477123..cb7c698195 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -25,26 +25,38 @@ package net.runelite.client.plugins.experiencedrop; import com.google.inject.Provides; + +import java.time.Duration; +import java.time.Instant; import java.util.Arrays; import java.util.EnumMap; import java.util.Map; import java.util.stream.IntStream; import javax.inject.Inject; -import net.runelite.api.Client; + +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.*; + import static net.runelite.api.ScriptID.XPDROP_DISABLED; -import net.runelite.api.Skill; -import net.runelite.api.SpriteID; -import net.runelite.api.Varbits; -import net.runelite.api.events.ExperienceChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.WidgetHiddenChanged; +import static net.runelite.client.plugins.attackstyles.AttackStyle.*; + +import net.runelite.api.events.*; import net.runelite.api.widgets.Widget; 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.game.HiscoreManager; +import net.runelite.client.game.NPCManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.attackstyles.AttackStyle; +import net.runelite.client.plugins.attackstyles.WeaponType; +import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.util.Text; +import net.runelite.http.api.hiscore.HiscoreEndpoint; +import net.runelite.http.api.hiscore.HiscoreResult; @PluginDescriptor( name = "XP Drop", @@ -54,6 +66,7 @@ import net.runelite.client.plugins.PluginDescriptor; public class XpDropPlugin extends Plugin { private static final int XPDROP_PADDING = 2; // space between xp drop icons + private static final Duration WAIT = Duration.ofSeconds(5); @Inject private Client client; @@ -63,11 +76,39 @@ public class XpDropPlugin extends Plugin private int tickCounter = 0; private int previousExpGained; + private boolean hasHit = false; private boolean hasDropped = false; private boolean correctPrayer; private Skill lastSkill = null; private Map previousSkillExpTable = new EnumMap<>(Skill.class); private PrayerType currentTickPrayer; + private AttackStyle attackStyle; + private int attackStyleVarbit = -1; + private int equippedWeaponTypeVarbit = -1; + private int castingModeVarbit = -1; + private int opponentHealth = -1; + private int xpGains = 0; + private AttackStyle[] offensiveStyles = {ACCURATE, AGGRESSIVE, DEFENSIVE, CONTROLLED, RANGING, LONGRANGE, CASTING, DEFENSIVE_CASTING}; + + @Getter(AccessLevel.PACKAGE) + private int damage = 0; + + @Getter(AccessLevel.PACKAGE) + private Actor lastOpponent; + + private Instant lastTime; + + @Inject + private OverlayManager overlayManager; + + @Inject + private XpDropOverlay overlay; + + @Inject + private NPCManager npcManager; + + @Inject + private HiscoreManager hiscoreManager; @Provides XpDropConfig provideConfig(ConfigManager configManager) @@ -75,6 +116,23 @@ public class XpDropPlugin extends Plugin return configManager.getConfig(XpDropConfig.class); } + @Override + protected void startUp() throws Exception + { + lastOpponent = null; + overlayManager.add(overlay); + if (client.getGameState() == GameState.LOGGED_IN) + { + attackStyleVarbit = client.getVar(VarPlayer.ATTACK_STYLE); + equippedWeaponTypeVarbit = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE); + castingModeVarbit = client.getVar(Varbits.DEFENSIVE_CASTING_MODE); + updateAttackStyle( + equippedWeaponTypeVarbit, + attackStyleVarbit, + castingModeVarbit); + } + } + @Subscribe public void onWidgetHiddenChanged(WidgetHiddenChanged event) { @@ -203,6 +261,42 @@ public class XpDropPlugin extends Plugin @Subscribe public void onGameTick(GameTick tick) { + // Detect hitting a 0 + if (lastOpponent != null) + { + int health = calculateHealth(lastOpponent); + if (health != -1 && opponentHealth != -1 && health == opponentHealth && hasHit) + { + damage = 0; + hasHit = false; + } + } + + // Handle getting XP gains + if (hasDropped) + { + if (xpGains != 0 && attackStyle.getSkills().length > 1 && attackStyle != LONGRANGE) + { + damage = (int) (xpGains / (attackStyle.getSkills().length * 1.3)); + } + else if (xpGains != 0) + { + damage = xpGains / 4; + } + + xpGains = 0; + hasDropped = false; + } + + // Clear opponent + if (lastOpponent != null && lastTime != null && client.getLocalPlayer().getInteracting() == null) + { + if (Duration.between(lastTime, Instant.now()).compareTo(WAIT) > 0) + { + lastOpponent = null; + } + } + currentTickPrayer = getActivePrayerType(); correctPrayer = false; @@ -240,9 +334,115 @@ public class XpDropPlugin extends Plugin Integer previous = previousSkillExpTable.put(skill, xp); if (previous != null) { + opponentHealth = calculateHealth(lastOpponent); previousExpGained = xp - previous; + if (skill != Skill.HITPOINTS && Arrays.stream(offensiveStyles).anyMatch(attackStyle::equals)) + { + xpGains += previousExpGained; + } + hasDropped = true; + hasHit = true; } } + private void updateAttackStyle(int equippedWeaponType, int attackStyleIndex, int castingMode) + { + AttackStyle[] attackStyles = WeaponType.getWeaponType(equippedWeaponType).getAttackStyles(); + if (attackStyleIndex < attackStyles.length) + { + attackStyle = attackStyles[attackStyleIndex]; + if (attackStyle == null) + { + attackStyle = OTHER; + } + else if ((attackStyle == CASTING) && (castingMode == 1)) + { + attackStyle = DEFENSIVE_CASTING; + } + } + } + + @Subscribe + public void onInteractingChanged(InteractingChanged event) + { + if (event.getSource() != client.getLocalPlayer()) + { + return; + } + + Actor opponent = event.getTarget(); + + if (opponent == null) + { + lastTime = Instant.now(); + return; + } + + damage = 0; + lastOpponent = opponent; + opponentHealth = calculateHealth(opponent); + } + + private int calculateHealth(Actor target) + { + if (target == null || target.getName() == null) + { + return -1; + } + + final int healthScale = target.getHealth(); + final int healthRatio = target.getHealthRatio(); + final String targetName = Text.removeTags(target.getName()); + + Integer maxHealth = -1; + if (target instanceof NPC) + { + maxHealth = npcManager.getHealth(targetName, target.getCombatLevel()); + } + else if (target instanceof Player) + { + final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(targetName, HiscoreEndpoint.NORMAL); + if (hiscoreResult != null) + { + final int hp = hiscoreResult.getHitpoints().getLevel(); + if (hp > 0) + { + maxHealth = hp; + } + } + } + + if (healthRatio < 0 || healthScale <= 0 || maxHealth == null) + { + return -1; + } + + return (int)((maxHealth * healthRatio / healthScale) + 0.5f); + } + + @Subscribe + public void onVarbitChanged(VarbitChanged event) + { + if (attackStyleVarbit == -1 || attackStyleVarbit != client.getVar(VarPlayer.ATTACK_STYLE)) + { + attackStyleVarbit = client.getVar(VarPlayer.ATTACK_STYLE); + updateAttackStyle(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE), attackStyleVarbit, + client.getVar(Varbits.DEFENSIVE_CASTING_MODE)); + } + + if (equippedWeaponTypeVarbit == -1 || equippedWeaponTypeVarbit != client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)) + { + equippedWeaponTypeVarbit = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE); + updateAttackStyle(equippedWeaponTypeVarbit, client.getVar(VarPlayer.ATTACK_STYLE), + client.getVar(Varbits.DEFENSIVE_CASTING_MODE)); + } + + if (castingModeVarbit == -1 || castingModeVarbit != client.getVar(Varbits.DEFENSIVE_CASTING_MODE)) + { + castingModeVarbit = client.getVar(Varbits.DEFENSIVE_CASTING_MODE); + updateAttackStyle(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE), client.getVar(VarPlayer.ATTACK_STYLE), + castingModeVarbit); + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fightcavejadhelper/FightCaveJadHelperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fightcavejadhelper/FightCaveJadHelperPlugin.java index 4eeb311101..8488545015 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fightcavejadhelper/FightCaveJadHelperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fightcavejadhelper/FightCaveJadHelperPlugin.java @@ -15,9 +15,10 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( - name = "!Fight Cave - Jad", + name = "Fight Cave - Jad", description = "Show what to pray against Jad", tags = {"bosses", "combat", "minigame", "overlay", "prayer", "pve", "pvm"}, + type = "PVM", enabledByDefault = false ) public class FightCaveJadHelperPlugin extends Plugin diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fightcavewavehelper/FightCaveWaveHelperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fightcavewavehelper/FightCaveWaveHelperPlugin.java index d06451a9d0..b3321a3b33 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fightcavewavehelper/FightCaveWaveHelperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fightcavewavehelper/FightCaveWaveHelperPlugin.java @@ -45,9 +45,10 @@ import net.runelite.client.ui.overlay.OverlayManager; import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( - name = "!Fight Cave - Waves", + name = "Fight Cave - Waves", description = "Displays current and upcoming wave monsters in the Fight Caves", tags = {"bosses", "combat", "minigame", "overlay", "pve", "pvm", "jad", "fire", "cape", "wave"}, + type = "PVM", enabledByDefault = false ) public class FightCaveWaveHelperPlugin extends Plugin diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoConfig.java new file mode 100644 index 0000000000..b24a585f2e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoConfig.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.flexo; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +import java.awt.*; + +@ConfigGroup("flexo") +public interface FlexoConfig extends Config { + + @ConfigItem( + position = 0, + keyName = "overlayEnabled", + name = "Overlay Enabled", + description = "Shows clicking area and points etc." + ) + default boolean overlayEnabled() { + return true; + } + + @ConfigItem( + position = 1, + keyName = "minDelayAmount", + name = "Min Delay", + description = "Minimum delay that is applied to every action at the end (ms)" + ) + default int minDelayAmt() { + return 45; + } + + + @ConfigItem( + position = 2, + keyName = "reactionTime", + name = "Reaction Time", + description = "The base time between actions (ms)" + ) + default int getReactionTimeVariation() { + return 80; + } + + @ConfigItem( + position = 3, + keyName = "mouseDragSpeed", + name = "Mouse drag speed", + description = "The speed at which steps are executed. Keep at 49? cuz jagex mouse recorder?" + ) + default int getMouseDragSpeed() { + return 49; + } + + + @ConfigItem( + position = 4, + keyName = "overshoots", + name = "Overshoots", + description = "Higher number = more overshoots" + ) + default int getOvershoots() { + return 4; + } + + @ConfigItem( + position = 5, + keyName = "variatingFlow", + name = "Flow - Variating", + description = "" + ) + default boolean getVariatingFlow() { + return true; + } + + @ConfigItem( + position = 6, + keyName = "slowStartupFlow", + name = "Flow - Slow startup", + description = "" + ) + default boolean getSlowStartupFlow() { + return true; + } + + + @ConfigItem( + position = 7, + keyName = "slowStartup2Flow", + name = "Flow - Slow startup 2", + description = "" + ) + default boolean getSlowStartup2Flow() { + return true; + } + + @ConfigItem( + position = 8, + keyName = "jaggedFlow", + name = "Flow - Jagged", + description = "" + ) + default boolean getJaggedFlow() { + return true; + } + + @ConfigItem( + position = 9, + keyName = "interruptedFlow", + name = "Flow - Interrupted", + description = "" + ) + default boolean getInterruptedFlow() { + return false; + } + + + @ConfigItem( + position = 10, + keyName = "interruptedFlow2", + name = "Flow - Interrupted 2", + description = "" + ) + default boolean getInterruptedFlow2() { + return false; + } + + @ConfigItem( + position = 11, + keyName = "stoppingFlow", + name = "Flow - Stopping", + description = "" + ) + default boolean getStoppingFlow() { + return false; + } + + @ConfigItem( + position = 12, + keyName = "deviationSlopeDivider", + name = "Deviation slope divider", + description = "" + ) + default int getDeviationSlope() { + return 10; + } + + + @ConfigItem( + position = 13, + keyName = "noisinessDivider", + name = "Noisiness divider", + description = "" + ) + default String getNoisinessDivider() { + return "2.0D"; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoOverlay.java new file mode 100644 index 0000000000..99072b88bf --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoOverlay.java @@ -0,0 +1,42 @@ +package net.runelite.client.plugins.flexo; + +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 javax.annotation.Nullable; +import javax.inject.Inject; +import java.awt.*; +import java.awt.geom.Ellipse2D; + +public class FlexoOverlay extends Overlay { + + public static Rectangle clickArea; + + @Inject + private Client client; + + @Inject + private FlexoPlugin plugin; + + @Inject + private FlexoConfig config; + + @Inject + public FlexoOverlay(@Nullable Client client, FlexoPlugin plugin, FlexoConfig config) { + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_WIDGETS); + this.client = client; + this.plugin = plugin; + this.config = config; + } + + + @Override + public Dimension render(Graphics2D graphics) { + if (clickArea!=null) + graphics.draw(clickArea); + return null; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoPlugin.java new file mode 100644 index 0000000000..7cd7b961bc --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/flexo/FlexoPlugin.java @@ -0,0 +1,127 @@ +package net.runelite.client.plugins.flexo; + +import com.github.joonasvali.naturalmouse.api.MouseMotionFactory; +import com.github.joonasvali.naturalmouse.support.DefaultNoiseProvider; +import com.github.joonasvali.naturalmouse.support.DefaultOvershootManager; +import com.github.joonasvali.naturalmouse.support.DefaultSpeedManager; +import com.github.joonasvali.naturalmouse.support.Flow; +import com.github.joonasvali.naturalmouse.support.SinusoidalDeviationProvider; +import com.github.joonasvali.naturalmouse.util.FlowTemplates; +import com.google.inject.Provides; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.GameTick; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.flexo.Flexo; +import net.runelite.client.flexo.FlexoUtils; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.stretchedmode.StretchedModeConfig; +import net.runelite.client.ui.overlay.OverlayManager; + +import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; + +@PluginDescriptor( + name = "Flexo Config", + description = "Customizes Flexo, the MouseInput Assistant ;)", + tags = {"flexo", "null"}, + type = "utility" +) +@Slf4j +public class FlexoPlugin extends Plugin { + + @Inject + private Client client; + + @Inject + private ConfigManager configManager; + + @Inject + private OverlayManager overlayManager; + + @Inject + private FlexoOverlay overlay; + + @Provides + FlexoConfig getConfig(ConfigManager configManager) { + return configManager.getConfig(FlexoConfig.class); + } + + @Subscribe + private void onConfigChanged(ConfigChanged event) { + if (event.getKey().compareTo("overlayEnabled")==0) { + if (getConfig(configManager).overlayEnabled()) { + overlayManager.add(overlay); + } else { + overlayManager.remove(overlay); + } + } + updateMouseMotionFactory(); + } + + @Subscribe + public void onGameTick(GameTick event) { + Flexo.isStretched = client.isStretchedEnabled(); + Flexo.scale = configManager.getConfig(StretchedModeConfig.class).scalingFactor(); + } + + private void updateMouseMotionFactory() { + Flexo.minDelay = getConfig(configManager).minDelayAmt(); + MouseMotionFactory factory = new MouseMotionFactory(); + //TODO:Add Options for various flows to allow more personalization + List flows = new ArrayList<>(); + + //Always add random + flows.add(new Flow(FlowTemplates.random())); + + if (getConfig(configManager).getVariatingFlow()) + flows.add(new Flow(FlowTemplates.variatingFlow())); + + if (getConfig(configManager).getSlowStartupFlow()) + flows.add(new Flow(FlowTemplates.slowStartupFlow())); + + if (getConfig(configManager).getSlowStartup2Flow()) + flows.add(new Flow(FlowTemplates.slowStartup2Flow())); + + if (getConfig(configManager).getJaggedFlow()) + flows.add(new Flow(FlowTemplates.jaggedFlow())); + + if (getConfig(configManager).getInterruptedFlow()) + flows.add(new Flow(FlowTemplates.interruptedFlow())); + + if (getConfig(configManager).getInterruptedFlow2()) + flows.add(new Flow(FlowTemplates.interruptedFlow2())); + + if (getConfig(configManager).getStoppingFlow()) + flows.add(new Flow(FlowTemplates.stoppingFlow())); + + DefaultSpeedManager manager = new DefaultSpeedManager(flows); + //TODO:Add options for custom Deviation Provider and Noise Provider + factory.setDeviationProvider(new SinusoidalDeviationProvider(getConfig(configManager).getDeviationSlope())); + factory.setNoiseProvider(new DefaultNoiseProvider(Double.valueOf(getConfig(configManager).getNoisinessDivider()))); + factory.getNature().setReactionTimeVariationMs(getConfig(configManager).getReactionTimeVariation()); + manager.setMouseMovementBaseTimeMs(getConfig(configManager).getMouseDragSpeed()); + + DefaultOvershootManager overshootManager = (DefaultOvershootManager) factory.getOvershootManager(); + overshootManager.setOvershoots(getConfig(configManager).getOvershoots()); + + factory.setSpeedManager(manager); + Flexo.currentMouseMotionFactory = factory; + } + + @Override + protected void startUp() throws Exception { + Flexo.isStretched = client.isStretchedEnabled(); + overlayManager.add(overlay); + updateMouseMotionFactory(); + } + + @Override + protected void shutDown() throws Exception { + overlayManager.remove(overlay); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java index 6b80dd4ce3..3e9fc7d6ec 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Barrage.java @@ -1,43 +1,68 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; +import lombok.Getter; import net.runelite.api.Actor; -import net.runelite.client.plugins.freezetimers.Spell; import net.runelite.client.util.Text; +import org.jetbrains.annotations.NotNull; -public class Barrage -extends Spell { - public static final long DURATION = 20000L; +public class Barrage extends Spell +{ + + + @Getter + public static final long DURATION = 20000; private long remainingTime; + @Getter private boolean isFinished; - public Barrage(Actor affectedTarget, Actor caster) { + + public Barrage(Actor affectedTarget, Actor caster) + { super(affectedTarget, caster); } - public long getRemainingTime() { + public long getRemainingTime() + { long elapsedTime = System.currentTimeMillis() - this.startTime; - if (Barrage.getDURATION() > elapsedTime) { - return Barrage.getDURATION() - elapsedTime; + if (getDURATION() > elapsedTime) + { + return getDURATION() - elapsedTime; } - this.isFinished = true; - return 0L; - } - - public boolean equals(Object o) { - if (o instanceof Barrage) { - Barrage barrage = (Barrage)o; - return Text.standardize(this.getAffectedTarget().getName()).equals(Text.standardize(((Barrage)o).getAffectedTarget().getName())) && this.getStartTime() == ((Barrage)o).getStartTime(); + else + { + this.isFinished = true; + return 0; } - return false; } - public static long getDURATION() { - return 20000L; + public boolean equals(Object o) + { + if (o instanceof Barrage) + { + Barrage barrage = (Barrage) o; + if (Text.standardize(this.getAffectedTarget().getName()).equals(Text.standardize(((Barrage) o) + .getAffectedTarget().getName())) && this.getStartTime() == ((Barrage) o).getStartTime()) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } } - @Override - public boolean isFinished() { - return this.isFinished; - } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java index 512905759d..8d484f11cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersConfig.java @@ -5,38 +5,75 @@ import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -@ConfigGroup(value="freezetimers") -public interface FreezeTimersConfig -extends Config { - @ConfigItem(position=0, keyName="freezeenable", name="Enable PvP freeze timers", description="Configures whether or not to show freeze timers.") - default public boolean EnableFreezeTimers() { +@ConfigGroup("freezetimers") +public interface FreezeTimersConfig extends Config +{ + + @ConfigItem( + position = 0, + keyName = "freezeenable", + name = "Enable PvP freeze timers", + description = "Configures whether or not to show freeze timers." + ) + default boolean EnableFreezeTimers() + { return false; } - @ConfigItem(position=1, keyName="tilehighlight", name="Frozen opponent tile highlighting", description="Configures whether or not to highlight tiles frozen opponents are standing on.") - default public boolean drawTiles() { + @ConfigItem( + position = 1, + keyName = "tilehighlight", + name = "Frozen opponent tile highlighting", + description = "Configures whether or not to highlight tiles frozen opponents are standing on." + ) + default boolean drawTiles() + { return false; } - @ConfigItem(position=2, keyName="timercolor", name="Freeze Timer Color", description="Color of freeze timer") - default public Color FreezeTimerColor() { + @ConfigItem( + position = 2, + keyName = "timercolor", + name = "Freeze Timer Color", + description = "Color of freeze timer" + ) + default Color FreezeTimerColor() + { return new Color(0, 184, 212); } - @ConfigItem(position=3, keyName="spellIcon", name="Show spell icon", description="Shows the spell icon for the freeze spell affecting the target") - default public boolean spellIcon() { + @ConfigItem( + position = 3, + keyName = "spellIcon", + name = "Show spell icon", + description = "Shows the spell icon for the freeze spell affecting the target" + ) + default boolean spellIcon() + { return true; } - @ConfigItem(position=4, keyName="refreezeTimer", name="Refreeze Timer", description="Show a timer that counts up until the target can be refrozen") - default public boolean refreezeTimer() { + @ConfigItem( + position = 4, + keyName = "refreezeTimer", + name = "Refreeze Timer", + description = "Show a timer that counts up until the target can be refrozen" + ) + default boolean refreezeTimer() + { return true; } - @ConfigItem(position=5, keyName="refreezeTimerColor", name="Refreeze color", description="The color for the timer that counts until the target can be refrozen") - default public Color RefreezeTimerColor() { + @ConfigItem( + position = 5, + keyName = "refreezeTimerColor", + name = "Refreeze color", + description = "The color for the timer that counts until the target can be refrozen" + ) + default Color RefreezeTimerColor() + { return Color.red; - } + } @ConfigItem(position = 6, keyName = "tbtimer", name = "Tele Block Timer", description = "Enables tele block timer") default boolean TBTimer() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java index 1d7dbd162e..5718c506d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersOverlay.java @@ -1,24 +1,25 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; import java.awt.Graphics2D; -import java.awt.Stroke; -import java.awt.image.BufferedImage; -import java.util.function.BiConsumer; +import java.awt.font.TextLayout; +import java.awt.image.*; import javax.inject.Inject; import javax.inject.Singleton; -import net.runelite.api.Client; -import net.runelite.api.HeadIcon; -import net.runelite.api.Player; -import net.runelite.api.Point; + +import net.runelite.api.*; import net.runelite.client.game.SpriteManager; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersPlugin; -import net.runelite.client.plugins.freezetimers.FreezeTimersService; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; @@ -26,8 +27,8 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; @Singleton -public class FreezeTimersOverlay -extends Overlay { +public class FreezeTimersOverlay extends Overlay +{ private final FreezeTimersService FreezeTimersService; private final FreezeTimersConfig config; private final FreezeTimersPlugin plugin; @@ -35,123 +36,165 @@ extends Overlay { private final Client client; @Inject - private FreezeTimersOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService2, FreezeTimersPlugin plugin, Client client, SpriteManager spriteManager) { + private FreezeTimersOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService, FreezeTimersPlugin plugin, Client client, SpriteManager spriteManager) + { this.config = config; - this.FreezeTimersService = FreezeTimersService2; + this.FreezeTimersService = FreezeTimersService; this.plugin = plugin; this.client = client; this.spriteManager = spriteManager; - this.setPosition(OverlayPosition.DYNAMIC); - this.setPriority(OverlayPriority.MED); + setPosition(OverlayPosition.DYNAMIC); + setPriority(OverlayPriority.MED); } @Override - public Dimension render(Graphics2D graphics) { - if (!this.config.EnableFreezeTimers()) { + public Dimension render(Graphics2D graphics) + { + if (!config.EnableFreezeTimers()) + { return null; } - this.FreezeTimersService.forEachPlayer((player, color) -> this.renderPlayerOverlay(graphics, (Player)player, (Color)color)); + FreezeTimersService.forEachPlayer((player, color) -> renderPlayerOverlay(graphics, player, color)); return null; } - private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) { - BufferedImage clanchatImage; + private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) + { int timer = 0; String name = actor.getName(); - int freezetype = this.plugin.freezetype(name); - boolean frozenoverlay = false; + int freezetype = plugin.freezetype(name); + boolean frozenoverlay = false; int offset = 5; - long dtime = this.plugin.opponentfreezetime(name); - long tbed = plugin.istbed(name); + long dtime = plugin.opponentfreezetime(name); + long tbed = plugin.istbed(name); Point textLocation = null; HeadIcon headIcon = actor.getOverheadIcon(); int freezetime = 0; - if (freezetype == 1 || freezetype == 4) { + if (freezetype == 1 || freezetype == 4) + { freezetime = 5000; - } else if (freezetype == 2 || freezetype == 5) { + } + else if (freezetype == 2 || freezetype == 5) + { freezetime = 10000; - } else if (freezetype == 3 || freezetype == 6) { + } + else if (freezetype == 3 || freezetype == 6) + { freezetime = 15000; - } else if (freezetype == 7) { + } + else if (freezetype == 7) + { freezetime = 20000; - } else if (freezetype == 8) { + } + else if (freezetype == 8) + { freezetime = 2500; - } else if (freezetype == 9) { + } + else if (freezetype == 9) + { freezetime = 5000; - } else if (freezetype == 10) { + } + else if (freezetype == 10) + { freezetime = 7500; } + long currenttime = System.currentTimeMillis(); long timediff = currenttime - dtime; - timer = (freezetime - (int)timediff) / 1000; - if (timediff < (long)freezetime) { - textLocation = actor.getCanvasTextLocation(graphics, String.valueOf(timer), actor.getLogicalHeight() + config.FreezeTimerPos()); + timer = (freezetime - (int) timediff) / 1000; + + if (timediff < freezetime) + { + // if the freezetimer is still active. . . + textLocation = actor.getCanvasTextLocation(graphics, String.valueOf((timer)), offset); textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); - } else if (timediff < (long)(freezetime + 3000)) { - timer = Math.abs(timer); - ++timer; - if (this.config.refreezeTimer()) { - textLocation = actor.getCanvasTextLocation(graphics, String.valueOf(timer), actor.getLogicalHeight() + config.FreezeTimerPos()); - textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); - graphics.setFont(FontManager.getRunescapeBoldFont()); - if (headIcon != null) { + } + else + { + if (timediff < freezetime + 3000) + { + timer = Math.abs(timer); + timer += 1; + if (config.refreezeTimer()) + { + textLocation = actor.getCanvasTextLocation(graphics, String.valueOf((timer)), offset); textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); + graphics.setFont(FontManager.getRunescapeBoldFont()); + if (headIcon != null) + { + textLocation = new Point(textLocation.getX() + 10, textLocation.getY() + 5); + } + frozenoverlay = true; + OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf((timer)), config.RefreezeTimerColor()); + return; } - frozenoverlay = true; - OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), this.config.RefreezeTimerColor()); - return; } - } else { - this.plugin.deleteopponent(name); - } - if (textLocation != null && (clanchatImage = this.plugin.GetFreezeIcon(freezetype - 1)) != null) { - int width = clanchatImage.getWidth(); - int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent(); - Point imageLocation = new Point(textLocation.getX(), textLocation.getY() - (config.FreezeTimerPos() / 2)); - graphics.setFont(FontManager.getRunescapeFont()); - graphics.setStroke(new BasicStroke(3.0f)); - if (this.config.spellIcon()) { - frozenoverlay = true; - graphics.drawOval(imageLocation.getX(), imageLocation.getY(), clanchatImage.getWidth(), clanchatImage.getHeight()); - OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); - OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), color); - } else { - graphics.setColor(Color.cyan); - graphics.drawOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), graphics.getFontMetrics().getHeight()); - graphics.setColor(Color.blue); - graphics.fillOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), graphics.getFontMetrics().getHeight()); - OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), Color.WHITE); + else + { + plugin.deleteopponent(name); } } - if (config.TBTimer()) { - if (tbed > 0) { - int type = plugin.tbtype(name); - int tbexpiry; - if (type > 0) { - if (type == 1) { - tbexpiry = 300000; - } else if (type == 2) { - tbexpiry = 150000; - } else { - return; - } - long tbtime = currenttime - tbed; - int tbtimer = (tbexpiry - (int) tbtime) / 1000; - if (tbtime < tbexpiry) { - textLocation = actor.getCanvasTextLocation(graphics, Integer.toString(tbtimer), actor.getLogicalHeight() + config.FreezeTimerPos()); - if (frozenoverlay) { - textLocation = new Point(textLocation.getX() + 40, textLocation.getY() - config.FreezeTimerPos()); - } else { - textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); - } - } else { - plugin.deletetb(name); - } - } + if (textLocation != null) + { + BufferedImage clanchatImage = plugin.GetFreezeIcon(freezetype - 1); - } - } - } -} + if (clanchatImage != null) + { + int width = clanchatImage.getWidth(); + int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent(); + Point imageLocation = new Point(textLocation.getX() - width, ((textLocation.getY() - + graphics.getFontMetrics().getHeight()) + 10)); + graphics.setFont(FontManager.getRunescapeFont()); + // graphics.setStroke(new BasicStroke(3)); + if (config.spellIcon()) + { + frozenoverlay = true; + // graphics.drawOval(imageLocation.getX(), imageLocation.getY(), clanchatImage.getWidth(), clanchatImage.getHeight()); + OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); + OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), color); + + } + else + { + graphics.setColor(Color.cyan); + graphics.drawOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), + graphics.getFontMetrics().getHeight()); + graphics.setColor(Color.blue); + graphics.fillOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(), + graphics.getFontMetrics().getHeight()); + + OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), Color.WHITE); + } + } + if (config.TBTimer()) { + if (tbed > 0) { + int type = plugin.tbtype(name); + int tbexpiry; + if (type > 0) { + if (type == 1) { + tbexpiry = 300000; + } else if (type == 2) { + tbexpiry = 150000; + } else { + return; + } + long tbtime = currenttime - tbed; + int tbtimer = (tbexpiry - (int) tbtime) / 1000; + if (tbtime < tbexpiry) { + textLocation = actor.getCanvasTextLocation(graphics, Integer.toString(tbtimer), actor.getLogicalHeight() + config.FreezeTimerPos()); + if (frozenoverlay) { + textLocation = new Point(textLocation.getX() + 40, textLocation.getY() - config.FreezeTimerPos()); + } else { + textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos()); + } + } else { + plugin.deletetb(name); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java index 878270bfd4..cb97861189 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersPlugin.java @@ -1,98 +1,86 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; - - - - +import net.runelite.api.events.*; +import net.runelite.client.eventbus.Subscribe; import com.google.inject.Provides; +import javax.inject.Inject; import java.awt.*; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; import java.awt.image.*; -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.DataBuffer; -import java.awt.image.DataBufferByte; -import java.awt.image.ImageObserver; -import java.awt.image.IndexColorModel; -import java.awt.image.WritableRaster; import java.util.*; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.inject.Inject; + import net.runelite.api.*; -import net.runelite.api.Actor; -import net.runelite.api.Client; -import net.runelite.api.events.*; -import net.runelite.api.GameState; -import net.runelite.api.HeadIcon; -import net.runelite.api.IndexedSprite; -import net.runelite.api.Player; -import net.runelite.api.Skill; + import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.AnimationChanged; -import net.runelite.api.events.ExperienceChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.MenuOptionClicked; import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.SpriteManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.freezetimers.Barrage; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersOverlay; -import net.runelite.client.plugins.freezetimers.FreezeTimersTileOverlay; -import net.runelite.client.plugins.freezetimers.Spell; -import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ImageUtil; import org.slf4j.Logger; @PluginDescriptor( - name = "!Freeze Timers", - description = "PVP Freeze Timers", - tags = {"PvP", "Freeze", "Timers"} + name = "Freeze Timers", + description = "PVP Freeze Timers", + type = "PVP", + tags = {"PvP", "Freeze", "Timers", "pklite"} ) - -public class FreezeTimersPlugin -extends Plugin { +public class FreezeTimersPlugin extends Plugin +{ @Inject private OverlayManager overlayManager; + @Inject private FreezeTimersConfig config; + @Inject private FreezeTimersOverlay FreezeTimersOverlay; + @Inject private FreezeTimersTileOverlay FreezeTimersTileOverlay; + @Inject private Client client; + @Inject private SpriteManager spriteManager; - - private static final int[] FREEZE_ICONS = { - SpriteID.SPELL_BIND, - SpriteID.SPELL_SNARE, - SpriteID.SPELL_ENTANGLE, - SpriteID.SPELL_ICE_RUSH, - SpriteID.SPELL_ICE_BURST, - SpriteID.SPELL_ICE_BLITZ, - SpriteID.SPELL_ICE_BARRAGE, - SpriteID.SPELL_BIND, - SpriteID.SPELL_SNARE, - SpriteID.SPELL_ENTANGLE, - SpriteID.SPELL_TELE_BLOCK - }; - private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(25, 25); + + @Provides + FreezeTimersConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(FreezeTimersConfig.class); + } + + private static final int[] FREEZE_ICONS = + { + SpriteID.SPELL_BIND, + SpriteID.SPELL_SNARE, + SpriteID.SPELL_ENTANGLE, + SpriteID.SPELL_ICE_RUSH, + SpriteID.SPELL_ICE_BURST, + SpriteID.SPELL_ICE_BLITZ, + SpriteID.SPELL_ICE_BARRAGE, + SpriteID.SPELL_BIND, + SpriteID.SPELL_SNARE, + SpriteID.SPELL_ENTANGLE, + SpriteID.SPELL_TELE_BLOCK + }; + + private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(25, 25); private static final Color FREEZE_ICON_OUTLINE_COLOR = new Color(33, 33, 33); private final BufferedImage[] FreezeIcons = new BufferedImage[FREEZE_ICONS.length]; + private final int SPLASH_ID = 85; Map tbedthings = new HashMap<>(); Map tbtypes = new HashMap<>(); @@ -107,248 +95,319 @@ extends Plugin { String currtarget; String spell; - @Provides - FreezeTimersConfig provideConfig(ConfigManager configManager) { - return configManager.getConfig(FreezeTimersConfig.class); - } @Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { if (gameStateChanged.getGameState() == GameState.LOGGED_IN) { - this.loadFreezeIcons(); + loadFreezeIcons(); } } @Override protected void startUp() throws Exception { - this.overlayManager.add(this.FreezeTimersOverlay); - this.overlayManager.add(this.FreezeTimersTileOverlay); + overlayManager.add(FreezeTimersOverlay); + overlayManager.add(FreezeTimersTileOverlay); } @Override protected void shutDown() throws Exception { - this.overlayManager.remove(this.FreezeTimersOverlay); - this.overlayManager.remove(this.FreezeTimersTileOverlay); - this.frozenthings.clear(); - this.frozenthingpoints.clear(); - this.tbedthings.clear(); - this.tbtypes.clear(); + overlayManager.remove(FreezeTimersOverlay); + overlayManager.remove(FreezeTimersTileOverlay); + frozenthings.clear(); + frozenthingpoints.clear(); + tbedthings.clear(); + tbtypes.clear(); } + @Subscribe - public void onMenuOptionClicked(MenuOptionClicked event) { - if (event.getMenuTarget().contains("->")) { - Pattern spattern = Pattern.compile(">(.+?)"); - Pattern ppattern = Pattern.compile("> (.+?)")) + { + final Pattern spattern = Pattern.compile(">(.+?)"); + final Pattern ppattern = Pattern.compile("> (.+?) 0 && this.currtarget != null) { - if (this.frozenthings.containsKey(this.currtarget)) { - this.currtarget = null; + if (xp > 0 && currtarget != null) + { + if (frozenthings.containsKey(currtarget)) + { + currtarget = null; return; } WorldPoint targetPosition = null; - for (Player player : this.client.getPlayers()) { - String playerName; - if (player == null || !(playerName = player.getName()).equals(this.currtarget)) continue; - if (player.getOverheadIcon() != null && player.getOverheadIcon().equals((Object)HeadIcon.MAGIC)) { - praymage = true; + for (Player player : client.getPlayers()) + { + if (player == null) + { + continue; + } + String playerName = player.getName(); + if (playerName.equals(currtarget)) + { + if (player.getOverheadIcon() != null) + { + if (player.getOverheadIcon().equals(HeadIcon.MAGIC)) + { + praymage = true; + } + } + targetPosition = player.getWorldLocation(); + break; } - targetPosition = player.getWorldLocation(); - break; } - if (targetPosition != null) { - if (this.spell.equals("Bind") && xp > 30) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - if (praymage) { - this.freezetype.put(this.currtarget, 8); - } else { - this.freezetype.put(this.currtarget, 1); + if (targetPosition != null) + { + if (spell.equals("Bind") && xp > 30) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + if (praymage) + { + freezetype.put(currtarget, 8); } - } else if (this.spell.equals("Snare") && xp > 60) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - if (praymage) { - this.freezetype.put(this.currtarget, 9); - } else { - this.freezetype.put(this.currtarget, 2); + else + { + freezetype.put(currtarget, 1); } - } else if (this.spell.equals("Entangle") && xp >= 89) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - if (praymage) { - this.freezetype.put(this.currtarget, 10); - } else { - this.freezetype.put(this.currtarget, 3); + } + else if (spell.equals("Snare") && xp > 60) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + if (praymage) + { + freezetype.put(currtarget, 9); } - } else if (this.spell.equals("Ice Rush") && xp > 34) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 4); - } else if (this.spell.equals("Ice Burst") && xp > 40) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 5); - } else if (this.spell.equals("Ice Blitz") && xp > 46) { - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 6); - } else if (this.spell.equals("Ice Barrage") && xp > 52) { - Barrage barrage = new Barrage(this.client.getLocalPlayer().getInteracting(), this.client.getLocalPlayer()); - this.testMap.put(this.currtarget, barrage); - this.frozenthings.put(this.currtarget, System.currentTimeMillis()); - this.frozenthingpoints.put(this.currtarget, targetPosition); - this.freezetype.put(this.currtarget, 7); - } else if (spell.equals("Tele Block") && xp == 95) { - if (config.TBTimer()) { - if (praymage) { - this.tbtypes.put(this.currtarget, 2); - } else { - this.tbtypes.put(this.currtarget, 1); - } - this.tbedthings.put(this.currtarget, System.currentTimeMillis()); - } + else + { + freezetype.put(currtarget, 2); + } + } + else if (spell.equals("Entangle") && xp >= 89) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + if (praymage) + { + freezetype.put(currtarget, 10); + } + else + { + freezetype.put(currtarget, 3); + } + } + else if (spell.equals("Ice Rush") && xp > 34) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 4); + } + else if (spell.equals("Ice Burst") && xp > 40) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 5); + } + else if (spell.equals("Ice Blitz") && xp > 46) + { + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 6); + } + else if (spell.equals("Ice Barrage") && xp > 52) + { + Barrage barrage = new Barrage(client.getLocalPlayer().getInteracting(), client.getLocalPlayer()); + testMap.put(currtarget, barrage); + frozenthings.put(currtarget, System.currentTimeMillis()); + frozenthingpoints.put(currtarget, targetPosition); + freezetype.put(currtarget, 7); + } + } else if (spell.equals("Tele Block") && xp == 95) { + if (config.TBTimer()) { + if (praymage) { + tbtypes.put(currtarget, 2); + } else { + tbtypes.put(currtarget, 1); + } + tbedthings.put(currtarget, System.currentTimeMillis()); } } } - if (this.currtarget != null && this.ticks > this.currticks + 1) { - Player local = this.client.getLocalPlayer(); + if (currtarget != null && ticks > currticks + 1) + { + Player local = client.getLocalPlayer(); Actor interacting = local.getInteracting(); - if (interacting != null) { - if (!interacting.getName().equals(this.currtarget)) { - this.currtarget = null; + if (interacting != null) + { + if (!interacting.getName().equals(currtarget)) + { + currtarget = null; } - } else { - this.currtarget = null; + } + else + { + currtarget = null; } } - ++this.ticks; + ticks++; } - public long opponentfreezetime(String name) { - if (this.frozenthings.containsKey(name)) { - return this.frozenthings.get(name); + public long opponentfreezetime(String name) + { + if (frozenthings.containsKey(name)) + { + return frozenthings.get(name); } - return 0L; + return 0; } - public WorldPoint playerpos(String name) { - if (this.frozenthingpoints.containsKey(name)) { - return this.frozenthingpoints.get(name); + public WorldPoint playerpos(String name) + { + if (frozenthingpoints.containsKey(name)) + { + return frozenthingpoints.get(name); } return null; } - public void updatePosition(String name, WorldPoint point) { - if (this.frozenthingpoints.containsKey(name)) { - this.frozenthingpoints.remove(name); - this.frozenthingpoints.put(name, point); + public void updatePosition(String name, WorldPoint point) + { + if (frozenthingpoints.containsKey(name)) + { + frozenthingpoints.remove(name); + frozenthingpoints.put(name, point); } } - public int freezetype(String name) { - if (this.freezetype.containsKey(name)) { - return this.freezetype.get(name); + public int freezetype(String name) + { + if (freezetype.containsKey(name)) + { + return freezetype.get(name); } return 0; } - public long istbed(String name) { - if (this.tbedthings.containsKey(name)) { - return this.tbedthings.get(name); - } - return 0; - } - public int tbtype(String name) { - if (this.tbtypes.containsKey(name)) { - return this.tbtypes.get(name); - } - return 0; - } - public void deleteopponent(String name) { - if (this.frozenthings.containsKey(name)) { - this.frozenthings.remove(name); + + public long istbed(String name) { + if (tbedthings.containsKey(name)) { + return tbedthings.get(name); } - if (this.frozenthingpoints.containsKey(name)) { - this.frozenthingpoints.remove(name); + return 0; + } + public int tbtype(String name) { + if (tbtypes.containsKey(name)) { + return tbtypes.get(name); } - if (this.freezetype.containsKey(name)) { - this.freezetype.remove(name); + return 0; + } + + public void deleteopponent(String name) + { + if (frozenthings.containsKey(name)) + { + frozenthings.remove(name); + } + if (frozenthingpoints.containsKey(name)) + { + frozenthingpoints.remove(name); + } + if (freezetype.containsKey(name)) + { + freezetype.remove(name); } } - public void deletetb(String name) { - if (this.tbedthings.containsKey(name)) { - this.tbedthings.remove(name); - } - if (this.tbtypes.containsKey(name)) { - this.tbtypes.remove(name); - } - } - private void loadFreezeIcons() { - IndexedSprite[] freezeIcons = new IndexedSprite[]{}; - IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length); + + public void deletetb(String name) { + if (tbedthings.containsKey(name)) { + tbedthings.remove(name); + } + if (tbtypes.containsKey(name)) { + tbtypes.remove(name); + } + } + + private void loadFreezeIcons() + { + final IndexedSprite[] freezeIcons = {}; + final IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length); int curPosition = 0; - int i = 0; - while (i < FREEZE_ICONS.length) { - int resource = FREEZE_ICONS[i]; - this.FreezeIcons[i] = FreezeTimersPlugin.rgbaToIndexedBufferedImage(FreezeTimersPlugin.FreezeIconFromSprite(this.spriteManager.getSprite(resource, 0))); - newfreezeIcons[curPosition] = FreezeTimersPlugin.createIndexedSprite(this.client, this.FreezeIcons[i]); - ++i; - ++curPosition; + + for (int i = 0; i < FREEZE_ICONS.length; i++, curPosition++) + { + final int resource = FREEZE_ICONS[i]; + FreezeIcons[i] = rgbaToIndexedBufferedImage(FreezeIconFromSprite(spriteManager.getSprite(resource, 0))); + newfreezeIcons[curPosition] = createIndexedSprite(client, FreezeIcons[i]); } } @@ -372,7 +431,7 @@ extends Plugin { } private static BufferedImage rgbaToIndexedBufferedImage(BufferedImage sourceBufferedImage) { - BufferedImage indexedImage = new BufferedImage(sourceBufferedImage.getWidth(), sourceBufferedImage.getHeight(), 13); + BufferedImage indexedImage = new BufferedImage(sourceBufferedImage.getWidth(), sourceBufferedImage.getHeight(), BufferedImage.TYPE_BYTE_INDEXED); ColorModel cm = indexedImage.getColorModel(); IndexColorModel icm = (IndexColorModel)cm; int size = icm.getMapSize(); @@ -382,21 +441,23 @@ extends Plugin { icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); - WritableRaster raster = indexedImage.getRaster(); - int pixel = raster.getSample(0, 0, 0); - IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel); - BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null); + + final WritableRaster raster = indexedImage.getRaster(); + final int pixel = raster.getSample(0, 0, 0); + final IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel); + final BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null); resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null); return resultIndexedImage; } - private static BufferedImage FreezeIconFromSprite(BufferedImage freezeSprite) { - BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, FreezeTimersPlugin.FREEZE_ICON_DIMENSION.width, FreezeTimersPlugin.FREEZE_ICON_DIMENSION.height); + private static BufferedImage FreezeIconFromSprite(final BufferedImage freezeSprite) + { + final BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, FREEZE_ICON_DIMENSION.width, FREEZE_ICON_DIMENSION.height); return ImageUtil.outlineImage(freezeCanvas, FREEZE_ICON_OUTLINE_COLOR); } - BufferedImage GetFreezeIcon(int id) { - return this.FreezeIcons[id]; + BufferedImage GetFreezeIcon(int id) + { + return FreezeIcons[id]; } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java index 257aae69b8..912c106ba1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersService.java @@ -1,81 +1,123 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; import java.awt.Color; -import java.util.List; +import java.util.Objects; import java.util.function.BiConsumer; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Player; import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersPlugin; + @Singleton -public class FreezeTimersService { +public class FreezeTimersService +{ private final Client client; private final FreezeTimersConfig config; private final FreezeTimersPlugin plugin; @Inject - private FreezeTimersService(Client client, FreezeTimersConfig config, FreezeTimersPlugin plugin) { + private FreezeTimersService(Client client, FreezeTimersConfig config, FreezeTimersPlugin plugin) + { this.config = config; this.plugin = plugin; this.client = client; } - public void forEachPlayer(BiConsumer consumer) { - for (Player player : this.client.getPlayers()) { - if (player == null || player.getName() == null) continue; + public void forEachPlayer(final BiConsumer consumer) + { + + for (Player player : client.getPlayers()) + { + if (player == null || player.getName() == null) + { + continue; + } + String name = player.getName(); - int freezetype = this.plugin.freezetype(name); - long tbed = plugin.istbed(name); - long dtime = this.plugin.opponentfreezetime(name); + int freezetype = plugin.freezetype(name); + long dtime = plugin.opponentfreezetime(name); + long tbed = plugin.istbed(name); int freezetime = 0; - if (freezetype == 1 || freezetype == 4) { + if (freezetype == 1 || freezetype == 4) + { freezetime = 5000; - } else if (freezetype == 2 || freezetype == 5) { + } + else if (freezetype == 2 || freezetype == 5) + { freezetime = 10000; - } else if (freezetype == 3 || freezetype == 6) { + } + else if (freezetype == 3 || freezetype == 6) + { freezetime = 15000; - } else if (freezetype == 7) { + } + else if (freezetype == 7) + { freezetime = 20000; - } else if (freezetype == 8) { + } + else if (freezetype == 8) + { freezetime = 2500; - } else if (freezetype == 9) { + } + else if (freezetype == 9) + { freezetime = 5000; - } else if (freezetype == 10) { + } + else if (freezetype == 10) + { freezetime = 7500; } - if (dtime <= 0L) continue; - long currenttime = System.currentTimeMillis(); - long timediff = currenttime - dtime; - if (timediff < (long)freezetime) { - WorldPoint lastWorldPoint; - WorldPoint currentWorldPoint = player.getWorldLocation(); - if (currentWorldPoint.equals(lastWorldPoint = this.plugin.playerpos(name))) { - consumer.accept(player, this.config.FreezeTimerColor()); - continue; + if (dtime > 0) + { + long currenttime = System.currentTimeMillis(); + long timediff = currenttime - dtime; + if (timediff < freezetime) + { + WorldPoint currentWorldPoint = player.getWorldLocation(); + WorldPoint lastWorldPoint = plugin.playerpos(name); + if (currentWorldPoint.equals(lastWorldPoint)) + { + consumer.accept(player, config.FreezeTimerColor()); + } + else + { + if (timediff < 605) + { + plugin.updatePosition(name, currentWorldPoint); + consumer.accept(player, config.FreezeTimerColor()); + } + else + { + plugin.deleteopponent(name); + } + } } - if (timediff < 605L) { - this.plugin.updatePosition(name, currentWorldPoint); - consumer.accept(player, this.config.FreezeTimerColor()); - continue; + else + { + if (timediff < freezetime + 3000) + { + consumer.accept(player, Color.YELLOW); + } + else + { + plugin.deleteopponent(name); + } + if (tbed > 0) { + consumer.accept(player, config.FreezeTimerColor()); + return; + } } - this.plugin.deleteopponent(name); - continue; } - if (timediff < (long)(freezetime + 3000)) { - consumer.accept(player, Color.YELLOW); - continue; - } else { - this.plugin.deleteopponent(name); - } - if (tbed > 0) { - consumer.accept(player, config.FreezeTimerColor()); - return; - } } } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java index a945470c85..37eea87b7a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeTimersTileOverlay.java @@ -1,46 +1,57 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; -import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; -import java.util.function.BiConsumer; import javax.inject.Inject; -import net.runelite.api.Player; -import net.runelite.client.plugins.freezetimers.FreezeTimersConfig; -import net.runelite.client.plugins.freezetimers.FreezeTimersService; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; -public class FreezeTimersTileOverlay -extends Overlay { +public class FreezeTimersTileOverlay extends Overlay +{ private final FreezeTimersService FreezeTimersService; private final FreezeTimersConfig config; @Inject - private FreezeTimersTileOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService2) { + private FreezeTimersTileOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService) + { this.config = config; - this.FreezeTimersService = FreezeTimersService2; - this.setLayer(OverlayLayer.ABOVE_SCENE); - this.setPosition(OverlayPosition.DYNAMIC); - this.setPriority(OverlayPriority.MED); + this.FreezeTimersService = FreezeTimersService; + setLayer(OverlayLayer.ABOVE_SCENE); + setPosition(OverlayPosition.DYNAMIC); + setPriority(OverlayPriority.MED); } @Override - public Dimension render(Graphics2D graphics) { - if (!this.config.drawTiles()) { + public Dimension render(Graphics2D graphics) + { + if (!config.drawTiles()) + { return null; } - this.FreezeTimersService.forEachPlayer((player, color) -> { - Polygon poly = player.getCanvasTilePoly(); - if (poly != null) { + + FreezeTimersService.forEachPlayer((player, color) -> + { + final Polygon poly = player.getCanvasTilePoly(); + + if (poly != null) + { OverlayUtil.renderPolygon(graphics, poly, color); } }); + return null; } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java index 8bc136fbb5..a2d47b7695 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PlayerSpellEffect.java @@ -1,35 +1,41 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; -public enum PlayerSpellEffect { +import lombok.Getter; +import lombok.Setter; + +public enum PlayerSpellEffect +{ + + BARRAGE("Ice Barrage", 20000, false), BLITZ("Ice Blitz", 15000, false); - - private final String SPELL_NAME; - private long startTime; - private int duration; - private boolean halvable; - private PlayerSpellEffect(String name, int duration, boolean halvable) { + @Getter + private final String SPELL_NAME; + @Getter + private long startTime; + @Getter + private int duration; + @Getter + private boolean halvable; + //private final BufferedImage SPELL_ICON; + + + + PlayerSpellEffect(String name, int duration, boolean halvable) + { this.SPELL_NAME = name; this.duration = duration; this.halvable = halvable; this.startTime = System.currentTimeMillis(); } - - public String getSPELL_NAME() { - return this.SPELL_NAME; - } - - public long getStartTime() { - return this.startTime; - } - - public int getDuration() { - return this.duration; - } - - public boolean isHalvable() { - return this.halvable; - } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java index d9033a7c0d..5407951aa8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Spell.java @@ -1,34 +1,34 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + package net.runelite.client.plugins.freezetimers; +import lombok.Getter; import net.runelite.api.Actor; -public abstract class Spell { +public abstract class Spell +{ + + @Getter private final Actor affectedTarget; + @Getter private final Actor caster; + @Getter public final long startTime; private long remainingTime; + @Getter private boolean isFinished; - protected Spell(Actor affectedTarget, Actor caster) { + protected Spell(Actor affectedTarget, Actor caster) + { this.affectedTarget = affectedTarget; this.caster = caster; - this.startTime = System.currentTimeMillis(); - } - - public Actor getAffectedTarget() { - return this.affectedTarget; - } - - public Actor getCaster() { - return this.caster; - } - - public long getStartTime() { - return this.startTime; - } - - public boolean isFinished() { - return this.isFinished; + startTime = System.currentTimeMillis(); } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/friendtagging/FriendTaggingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/friendtagging/FriendTaggingPlugin.java deleted file mode 100644 index c083887aca..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/friendtagging/FriendTaggingPlugin.java +++ /dev/null @@ -1,162 +0,0 @@ -package net.runelite.client.plugins.friendtagging; - -import com.google.common.base.Strings; -import com.google.common.collect.ObjectArrays; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import javax.inject.Inject; -import lombok.NonNull; -import net.runelite.api.Client; -import net.runelite.api.Friend; -import net.runelite.api.MenuAction; -import net.runelite.api.MenuEntry; -import net.runelite.api.Nameable; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.api.events.MenuOptionClicked; -import net.runelite.api.events.NameableNameChanged; -import net.runelite.api.events.RemovedFriend; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.chatbox.ChatboxPanelManager; -import net.runelite.client.game.chatbox.ChatboxTextInput; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.util.Text; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@PluginDescriptor( - name="Friend Tagging", - description="Tag people on your friends list." - ) - -public class FriendTaggingPlugin extends Plugin -{ - private static final Logger log = LoggerFactory.getLogger(FriendTaggingPlugin.class); - public static ConcurrentHashMap taggedFriends = new ConcurrentHashMap(); - private static final String CONFIG_GROUP = "friendtagging"; - private static final int CHARACTER_LIMIT = 30; - private static final String KEY_PREFIX = "tag_"; - private static final String ADD_TAG = "Add Tag"; - private static final String DELETE_TAG = "Delete Tag"; - @Inject - private Client client; - @Inject - private ConfigManager configManager; - @Inject - private ChatboxPanelManager chatboxPanelManager; - - @Override - protected void startUp() throws Exception { - this.loadFriendTags(); - } - - @Override - protected void shutDown() throws Exception { - super.shutDown(); - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded event) { - int groupId = WidgetInfo.TO_GROUP(event.getActionParam1()); - if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() && event.getOption().equals("Message")) { - String friendName = Text.removeTags(event.getTarget()); - MenuEntry entry = new MenuEntry(); - entry.setOption(friendName == null || this.getTag(friendName) == null ? ADD_TAG : DELETE_TAG); - entry.setType(MenuAction.RUNELITE.getId()); - entry.setTarget(event.getTarget()); - entry.setParam0(event.getActionParam0()); - entry.setParam1(event.getActionParam1()); - MenuEntry[] menuEntries = ObjectArrays.concat(this.client.getMenuEntries(), entry); - this.client.setMenuEntries(menuEntries); - } - } - - @Subscribe - public void onRemovedFriend(RemovedFriend event) { - String displayName = event.getName().trim().toLowerCase(); - this.deleteTag(displayName); - } - - @Subscribe - public void onNameableNameChanged(NameableNameChanged event) { - Friend friend; - Nameable nameable = event.getNameable(); - if (nameable instanceof Friend && (friend = (Friend)nameable).getName() != null && friend.getPrevName() != null) { - this.migrateFriendTag(friend.getName(), friend.getPrevName()); - } - } - - @Subscribe - public void onMenuOptionClicked(MenuOptionClicked event) { - if (WidgetInfo.TO_GROUP(event.getWidgetId()) == WidgetInfo.FRIENDS_LIST.getGroupId()) { - if (Strings.isNullOrEmpty(event.getMenuTarget())) { - return; - } - String sanitizedTarget = Text.removeTags(event.getMenuTarget()); - if (event.getMenuOption().equals(ADD_TAG)) { - event.consume(); - ChatboxTextInput chatboxTextInput = this.chatboxPanelManager.openTextInput("Enter the tag").value("").onDone(content -> { - if (content == null) { - return; - } - content = Text.removeTags(content).trim(); - this.setTag(sanitizedTarget, (String)content); - }).build(); - } - if (event.getMenuOption().equals(DELETE_TAG)) { - event.consume(); - this.client.getLogger().info(sanitizedTarget); - taggedFriends.forEach((k, v) -> this.client.getLogger().info(k + ": ", v)); - this.deleteTag(sanitizedTarget); - } - } - } - - @NonNull - private String getTag(String name) { - name = name.trim().toLowerCase(); - String keyName = KEY_PREFIX + name; - return taggedFriends.get(keyName); - } - - private void setTag(String name, String tag) { - this.client.getLogger().info("SETTING " + name + ": " + tag); - name = name.trim().toLowerCase(); - String keyName = KEY_PREFIX + name; - if (tag.length() <= 30) { - taggedFriends.put(keyName, tag); - this.configManager.setConfiguration(CONFIG_GROUP, keyName, tag); - } - } - - private void deleteTag(String name) { - name = name.trim().toLowerCase(); - String keyName = KEY_PREFIX + name; - this.configManager.unsetConfiguration(CONFIG_GROUP, keyName); - taggedFriends.remove(keyName); - } - - private void loadFriendTags() { - String prefix = "friendtagging.tag_"; - for (String key : this.configManager.getConfigurationKeys(prefix)) { - String result = this.configManager.getConfiguration(CONFIG_GROUP, key = key.replace("friendtagging.", "")); - if (!Objects.nonNull(result) || result.equals("")) continue; - taggedFriends.put(key, this.configManager.getConfiguration(CONFIG_GROUP, key)); - } - } - - private void migrateFriendTag(String currentDisplayName, String prevDisplayName) { - String prevTag; - String currentTag = this.getTag(currentDisplayName); - if (currentTag == null && (prevTag = this.getTag(prevDisplayName)) != null) { - this.setTag(prevDisplayName, ""); - this.setTag(currentDisplayName, prevTag); - } - } -} - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPlugin.java index d6df9dc49f..a7f59a7bed 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPlugin.java @@ -30,9 +30,10 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( - name = "!Grotesque Guardians", + name = "Grotesque Guardians", description = "Display tile indicators for the Grotesque Guardian special attacks", - tags = {"grotesque", "guardians", "gargoyle", "garg"} + tags = {"grotesque", "guardians", "gargoyle", "garg"}, + type = "PVM" ) public class GrotesqueGuardiansPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index f9c3a79e85..008429abf1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -358,4 +358,26 @@ public interface GroundItemsConfig extends Config { return false; } + + @ConfigItem( + position = 27, + keyName = "removeIgnored", + name = "Hide Ignored", + description = "Remove take option for items that are on the hidden items list." + ) + default boolean removeIgnored() + { + return false; + } + + @ConfigItem( + keyName = "toggleOutline", + name = "Text Outline", + description = "Use an outline around text instead of a text shadow", + position = 29 + ) + default boolean toggleOutline() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index 1406bb1747..17c0151ae7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -333,6 +333,15 @@ public class GroundItemsOverlay extends Overlay drawRectangle(graphics, itemHighlightBox, topItem && mouseInHighlightBox ? Color.GREEN : color, highlighted != null, false); } + if (config.toggleOutline()) + { + graphics.setColor(Color.BLACK); + graphics.drawString(itemString, textX + 1, textY + 1); + graphics.drawString(itemString, textX - 1, textY - 1); + graphics.drawString(itemString, textX - 1, textY + 1); + graphics.drawString(itemString, textX + 1, textY - 1); + } + textComponent.setText(itemString); textComponent.setColor(color); textComponent.setPosition(new java.awt.Point(textX, textY)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 6bb50180df..91718bab79 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -509,10 +509,40 @@ public class GroundItemsPlugin extends Plugin lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")"); } + if(config.removeIgnored() && event.getOption().equals("Take") && hiddenItemList.contains(Text.removeTags(event.getTarget()))) + { + menuEntries = removeOption(event.getOption(), event.getTarget()); + } + client.setMenuEntries(menuEntries); } } + private MenuEntry[] removeOption(String option, String target) + { + MenuEntry[] entries = client.getMenuEntries(); + int j = 0; + if(entries.length > 1) + { + MenuEntry[] newEntries = new MenuEntry[entries.length - 1]; + for (int i = 0; i < entries.length; ++i) + { + if (!(entries[i].getOption().equals(option) && entries[i].getTarget().equals(target))) + { + newEntries[j++] = entries[i]; + } + } + + return newEntries; + } + else + { + return entries; + } + + + } + void updateList(String item, boolean hiddenList) { final Set hiddenItemSet = new HashSet<>(hiddenItemList); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java index 768d90b51b..ec1814bde4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java @@ -43,7 +43,6 @@ import net.runelite.client.ui.overlay.OverlayUtil; public class GroundMarkerOverlay extends Overlay { - private static final int MAX_DRAW_DISTANCE = 32; private final Client client; private final GroundMarkerConfig config; @@ -87,12 +86,6 @@ public class GroundMarkerOverlay extends Overlay private void drawTile(Graphics2D graphics, WorldPoint point, Color color) { - WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation(); - - if (point.distanceTo(playerLocation) >= MAX_DRAW_DISTANCE) - { - return; - } LocalPoint lp = LocalPoint.fromWorld(client, point); if (lp == null) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hideprayers/HidePrayersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/hideprayers/HidePrayersPlugin.java index df473a5d0d..61f9b91b44 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hideprayers/HidePrayersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hideprayers/HidePrayersPlugin.java @@ -20,8 +20,9 @@ import java.util.Objects; import java.util.stream.Collectors; @PluginDescriptor( - name = "!Hide Prayers", - description = "Hides specific Prayers in the Prayer tab." + name = "Hide Prayers", + description = "Hides specific Prayers in the Prayer tab.", + type = "utility" ) public class HidePrayersPlugin extends Plugin { private static final int PRAYER_COUNT = Prayer.values().length; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/HydraPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/HydraPlugin.java index ba8c0317a7..f976a9cd2b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/HydraPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/HydraPlugin.java @@ -17,7 +17,8 @@ import java.util.Map; @PluginDescriptor( name = "Hydra", description = "Hydra Helper", - tags = {"Hydra", "Helper"} + tags = {"Hydra", "Helper"}, + type = "PVM" ) public class HydraPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetup.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetup.java deleted file mode 100644 index 043d22a30c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetup.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.runelite.client.plugins.inventorysetups; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; - -@AllArgsConstructor -public class InventorySetup -{ - @Getter - private ArrayList inventory; - @Getter - private ArrayList equipment; -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupBankOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupBankOverlay.java deleted file mode 100644 index 34ba341fc7..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupBankOverlay.java +++ /dev/null @@ -1,113 +0,0 @@ -package net.runelite.client.plugins.inventorysetups; - -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.Point; -import net.runelite.api.Query; -import net.runelite.api.SpritePixels; -import net.runelite.api.queries.BankItemQuery; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetItem; -import net.runelite.client.ui.FontManager; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.util.QueryRunner; - -import javax.inject.Inject; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.image.BufferedImage; -import java.util.Arrays; -import java.util.Objects; - -@Slf4j -public class InventorySetupBankOverlay extends Overlay -{ - private final Client client; - private final QueryRunner queryRunner; - private final InventorySetupPlugin plugin; - private final InventorySetupConfig config; - - @Inject - public InventorySetupBankOverlay(Client client, QueryRunner queryRunner, InventorySetupPlugin plugin, InventorySetupConfig config) - { - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.LOW); - setLayer(OverlayLayer.ABOVE_WIDGETS); - this.client = client; - this.queryRunner = queryRunner; - this.plugin = plugin; - this.config = config; - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (config.getBankHighlight()) - { - int[] ids = plugin.getCurrentInventorySetupIds(); - if (ids == null) - { - return null; - } - ids = Arrays.stream(ids) - .filter(Objects::nonNull) - .filter(id -> id != -1) - .toArray(); - final Query query = new BankItemQuery().idEquals(ids); - final WidgetItem[] widgetItems = queryRunner.runQuery(query); - final Widget bankContainer = client.getWidget(WidgetInfo.BANK_CONTAINER); - for (final WidgetItem item : widgetItems) - { - Point canvasLocation = item.getCanvasLocation(); - Rectangle canvasBounds = item.getCanvasBounds(); - Point windowLocation = bankContainer.getCanvasLocation(); - - if (canvasLocation == null || windowLocation == null) - { - return null; - } - - if (!(canvasLocation.getY() + 60 >= windowLocation.getY() + bankContainer.getHeight()) && !(canvasLocation.getY() + canvasBounds.getHeight() <= windowLocation.getY() + 90)) - { - final Color color = config.getBankHighlightColor(); - - if (color != null) - { - final BufferedImage outline = loadItemOutline(item.getId(), item.getQuantity(), color); - graphics.drawImage(outline, item.getCanvasLocation().getX() + 1, item.getCanvasLocation().getY() + 1, null); - if (item.getQuantity() > 1) - { - drawQuantity(graphics, item, Color.YELLOW); - } - else if (item.getQuantity() == 0) - { - drawQuantity(graphics, item, Color.YELLOW.darker()); - } - } - } - } - } - return null; - } - - private void drawQuantity(Graphics2D graphics, WidgetItem item, Color darker) - { - graphics.setColor(Color.BLACK); - graphics.drawString(String.valueOf(item.getQuantity()), item.getCanvasLocation().getX() + 2, item.getCanvasLocation().getY() + 11); - graphics.setColor(darker); - graphics.setFont(FontManager.getRunescapeSmallFont()); - graphics.drawString(String.valueOf(item.getQuantity()), item.getCanvasLocation().getX() + 1, item.getCanvasLocation().getY() + 10); - } - - private BufferedImage loadItemOutline(final int itemId, final int itemQuantity, final Color outlineColor) - { - final SpritePixels itemSprite = client.createItemSprite(itemId, itemQuantity, 2, 0, 0, true, 710); - return itemSprite.toBufferedOutline(outlineColor); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupConfig.java deleted file mode 100644 index edcc47cd9c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupConfig.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.runelite.client.plugins.inventorysetups; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -import java.awt.Color; - -@ConfigGroup("inventorysetups") -public interface InventorySetupConfig extends Config -{ - @ConfigItem( - keyName = "highlightDifferences", - name = "Highlight Differences", - description = "Highlight slots that don't match the selected setup", - position = 0 - ) - - default boolean getHighlightDifferences() - { - return false; - } - - @ConfigItem( - keyName = "highlightDifferenceColor", - name = "Highlight Color", - description = "The color used to highlight differences between setups", - position = 1 - ) - - default Color getHighlightColor() - { - return Color.RED; - } - - @ConfigItem( - keyName = "stackDifference", - name = "Stack Difference", - description = "Differences between setups will be highlighted if the stack size is different", - position = 2 - ) - - default boolean getStackDifference() - { - return false; - } - - @ConfigItem( - keyName = "variationDifference", - name = "Variation Difference", - description = "Variations of items (E.g., charged jewellery) will be counted as different", - position = 2 - ) - - default boolean getVariationDifference() - { - return false; - } - - @ConfigItem( - keyName = "bankHighlight", - name = "Bank Highlight", - description = "Highlight setup items in bank", - position = 4 - ) - - default boolean getBankHighlight() - { - return false; - } - - @ConfigItem( - keyName = "bankHighlightColor", - name = "Bank Highlight Color", - description = "The color used to highlight setup items in bank", - position = 5 - ) - - default Color getBankHighlightColor() - { - return Color.RED; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupItem.java deleted file mode 100644 index c1af4e68fd..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupItem.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.runelite.client.plugins.inventorysetups; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -public class InventorySetupItem -{ - @Getter - private final int id; - @Getter - private final String name; - @Getter - private final int quantity; -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupPlugin.java deleted file mode 100644 index 0830ec834a..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupPlugin.java +++ /dev/null @@ -1,402 +0,0 @@ -package net.runelite.client.plugins.inventorysetups; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -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.ItemContainer; -import net.runelite.api.events.ConfigChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.ItemContainerChanged; -import net.runelite.client.callback.ClientThread; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.ItemManager; -import net.runelite.client.game.ItemVariationMapping; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.inventorysetups.ui.InventorySetupPluginPanel; -import net.runelite.client.ui.ClientToolbar; -import net.runelite.client.ui.NavigationButton; -import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.client.util.ImageUtil; - -import javax.inject.Inject; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import java.awt.image.BufferedImage; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; - -@PluginDescriptor( - name = "Inventory Setups", - description = "Save inventory setups", - tags = { "items", "inventory", "setups"}, - enabledByDefault = false -) - -@Slf4j -public class InventorySetupPlugin extends Plugin -{ - - private static final String CONFIG_GROUP = "inventorysetups"; - private static final String CONFIG_KEY = "setups"; - private static final int NUM_INVENTORY_ITEMS = 28; - private static final int NUM_EQUIPMENT_ITEMS = 14; - - @Inject - private Client client; - - @Inject - private ItemManager itemManager; - - @Inject - private InventorySetupBankOverlay overlay; - - @Inject - private ClientToolbar clientToolbar; - - @Inject - private InventorySetupConfig config; - - @Inject - private OverlayManager overlayManager; - - @Inject - private ClientThread clientThread; - - @Inject - private ConfigManager configManager; - - private InventorySetupPluginPanel panel; - - private HashMap inventorySetups; - - private NavigationButton navButton; - - private boolean highlightDifference; - - @Override - public void startUp() - { - overlayManager.add(overlay); - - panel = new InventorySetupPluginPanel(this, itemManager); - - final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "inventorysetups_icon.png"); - - navButton = NavigationButton.builder() - .tooltip("Inventory Setups") - .icon(icon) - .priority(9) - .panel(panel) - .build(); - - clientToolbar.addNavigation(navButton); - - // load all the inventory setups from the config file - clientThread.invokeLater(() -> - { - if (client.getGameState() != GameState.LOGIN_SCREEN) - { - return false; - } - - loadConfig(); - panel.showNoSetupsPanel(); - return true; - }); - - } - - public void addInventorySetup() - { - final String name = JOptionPane.showInputDialog(panel, - "Enter the name of this setup.", - "Add New Setup", - JOptionPane.PLAIN_MESSAGE); - - // cancel button was clicked - if (name == null) - { - return; - } - - if (name.isEmpty()) - { - JOptionPane.showMessageDialog(panel, - "Invalid Setup Name", - "Names must not be empty.", - JOptionPane.PLAIN_MESSAGE); - return; - } - - if (inventorySetups.containsKey(name)) - { - String builder = "The setup " + name + " already exists. " + - "Would you like to replace it with the current setup?"; - int confirm = JOptionPane.showConfirmDialog(panel, - builder, - "Warning", - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.PLAIN_MESSAGE); - - if (confirm == JOptionPane.CANCEL_OPTION) - { - return; - } - - // delete the old setup, no need to ask for confirmation - // because the user confirmed above - removeInventorySetup(name, false); - } - - clientThread.invoke(() -> - { - ArrayList inv = getNormalizedContainer(InventoryID.INVENTORY); - ArrayList eqp = getNormalizedContainer(InventoryID.EQUIPMENT); - - final InventorySetup invSetup = new InventorySetup(inv, eqp); - SwingUtilities.invokeLater(() -> - { - inventorySetups.put(name, invSetup); - panel.addInventorySetup(name); - panel.setCurrentInventorySetup(name); - - updateConfig(); - }); - }); - } - - public void removeInventorySetup(final String name, boolean askForConfirmation) - { - if (inventorySetups.containsKey(name)) - { - int confirm = JOptionPane.YES_OPTION; - - if (askForConfirmation) - { - confirm = JOptionPane.showConfirmDialog(panel, - "Are you sure you want to remove this setup?", - "Warning", - JOptionPane.YES_NO_OPTION, - JOptionPane.PLAIN_MESSAGE); - } - - if (confirm == JOptionPane.YES_OPTION) - { - inventorySetups.remove(name); - panel.removeInventorySetup(name); - } - - updateConfig(); - } - } - - public final InventorySetup getInventorySetup(final String name) - { - return inventorySetups.get(name); - } - - @Provides - InventorySetupConfig provideConfig(ConfigManager configManager) - { - return configManager.getConfig(InventorySetupConfig.class); - } - - @Subscribe - public void onConfigChanged(ConfigChanged event) - { - if (event.getGroup().equals(CONFIG_GROUP)) - { - // only allow highlighting if the config is enabled and the player is logged in - highlightDifference = config.getHighlightDifferences() && client.getGameState() == GameState.LOGGED_IN; - final String setupName = panel.getSelectedInventorySetup(); - if (highlightDifference && !setupName.isEmpty()) - { - panel.setCurrentInventorySetup(setupName); - } - } - } - - private void updateConfig() - { - if (inventorySetups.isEmpty()) - { - configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_KEY); - return; - } - - final Gson gson = new Gson(); - final String json = gson.toJson(inventorySetups); - configManager.setConfiguration(CONFIG_GROUP, CONFIG_KEY, json); - } - - private void loadConfig() - { - // serialize the internal data structure from the json in the configuration - final String json = configManager.getConfiguration(CONFIG_GROUP, CONFIG_KEY); - if (json == null || json.isEmpty()) - { - inventorySetups = new HashMap<>(); - } - else - { - // TODO add last resort?, serialize exception just make empty map - final Gson gson = new Gson(); - Type type = new TypeToken>() - { - - }.getType(); - inventorySetups = gson.fromJson(json, type); - } - - for (final String key : inventorySetups.keySet()) - { - panel.addInventorySetup(key); - } - - highlightDifference = false; - } - - @Subscribe - public void onItemContainerChanged(ItemContainerChanged event) - { - - if (!highlightDifference || client.getGameState() != GameState.LOGGED_IN) - { - return; - } - - // empty entry, no need to compare anything - final String selectedInventorySetup = panel.getSelectedInventorySetup(); - if (selectedInventorySetup.isEmpty()) - { - return; - } - - // check to see that the container is the equipment or inventory - ItemContainer container = event.getItemContainer(); - - if (container == client.getItemContainer(InventoryID.INVENTORY)) - { - ArrayList normContainer = getNormalizedContainer(InventoryID.INVENTORY); - final InventorySetup setup = inventorySetups.get(selectedInventorySetup); - panel.highlightDifferences(normContainer, setup, InventoryID.INVENTORY); - } - else if (container == client.getItemContainer(InventoryID.EQUIPMENT)) - { - ArrayList normContainer = getNormalizedContainer(InventoryID.EQUIPMENT); - final InventorySetup setup = inventorySetups.get(selectedInventorySetup); - panel.highlightDifferences(normContainer, setup, InventoryID.EQUIPMENT); - } - - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - switch (event.getGameState()) - { - // set the highlighting off if login screen shows up - case LOGIN_SCREEN: - highlightDifference = false; - final String setupName = panel.getSelectedInventorySetup(); - if (!setupName.isEmpty()) - { - panel.setCurrentInventorySetup(setupName); - } - break; - - // set highlighting - case LOGGED_IN: - highlightDifference = config.getHighlightDifferences(); - break; - } - } - - public ArrayList getNormalizedContainer(final InventoryID id) - { - assert id == InventoryID.INVENTORY || id == InventoryID.EQUIPMENT : "invalid inventory ID"; - - final ItemContainer container = client.getItemContainer(id); - - ArrayList newContainer = new ArrayList<>(); - - Item[] items = null; - if (container != null) - { - items = container.getItems(); - } - - int size = id == InventoryID.INVENTORY ? NUM_INVENTORY_ITEMS : NUM_EQUIPMENT_ITEMS; - - for (int i = 0; i < size; i++) - { - if (items == null || i >= items.length) - { - newContainer.add(new InventorySetupItem(-1, "", 0)); - } - else - { - final Item item = items[i]; - String itemName = ""; - if (client.isClientThread()) - { - itemName = itemManager.getItemComposition(item.getId()).getName(); - } - newContainer.add(new InventorySetupItem(item.getId(), itemName, item.getQuantity())); - } - } - - return newContainer; - } - - public final InventorySetupConfig getConfig() - { - return config; - } - - public boolean getHighlightDifference() - { - return highlightDifference; - } - - @Override - public void shutDown() - { - overlayManager.remove(overlay); - clientToolbar.removeNavigation(navButton); - } - - final int[] getCurrentInventorySetupIds() - { - InventorySetup setup = inventorySetups.get(panel.getSelectedInventorySetup()); - if (setup == null) - { - return null; - } - ArrayList items = new ArrayList<>(); - items.addAll(setup.getEquipment()); - items.addAll(setup.getInventory()); - ArrayList itemIds = new ArrayList<>(); - for (InventorySetupItem item : items) - { - int id = item.getId(); - ItemComposition itemComposition = itemManager.getItemComposition(id); - if (id > 0) - { - itemIds.add(ItemVariationMapping.map(id)); - itemIds.add(itemComposition.getPlaceholderId()); - } - - } - return itemIds.stream().mapToInt(i -> i).toArray(); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupContainerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupContainerPanel.java deleted file mode 100644 index d5eda3697f..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupContainerPanel.java +++ /dev/null @@ -1,109 +0,0 @@ -package net.runelite.client.plugins.inventorysetups.ui; - -import net.runelite.client.game.AsyncBufferedImage; -import net.runelite.client.game.ItemManager; -import net.runelite.client.game.ItemVariationMapping; -import net.runelite.client.plugins.inventorysetups.InventorySetupConfig; -import net.runelite.client.plugins.inventorysetups.InventorySetupItem; -import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin; -import net.runelite.client.ui.ColorScheme; - -import javax.swing.JLabel; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Color; -import java.util.ArrayList; - -public abstract class InventorySetupContainerPanel extends JPanel -{ - - protected ItemManager itemManager; - - private final InventorySetupPlugin plugin; - - InventorySetupContainerPanel(final ItemManager itemManager, final InventorySetupPlugin plugin, String captionText) - { - this.itemManager = itemManager; - this.plugin = plugin; - JPanel containerPanel = new JPanel(); - - final JPanel containerSlotsPanel = new JPanel(); - - setupContainerPanel(containerSlotsPanel); - - // caption - final JLabel caption = new JLabel(captionText); - caption.setHorizontalAlignment(JLabel.CENTER); - caption.setVerticalAlignment(JLabel.CENTER); - - // panel that holds the caption and any other graphics - final JPanel captionPanel = new JPanel(); - captionPanel.add(caption); - - containerPanel.setLayout(new BorderLayout()); - containerPanel.add(captionPanel, BorderLayout.NORTH); - containerPanel.add(containerSlotsPanel, BorderLayout.CENTER); - - add(containerPanel); - } - - void setContainerSlot(int index, - final InventorySetupSlot containerSlot, - final ArrayList items) - { - if (index >= items.size() || items.get(index).getId() == -1) - { - containerSlot.setImageLabel(null, null); - return; - } - - int itemId = items.get(index).getId(); - int quantity = items.get(index).getQuantity(); - final String itemName = items.get(index).getName(); - AsyncBufferedImage itemImg = itemManager.getImage(itemId, quantity, quantity > 1); - String toolTip = itemName; - if (quantity > 1) - { - toolTip += " (" + quantity + ")"; - } - containerSlot.setImageLabel(toolTip, itemImg); - } - - void highlightDifferentSlotColor(InventorySetupItem savedItem, - InventorySetupItem currItem, - final InventorySetupSlot containerSlot) - { - // important note: do not use item names for comparisons - // they are all empty to avoid clientThread usage when highlighting - - final InventorySetupConfig config = plugin.getConfig(); - final Color highlightColor = config.getHighlightColor(); - - if (config.getStackDifference() && currItem.getQuantity() != savedItem.getQuantity()) - { - containerSlot.setBackground(highlightColor); - return; - } - - int currId = currItem.getId(); - int checkId = savedItem.getId(); - - if (!config.getVariationDifference()) - { - currId = ItemVariationMapping.map(currId); - checkId = ItemVariationMapping.map(checkId); - } - - if (currId != checkId) - { - containerSlot.setBackground(highlightColor); - return; - } - - // set the color back to the original, because they match - containerSlot.setBackground(ColorScheme.DARKER_GRAY_COLOR); - } - - abstract public void setupContainerPanel(final JPanel containerSlotsPanel); - -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupEquipmentPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupEquipmentPanel.java deleted file mode 100644 index 7e0fecfa2b..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupEquipmentPanel.java +++ /dev/null @@ -1,91 +0,0 @@ -package net.runelite.client.plugins.inventorysetups.ui; - -import net.runelite.api.EquipmentInventorySlot; -import net.runelite.client.game.ItemManager; -import net.runelite.client.plugins.inventorysetups.InventorySetup; -import net.runelite.client.plugins.inventorysetups.InventorySetupItem; -import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin; -import net.runelite.client.ui.ColorScheme; - -import javax.swing.JPanel; -import java.awt.GridLayout; -import java.util.ArrayList; -import java.util.HashMap; - -public class InventorySetupEquipmentPanel extends InventorySetupContainerPanel -{ - private HashMap equipmentSlots; - - InventorySetupEquipmentPanel(final ItemManager itemManager, final InventorySetupPlugin plugin) - { - super(itemManager, plugin, "Equipment"); - } - - @Override - public void setupContainerPanel(final JPanel containerSlotsPanel) - { - this.equipmentSlots = new HashMap<>(); - for (EquipmentInventorySlot slot : EquipmentInventorySlot.values()) - { - equipmentSlots.put(slot, new InventorySetupSlot(ColorScheme.DARKER_GRAY_COLOR)); - } - - final GridLayout gridLayout = new GridLayout(5, 3, 1, 1); - containerSlotsPanel.setLayout(gridLayout); - - // add the grid layouts, including invisible ones - containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.HEAD)); - containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.CAPE)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.AMULET)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.AMMO)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.WEAPON)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.BODY)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.SHIELD)); - containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.LEGS)); - containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.GLOVES)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.BOOTS)); - containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.RING)); - - } - - void setEquipmentSetupSlots(final InventorySetup setup) - { - final ArrayList equipment = setup.getEquipment(); - - for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values()) - { - int i = slot.getSlotIdx(); - super.setContainerSlot(i, equipmentSlots.get(slot), equipment); - } - - validate(); - repaint(); - - } - - void highlightDifferences(final ArrayList currEquipment, final InventorySetup inventorySetup) - { - final ArrayList equipToCheck = inventorySetup.getEquipment(); - - assert currEquipment.size() == equipToCheck.size() : "size mismatch"; - - for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values()) - { - - int slotIdx = slot.getSlotIdx(); - super.highlightDifferentSlotColor(equipToCheck.get(slotIdx), currEquipment.get(slotIdx), equipmentSlots.get(slot)); - } - } - - void resetEquipmentSlotsColor() - { - for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values()) - { - equipmentSlots.get(slot).setBackground(ColorScheme.DARKER_GRAY_COLOR); - } - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupInventoryPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupInventoryPanel.java deleted file mode 100644 index 136f4603ea..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupInventoryPanel.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.runelite.client.plugins.inventorysetups.ui; - -import net.runelite.client.game.ItemManager; -import net.runelite.client.plugins.inventorysetups.InventorySetup; -import net.runelite.client.plugins.inventorysetups.InventorySetupItem; -import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin; -import net.runelite.client.ui.ColorScheme; - -import javax.swing.JPanel; -import java.awt.GridLayout; -import java.util.ArrayList; - -public class InventorySetupInventoryPanel extends InventorySetupContainerPanel -{ - - private static final int ITEMS_PER_ROW = 4; - private static final int NUM_INVENTORY_ITEMS = 28; - - private ArrayList inventorySlots; - - InventorySetupInventoryPanel(final ItemManager itemManager, final InventorySetupPlugin plugin) - { - super(itemManager, plugin, "Inventory"); - } - - - @Override - public void setupContainerPanel(final JPanel containerSlotsPanel) - { - this.inventorySlots = new ArrayList<>(); - for (int i = 0; i < NUM_INVENTORY_ITEMS; i++) - { - inventorySlots.add(new InventorySetupSlot(ColorScheme.DARKER_GRAY_COLOR)); - } - - int numRows = (NUM_INVENTORY_ITEMS + ITEMS_PER_ROW - 1) / ITEMS_PER_ROW; - containerSlotsPanel.setLayout(new GridLayout(numRows, ITEMS_PER_ROW, 1, 1)); - for (int i = 0; i < NUM_INVENTORY_ITEMS; i++) - { - containerSlotsPanel.add(inventorySlots.get(i)); - } - } - - void setInventorySetupSlots(final InventorySetup setup) - { - ArrayList inventory = setup.getInventory(); - - for (int i = 0; i < NUM_INVENTORY_ITEMS; i++) - { - super.setContainerSlot(i, inventorySlots.get(i), inventory); - } - - validate(); - repaint(); - - } - - void highlightDifferentSlots(final ArrayList currInventory, final InventorySetup inventorySetup) - { - - final ArrayList inventoryToCheck = inventorySetup.getInventory(); - - assert currInventory.size() == inventoryToCheck.size() : "size mismatch"; - - for (int i = 0; i < NUM_INVENTORY_ITEMS; i++) - { - super.highlightDifferentSlotColor(inventoryToCheck.get(i), currInventory.get(i), inventorySlots.get(i)); - } - } - - void resetInventorySlotsColor() - { - for (InventorySetupSlot inventorySlot : inventorySlots) - { - inventorySlot.setBackground(ColorScheme.DARKER_GRAY_COLOR); - } - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPluginPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPluginPanel.java deleted file mode 100644 index b1b88a02c7..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPluginPanel.java +++ /dev/null @@ -1,287 +0,0 @@ -package net.runelite.client.plugins.inventorysetups.ui; - -import net.runelite.api.InventoryID; -import net.runelite.client.game.ItemManager; -import net.runelite.client.plugins.inventorysetups.InventorySetup; -import net.runelite.client.plugins.inventorysetups.InventorySetupItem; -import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin; -import net.runelite.client.ui.PluginPanel; -import net.runelite.client.ui.components.PluginErrorPanel; -import net.runelite.client.util.ImageUtil; - -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.ImageIcon; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.border.EmptyBorder; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ItemEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; -import java.util.ArrayList; - -public class InventorySetupPluginPanel extends PluginPanel -{ - - private static ImageIcon ADD_ICON; - private static ImageIcon ADD_HOVER_ICON; - private static ImageIcon REMOVE_ICON; - private static ImageIcon REMOVE_HOVER_ICON; - - private final JPanel noSetupsPanel; - private final JPanel invEqPanel; - - private final InventorySetupInventoryPanel invPanel; - private final InventorySetupEquipmentPanel eqpPanel; - - private final JComboBox setupComboBox; - - private final JLabel removeMarker; - - private final InventorySetupPlugin plugin; - - static - { - final BufferedImage addIcon = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "add_icon.png"); - ADD_ICON = new ImageIcon(addIcon); - ADD_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(addIcon, 0.53f)); - - final BufferedImage removeIcon = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "remove_icon.png"); - REMOVE_ICON = new ImageIcon(removeIcon); - REMOVE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(removeIcon, 0.53f)); - } - - public InventorySetupPluginPanel(final InventorySetupPlugin plugin, final ItemManager itemManager) - { - super(false); - this.plugin = plugin; - this.removeMarker = new JLabel(REMOVE_ICON); - this.invPanel = new InventorySetupInventoryPanel(itemManager, plugin); - this.eqpPanel = new InventorySetupEquipmentPanel(itemManager, plugin); - this.noSetupsPanel = new JPanel(); - this.invEqPanel = new JPanel(); - this.setupComboBox = new JComboBox<>(); - - // setup the title - final JLabel addMarker = new JLabel(ADD_ICON); - final JLabel title = new JLabel(); - title.setText("Inventory Setups"); - title.setForeground(Color.WHITE); - - // setup the add marker (+ sign in the top right) - addMarker.setToolTipText("Add a new inventory setup"); - addMarker.addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - plugin.addInventorySetup(); - } - - @Override - public void mouseEntered(MouseEvent e) - { - addMarker.setIcon(ADD_HOVER_ICON); - } - - @Override - public void mouseExited(MouseEvent e) - { - addMarker.setIcon(ADD_ICON); - } - }); - - // setup the remove marker (X sign in the top right) - removeMarker.setToolTipText("Remove the current inventory setup"); - removeMarker.addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - final String name = (String)setupComboBox.getSelectedItem(); - plugin.removeInventorySetup(name, true); - } - - @Override - public void mouseEntered(MouseEvent e) - { - if (removeMarker.isEnabled()) - { - removeMarker.setIcon(REMOVE_HOVER_ICON); - } - } - - @Override - public void mouseExited(MouseEvent e) - { - removeMarker.setIcon(REMOVE_ICON); - } - }); - - // setup the combo box for selection switching - // add empty to indicate the empty position - setupComboBox.addItem(""); - setupComboBox.setSelectedIndex(0); - setupComboBox.addItemListener(e -> - { - if (e.getStateChange() == ItemEvent.SELECTED) - { - String selection = (String)e.getItem(); - setCurrentInventorySetup(selection); - } - }); - - // the panel on the top right that holds the add and delete buttons - final JPanel markersPanel = new JPanel(); - markersPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0)); - markersPanel.add(removeMarker); - markersPanel.add(addMarker); - - // the top panel that has the title and the buttons - final JPanel titleAndMarkersPanel = new JPanel(); - titleAndMarkersPanel.setLayout(new BorderLayout()); - titleAndMarkersPanel.add(title, BorderLayout.WEST); - titleAndMarkersPanel.add(markersPanel, BorderLayout.EAST); - - // the panel that stays at the top and doesn't scroll - // contains the title, buttons, and the combo box - final JPanel northAnchoredPanel = new JPanel(); - northAnchoredPanel.setLayout(new BoxLayout(northAnchoredPanel, BoxLayout.Y_AXIS)); - northAnchoredPanel.setBorder(new EmptyBorder(0, 0, 10, 0)); - northAnchoredPanel.add(titleAndMarkersPanel); - northAnchoredPanel.add(Box.createRigidArea(new Dimension(0, 10))); - northAnchoredPanel.add(setupComboBox); - - // the panel that holds the inventory and equipment panels - final BoxLayout invEqLayout = new BoxLayout(invEqPanel, BoxLayout.Y_AXIS); - invEqPanel.setLayout(invEqLayout); - invEqPanel.add(invPanel); - invEqPanel.add(Box.createRigidArea(new Dimension(0, 10))); - invEqPanel.add(eqpPanel); - - // setup the error panel. It's wrapped around a normal panel - // so it doesn't stretch to fill the parent panel - final PluginErrorPanel errorPanel = new PluginErrorPanel(); - errorPanel.setContent("Inventory Setups", "Select or create an inventory setup."); - noSetupsPanel.add(errorPanel); - - // the panel that holds the inventory panels, and the error panel - final JPanel contentPanel = new JPanel(); - final BoxLayout contentLayout = new BoxLayout(contentPanel, BoxLayout.Y_AXIS); - contentPanel.setLayout(contentLayout); - contentPanel.add(invEqPanel); - contentPanel.add(noSetupsPanel); - - // wrapper for the main content panel to keep it from stretching - final JPanel contentWrapper = new JPanel(new BorderLayout()); - contentWrapper.add(Box.createGlue(), BorderLayout.CENTER); - contentWrapper.add(contentPanel, BorderLayout.NORTH); - final JScrollPane contentWrapperPane = new JScrollPane(contentWrapper); - contentWrapperPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - - setLayout(new BorderLayout()); - setBorder(new EmptyBorder(10, 10, 10, 10)); - add(northAnchoredPanel, BorderLayout.NORTH); - add(contentWrapperPane, BorderLayout.CENTER); - - // show the no setups panel on startup - showNoSetupsPanel(); - - } - - public void showNoSetupsPanel() - { - setupComboBox.setSelectedIndex(0); - removeMarker.setEnabled(false); - noSetupsPanel.setVisible(true); - invEqPanel.setVisible(false); - } - - private void showHasSetupPanel(final String name) - { - setupComboBox.setSelectedItem(name); - removeMarker.setEnabled(true); - noSetupsPanel.setVisible(false); - invEqPanel.setVisible(true); - } - - public void setCurrentInventorySetup(final String name) - { - if (name.isEmpty()) - { - showNoSetupsPanel(); - return; - } - - showHasSetupPanel(name); - - final InventorySetup inventorySetup = plugin.getInventorySetup(name); - - invPanel.setInventorySetupSlots(inventorySetup); - eqpPanel.setEquipmentSetupSlots(inventorySetup); - - if (plugin.getHighlightDifference()) - { - final ArrayList normInv = plugin.getNormalizedContainer(InventoryID.INVENTORY); - final ArrayList normEqp = plugin.getNormalizedContainer(InventoryID.EQUIPMENT); - - highlightDifferences(normInv, inventorySetup, InventoryID.INVENTORY); - highlightDifferences(normEqp, inventorySetup, InventoryID.EQUIPMENT); - } - else - { - invPanel.resetInventorySlotsColor(); - eqpPanel.resetEquipmentSlotsColor(); - } - - validate(); - repaint(); - } - - public void addInventorySetup(final String name) - { - setupComboBox.addItem(name); - } - - public void removeInventorySetup(final String name) - { - setupComboBox.removeItem(name); - showNoSetupsPanel(); - - invPanel.resetInventorySlotsColor(); - eqpPanel.resetEquipmentSlotsColor(); - - validate(); - repaint(); - } - - public void highlightDifferences(final ArrayList container, - final InventorySetup setupToCheck, - final InventoryID type) - { - switch (type) - { - case INVENTORY: - invPanel.highlightDifferentSlots(container, setupToCheck); - break; - - case EQUIPMENT: - eqpPanel.highlightDifferences(container, setupToCheck); - break; - } - } - - public final String getSelectedInventorySetup() - { - return (String)setupComboBox.getSelectedItem(); - } - - -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupSlot.java deleted file mode 100644 index 13bbbaef14..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupSlot.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.runelite.client.plugins.inventorysetups.ui; - -import net.runelite.client.game.AsyncBufferedImage; - -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import java.awt.Color; -import java.awt.Dimension; - -public class InventorySetupSlot extends JPanel -{ - - private final JLabel imageLabel; - - public InventorySetupSlot(Color color) - { - imageLabel = new JLabel(); - imageLabel.setVerticalAlignment(SwingConstants.CENTER); - setPreferredSize(new Dimension(46, 42)); - setBackground(color); - add(imageLabel); - - } - - public void setImageLabel(String toolTip, AsyncBufferedImage itemImage) - { - if (itemImage == null || toolTip == null) - { - imageLabel.setToolTipText(""); - imageLabel.setIcon(null); - imageLabel.revalidate(); - return; - } - - imageLabel.setToolTipText(toolTip); - itemImage.addTo(imageLabel); - - validate(); - repaint(); - } - - - -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsOverlay.java index 99798156ad..14fe723a71 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsOverlay.java @@ -43,6 +43,8 @@ public class InventoryTagsOverlay extends WidgetItemOverlay { this.itemManager = itemManager; this.plugin = plugin; + showOnEquipment(); + showOnInventory(); } @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerConfig.java index 1dbc0f7901..38ff6d6e3d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerConfig.java @@ -1,19 +1,63 @@ +/* + * Copyright (c) 2019 Hydrox6 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package net.runelite.client.plugins.inventoryviewer; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -@ConfigGroup("inventoryviewer") +@ConfigGroup(InventoryViewerPlugin.CONFIG_GROUP_KEY) public interface InventoryViewerConfig extends Config { @ConfigItem( - keyName = "hideWhenInvOpen", - name = "Hide when inventory is open", - description = "Hide the inventory viewer when the player's inventory is open" + keyName = "viewerMode", + name = "Mode", + description = "The mode to display the inventory viewer with" ) - default boolean hideWhenInvOpen() + default InventoryViewerMode viewerMode() + { + return InventoryViewerMode.FULL; + } + + @ConfigItem( + keyName = "showFreeSlots", + name = "Show Free Slots", + description = "Whether to show a label with the free slots in the inventory" + ) + default boolean showFreeSlots() { return false; } + + @ConfigItem( + keyName = "hideWhenInvOpen", + name = "Hide when inventory is open", + description = "Hide the inventory viewer when the player's inventory is open" + ) + default boolean hideWhenInvOpen() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerMode.java new file mode 100644 index 0000000000..562ae8c972 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerMode.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019 Hydrox6 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.inventoryviewer; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum InventoryViewerMode +{ + FULL("Full"), + GROUPED("Grouped"); + + private final String name; + + @Override + public String toString() + { + return name; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerOverlay.java index bb59bd41b4..d66718f4c0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerOverlay.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2018 AWPH-I + * Copyright (c) 2019 Hydrox6 * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,9 +25,12 @@ */ package net.runelite.client.plugins.inventoryviewer; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; import net.runelite.api.Client; @@ -38,8 +42,10 @@ import net.runelite.api.VarClientInt; import net.runelite.client.game.ItemManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.ComponentConstants; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; class InventoryViewerOverlay extends Overlay { @@ -49,21 +55,39 @@ class InventoryViewerOverlay extends Overlay private static final ImageComponent PLACEHOLDER_IMAGE = new ImageComponent(new BufferedImage(PLACEHOLDER_WIDTH, PLACEHOLDER_HEIGHT, BufferedImage.TYPE_4BYTE_ABGR)); private final Client client; - private final InventoryViewerConfig config; private final ItemManager itemManager; + private final InventoryViewerConfig config; - private final PanelComponent panelComponent = new PanelComponent(); + private final PanelComponent wrapperComponent = new PanelComponent(); + private final PanelComponent inventoryComponent = new PanelComponent(); + private final TitleComponent freeSlotsComponent = TitleComponent.builder().build(); @Inject - private InventoryViewerOverlay(Client client, InventoryViewerConfig config, ItemManager itemManager) + private InventoryViewerOverlay(Client client, ItemManager itemManager, InventoryViewerConfig config) { setPosition(OverlayPosition.BOTTOM_RIGHT); - panelComponent.setWrapping(4); - panelComponent.setGap(new Point(6, 4)); - panelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL); + + inventoryComponent.setWrapping(4); + inventoryComponent.setGap(new Point(6, 4)); + inventoryComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL); + inventoryComponent.setBackgroundColor(null); + inventoryComponent.setBorder(new Rectangle( + 0, + ComponentConstants.STANDARD_BORDER, + 0, + ComponentConstants.STANDARD_BORDER)); + + wrapperComponent.setOrientation(PanelComponent.Orientation.VERTICAL); + wrapperComponent.setWrapping(2); + wrapperComponent.setBorder(new Rectangle( + ComponentConstants.STANDARD_BORDER * 2, + ComponentConstants.STANDARD_BORDER, + ComponentConstants.STANDARD_BORDER * 2, + ComponentConstants.STANDARD_BORDER)); + + this.itemManager = itemManager; this.client = client; this.config = config; - this.itemManager = itemManager; } @Override @@ -82,10 +106,50 @@ class InventoryViewerOverlay extends Overlay return null; } - panelComponent.getChildren().clear(); + inventoryComponent.getChildren().clear(); + wrapperComponent.getChildren().clear(); final Item[] items = itemContainer.getItems(); + if (config.viewerMode() == InventoryViewerMode.GROUPED) + { + Multiset totals = HashMultiset.create(); + for (Item item : items) + { + if (item.getId() != -1) + { + totals.add(item.getId(), item.getQuantity()); + } + } + + final long remaining = INVENTORY_SIZE - totals.size(); + if (remaining == INVENTORY_SIZE) + { + return null; + } + + for (Multiset.Entry cursor : totals.entrySet()) + { + final BufferedImage image = itemManager.getImage(cursor.getElement(), cursor.getCount(), true); + if (image != null) + { + inventoryComponent.getChildren().add(new ImageComponent(image)); + } + } + wrapperComponent.getChildren().add(inventoryComponent); + + if (config.showFreeSlots()) + { + freeSlotsComponent.setText(remaining + " free"); + wrapperComponent.setPreferredSize(new Dimension(Math.min(totals.elementSet().size(), 4) * (PLACEHOLDER_WIDTH + 6) + ComponentConstants.STANDARD_BORDER * 2, 0)); + wrapperComponent.getChildren().add(freeSlotsComponent); + } + + return wrapperComponent.render(graphics); + } + + int remaining = 28; + for (int i = 0; i < INVENTORY_SIZE; i++) { if (i < items.length) @@ -93,20 +157,30 @@ class InventoryViewerOverlay extends Overlay final Item item = items[i]; if (item.getQuantity() > 0) { + remaining -= 1; final BufferedImage image = getImage(item); if (image != null) { - panelComponent.getChildren().add(new ImageComponent(image)); + inventoryComponent.getChildren().add(new ImageComponent(image)); continue; } } } // put a placeholder image so each item is aligned properly and the panel is not resized - panelComponent.getChildren().add(PLACEHOLDER_IMAGE); + inventoryComponent.getChildren().add(PLACEHOLDER_IMAGE); } - return panelComponent.render(graphics); + wrapperComponent.getChildren().add(inventoryComponent); + + if (config.showFreeSlots()) + { + freeSlotsComponent.setText(remaining + " free"); + wrapperComponent.setPreferredSize(new Dimension(4 * (PLACEHOLDER_WIDTH + 6) + ComponentConstants.STANDARD_BORDER * 2, 0)); + wrapperComponent.getChildren().add(freeSlotsComponent); + } + + return wrapperComponent.render(graphics); } private BufferedImage getImage(Item item) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerPlugin.java index 01bc51dc33..71032a10c7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerPlugin.java @@ -24,8 +24,8 @@ */ package net.runelite.client.plugins.inventoryviewer; -import javax.inject.Inject; import com.google.inject.Provides; +import javax.inject.Inject; import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -39,6 +39,8 @@ import net.runelite.client.ui.overlay.OverlayManager; ) public class InventoryViewerPlugin extends Plugin { + static final String CONFIG_GROUP_KEY = "inventoryviewer"; + @Inject private InventoryViewerOverlay overlay; @@ -46,7 +48,7 @@ public class InventoryViewerPlugin extends Plugin private OverlayManager overlayManager; @Provides - InventoryViewerConfig getConfig(ConfigManager configManager) + InventoryViewerConfig provideConfig(ConfigManager configManager) { return configManager.getConfig(InventoryViewerConfig.class); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java index a37570aa22..5082ab2ccd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java @@ -51,6 +51,8 @@ class ItemChargeOverlay extends WidgetItemOverlay { this.itemChargePlugin = itemChargePlugin; this.config = config; + showOnInventory(); + showOnEquipment(); } @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kittennotifier/KittenNotifierConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/kittennotifier/KittenNotifierConfig.java deleted file mode 100644 index e9d28f6b26..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kittennotifier/KittenNotifierConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.runelite.client.plugins.kittennotifier; -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("kittennotifier") -public interface KittenNotifierConfig extends Config{ - @ConfigItem( - keyName = "absolutelyNeeded", - name = "Notify only on Absolute Need", - description = "Only notify when kitten absolutely needs food or attention." - ) - default boolean absolutelyNeeded() { return false; } - @ConfigItem( - keyName = "catOwned", - name = "", - description = "", - hidden = true - ) - default boolean catOwned() { return false; } - @ConfigItem( - keyName = "catOwned", - name = "", - description = "" - ) - void catOwned(Boolean bool); -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kittennotifier/KittenNotifierPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/kittennotifier/KittenNotifierPlugin.java deleted file mode 100644 index 921dcd4a46..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kittennotifier/KittenNotifierPlugin.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.runelite.client.plugins.kittennotifier; -import com.google.inject.Provides; -import net.runelite.api.ChatMessageType; -import net.runelite.api.events.ChatMessage; -import net.runelite.api.events.NpcActionChanged; -import net.runelite.api.events.NpcSpawned; -import net.runelite.client.Notifier; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.api.NPC; -import net.runelite.api.Client; -import javax.inject.Inject; - -@PluginDescriptor( - name = "!Kitten Notifier", - description = "Sends a notification when your kitten needs food, attention, or is grown.", - tags = {"kitten, notifications"} -) -public class KittenNotifierPlugin extends Plugin{ - @Inject - private Notifier notifier; - @Inject - private KittenNotifierConfig config; - @Inject - private Client client; - @Provides - KittenNotifierConfig getConfig(ConfigManager configManager) - { - return configManager.getConfig(KittenNotifierConfig.class); - } - @Subscribe - public void onChatMessage(ChatMessage event) { - if (event.getType() == ChatMessageType.ENGINE && !config.catOwned()) { - if (!config.absolutelyNeeded()) { - if (event.getMessage().contentEquals("Your kitten is hungry.")) { - notifier.notify("Your kitten is hungry."); - } - if (event.getMessage().contentEquals("Your kitten wants attention.")) { - notifier.notify("Your kitten wants attention."); - } - } - if (event.getMessage().contentEquals("Your kitten is very hungry.")) { - notifier.notify("Your kitten is very hungry."); - } - if (event.getMessage().contentEquals("Your kitten really wants attention.")) { - notifier.notify("Your kitten really wants attention."); - } - } - } - @Subscribe - public void onNpcActionChanged(NpcActionChanged event) { - if (!config.catOwned()) { - for (NPC npc : client.getNpcs()) { - if (npc.getInteracting() != null) { - if (npc.getName().contentEquals("Cat") && !config.catOwned()) { - // If this if statement is included in previous it could null. - if (npc.getInteracting().getName().contentEquals(client.getLocalPlayer().getName())) { - config.catOwned(true); - notifier.notify("Your kitten has grown into a cat."); - } - } - } - } - } - } - @Subscribe - public void onNpcSpawned(NpcSpawned event) { - NPC cat = event.getNpc(); - if (cat.getName() != null) { - if (cat.getName().equalsIgnoreCase("Kitten")) { - if (cat.getInteracting().getName().contentEquals(client.getLocalPlayer().getName())) { - config.catOwned(false); - } - } - else if (cat.getName().contentEquals("Cat")) { - if (cat.getInteracting().getName().equalsIgnoreCase(client.getLocalPlayer().getName())) { - config.catOwned(true); - } - } - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanPlugin.java index e6b3923fea..6b93885523 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanPlugin.java @@ -19,10 +19,11 @@ import java.util.Map; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( - name = "!Lizard Shamans", + name = "Lizard Shamans", description = "Configures timer for lizardmen shaman spawns.", enabledByDefault = false, - tags = {"shaman", "lizard", "lizardmen"} + tags = {"shaman", "lizard", "lizardmen"}, + type = "PVM" ) @Slf4j public class LizardmenShamanPlugin extends Plugin diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java index d9cfdd7bf9..5d28a4bbea 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerPlugin.java @@ -35,6 +35,7 @@ import javax.inject.Inject; name = "PvP Looting Bag Viewer", description = "Add an overlay showing the contents of your looting bag", tags = {"alternate", "items", "overlay", "second"}, + type = "utility", enabledByDefault = false ) public class LootingBagViewerPlugin extends Plugin @@ -56,4 +57,4 @@ public class LootingBagViewerPlugin extends Plugin { overlayManager.remove(overlay); } -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/MaxHitPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/MaxHitPlugin.java new file mode 100644 index 0000000000..874f038774 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/MaxHitPlugin.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit; + +import net.runelite.api.Client; +import net.runelite.api.InventoryID; +import net.runelite.api.Item; +import net.runelite.api.ItemContainer; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.api.events.VarbitChanged; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.maxhit.calculators.MagicMaxHitCalculator; +import net.runelite.client.plugins.maxhit.calculators.MeleeMaxHitCalculator; +import net.runelite.client.plugins.maxhit.calculators.RangeMaxHitCalculator; + +import javax.inject.Inject; + +@PluginDescriptor( + name = "Max Hit", + description = "Max Hit Calculator", + type = "PVM", + enabledByDefault = false +) +public class MaxHitPlugin extends Plugin +{ + + @Inject + private Client client; + + @Subscribe + public void onItemContainerChanged(final ItemContainerChanged event) + { + this.updateMaxHitWidget(); + } + + @Subscribe + public void onConfigChanged(final ConfigChanged event) + { + this.updateMaxHitWidget(); + } + + @Subscribe + public void onVarbitChanged(VarbitChanged event) + { + this.updateMaxHitWidget(); + } + + private void updateMaxHitWidget() + { + Widget equipmentStats = client.getWidget(WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER); + + ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT); + Item[] equipedItems = new Item[14]; + + if (equipmentStats != null && !equipmentStats.isHidden()) + { + if (equipmentContainer != null) + { + equipedItems = equipmentContainer.getItems(); + } + + MeleeMaxHitCalculator meleeMaxHitCalculator = new MeleeMaxHitCalculator(this.client, equipedItems); + RangeMaxHitCalculator rangeMaxHitCalculator = new RangeMaxHitCalculator(this.client, equipedItems); + MagicMaxHitCalculator magicMaxHitCalculator = new MagicMaxHitCalculator(this.client, equipedItems); + + MaxHit maxHit = new MaxHit(meleeMaxHitCalculator.getMaxHit(), rangeMaxHitCalculator.getMaxHit(), magicMaxHitCalculator.getMaxHit()); + this.setWidgetMaxHit(maxHit); + } + } + + private void setWidgetMaxHit(MaxHit maxhit) + { + Widget equipYourCharacter = client.getWidget(WidgetInfo.EQUIP_YOUR_CHARACTER); + String maxHitText = "Melee Max Hit: " + maxhit.getMaxMeleeHit(); + maxHitText += "
Range Max Hit: " + maxhit.getMaxRangeHit(); + maxHitText += "
Magic Max Hit: " + maxhit.getMaxMagicHit(); + + + equipYourCharacter.setText(maxHitText); + } + + private class MaxHit + { + private final double maxMeleeHit; + private final double maxRangeHit; + private final double maxMagicHit; + + MaxHit(double maxMeleeHit, double maxRangeHit, double maxMagicHit) + { + this.maxMeleeHit = maxMeleeHit; + this.maxRangeHit = maxRangeHit; + this.maxMagicHit = maxMagicHit; + } + + double getMaxMeleeHit() + { + return maxMeleeHit; + } + + double getMaxRangeHit() + { + return maxRangeHit; + } + + double getMaxMagicHit() + { + return maxMagicHit; + } + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/attackstyle/AttackStyle.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/attackstyle/AttackStyle.java new file mode 100644 index 0000000000..e9e9d9b18d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/attackstyle/AttackStyle.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.attackstyle; + +public enum AttackStyle +{ + ACCURATE(0), + AGGRESSIVE(3), + DEFENSIVE(0), + CONTROLLED(1), + ACCURATERANGING(3), + RANGING(0), + LONGRANGE(0), + CASTING(0), + DEFENSIVE_CASTING(0), + OTHER(0); + + private final int maxHitBonus; + + AttackStyle(int maxHitBonus) + { + this.maxHitBonus = maxHitBonus; + } + + public double getMaxHitBonus() + { + return this.maxHitBonus; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/attackstyle/WeaponType.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/attackstyle/WeaponType.java new file mode 100644 index 0000000000..97ed177f27 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/attackstyle/WeaponType.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.attackstyle; + +import java.util.HashMap; +import java.util.Map; + +import static net.runelite.client.plugins.maxhit.attackstyle.AttackStyle.*; + +public enum WeaponType +{ + TYPE_0(ACCURATE, AGGRESSIVE, null, DEFENSIVE), + TYPE_1(ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE), + TYPE_2(ACCURATE, AGGRESSIVE, null, DEFENSIVE), + TYPE_3(ACCURATERANGING, RANGING, null, LONGRANGE), + TYPE_4(ACCURATE, AGGRESSIVE, CONTROLLED, DEFENSIVE), + TYPE_5(ACCURATERANGING, RANGING, null, LONGRANGE), + TYPE_6(AGGRESSIVE, RANGING, DEFENSIVE_CASTING, null), + TYPE_7(ACCURATERANGING, RANGING, null, LONGRANGE), + TYPE_8(OTHER, AGGRESSIVE, null, null), + TYPE_9(ACCURATE, AGGRESSIVE, CONTROLLED, DEFENSIVE), + TYPE_10(ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE), + TYPE_11(ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE), + TYPE_12(CONTROLLED, AGGRESSIVE, null, DEFENSIVE), + TYPE_13(ACCURATE, AGGRESSIVE, null, DEFENSIVE), + TYPE_14(ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE), + TYPE_15(CONTROLLED, CONTROLLED, CONTROLLED, DEFENSIVE), + TYPE_16(ACCURATE, AGGRESSIVE, CONTROLLED, DEFENSIVE), + TYPE_17(ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE), + TYPE_18(ACCURATE, AGGRESSIVE, null, DEFENSIVE, CASTING, DEFENSIVE_CASTING), + TYPE_19(ACCURATERANGING, RANGING, null, LONGRANGE), + TYPE_20(ACCURATE, CONTROLLED, null, DEFENSIVE), + TYPE_21(ACCURATE, AGGRESSIVE, null, DEFENSIVE, CASTING, DEFENSIVE_CASTING), + TYPE_22(ACCURATE, AGGRESSIVE, AGGRESSIVE, DEFENSIVE), + TYPE_23(CASTING, CASTING, null, DEFENSIVE_CASTING), + TYPE_24(ACCURATE, AGGRESSIVE, CONTROLLED, DEFENSIVE), + TYPE_25(CONTROLLED, AGGRESSIVE, null, DEFENSIVE), + TYPE_26(AGGRESSIVE, AGGRESSIVE, null, AGGRESSIVE), + TYPE_27(ACCURATE, null, null, OTHER); + + private static final Map weaponTypes = new HashMap<>(); + + static + { + for (WeaponType weaponType : values()) + { + weaponTypes.put(weaponType.ordinal(), weaponType); + } + } + + private final AttackStyle[] attackStyles; + + WeaponType(AttackStyle... attackStyles) + { + this.attackStyles = attackStyles; + } + + public static WeaponType getWeaponType(int id) + { + return weaponTypes.get(id); + } + + public AttackStyle[] getAttackStyles() + { + return attackStyles; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MagicMaxHitCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MagicMaxHitCalculator.java new file mode 100644 index 0000000000..8b14e3d988 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MagicMaxHitCalculator.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators; + +import net.runelite.api.Client; +import net.runelite.api.Item; +import net.runelite.api.Skill; +import net.runelite.api.Varbits; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.plugins.maxhit.config.EquipmentBonusConfig; +import net.runelite.client.plugins.maxhit.config.SpellBaseDamageConfig; + +public class MagicMaxHitCalculator extends MaxHitCalculator +{ + + public MagicMaxHitCalculator(Client client, Item[] equipedItems) + { + super(client, CombatMethod.MAGIC, equipedItems); + } + + @Override + protected String getSkillStrengthText(String equipmentText) + { + return equipmentText.replace("Magic damage: ", "").replace(".", "").replace("%", ""); + } + + @Override + Widget equipmentSkillPower() + { + return this.client.getWidget(WidgetInfo.EQUIPMENT_MAGIC_DAMAGE); + } + + @Override + public double getCurrentSkillPower() + { + return this.client.getBoostedSkillLevel(Skill.MAGIC); + } + + /* + * Damage formula based on: + * http://services.runescape.com/m=forum/forums.ws?317,318,712,65587452 + * Section 4. + * */ + @Override + public double calculate() + { + int spellBaseDamage = this.baseDamage; + + if (spellBaseDamage == 0) + { + int autoCastSpellId = client.getVar(Varbits.AUTO_CAST_SPELL); + if (autoCastSpellId == 0) + { + return 0.0; + } + + SpellBaseDamageConfig autoCastSpell = SpellBaseDamageConfig.findSpellById(autoCastSpellId); + spellBaseDamage = autoCastSpell.getBaseDamage(); + } + +// a.Find the base maximum damage a spell can deal. +// See CustomFormulaConfig for spells based on magic lvl + double maxHit = spellBaseDamage; + +// b. Increase the base damage (Chaos Gauntlets) + maxHit = this.applyEquipmentBonus(maxHit, EquipmentBonusConfig.BonusType.SPECIAL); + +// c. The following bonuses stack by adding up. (List of bonus items) + maxHit = this.applyEquipmentBonus(maxHit, EquipmentBonusConfig.BonusType.EQUIPMENT); + +// d. Round down to the nearest integer. + maxHit = Math.floor(maxHit); + +// e. On a slayer task, multiply by 1.15 (imbued) + maxHit = this.applyEquipmentBonus(maxHit, EquipmentBonusConfig.BonusType.SLAYER); + +// f. Round down to the nearest integer. + maxHit = Math.floor(maxHit); + +// g. If a fire spell is used, multiply by 1.5 (Tome of fire) + maxHit = this.applyEquipmentBonus(maxHit, EquipmentBonusConfig.BonusType.MAGIC_SPECIAL); + +// h. Round down to the nearest integer. + maxHit = Math.floor(maxHit); + +// i, j. Castle Wars will not be included + return maxHit; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MaxHitCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MaxHitCalculator.java new file mode 100644 index 0000000000..95cc98a266 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MaxHitCalculator.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators; + +import net.runelite.api.Client; +import net.runelite.api.Item; +import net.runelite.api.VarPlayer; +import net.runelite.api.Varbits; +import net.runelite.api.widgets.Widget; +import net.runelite.client.plugins.maxhit.attackstyle.AttackStyle; +import net.runelite.client.plugins.maxhit.attackstyle.WeaponType; +import net.runelite.client.plugins.maxhit.config.CustomFormulaConfig; +import net.runelite.client.plugins.maxhit.config.EquipmentBonusConfig; +import net.runelite.client.plugins.maxhit.config.PrayerBonusConfig; +import net.runelite.client.plugins.maxhit.equipment.EquipmentHelper; +import net.runelite.client.plugins.maxhit.equipment.EquipmentItemset; + +import java.util.ArrayList; +import java.util.function.BiFunction; + +public abstract class MaxHitCalculator +{ + + final Client client; + private final CombatMethod combatMethod; + private final Item[] equipedItems; + int baseDamage = 0; + + MaxHitCalculator(Client client, CombatMethod combatMethod, Item[] equipedItems) + { + this.client = client; + this.combatMethod = combatMethod; + this.equipedItems = equipedItems; + } + + protected abstract String getSkillStrengthText(String equipmentText); + + abstract Widget equipmentSkillPower(); + + public abstract double getCurrentSkillPower(); + + AttackStyle getAttackStyle() + { + int equippedWeaponTypeId = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE); + int attackStyleId = client.getVar(VarPlayer.ATTACK_STYLE); + + AttackStyle[] attackStyles = WeaponType.getWeaponType(equippedWeaponTypeId).getAttackStyles(); + + if (attackStyleId < attackStyles.length) + { + AttackStyle attackStyle = attackStyles[attackStyleId]; + if (attackStyle != null) + { + return attackStyle; + } + } + + return AttackStyle.OTHER; + } + + double getPrayerBonus() + { + double bonus = 1; + for (PrayerBonusConfig prayerBonus : PrayerBonusConfig.values()) + { + boolean prayerActive = client.getVar(prayerBonus.getPrayerVarbit()) == 1; + boolean sameCombatMethod = prayerBonus.getCombatMethod() == this.combatMethod; + if (prayerActive && sameCombatMethod) + { + bonus += prayerBonus.getStrengthBonus(); + } + } + return bonus; + } + + double applyEquipmentBonus(double maxhit, EquipmentBonusConfig.BonusType bonusType) + { + double bonus = 1; + ArrayList addList = new ArrayList<>(); + + ArrayList equipmentBonuses = EquipmentBonusConfig.getBonusByType(bonusType); + + for (EquipmentBonusConfig equipmentBonus : equipmentBonuses) + { + EquipmentItemset itemSet = equipmentBonus.getItemset(); + boolean wearsSet = EquipmentHelper.wearsItemSet(this.equipedItems, itemSet); + if (wearsSet && equipmentBonus.meetsRequirements(this.client)) + { + if (equipmentBonus.getOperation() == EquipmentBonusConfig.Operation.MULTIPLY) + { + bonus += equipmentBonus.getBonus(this.combatMethod); + } + else if (equipmentBonus.getOperation() == EquipmentBonusConfig.Operation.ADD) + { + addList.add(equipmentBonus.getBonus(this.combatMethod)); + } + } + } + + maxhit *= bonus; + + maxhit = maxhit + addList.stream().reduce(0.0, Double::sum); + + return maxhit; + } + + public double getMaxHit() + { + BiFunction customFormula = this.getCustomFormula(); + if (customFormula != null) + { + return customFormula.apply(this.client, this); + } + + return this.calculate(); + } + + private BiFunction getCustomFormula() + { + for (CustomFormulaConfig customFormula : CustomFormulaConfig.values()) + { + if (this.combatMethod != customFormula.getRequiredCombatMethod()) + { + continue; + } + + boolean meetsRequirements = customFormula.getRequirements().stream().allMatch(requirement -> requirement.meetsRequirements(this.client)); + + if (meetsRequirements) + { + return customFormula.getCustomFormula(); + } + } + + return null; + } + + public abstract double calculate(); + + public void setBaseDamage(int baseDamage) + { + this.baseDamage = baseDamage; + } + + double getSkillStrength() + { + return Double.parseDouble(this.getSkillStrengthText(this.equipmentSkillPower().getText())); + } + + public enum CombatMethod + { + MELEE, + RANGE, + MAGIC + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MeleeMaxHitCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MeleeMaxHitCalculator.java new file mode 100644 index 0000000000..d3f6d78a0b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/MeleeMaxHitCalculator.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators; + +import net.runelite.api.Client; +import net.runelite.api.Item; +import net.runelite.api.Skill; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.plugins.maxhit.attackstyle.AttackStyle; +import net.runelite.client.plugins.maxhit.config.EquipmentBonusConfig; + +public class MeleeMaxHitCalculator extends MaxHitCalculator +{ + + public MeleeMaxHitCalculator(Client client, Item[] equipedItems) + { + super(client, CombatMethod.MELEE, equipedItems); + } + + MeleeMaxHitCalculator(Client client, CombatMethod combatMethod, Item[] equipedItems) + { + super(client, combatMethod, equipedItems); + } + + @Override + protected String getSkillStrengthText(String equipmentText) + { + return equipmentText.replace("Melee strength: ", ""); + } + + @Override + public Widget equipmentSkillPower() + { + return this.client.getWidget(WidgetInfo.EQUIPMENT_MELEE_STRENGTH); + } + + @Override + public double getCurrentSkillPower() + { + return this.client.getBoostedSkillLevel(Skill.STRENGTH); + } + + private double getEffectiveLevel() + { +// a. Take the visible strength or ranged level from the skills interface. + double skillPower = this.getCurrentSkillPower(); + +// b. Multiply the level by the prayer adjustment + double effectiveLevel = skillPower * this.getPrayerBonus(); + +// c. Round down to the nearest integer. + effectiveLevel = Math.floor(effectiveLevel); + +// d. Add the stance bonus from the combat options interface. +// Melee: +// • Aggressive: +3 +// • Controlled: +1 +// Ranged: +// * Accurate: +3 + AttackStyle attackStyle = this.getAttackStyle(); + effectiveLevel += attackStyle.getMaxHitBonus(); + +// e. Add up +8. + effectiveLevel += 8; + +// f. Multiply by the void bonus: +// • Void melee: multiply by 1.10. Round down. +// • Void ranged: multiply by 1.10. Round down. +// • Elite void ranged: multiply by 1.125. Round down. + effectiveLevel = this.applyEquipmentBonus(effectiveLevel, EquipmentBonusConfig.BonusType.VOID_KNIGHT); + +// g. This is the effective (ranged) strength level. Let this equal 'A' in the formula in + return effectiveLevel; + } + + // 3.3 Take the melee or ranged strength bonus from the equipment stats interface and let this equal 'B' in the formula in 3.1. + private double getEquipmentBonus() + { + return this.getSkillStrength(); + } + + /* + * Damage formula based on: + * http://services.runescape.com/m=forum/forums.ws?317,318,712,65587452 + * Section 3.1 + * */ + @Override + public double calculate() + { + +// a. Max hit = 0.5 + A * (B+64) /640 (A is effective level, B is Equipment bonus) + double maxHit = 0.5 + this.getEffectiveLevel() * (this.getEquipmentBonus() + 64) / 640; + +// b. Round down the max hit to the nearest integer. + maxHit = Math.floor(maxHit); + +// 3.4 Special attacks (not actually taking weapon special attacks into account) +// a. Multiply by the bonus of one of the following items (slayer) + maxHit = this.applyEquipmentBonus(maxHit, EquipmentBonusConfig.BonusType.SLAYER); + +// b. Round down the max hit to the nearest integer. + maxHit = Math.floor(maxHit); + +// c. Multiply by the bonus of one of the following items + maxHit = this.applyEquipmentBonus(maxHit, EquipmentBonusConfig.BonusType.SPECIAL); + +// d. Round down to the nearest integer. + maxHit = Math.floor(maxHit); + + return maxHit; + } +} + + diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/RangeMaxHitCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/RangeMaxHitCalculator.java new file mode 100644 index 0000000000..0b397e76d5 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/calculators/RangeMaxHitCalculator.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators; + +import net.runelite.api.Client; +import net.runelite.api.Item; +import net.runelite.api.Skill; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; + +public class RangeMaxHitCalculator extends MeleeMaxHitCalculator +{ + + public RangeMaxHitCalculator(Client client, Item[] equipedItems) + { + super(client, CombatMethod.RANGE, equipedItems); + } + + @Override + protected String getSkillStrengthText(String equipmentText) + { + return equipmentText.replace("Ranged strength: ", "").replace(".", "").replace("%", ""); + } + + @Override + public Widget equipmentSkillPower() + { + return this.client.getWidget(WidgetInfo.EQUIPMENT_RANGED_STRENGTH); + } + + @Override + public double getCurrentSkillPower() + { + return this.client.getBoostedSkillLevel(Skill.RANGED); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/CustomFormulaConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/CustomFormulaConfig.java new file mode 100644 index 0000000000..b050af543d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/CustomFormulaConfig.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.config; + +import net.runelite.api.Client; +import net.runelite.api.EquipmentInventorySlot; +import net.runelite.api.ItemID; +import net.runelite.api.Skill; +import net.runelite.client.plugins.maxhit.calculators.MaxHitCalculator; +import net.runelite.client.plugins.maxhit.equipment.EquipmentItemset; +import net.runelite.client.plugins.maxhit.equipment.EquipmentSlotItem; +import net.runelite.client.plugins.maxhit.requirements.EquipmentItemRequirement; +import net.runelite.client.plugins.maxhit.requirements.EquipmentItemSetRequirement; +import net.runelite.client.plugins.maxhit.requirements.Requirement; +import net.runelite.client.plugins.maxhit.requirements.SpellRequirement; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.function.BiFunction; + +public enum CustomFormulaConfig +{ + + MAGIC_DART( + MaxHitCalculator.CombatMethod.MAGIC, + new ArrayList<>(Arrays.asList( + new EquipmentItemRequirement(new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.SLAYERS_STAFF, + ItemID.SLAYERS_STAFF_E + )))), + new SpellRequirement(SpellBaseDamageConfig.MAGIC_DART) + )), + (client, calculator) -> + { + int magicLevel = client.getBoostedSkillLevel(Skill.MAGIC); + return Math.floor((magicLevel / 10.0) + 10.0); + } + ), + + TRIDENT_OF_SEAS( + MaxHitCalculator.CombatMethod.MAGIC, + new ArrayList<>(Collections.singletonList( + new EquipmentItemRequirement(new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.TRIDENT_OF_THE_SEAS_FULL, + ItemID.TRIDENT_OF_THE_SEAS, + ItemID.TRIDENT_OF_THE_SEAS_E + )))) + )), + (client, calculator) -> + { + int magicLevel = client.getBoostedSkillLevel(Skill.MAGIC); + + int baseDamage = (int) Math.floor(magicLevel / 3.0) - 5; + calculator.setBaseDamage(baseDamage); + + return calculator.calculate(); + } + ), + + TRIDENT_OF_SWAMP( + MaxHitCalculator.CombatMethod.MAGIC, + new ArrayList<>(Collections.singletonList( + new EquipmentItemRequirement(new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.TRIDENT_OF_THE_SWAMP, + ItemID.TRIDENT_OF_THE_SWAMP_E + )))) + )), + (client, calculator) -> + { + int magicLevel = client.getBoostedSkillLevel(Skill.MAGIC); + + int baseDamage = (int) Math.floor(magicLevel / 3.0) - 2; + calculator.setBaseDamage(baseDamage); + + return calculator.calculate(); + } + ), + + SWAMP_LIZARD( + MaxHitCalculator.CombatMethod.MAGIC, + new ArrayList<>(Collections.singletonList( + new EquipmentItemRequirement(new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Collections.singletonList( + ItemID.SWAMP_LIZARD + )))) + )), + (client, calculator) -> + { + int magicLevel = client.getBoostedSkillLevel(Skill.MAGIC); + return Math.floor(0.5 + magicLevel * (64.0 + 56.0) / 640.0); + } + ), + + ORANGE_SALAMANDER( + MaxHitCalculator.CombatMethod.MAGIC, + new ArrayList<>(Collections.singletonList( + new EquipmentItemRequirement(new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Collections.singletonList( + ItemID.ORANGE_SALAMANDER + )))) + )), + (client, calculator) -> + { + int magicLevel = client.getBoostedSkillLevel(Skill.MAGIC); + return Math.floor(0.5 + magicLevel * (64.0 + 59.0) / 640.0); + } + ), + + RED_SALAMANDER( + MaxHitCalculator.CombatMethod.MAGIC, + new ArrayList<>(Collections.singletonList( + new EquipmentItemRequirement(new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Collections.singletonList( + ItemID.RED_SALAMANDER + )))) + )), + (client, calculator) -> + { + int magicLevel = client.getBoostedSkillLevel(Skill.MAGIC); + return Math.floor(0.5 + magicLevel * (64.0 + 77.0) / 640.0); + } + ), + + BLACK_SALAMANDER( + MaxHitCalculator.CombatMethod.MAGIC, + new ArrayList<>(Collections.singletonList( + new EquipmentItemRequirement(new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Collections.singletonList( + ItemID.BLACK_SALAMANDER + )))) + )), + (client, calculator) -> + { + int magicLevel = client.getBoostedSkillLevel(Skill.MAGIC); + return Math.floor(0.5 + magicLevel * (64.0 + 92.0) / 640.0); + } + ), + + DHAROK( + MaxHitCalculator.CombatMethod.MELEE, + new ArrayList<>(Collections.singletonList(new EquipmentItemSetRequirement(new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.DHAROKS_HELM, + ItemID.DHAROKS_HELM_100, + ItemID.DHAROKS_HELM_75, + ItemID.DHAROKS_HELM_50, + ItemID.DHAROKS_HELM_25, + ItemID.DHAROKS_HELM_0 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Arrays.asList( + ItemID.DHAROKS_PLATEBODY, + ItemID.DHAROKS_PLATEBODY_100, + ItemID.DHAROKS_PLATEBODY_75, + ItemID.DHAROKS_PLATEBODY_50, + ItemID.DHAROKS_PLATEBODY_25, + ItemID.DHAROKS_PLATEBODY_0 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Arrays.asList( + ItemID.DHAROKS_PLATELEGS, + ItemID.DHAROKS_PLATELEGS_100, + ItemID.DHAROKS_PLATELEGS_75, + ItemID.DHAROKS_PLATELEGS_50, + ItemID.DHAROKS_PLATELEGS_25, + ItemID.DHAROKS_PLATELEGS_0 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.DHAROKS_GREATAXE, + ItemID.DHAROKS_GREATAXE_100, + ItemID.DHAROKS_GREATAXE_75, + ItemID.DHAROKS_GREATAXE_50, + ItemID.DHAROKS_GREATAXE_25, + ItemID.DHAROKS_GREATAXE_0 + ))) + ))))), + (client, calculator) -> + { + int currentHP = client.getBoostedSkillLevel(Skill.HITPOINTS); + int maxHP = client.getRealSkillLevel(Skill.HITPOINTS); + int lostHP = maxHP - currentHP; + + double initialMaxHit = calculator.calculate(); + + double multiplier = (1.0 + ((lostHP / 100.0) * (maxHP / 100.0))); + + return Math.floor(initialMaxHit * multiplier); + } + ); + + private final MaxHitCalculator.CombatMethod requiredCombatMethod; + private final ArrayList requirements; + private final BiFunction customFormula; + + CustomFormulaConfig(MaxHitCalculator.CombatMethod requiredCombatMethod, ArrayList requirements, BiFunction customFormula) + { + this.requiredCombatMethod = requiredCombatMethod; + this.requirements = requirements; + this.customFormula = customFormula; + } + + public MaxHitCalculator.CombatMethod getRequiredCombatMethod() + { + return requiredCombatMethod; + } + + public BiFunction getCustomFormula() + { + return customFormula; + } + + public ArrayList getRequirements() + { + return this.requirements; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/EquipmentBonusConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/EquipmentBonusConfig.java new file mode 100644 index 0000000000..fce5816c64 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/EquipmentBonusConfig.java @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.config; + +import net.runelite.api.Client; +import net.runelite.api.EquipmentInventorySlot; +import net.runelite.api.ItemID; +import net.runelite.client.plugins.maxhit.calculators.MaxHitCalculator; +import net.runelite.client.plugins.maxhit.equipment.EquipmentCombatBonus; +import net.runelite.client.plugins.maxhit.equipment.EquipmentItemset; +import net.runelite.client.plugins.maxhit.equipment.EquipmentSlotItem; +import net.runelite.client.plugins.maxhit.requirements.AutocastSpellRequirement; +import net.runelite.client.plugins.maxhit.requirements.Requirement; +import net.runelite.client.plugins.maxhit.requirements.SpellBookRequirement; + +import java.util.*; + + +public enum EquipmentBonusConfig +{ + + /* + * Slayer bonus items + */ + BLACKMASK(BonusType.SLAYER, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.BLACK_MASK_10, + ItemID.BLACK_MASK_9, + ItemID.BLACK_MASK_8, + ItemID.BLACK_MASK_7, + ItemID.BLACK_MASK_6, + ItemID.BLACK_MASK_5, + ItemID.BLACK_MASK_4, + ItemID.BLACK_MASK_3, + ItemID.BLACK_MASK_2, + ItemID.BLACK_MASK_1, + ItemID.BLACK_MASK + ))) + )), new EquipmentCombatBonus(((7.0 / 6.0) - 1), 0, 0)), + + SLAYERHELM(BonusType.SLAYER, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.SLAYER_HELMET, + ItemID.BLACK_SLAYER_HELMET, + ItemID.GREEN_SLAYER_HELMET, + ItemID.RED_SLAYER_HELMET, + ItemID.PURPLE_SLAYER_HELMET, + ItemID.TURQUOISE_SLAYER_HELMET, + ItemID.HYDRA_SLAYER_HELMET + ))) + )), new EquipmentCombatBonus(((7.0 / 6.0) - 1), 0, 0)), + + BLACKMASKI(BonusType.SLAYER, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.BLACK_MASK_10_I, + ItemID.BLACK_MASK_9_I, + ItemID.BLACK_MASK_8_I, + ItemID.BLACK_MASK_7_I, + ItemID.BLACK_MASK_6_I, + ItemID.BLACK_MASK_5_I, + ItemID.BLACK_MASK_4_I, + ItemID.BLACK_MASK_3_I, + ItemID.BLACK_MASK_2_I, + ItemID.BLACK_MASK_1_I, + ItemID.BLACK_MASK_I + ))) + )), new EquipmentCombatBonus(((7.0 / 6.0) - 1), 0.15, 0.15)), + + SLAYERHELMI(BonusType.SLAYER, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.SLAYER_HELMET_I, + ItemID.BLACK_SLAYER_HELMET_I, + ItemID.GREEN_SLAYER_HELMET_I, + ItemID.RED_SLAYER_HELMET_I, + ItemID.PURPLE_SLAYER_HELMET_I, + ItemID.TURQUOISE_SLAYER_HELMET_I, + ItemID.HYDRA_SLAYER_HELMET_I + ))) + )), new EquipmentCombatBonus(((7.0 / 6.0) - 1), 0.15, 0.15)), + + /* + * Void bonus items + * */ + MELEEVOID(BonusType.VOID_KNIGHT, new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.VOID_MELEE_HELM, + ItemID.VOID_MELEE_HELM_11676 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Arrays.asList( + ItemID.VOID_KNIGHT_TOP, + ItemID.VOID_KNIGHT_TOP_10611 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Collections.singletonList( + ItemID.VOID_KNIGHT_ROBE + ))), + new EquipmentSlotItem(EquipmentInventorySlot.GLOVES, new ArrayList<>(Collections.singletonList( + ItemID.VOID_KNIGHT_GLOVES + ))) + )), new EquipmentCombatBonus(0.1, 0, 0)), + + RANGERVOID(BonusType.VOID_KNIGHT, new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.VOID_RANGER_HELM, + ItemID.VOID_RANGER_HELM_11675 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Arrays.asList( + ItemID.VOID_KNIGHT_TOP, + ItemID.VOID_KNIGHT_TOP_10611 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Collections.singletonList( + ItemID.VOID_KNIGHT_ROBE + ))), + new EquipmentSlotItem(EquipmentInventorySlot.GLOVES, new ArrayList<>(Collections.singletonList( + ItemID.VOID_KNIGHT_GLOVES + ))) + )), new EquipmentCombatBonus(0, 0.1, 0)), + + + ELITEMELEERVOID(BonusType.VOID_KNIGHT, new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.VOID_MELEE_HELM, + ItemID.VOID_MELEE_HELM_11676 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Collections.singletonList( + ItemID.ELITE_VOID_TOP + ))), + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Collections.singletonList( + ItemID.ELITE_VOID_ROBE + ))), + new EquipmentSlotItem(EquipmentInventorySlot.GLOVES, new ArrayList<>(Collections.singletonList( + ItemID.VOID_KNIGHT_GLOVES + ))) + )), new EquipmentCombatBonus(0.125, 0, 0)), + + + ELITERANGERVOID(BonusType.VOID_KNIGHT, new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.VOID_RANGER_HELM, + ItemID.VOID_RANGER_HELM_11675 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Collections.singletonList( + ItemID.ELITE_VOID_TOP + ))), + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Collections.singletonList( + ItemID.ELITE_VOID_ROBE + ))), + new EquipmentSlotItem(EquipmentInventorySlot.GLOVES, new ArrayList<>(Collections.singletonList( + ItemID.VOID_KNIGHT_GLOVES + ))) + )), new EquipmentCombatBonus(0, 0.125, 0)), + + ELITEMAGICVOID(BonusType.EQUIPMENT, new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Arrays.asList( + ItemID.VOID_MAGE_HELM, + ItemID.VOID_MAGE_HELM_11674 + ))), + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Collections.singletonList( + ItemID.ELITE_VOID_TOP + ))), + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Collections.singletonList( + ItemID.ELITE_VOID_ROBE + ))), + new EquipmentSlotItem(EquipmentInventorySlot.GLOVES, new ArrayList<>(Collections.singletonList( + ItemID.VOID_KNIGHT_GLOVES + ))) + )), new EquipmentCombatBonus(0, 0, 0.025)), + + /* + * Special Melee Equipment + * */ + OBISIDIAN(BonusType.SPECIAL, new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Collections.singletonList( + ItemID.OBSIDIAN_HELMET + ))), + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Collections.singletonList( + ItemID.OBSIDIAN_PLATEBODY + ))), + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Collections.singletonList( + ItemID.OBSIDIAN_PLATELEGS + ))), + new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.TOKTZXILAK, + ItemID.TOKTZXILEK, + ItemID.TZHAARKETEM, + ItemID.TZHAARKETOM, + ItemID.TOKTZXILAK_20554 + ))) + )), new EquipmentCombatBonus(0.1, 0, 0)), + + BERSERKERNECKLACE(BonusType.SPECIAL, new EquipmentItemset(Arrays.asList( + new EquipmentSlotItem(EquipmentInventorySlot.AMULET, new ArrayList<>(Collections.singletonList(ItemID.BERSERKER_NECKLACE))), + new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.TOKTZXILAK, + ItemID.TOKTZXILEK, + ItemID.TZHAARKETEM, + ItemID.TZHAARKETOM, + ItemID.TOKTZXILAK_20554 + ))) + )), new EquipmentCombatBonus(0.2, 0, 0)), + + + /* + * Magic Equipment + */ + ANCESTRAL_HAT(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.HEAD, new ArrayList<>(Collections.singletonList( + ItemID.ANCESTRAL_HAT + ))) + )), new EquipmentCombatBonus(0, 0, 0.02)), + + ANCESTRAL_ROBE_TOP(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.BODY, new ArrayList<>(Collections.singletonList( + ItemID.ANCESTRAL_ROBE_TOP + ))) + )), new EquipmentCombatBonus(0, 0, 0.02)), + + ANCESTRAL_ROBE_BOTTOM(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.LEGS, new ArrayList<>(Collections.singletonList( + ItemID.ANCESTRAL_ROBE_BOTTOM + ))) + )), new EquipmentCombatBonus(0, 0, 0.02)), + + IMBUED_GOD_CAPE(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.CAPE, new ArrayList<>(Arrays.asList( + ItemID.IMBUED_SARADOMIN_MAX_CAPE, + ItemID.IMBUED_SARADOMIN_CAPE, + ItemID.IMBUED_ZAMORAK_MAX_CAPE, + ItemID.IMBUED_ZAMORAK_CAPE, + ItemID.IMBUED_GUTHIX_MAX_CAPE, + ItemID.IMBUED_GUTHIX_CAPE + ))) + )), new EquipmentCombatBonus(0, 0, 0.02)), + + KODAI_WAND(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Collections.singletonList( + ItemID.KODAI_WAND + ))) + )), new EquipmentCombatBonus(0, 0, 0.15)), + + OCCULT_NECKLACE(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.AMULET, new ArrayList<>(Arrays.asList( + ItemID.OCCULT_NECKLACE, + ItemID.OCCULT_NECKLACE_OR + ))) + )), new EquipmentCombatBonus(0, 0, 0.10)), + + STAFF_OF_THE_DEAD(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.STAFF_OF_THE_DEAD, + ItemID.TOXIC_STAFF_OF_THE_DEAD, + ItemID.STAFF_OF_LIGHT + ))) + )), new EquipmentCombatBonus(0, 0, 0.15)), + + TORMENTED_BRACELET(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.GLOVES, new ArrayList<>(Collections.singletonList( + ItemID.TORMENTED_BRACELET + ))) + )), new EquipmentCombatBonus(0, 0, 0.05)), + + SMOKE_STAFF(BonusType.EQUIPMENT, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.WEAPON, new ArrayList<>(Arrays.asList( + ItemID.SMOKE_BATTLESTAFF, + ItemID.MYSTIC_SMOKE_STAFF + ))) + )), new EquipmentCombatBonus(0, 0, 0.10), Collections.singletonList(new SpellBookRequirement(SpellBaseDamageConfig.SpellBook.NORMAL))), + + + /* + * Special magic bonusses + * */ + + CHAOS_GAUNTLETS(BonusType.SPECIAL, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.GLOVES, new ArrayList<>(Collections.singletonList( + ItemID.CHAOS_GAUNTLETS + ))))), + new EquipmentCombatBonus(0, 0, 3), + Collections.singletonList( + new AutocastSpellRequirement(new ArrayList<>(Arrays.asList( + SpellBaseDamageConfig.AIR_BOLT, + SpellBaseDamageConfig.WATER_BOLT, + SpellBaseDamageConfig.EARTH_BOLT, + SpellBaseDamageConfig.FIRE_BOLT + ))) + ), + Operation.ADD + ), + + TOME_OF_FIRE(BonusType.MAGIC_SPECIAL, new EquipmentItemset(Collections.singletonList( + new EquipmentSlotItem(EquipmentInventorySlot.SHIELD, new ArrayList<>(Collections.singletonList( + ItemID.TOME_OF_FIRE + ))))), + new EquipmentCombatBonus(0, 0, 0.5), + Collections.singletonList( + new AutocastSpellRequirement(new ArrayList<>(Arrays.asList( + SpellBaseDamageConfig.FIRE_BLAST, + SpellBaseDamageConfig.FIRE_BOLT, + SpellBaseDamageConfig.FIRE_STRIKE, + SpellBaseDamageConfig.FIRE_SURGE, + SpellBaseDamageConfig.FIRE_WAVE + ))) + ) + ); + + + private static final Map> bonusTypes = new HashMap<>(); + + static + { + for (EquipmentBonusConfig equipmentBonus : values()) + { + BonusType bonusType = equipmentBonus.bonusType; + if (!bonusTypes.containsKey(bonusType)) + { + bonusTypes.put(bonusType, new ArrayList<>()); + } + ArrayList list = bonusTypes.get(bonusType); + list.add(equipmentBonus); + bonusTypes.put(bonusType, list); + } + } + + private final EquipmentItemset itemset; + private BonusType bonusType; + private EquipmentCombatBonus equipmentCombatBonus; + private List requirements = new ArrayList<>(); + private Operation operation = Operation.MULTIPLY; + EquipmentBonusConfig(BonusType bonusType, EquipmentItemset itemset, EquipmentCombatBonus equipmentCombatBonus) + { + this.bonusType = bonusType; + this.itemset = itemset; + this.equipmentCombatBonus = equipmentCombatBonus; + } + EquipmentBonusConfig(BonusType bonusType, EquipmentItemset itemset, EquipmentCombatBonus equipmentCombatBonus, List requirements) + { + this.bonusType = bonusType; + this.itemset = itemset; + this.equipmentCombatBonus = equipmentCombatBonus; + this.requirements = requirements; + } + + EquipmentBonusConfig(BonusType bonusType, EquipmentItemset itemset, EquipmentCombatBonus equipmentCombatBonus, List requirements, Operation operation) + { + this.bonusType = bonusType; + this.itemset = itemset; + this.equipmentCombatBonus = equipmentCombatBonus; + this.requirements = requirements; + this.operation = operation; + } + + public static ArrayList getBonusByType(BonusType bonusType) + { + if (!bonusTypes.containsKey(bonusType)) + { + return new ArrayList<>(); + } + return bonusTypes.get(bonusType); + } + + public EquipmentItemset getItemset() + { + return itemset; + } + + public Operation getOperation() + { + return operation; + } + + public double getBonus(MaxHitCalculator.CombatMethod combatMethod) + { + return this.equipmentCombatBonus.getCombatBonus(combatMethod); + } + + public boolean meetsRequirements(Client client) + { + return requirements.stream().allMatch(requirement -> requirement.meetsRequirements(client)); + } + + public enum BonusType + { + EQUIPMENT, + SLAYER, + VOID_KNIGHT, + SPECIAL, + MAGIC_SPECIAL + } + + public enum Operation + { + ADD, + MULTIPLY + } + +} + diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/PrayerBonusConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/PrayerBonusConfig.java new file mode 100644 index 0000000000..fda776f170 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/PrayerBonusConfig.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.config; + +import net.runelite.api.Varbits; +import net.runelite.client.plugins.maxhit.calculators.MaxHitCalculator; + +public enum PrayerBonusConfig +{ + BURST_OF_STRENGTH(MaxHitCalculator.CombatMethod.MELEE, Varbits.PRAYER_BURST_OF_STRENGTH, 0.05), + SUPERHUMAN_STRENGTH(MaxHitCalculator.CombatMethod.MELEE, Varbits.PRAYER_SUPERHUMAN_STRENGTH, 0.1), + ULTIMATE_STRENGTH(MaxHitCalculator.CombatMethod.MELEE, Varbits.PRAYER_ULTIMATE_STRENGTH, 0.15), + CHIVALRY(MaxHitCalculator.CombatMethod.MELEE, Varbits.PRAYER_CHIVALRY, 0.18), + PIETY(MaxHitCalculator.CombatMethod.MELEE, Varbits.PRAYER_PIETY, 0.23), + + SHARP_EYE(MaxHitCalculator.CombatMethod.RANGE, Varbits.PRAYER_SHARP_EYE, 0.05), + HAWK_EYE(MaxHitCalculator.CombatMethod.RANGE, Varbits.PRAYER_HAWK_EYE, 0.1), + EAGLE_EYE(MaxHitCalculator.CombatMethod.RANGE, Varbits.PRAYER_EAGLE_EYE, 0.15), + RIGOUR(MaxHitCalculator.CombatMethod.RANGE, Varbits.PRAYER_RIGOUR, 0.23); + + private final MaxHitCalculator.CombatMethod combatMethod; + private final Varbits prayerVarbit; + private final double strengthBonus; + + PrayerBonusConfig(MaxHitCalculator.CombatMethod combatMethod, Varbits prayerVarbit, double strengthBonus) + { + this.combatMethod = combatMethod; + this.prayerVarbit = prayerVarbit; + this.strengthBonus = strengthBonus; + } + + public MaxHitCalculator.CombatMethod getCombatMethod() + { + return combatMethod; + } + + public Varbits getPrayerVarbit() + { + return prayerVarbit; + } + + public double getStrengthBonus() + { + return strengthBonus; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/SpellBaseDamageConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/SpellBaseDamageConfig.java new file mode 100644 index 0000000000..cc47af1562 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/config/SpellBaseDamageConfig.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.config; + +import java.util.Arrays; + +public enum SpellBaseDamageConfig +{ + + /* + * Normal Spellbook + * */ + AIR_STRIKE(SpellBook.NORMAL, 1, 2), + WATER_STRIKE(SpellBook.NORMAL, 2, 4), + EARTH_STRIKE(SpellBook.NORMAL, 3, 6), + FIRE_STRIKE(SpellBook.NORMAL, 4, 8), + + AIR_BOLT(SpellBook.NORMAL, 5, 9), + WATER_BOLT(SpellBook.NORMAL, 6, 10), + EARTH_BOLT(SpellBook.NORMAL, 7, 11), + FIRE_BOLT(SpellBook.NORMAL, 8, 12), + + WIND_BLAST(SpellBook.NORMAL, 9, 13), + WATER_BLAST(SpellBook.NORMAL, 10, 14), + EARTH_BLAST(SpellBook.NORMAL, 11, 15), + FIRE_BLAST(SpellBook.NORMAL, 12, 16), + + AIR_WAVE(SpellBook.NORMAL, 13, 17), + WATER_WAVE(SpellBook.NORMAL, 14, 18), + EARTH_WAVE(SpellBook.NORMAL, 15, 19), + FIRE_WAVE(SpellBook.NORMAL, 16, 20), + + AIR_SURGE(SpellBook.NORMAL, 48, 21), + WATER_SURGE(SpellBook.NORMAL, 49, 22), + EARTH_SURGE(SpellBook.NORMAL, 50, 23), + FIRE_SURGE(SpellBook.NORMAL, 51, 24), + + /* + * Ancient Spellbook + * */ + SMOKE_RUSH(SpellBook.ANCIENT, 31, 14), + SHADOW_RUSH(SpellBook.ANCIENT, 32, 15), + BLOOD_RUSH(SpellBook.ANCIENT, 33, 16), + ICE_RUSH(SpellBook.ANCIENT, 34, 17), + + SMOKE_BURST(SpellBook.ANCIENT, 35, 18), + SHADOW_BURST(SpellBook.ANCIENT, 36, 19), + BLOOD_BURST(SpellBook.ANCIENT, 37, 21), + ICE_BURST(SpellBook.ANCIENT, 38, 22), + + SMOKE_BLITZ(SpellBook.ANCIENT, 39, 23), + SHADOW_BLITZ(SpellBook.ANCIENT, 40, 24), + BLOOD_BLITZ(SpellBook.ANCIENT, 41, 25), + ICE_BLITZ(SpellBook.ANCIENT, 42, 26), + + SMOKE_BARRAGE(SpellBook.ANCIENT, 43, 27), + SHADOW_BARRAGE(SpellBook.ANCIENT, 44, 28), + BLOOD_BARRAGE(SpellBook.ANCIENT, 55, 29), + ICE_BARRAGE(SpellBook.ANCIENT, 46, 30), + + /* + * Other spells + * */ + CRUMBLE_UNDEAD(SpellBook.OTHER, 17, 15), + IBAN_BLAST(SpellBook.OTHER, 47, 25), + FLAMES_OF_ZAMAROK(SpellBook.OTHER, 20, 20), + CLAWS_OF_GUTHIX(SpellBook.OTHER, 19, 20), + SARADOMIN_STRIKE(SpellBook.OTHER, 52, 20), + + /* + * Custom Formula spells + * */ + MAGIC_DART(SpellBook.OTHER, 18, 0); + + private final SpellBook spellBook; + private final int spellID; + private final int baseDamage; + + SpellBaseDamageConfig(SpellBook spellBook, int spellID, int baseDamage) + { + this.spellBook = spellBook; + this.spellID = spellID; + this.baseDamage = baseDamage; + } + + public static SpellBaseDamageConfig findSpellById(int spellID) + { + return Arrays.stream(values()).filter(spell -> spell.getSpellID() == spellID).findFirst().orElse(null); + } + + public int getSpellID() + { + return spellID; + } + + public int getBaseDamage() + { + return baseDamage; + } + + public SpellBook getSpellBook() + { + return spellBook; + } + + public enum SpellBook + { + NORMAL, + ANCIENT, + OTHER + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentCombatBonus.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentCombatBonus.java new file mode 100644 index 0000000000..33ca175d4d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentCombatBonus.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.equipment; + +import net.runelite.client.plugins.maxhit.calculators.MaxHitCalculator; + +public class EquipmentCombatBonus +{ + + private final double meleeBonus; + private final double rangeBonus; + private final double magicBonus; + + public EquipmentCombatBonus(double meleeBonus, double rangeBonus, double magicBonus) + { + this.meleeBonus = meleeBonus; + this.rangeBonus = rangeBonus; + this.magicBonus = magicBonus; + } + + public double getCombatBonus(MaxHitCalculator.CombatMethod combatMethod) + { + switch (combatMethod) + { + default: + case MELEE: + return this.meleeBonus; + case RANGE: + return this.rangeBonus; + case MAGIC: + return this.magicBonus; + } + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentHelper.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentHelper.java new file mode 100644 index 0000000000..e13dee215c --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentHelper.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.equipment; + +import net.runelite.api.EquipmentInventorySlot; +import net.runelite.api.Item; + +public class EquipmentHelper +{ + + public static boolean wearsItemSet(Item[] equipedItems, EquipmentItemset itemSet) + { + return itemSet.getItems().stream().allMatch(item -> wearsItem(equipedItems, item)); + } + + private static boolean wearsItem(Item[] equipedItems, EquipmentInventorySlot slot, int itemId) + { + Item item = equipedItems[slot.getSlotIdx()]; + if (item == null) + { + return false; + } + return item.getId() == itemId; + } + + public static boolean wearsItem(Item[] equipedItems, EquipmentSlotItem equipmentSlotItem) + { + return equipmentSlotItem.getItems().stream().anyMatch(itemId -> + wearsItem(equipedItems, equipmentSlotItem.getEquipmentSlot(), itemId) + ); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentItemset.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentItemset.java new file mode 100644 index 0000000000..12c295443f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentItemset.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.equipment; + +import java.util.List; + +public class EquipmentItemset +{ + private final List items; + + public EquipmentItemset(List items) + { + this.items = items; + } + + public List getItems() + { + return items; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentSlotItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentSlotItem.java new file mode 100644 index 0000000000..dbc44b3a53 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/equipment/EquipmentSlotItem.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.equipment; + +import net.runelite.api.EquipmentInventorySlot; + +import java.util.ArrayList; + +public class EquipmentSlotItem +{ + private final EquipmentInventorySlot equipmentSlot; + private final ArrayList itemIds; + + public EquipmentSlotItem(EquipmentInventorySlot equipmentSlot, ArrayList itemIds) + { + this.equipmentSlot = equipmentSlot; + this.itemIds = itemIds; + } + + public ArrayList getItems() + { + return this.itemIds; + } + + public EquipmentInventorySlot getEquipmentSlot() + { + return this.equipmentSlot; + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/queries/WidgetItemQuery.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/AutocastSpellRequirement.java similarity index 62% rename from runelite-api/src/main/java/net/runelite/api/queries/WidgetItemQuery.java rename to runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/AutocastSpellRequirement.java index 9a71a9bf3c..988e459631 100644 --- a/runelite-api/src/main/java/net/runelite/api/queries/WidgetItemQuery.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/AutocastSpellRequirement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Devin French + * Copyright (c) 2019, Bartvollebregt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,53 +22,37 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.api.queries; +package net.runelite.client.plugins.maxhit.requirements; import net.runelite.api.Client; -import net.runelite.api.Query; -import net.runelite.api.widgets.WidgetItem; +import net.runelite.api.Varbits; +import net.runelite.client.plugins.maxhit.config.SpellBaseDamageConfig; -public abstract class WidgetItemQuery extends Query +import java.util.ArrayList; + +public class AutocastSpellRequirement implements Requirement { - public WidgetItemQuery idEquals(int... ids) - { - predicate = and(item -> - { - for (int id : ids) - { - if (item.getId() == id) - { - return true; - } - } - return false; - }); - return this; - } + private final ArrayList autocastSpells; - public WidgetItemQuery indexEquals(int... indexes) + public AutocastSpellRequirement(ArrayList autocastSpells) { - predicate = and(item -> - { - for (int index : indexes) - { - if (item.getIndex() == index) - { - return true; - } - } - return false; - }); - return this; - } - - public WidgetItemQuery quantityEquals(int quantity) - { - predicate = and(item -> item.getQuantity() == quantity); - return this; + this.autocastSpells = autocastSpells; } @Override - public abstract WidgetItem[] result(Client client); + public boolean meetsRequirements(Client client) + { + int autoCastSpellId = client.getVar(Varbits.AUTO_CAST_SPELL); + + if (autoCastSpellId == 0) + { + + return false; + + } + + return this.autocastSpells.stream().anyMatch(spell -> spell.getSpellID() == autoCastSpellId); + + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/EquipmentItemRequirement.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/EquipmentItemRequirement.java new file mode 100644 index 0000000000..d0ed360f43 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/EquipmentItemRequirement.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.requirements; + +import net.runelite.api.Client; +import net.runelite.api.InventoryID; +import net.runelite.api.Item; +import net.runelite.api.ItemContainer; +import net.runelite.client.plugins.maxhit.equipment.EquipmentHelper; +import net.runelite.client.plugins.maxhit.equipment.EquipmentSlotItem; + +public class EquipmentItemRequirement implements Requirement +{ + private final EquipmentSlotItem item; + + public EquipmentItemRequirement(EquipmentSlotItem item) + { + this.item = item; + } + + @Override + public boolean meetsRequirements(Client client) + { + ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT); + if (equipmentContainer == null) + { + return false; + } + Item[] equipedItems = equipmentContainer.getItems(); + return EquipmentHelper.wearsItem(equipedItems, this.item); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/EquipmentItemSetRequirement.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/EquipmentItemSetRequirement.java new file mode 100644 index 0000000000..31b322c02d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/EquipmentItemSetRequirement.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.requirements; + +import net.runelite.api.Client; +import net.runelite.api.InventoryID; +import net.runelite.api.Item; +import net.runelite.api.ItemContainer; +import net.runelite.client.plugins.maxhit.equipment.EquipmentHelper; +import net.runelite.client.plugins.maxhit.equipment.EquipmentItemset; + +public class EquipmentItemSetRequirement implements Requirement +{ + private final EquipmentItemset itemSet; + + public EquipmentItemSetRequirement(EquipmentItemset itemSet) + { + this.itemSet = itemSet; + } + + @Override + public boolean meetsRequirements(Client client) + { + ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT); + if (equipmentContainer == null) + { + return false; + } + Item[] equipedItems = equipmentContainer.getItems(); + + return EquipmentHelper.wearsItemSet(equipedItems, this.itemSet); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/util/QueryRunner.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/Requirement.java similarity index 78% rename from runelite-client/src/main/java/net/runelite/client/util/QueryRunner.java rename to runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/Requirement.java index 0f34fc5448..48e9cc677a 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/QueryRunner.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/Requirement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Tomas Slusny + * Copyright (c) 2019, Bartvollebregt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,22 +22,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.util; +package net.runelite.client.plugins.maxhit.requirements; -import javax.inject.Inject; -import javax.inject.Singleton; import net.runelite.api.Client; -import net.runelite.api.Query; -@Singleton -public class QueryRunner +public interface Requirement { - @Inject - private Client client; - - @SuppressWarnings("unchecked") - public T[] runQuery(Query query) - { - return (T[]) query.result(client); - } -} \ No newline at end of file + boolean meetsRequirements(Client client); +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/SpellBookRequirement.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/SpellBookRequirement.java new file mode 100644 index 0000000000..d59723577e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/SpellBookRequirement.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.requirements; + +import net.runelite.api.Client; +import net.runelite.api.Varbits; +import net.runelite.client.plugins.maxhit.config.SpellBaseDamageConfig; + +public class SpellBookRequirement implements Requirement +{ + private final SpellBaseDamageConfig.SpellBook spellBook; + + public SpellBookRequirement(SpellBaseDamageConfig.SpellBook spellBook) + { + this.spellBook = spellBook; + } + + @Override + public boolean meetsRequirements(Client client) + { + int autoCastSpellId = client.getVar(Varbits.AUTO_CAST_SPELL); + if (autoCastSpellId == 0) + { + return false; + } + + SpellBaseDamageConfig autoCastSpell = SpellBaseDamageConfig.findSpellById(autoCastSpellId); + return autoCastSpell.getSpellBook() == this.spellBook; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/SpellRequirement.java b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/SpellRequirement.java new file mode 100644 index 0000000000..4084044048 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/maxhit/requirements/SpellRequirement.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.requirements; + +import net.runelite.api.Client; +import net.runelite.api.Varbits; +import net.runelite.client.plugins.maxhit.config.SpellBaseDamageConfig; + +public class SpellRequirement implements Requirement +{ + private final SpellBaseDamageConfig spellBaseDamageConfig; + + public SpellRequirement(SpellBaseDamageConfig spellBaseDamageConfig) + { + this.spellBaseDamageConfig = spellBaseDamageConfig; + } + + @Override + public boolean meetsRequirements(Client client) + { + int autoCastSpellId = client.getVar(Varbits.AUTO_CAST_SPELL); + if (autoCastSpellId == 0) + { + return false; + } + + return autoCastSpellId == this.spellBaseDamageConfig.getSpellID(); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index e60824686c..cb68438e51 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2018, Adam * All rights reserved. @@ -192,35 +193,11 @@ public interface MenuEntrySwapperConfig extends Config return true; } - @ConfigItem( - keyName = "swapBlackjack", - name = "Blackjacking", - description = "Requires \"The Fued\" quest completed." - ) - - default boolean swapBlackjack() {return false; } - - - @ConfigItem( - keyName = "setDelay", - name = "Blackjacking Delay", - description = "Sets the delay for how long you can pickpocket after knocking target out in milliseconds" - ) - default int setDelay() - { - return 2000; - } - - @ConfigItem( keyName = "swapPay", name = "Pay", description = "Swap Talk-to with Pay on NPC
Example: Elstan, Heskel, Fayeth" ) - - - - default boolean swapPay() { return true; @@ -305,4 +282,14 @@ public interface MenuEntrySwapperConfig extends Config { return true; } -} + + @ConfigItem( + keyName = "swapRogueschests", + name = "Rogueschests", + description = "Swap Rogueschests from open to Search for traps" + ) + default boolean swapRogueschests() + { + return true; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java index 0ff5e23915..d051028e5b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperPlugin.java @@ -31,8 +31,19 @@ import java.util.Set; import javax.inject.Inject; import lombok.Getter; import lombok.Setter; -import net.runelite.api.*; -import net.runelite.api.events.*; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.ItemComposition; +import net.runelite.api.MenuAction; +import net.runelite.api.MenuEntry; +import net.runelite.api.NPC; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.FocusChanged; +import net.runelite.api.events.MenuEntryAdded; +import net.runelite.api.events.MenuOpened; +import net.runelite.api.events.MenuOptionClicked; +import net.runelite.api.events.PostItemComposition; +import net.runelite.api.events.WidgetMenuOptionClicked; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; @@ -48,7 +59,7 @@ import net.runelite.client.util.Text; import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( - name = "!Menu Entry Swapper", + name = "Menu Entry Swapper", description = "Change the default option that is displayed when hovering over objects", tags = {"npcs", "inventory", "items", "objects"}, enabledByDefault = false @@ -89,9 +100,6 @@ public class MenuEntrySwapperPlugin extends Plugin MenuAction.NPC_FIFTH_OPTION, MenuAction.EXAMINE_NPC); - private static long timeSinceKnockout; - private static long timeSinceAggro; - @Inject private Client client; @@ -363,19 +371,6 @@ public class MenuEntrySwapperPlugin extends Plugin return; } - if (config.swapBlackjack() && (target.contains("bandit") | target.contains("menaphite thug"))) { - Quest quest = Quest.THE_FEUD; - if (quest.getState(client) == QuestState.FINISHED) { - if (System.currentTimeMillis() < (timeSinceKnockout + config.setDelay())) { - swap("pickpocket", option, target, true); - } - if (System.currentTimeMillis() < (timeSinceAggro + 1300)) { - swap("pickpocket", option, target, true); - } - swap("knock-out", option, target, true); - } - } - if (option.equals("talk-to")) { if (config.swapPickpocket() && target.contains("h.a.m.")) @@ -549,6 +544,10 @@ public class MenuEntrySwapperPlugin extends Plugin { swap("pick-lots", option, target, true); } + else if (config.swapRogueschests() && target.contains("chest")) + { + swap("search for traps", option, target, true); + } else if (config.shiftClickCustomization() && shiftModifier && !option.equals("use")) { Integer customOption = getSwapConfig(eventId); @@ -598,17 +597,6 @@ public class MenuEntrySwapperPlugin extends Plugin } } - @Subscribe - public void onChatMessage(ChatMessage event) { - if (event.getType() == ChatMessageType.SPAM) { - if (event.getMessage().contains("ou smack the bandit over the head and render them unconsci")) { - timeSinceKnockout = System.currentTimeMillis(); - } else if (event.getMessage().contains("our blow only glances off the bandi")) { - timeSinceAggro = System.currentTimeMillis(); - } - } - } - private int searchIndex(MenuEntry[] entries, String option, String target, boolean strict) { for (int i = entries.length - 1; i >= 0; i--) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menumodifier/MenuModifierPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/menumodifier/MenuModifierPlugin.java index dc5b9e7a27..fedf163a55 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menumodifier/MenuModifierPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menumodifier/MenuModifierPlugin.java @@ -25,10 +25,11 @@ import java.util.Iterator; import java.util.List; @PluginDescriptor( - name = "!Menu Modifier", + name = "Menu Modifier", description = "Changes right click menu for players", tags = { "menu", "modifier", "right", "click", "pk", "bogla" }, - enabledByDefault = false + enabledByDefault = false, + type = "utility" ) public class MenuModifierPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MinedRock.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MinedRock.java deleted file mode 100644 index e970077dfa..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MinedRock.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import lombok.AccessLevel; -import lombok.Getter; - -public class MinedRock -{ - - @Getter(AccessLevel.PACKAGE) - private final MiningRockType type; - - private final long minRespawnTime, maxRespawnTime; - - public MinedRock(MiningRockType type, boolean halve) - { - this.type = type; - this.minRespawnTime = System.currentTimeMillis() + (int)((halve ? type.getMinRespawnTime() / 2 : type.getMinRespawnTime()) * 1000); - this.maxRespawnTime = type.getMaxRespawnTime() == -1 ? -1 : System.currentTimeMillis() + (int)((halve ? type.getMaxRespawnTime() / 2 : type.getMaxRespawnTime()) * 1000); - } - - public int getMinSecondsUntilRespawn(boolean allowNegative) - { - long remaining = minRespawnTime - System.currentTimeMillis(); - if (remaining > 0 || allowNegative) - { - return (int) (remaining / 1000) + (remaining % 1000 > 0 ? 1 : 0); - } - else - { - return (maxRespawnTime > minRespawnTime) ? 0 : 1; - } - } - - public int getMaxSecondsUntilRespawn() - { - if (maxRespawnTime == -1) - { - return -1; - } - long remaining = maxRespawnTime - System.currentTimeMillis(); - if (remaining > 0 && maxRespawnTime > minRespawnTime) - { - return (int) (remaining / 1000) + (remaining % 1000 > 0 ? 1 : 0); - } - else - { - // Return -1 if the ore does not have a maximum respawn time (no range) - return 1; - } - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java deleted file mode 100644 index 960542aff0..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("miningplugin") -public interface MiningConfig extends Config -{ - - @ConfigItem( - position = 1, - keyName = "statTimeout", - name = "Reset stats (minutes)", - description = "The time until mining session data is reset in minutes." - ) - default int statTimeout() - { - return 5; - } - - @ConfigItem( - position = 2, - keyName = "showRespawn", - name = "Show ore respawn timers", - description = "If the amount of seconds left until a ore respawns should be shown." - ) - default boolean showRespawnTimer() - { - return true; - } - - @ConfigItem( - position = 3, - keyName = "showAllRespawns", - name = "Show timers for every ore", - description = "Show timers for every ore mined in your nearby vicinity" - ) - default boolean showAllRespawnTimers() - { - return false; - } - - @ConfigItem( - position = 4, - keyName = "showMiningStats", - name = "Show mining session stats", - description = "Configures whether to display mining session stats" - ) - default boolean showMiningStats() - { - return true; - } - - @ConfigItem( - position = 5, - keyName = "showMiningState", - name = "Show current mining state", - description = "Shows current mining state. 'You are currently mining' / 'You are currently NOT mining'" - ) - default boolean showMiningState() - { - return true; - } - - @ConfigItem( - position = 6, - keyName = "disableInMLM", - name = "Disable in MLM", - description = "Disables the trackers if you're in the motherloade mine" - ) - default boolean disableInMLM() - { - return true; - } - - @ConfigItem( - position = 7, - keyName = "trackWorldRock", - name = "World Tracker", - description = "Tracks the respawn time of a certain ore as you switch worlds" - ) - default MiningRockType.WorldRock trackWorldRock() - { - return MiningRockType.WorldRock.None; - } - - @ConfigItem( - position = 8, - keyName = "trackTimeout", - name = "Stop tracking (seconds)", - description = "The time a world will keep on displaying after the ore has respawned in seconds" - ) - default int trackTimeout() - { - return 60; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java deleted file mode 100644 index bf19cb9bb1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import com.google.common.collect.ImmutableSet; -import static net.runelite.api.AnimationID.MINING_3A_PICKAXE; -import static net.runelite.api.AnimationID.MINING_ADAMANT_PICKAXE; -import static net.runelite.api.AnimationID.MINING_BLACK_PICKAXE; -import static net.runelite.api.AnimationID.MINING_BRONZE_PICKAXE; -import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE; -import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE_ORN; -import static net.runelite.api.AnimationID.MINING_INFERNAL_PICKAXE; -import static net.runelite.api.AnimationID.MINING_IRON_PICKAXE; -import static net.runelite.api.AnimationID.MINING_MITHRIL_PICKAXE; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_ADAMANT; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BLACK; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BRONZE; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_DRAGON; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_DRAGON_ORN; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_INFERNAL; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_IRON; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_MITHRIL; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_RUNE; -import static net.runelite.api.AnimationID.MINING_MOTHERLODE_STEEL; -import static net.runelite.api.AnimationID.MINING_RUNE_PICKAXE; -import static net.runelite.api.AnimationID.MINING_STEEL_PICKAXE; -import net.runelite.api.Client; -import net.runelite.client.game.SkillIconManager; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; -import javax.inject.Inject; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.time.Duration; -import java.time.Instant; -import java.util.Set; - -/** - * Displays information about the players current mining state and rocks mined - */ -public class MiningOverlay extends Overlay -{ - - private static final Set MINING_ANIMATION_IDS = ImmutableSet.of( - MINING_3A_PICKAXE, MINING_ADAMANT_PICKAXE, MINING_BLACK_PICKAXE, - MINING_BRONZE_PICKAXE, MINING_DRAGON_PICKAXE, MINING_DRAGON_PICKAXE_ORN, - MINING_INFERNAL_PICKAXE, MINING_IRON_PICKAXE, MINING_MITHRIL_PICKAXE, - MINING_RUNE_PICKAXE, MINING_STEEL_PICKAXE, MINING_MOTHERLODE_BRONZE, - MINING_MOTHERLODE_IRON, MINING_MOTHERLODE_STEEL, MINING_MOTHERLODE_BLACK, - MINING_MOTHERLODE_MITHRIL, MINING_MOTHERLODE_ADAMANT, MINING_MOTHERLODE_RUNE, - MINING_MOTHERLODE_DRAGON, MINING_MOTHERLODE_DRAGON_ORN, MINING_MOTHERLODE_INFERNAL - ); - - private final MiningConfig config; - private final Client client; - private final MiningPlugin plugin; - private final PanelComponent panelComponent = new PanelComponent(); - - @Inject - MiningOverlay(Client client, MiningPlugin plugin, MiningConfig config, SkillIconManager iconManager) - { - setPosition(OverlayPosition.TOP_LEFT); - this.client = client; - this.config = config; - this.plugin = plugin; - } - - @Override - public Dimension render(Graphics2D graphics) - { - // Prevents conflicts with the motherloade plugin - if (config.disableInMLM() && plugin.isInMlm()) - { - return null; - } - - panelComponent.getChildren().clear(); - - if (config.showMiningState()) - { - if (MINING_ANIMATION_IDS.contains(client.getLocalPlayer().getAnimation())) - { - panelComponent.getChildren().add(TitleComponent.builder() - .text("Mining") - .color(Color.GREEN) - .build()); - } - else - { - panelComponent.getChildren().add(TitleComponent.builder() - .text("NOT mining") - .color(Color.RED) - .build()); - } - } - - MiningSession session = plugin.getSession(); - if (session.getLastMined() != null) - { - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); - Duration sinceCut = Duration.between(session.getLastMined(), Instant.now()); - if (sinceCut.compareTo(statTimeout) < 0) - { - if (config.showMiningStats()) - { - for (MiningRockType rock : MiningRockType.values()) - { - if (session.showRockRespawnTimes(rock)) - { - panelComponent.getChildren().add(LineComponent.builder() - .left(rock.getName() + " mined:") - .right(Integer.toString(session.getSessionStats().get(rock).getTotalMined())) - .build()); - panelComponent.getChildren().add(LineComponent.builder() - .left(rock.getName() + "/hr:") - .right(session.getSessionStats().get(rock).getRecentMined() > 2 ? Integer.toString(session.getSessionStats().get(rock).getPerHour()) : "") - .build()); - } - } - } - if (panelComponent.getChildren().size() > 0) - { - return panelComponent.render(graphics); - } - } - } - return null; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java deleted file mode 100644 index 4414464636..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningPlugin.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Provides; -import lombok.AccessLevel; -import lombok.Getter; -import net.runelite.api.ChatMessageType; -import net.runelite.api.Client; -import net.runelite.api.Experience; -import net.runelite.api.GameObject; -import net.runelite.api.GameState; -import net.runelite.api.Skill; -import net.runelite.api.TileObject; -import net.runelite.api.WallObject; -import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.ChatMessage; -import net.runelite.api.events.ConfigChanged; -import net.runelite.api.events.ExperienceChanged; -import net.runelite.api.events.GameObjectDespawned; -import net.runelite.api.events.GameObjectSpawned; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.WallObjectDespawned; -import net.runelite.api.events.WallObjectSpawned; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.task.Schedule; -import net.runelite.client.ui.overlay.OverlayManager; -import javax.inject.Inject; -import java.time.Duration; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.HashMap; -import java.util.Set; - -@PluginDescriptor( - name = "Mining", - description = "Show helpful information when mining", - tags = {"mining", "mine"}, - enabledByDefault = false -) -public class MiningPlugin extends Plugin -{ - - @Inject - private OverlayManager overlayManager; - - @Inject - MiningRockOverlay oreOverlay; - - @Inject - MiningWorldHopperOverlay worldHopperOverlay; - - @Inject - MiningOverlay miningOverlay; - - @Inject - MiningConfig config; - - @Inject - private Client client; - - @Getter(AccessLevel.PACKAGE) - private int miningLevel; - - @Getter(AccessLevel.PACKAGE) - private final HashMap ores = new HashMap<>(); - - @Provides - MiningConfig getConfig(ConfigManager configManager) - { - return configManager.getConfig(MiningConfig.class); - } - - @Getter(AccessLevel.PACKAGE) - private MiningSession session; - - @Getter(AccessLevel.PUBLIC) - private MiningWorldTracker miningTracker; - - private static final Set MOTHERLODE_MAP_REGIONS = ImmutableSet.of(14679, 14680, 14681, 14935, 14936, 14937, 15191, 15192, 15193); - private static final int P2P_MINING_GUILD_REGION = 12183; - private final static int MINING_GUILD_RESPAWN_RATE_HALVE_Y = 9727; - - @Override - protected void startUp() - { - overlayManager.add(miningOverlay); - overlayManager.add(oreOverlay); - overlayManager.add(worldHopperOverlay); - session = new MiningSession(); - if (config.trackWorldRock() != MiningRockType.WorldRock.None) - { - miningTracker = new MiningWorldTracker(config.trackWorldRock()); - } - else - { - miningTracker = null; - } - } - - @Override - protected void shutDown() throws Exception - { - overlayManager.remove(miningOverlay); - overlayManager.remove(oreOverlay); - overlayManager.remove(worldHopperOverlay); - ores.clear(); - miningLevel = Experience.getLevelForXp(client.getSkillExperience(Skill.MINING)); - session = null; - miningTracker = null; - } - - @Subscribe - public void onConfigChanged(ConfigChanged event) - { - if (event.getKey().equals("trackWorldRock")) - { - MiningRockType.WorldRock worldRock = config.trackWorldRock(); - if (worldRock == MiningRockType.WorldRock.None) - { - miningTracker = null; - } - else - { - miningTracker = new MiningWorldTracker(config.trackWorldRock()); - } - } - } - - @Subscribe - public void onGameObjectSpawned(GameObjectSpawned event) - { - GameObject object = event.getGameObject(); - MiningRockType rock = MiningRockType.getTypeFromID(object.getId()); - if (rock != null) - { - for (TileObject o : ores.keySet()) - { - if (o.getX() == object.getX() && o.getY() == object.getY()) - { - // Remove ground rock as it has respawned - ores.remove(o); - break; - } - } - } - } - - @Subscribe - public void onGameObjectDespawned(GameObjectDespawned event) - { - Duration timeSinceStart = Duration.between(session.getIgnoreSpawn(), Instant.now()); - // Ignore anything spawned within 1 second of logging in or changing regions (prevents timers appearing on already mined rocks) - if (timeSinceStart.getSeconds() > 1) - { - GameObject object = event.getGameObject(); - MiningRockType rock = MiningRockType.getTypeFromID(object.getId()); - if (rock != null && miningLevel >= rock.getRequiredMiningLevel()) - { - if (!ores.containsKey(object)) - { - ores.put(object, new MinedRock(rock, isInMiningGuildPay2Play(object.getWorldLocation()))); - } - } - } - } - - @Subscribe - public void onWallObjectSpawned(WallObjectSpawned event) - { - Duration timeSinceStart = Duration.between(session.getIgnoreSpawn(), Instant.now()); - // Ignore anything spawned within 1 second of logging in or changing regions (prevents timers appearing on already mined rocks) - if (timeSinceStart.getSeconds() > 1) - { - WallObject object = event.getWallObject(); - MiningRockType rock = MiningRockType.getTypeFromID(object.getId()); - if (rock != null && miningLevel >= rock.getRequiredMiningLevel()) - { - if (!ores.containsKey(object)) - { - ores.put(object, new MinedRock(rock, isInMiningGuildPay2Play(object.getWorldLocation()))); - } - } - } - } - - @Subscribe - public void onWallObjectDespawned(WallObjectDespawned event) - { - WallObject object = event.getWallObject(); - MiningRockType rock = MiningRockType.getTypeFromID(object.getId()); - if (rock != null) - { - for (TileObject o : ores.keySet()) - { - if (o.getX() == object.getX() && o.getY() == object.getY()) - { - // Remove wall rock as it has respawned - ores.remove(o); - break; - } - } - } - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - GameState state = event.getGameState(); - if (state == GameState.HOPPING) - { - MiningRockType.WorldRock worldRock = config.trackWorldRock(); - if (worldRock != MiningRockType.WorldRock.None) - { - int world = client.getWorld(); - for (TileObject rock : ores.keySet()) - { - if (worldRock.getRockType() == ores.get(rock).getType()) - { - // If the type matches the multi-world rock then add to the mining tracker for this world - miningTracker.addTracked(world, rock, ores.get(rock)); - } - } - } - } - else if (state == GameState.LOADING) - { - ores.clear(); - session.setIgnoreSpawn(Instant.now()); - } - else if (state == GameState.LOGGED_IN) - { - int world = client.getWorld(); - if (miningTracker != null && miningTracker.getTrackedWorlds().containsKey(world)) - { - MiningWorld track = miningTracker.getTrackedWorlds().get(world); - track.clearNegativeRespawnTimes(); - // Load all the tracked ores in this world into the current session. Causing their respawn times to be rendered - for (TileObject o : track.getRocks().keySet()) - { - ores.put(o, track.getRocks().get(o)); - } - // We're on this world now, so don't track it in the world tracker anymore - miningTracker.getTrackedWorlds().remove(world); - } - } - } - - @Subscribe - public void onExperienceChanged(ExperienceChanged event) - { - if (event.getSkill() == Skill.MINING) - { - miningLevel = Experience.getLevelForXp(client.getSkillExperience(Skill.MINING)); - } - } - - @Subscribe - public void onChatMessage(ChatMessage event) - { - if (event.getType() != ChatMessageType.SPAM) - { - return; - } - if (event.getMessage().startsWith("You manage to mine some")) - { - String oreName = event.getMessage().substring(24).replace(".", ""); - MiningRockType rock = MiningRockType.getTypeFromName(oreName); - if (rock != null) - { - session.increaseRockMine(rock); - } - - } - } - - @Schedule( - period = 1, - unit = ChronoUnit.SECONDS - ) - public void checkIsMining() - { - for (MiningRockType rock : MiningRockType.values()) - { - if (session.getSessionStats().get(rock).getLastOreMined() != null) - { - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); - Duration sinceMined = Duration.between(session.getSessionStats().get(rock).getLastOreMined(), Instant.now()); - if (sinceMined.compareTo(statTimeout) >= 0) - { - session.clearSessionFor(rock); - } - } - } - } - - public boolean isInMlm() - { - if (client.getGameState() != GameState.LOGGED_IN) - { - return false; - } - - int[] currentMapRegions = client.getMapRegions(); - // Verify that all regions exist in MOTHERLODE_MAP_REGIONS - for (int region : currentMapRegions) - { - if (!MOTHERLODE_MAP_REGIONS.contains(region)) - { - return false; - } - } - - return true; - } - - public boolean isInMiningGuildPay2Play(WorldPoint point) - { - if (client.getGameState() != GameState.LOGGED_IN) - { - return false; - } - - int[] currentMapRegions = client.getMapRegions(); - for (int region : currentMapRegions) - { - if (region == P2P_MINING_GUILD_REGION) - { - return (point.getY() <= MINING_GUILD_RESPAWN_RATE_HALVE_Y); - } - } - return false; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRockOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRockOverlay.java deleted file mode 100644 index 492e79b276..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRockOverlay.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import net.runelite.api.Client; -import net.runelite.api.Perspective; -import net.runelite.api.Player; -import net.runelite.api.Point; -import net.runelite.api.TileObject; -import net.runelite.api.coords.LocalPoint; -import net.runelite.client.game.SkillIconManager; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import javax.inject.Inject; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import net.runelite.client.ui.overlay.OverlayPosition; - -/** - * Displays respawn timers over rocks - */ -public class MiningRockOverlay extends Overlay -{ - - private static final int MAX_DISTANCE = 2350; - - private final MiningConfig config; - private final Client client; - private final MiningPlugin plugin; - - @Inject - MiningRockOverlay(Client client, MiningPlugin plugin, MiningConfig config, SkillIconManager iconManager) - { - setPosition(OverlayPosition.DYNAMIC); - setLayer(OverlayLayer.ABOVE_SCENE); - this.client = client; - this.config = config; - this.plugin = plugin; - } - - @Override - public Dimension render(Graphics2D graphics) - { - Player local = client.getLocalPlayer(); - if (config.showRespawnTimer()) - { - renderRespawnTimers(graphics, local); - } - return null; - } - - private void renderRespawnTimers(Graphics2D graphics, Player local) - { - LocalPoint localLocation = local.getLocalLocation(); - for (TileObject ore : plugin.getOres().keySet()) - { - MinedRock rock = plugin.getOres().get(ore); - if ((config.showAllRespawnTimers() || plugin.getSession().showRockRespawnTimes(rock.getType())) && localLocation.distanceTo(ore.getLocalLocation()) <= MAX_DISTANCE) - { - // Check if we should display this rock to the user. Checks if the user has mined the rock within this session (or has all on within config) & is within range - renderRespawnTimerRock(graphics, ore, rock.getMinSecondsUntilRespawn(false), rock.getMaxSecondsUntilRespawn(), rock.getType().isGroundObject()); - } - } - } - - /** - * Renders a rocks respawn time - * @param rock The rock - * @param time Time until the rock respawns (minimum) - * @param max Maximum time until the rock respawns (-1 = no range) - * @param ground If the rock is on the ground (true = ground, false = wall) - used to offset the respawn time text - */ - private void renderRespawnTimerRock(Graphics2D graphics, TileObject rock, int time, int max, boolean ground) - { - Point canvasLoc = Perspective.getCanvasTextLocation(client, graphics, rock.getLocalLocation(), "" + time, ground ? 0 : 150); - if (canvasLoc != null) - { - String timeMessage = "" + time; - // Check if this rock has a respawn time range - if (max != -1) - { - // Check if the rock has reached the minimum respawn time - if (time <= 0) - { - // Display the maximum possible time remaining - timeMessage = "~" + max; - graphics.setColor(Color.CYAN); - } - else - { - // Rock has not yet reached the minimum respawn time of the range - timeMessage += "~"; - } - - } - graphics.drawString(timeMessage, canvasLoc.getX(), canvasLoc.getY()); - graphics.setColor(Color.WHITE); - } - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRockType.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRockType.java deleted file mode 100644 index e094fc66c4..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningRockType.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import static net.runelite.api.ObjectID.EMPTY_WALL; -import static net.runelite.api.ObjectID.ROCKS_7453; -import static net.runelite.api.ObjectID.ROCKS_7455; -import static net.runelite.api.ObjectID.ROCKS_7456; -import static net.runelite.api.ObjectID.ROCKS_7457; -import static net.runelite.api.ObjectID.ROCKS_7458; -import static net.runelite.api.ObjectID.ROCKS_7459; -import static net.runelite.api.ObjectID.ROCKS_7460; -import static net.runelite.api.ObjectID.ROCKS_7461; -import static net.runelite.api.ObjectID.ROCKS_7484; -import static net.runelite.api.ObjectID.ROCKS_7485; -import static net.runelite.api.ObjectID.ROCKS_7486; -import static net.runelite.api.ObjectID.ROCKS_7488; -import static net.runelite.api.ObjectID.ROCKS_7489; -import static net.runelite.api.ObjectID.ROCKS_7490; -import static net.runelite.api.ObjectID.ROCKS_7491; -import static net.runelite.api.ObjectID.ROCKS_7492; -import static net.runelite.api.ObjectID.ROCKS_7493; -import static net.runelite.api.ObjectID.ROCKS_7494; -import static net.runelite.api.ObjectID.DEPLETED_VEIN_26665; -import static net.runelite.api.ObjectID.DEPLETED_VEIN_26666; -import static net.runelite.api.ObjectID.DEPLETED_VEIN_26667; -import static net.runelite.api.ObjectID.DEPLETED_VEIN_26668; - -/** - * All the possible rock types the user can mine. - */ -@AllArgsConstructor -public enum MiningRockType -{ - - COPPER("Copper", 1, 2.5, -1, false, true, new int[] {ROCKS_7453, ROCKS_7484}), - TIN("Tin", 1, 2.5, -1, false, true, new int[] {ROCKS_7485, ROCKS_7486}), - IRON( "Iron", 15, 5.5, -1, false, true, new int[] {ROCKS_7455, ROCKS_7488}), - SILVER("Silver", 15, 60, -1, false, true, new int[] {ROCKS_7457, ROCKS_7490}), - COAL("Coal", 30, 29.5, -1, false, true, new int[] {ROCKS_7456, ROCKS_7489}), - GOLD("Gold", 40, 59.5, -1, false, true, new int[] {ROCKS_7458, ROCKS_7491}), - MITHRIL("Mithril", 55, 119.5, -1, false, true, new int[] {ROCKS_7459, ROCKS_7492}), - ADAMANTITE("Adamantite", 70, 239.5, -1, false, true, new int[] {ROCKS_7460, ROCKS_7493}), - RUNITE("Runite", 85, 720, -1, false, true, new int[] {ROCKS_7461, ROCKS_7494}), - AMETHYST("Amethyst", 92, 150, -1, true, false, new int[] {EMPTY_WALL}), - PAY_DIRT("Pay-Dirt", 30, 95, 125, true, false, new int[] {DEPLETED_VEIN_26665, DEPLETED_VEIN_26666, DEPLETED_VEIN_26667, DEPLETED_VEIN_26668}); - - @Getter(AccessLevel.PACKAGE) - private final String name; - - @Getter(AccessLevel.PACKAGE) - private final int requiredMiningLevel; - - @Getter(AccessLevel.PACKAGE) - private final double minRespawnTime, maxRespawnTime; - - @Getter(AccessLevel.PACKAGE) - private final boolean memberOnly; - - @Getter(AccessLevel.PACKAGE) - private final boolean groundObject; - - private final int[] rockIDs; - - public static MiningRockType getTypeFromID(int id) - { - for (MiningRockType type : values()) - { - for (int i : type.rockIDs) - { - if (i == id) - { - return type; - } - } - } - return null; - } - - public static MiningRockType getTypeFromName(String name) - { - for (MiningRockType type : values()) - { - if (type.getName().equalsIgnoreCase(name)) - { - return type; - } - } - return null; - } - - /** - * The rocks which can be tracked across worlds - */ - @AllArgsConstructor - public enum WorldRock - { - None(null), - Adamantite(MiningRockType.ADAMANTITE), - Gold(MiningRockType.GOLD), - Mithril(MiningRockType.MITHRIL), - Runite(MiningRockType.RUNITE); - - @Getter(AccessLevel.PACKAGE) - private final MiningRockType rockType; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorld.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorld.java deleted file mode 100644 index 7ad4e2a612..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorld.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import lombok.AccessLevel; -import lombok.Getter; -import net.runelite.api.TileObject; - -import java.util.ArrayList; - -/** - * Holds rocks mined in a certain world - */ -public class MiningWorld -{ - - @Getter(AccessLevel.PACKAGE) - private int world; - - @Getter(AccessLevel.PACKAGE) - private final BiMap rocks = HashBiMap.create(); - - public MiningWorld(int world) - { - this.world = world; - } - - public void clearNegativeRespawnTimes() - { - // Create a new array list, cause sometimes a concurrent modification occurs - for (MinedRock rock : new ArrayList<>(rocks.values())) - { - if (rock.getMinSecondsUntilRespawn(true) < 0) - { - rocks.inverse().remove(rock); - } - } - } - - public int getFirstSecondsUntilRespawn() - { - int least = Integer.MAX_VALUE; - for (MinedRock rock : rocks.values()) - { - int seconds = rock.getMinSecondsUntilRespawn(true); - if (seconds < least) - { - least = seconds; - } - } - return least; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorldHopperOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorldHopperOverlay.java deleted file mode 100644 index 96bf6bc6c9..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorldHopperOverlay.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import net.runelite.api.Client; -import net.runelite.client.game.SkillIconManager; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; -import javax.inject.Inject; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.util.List; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.stream.Collectors; - -/** - * Displays respawn timers on a per-world base for any rock recently mined by the player as they're hopping worlds - */ -public class MiningWorldHopperOverlay extends Overlay -{ - - private final MiningConfig config; - private final Client client; - private final MiningPlugin plugin; - private final PanelComponent panelComponent = new PanelComponent(); - - @Inject - MiningWorldHopperOverlay(Client client, MiningPlugin plugin, MiningConfig config, SkillIconManager iconManager) - { - setPosition(OverlayPosition.TOP_LEFT); - this.client = client; - this.config = config; - this.plugin = plugin; - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (config.trackWorldRock() == MiningRockType.WorldRock.None) - { - return null; - } - - MiningWorldTracker tracker = plugin.getMiningTracker(); - for (int worldID : new ArrayList<>(tracker.getTrackedWorlds().keySet())) - { - MiningWorld world = tracker.getTrackedWorlds().get(worldID); - for (MinedRock rock : new ArrayList<>(world.getRocks().values())) - { - // If this rock has respawned & we've passed the config defined timeout, then remove this rock - if (rock.getMinSecondsUntilRespawn(true) < 0 - config.trackTimeout()) - { - world.getRocks().inverse().remove(rock); - } - } - if (world.getRocks().size() == 0) - { - tracker.getTrackedWorlds().remove(worldID); - } - } - if (tracker.getTrackedWorlds().size() == 0) - { - return null; - } - - panelComponent.getChildren().clear(); - panelComponent.getChildren().add(TitleComponent.builder() - .text("Respawn Tracker") - .build()); - - List worlds = tracker.getTrackedWorlds().values() - .stream() - .sorted(Comparator.comparing(MiningWorld::getFirstSecondsUntilRespawn)) - .collect(Collectors.toList()); - for (MiningWorld world : worlds) - { - // Go through every remaining world, if they're here it means they have a rock that has not yet respawned (or timeout not yet passed) - int id = world.getWorld(); - int seconds = world.getFirstSecondsUntilRespawn(); - if (seconds < 0) - { - // If the time left until the rock respawns is less than zero, then it means it has respawned. - // However if it's not yet been cleared, it means the timeout has not yet passed so we still need to display this world to the user - seconds = 0; - } - panelComponent.getChildren().add(LineComponent.builder() - .left("World " + id) - .right(Integer.toString(seconds)) - .rightColor(seconds == 0 ? Color.GREEN : Color.ORANGE) - .build()); - } - return panelComponent.render(graphics); - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorldTracker.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorldTracker.java deleted file mode 100644 index 290869c284..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningWorldTracker.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2018, Craftiii4 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import lombok.AccessLevel; -import lombok.Getter; -import net.runelite.api.TileObject; - -import java.util.HashMap; - -/** - * Holds each world currently being tracked for respawn timers - */ -public class MiningWorldTracker -{ - - @Getter(AccessLevel.PACKAGE) - private MiningRockType.WorldRock trackingRock; - - @Getter(AccessLevel.PACKAGE) - private HashMap trackedWorlds = new HashMap<>(); - - public MiningWorldTracker(MiningRockType.WorldRock trackingRock) - { - this.trackingRock = trackingRock; - } - - /** - * Adds a tracked rock to a world. - * - * @param world World ID - * @param object The TileObject of the rock to track - * @param mined The MinedRock of the rock, containing the Type and respawn time - */ - public void addTracked(int world, TileObject object, MinedRock mined) - { - if (!trackedWorlds.containsKey(world)) - { - trackedWorlds.put(world, new MiningWorld(world)); - } - // Clear any rocks which have respawned, no point knowing about them if we are on this world & mining again - trackedWorlds.get(world).clearNegativeRespawnTimes(); - trackedWorlds.get(world).getRocks().put(object, mined); - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/MapLocations.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MapLocations.java similarity index 99% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/MapLocations.java rename to runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MapLocations.java index 81e8e0f527..09cdabf83f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/MapLocations.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MapLocations.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.zoneIndicators; +package net.runelite.client.plugins.multiindicators; import java.awt.Polygon; import java.awt.Rectangle; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsConfig.java similarity index 96% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsConfig.java rename to runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsConfig.java index 370533dac7..0436d936ce 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsConfig.java @@ -22,15 +22,15 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.zoneIndicators; +package net.runelite.client.plugins.multiindicators; import java.awt.Color; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -@ConfigGroup("zoneIndicators") -public interface ZoneIndicatorsConfig extends Config +@ConfigGroup("multiindicators") +public interface MultiIndicatorsConfig extends Config { @ConfigItem( keyName = "multicombatZoneVisibility", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsMinimapOverlay.java similarity index 94% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsMinimapOverlay.java rename to runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsMinimapOverlay.java index 699b0f0ddf..a0d87a4691 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsMinimapOverlay.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.zoneIndicators; +package net.runelite.client.plugins.multiindicators; import java.awt.Color; import java.awt.Dimension; @@ -40,7 +40,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; -public class ZoneIndicatorsMinimapOverlay extends Overlay +public class MultiIndicatorsMinimapOverlay extends Overlay { private final static int MAX_LOCAL_DRAW_LENGTH = 20 * Perspective.LOCAL_TILE_SIZE; @@ -48,13 +48,13 @@ public class ZoneIndicatorsMinimapOverlay extends Overlay private Client client; @Inject - private ZoneIndicatorsPlugin plugin; + private MultiIndicatorsPlugin plugin; @Inject - private ZoneIndicatorsConfig config; + private MultiIndicatorsConfig config; @Inject - public ZoneIndicatorsMinimapOverlay() + public MultiIndicatorsMinimapOverlay() { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ALWAYS_ON_TOP); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsOverlay.java similarity index 95% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsOverlay.java rename to runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsOverlay.java index 0f52222e8b..242effb5aa 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsOverlay.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.zoneIndicators; +package net.runelite.client.plugins.multiindicators; import java.awt.BasicStroke; import java.awt.Color; @@ -41,7 +41,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; -public class ZoneIndicatorsOverlay extends Overlay +public class MultiIndicatorsOverlay extends Overlay { private final static int MAX_LOCAL_DRAW_LENGTH = 20 * Perspective.LOCAL_TILE_SIZE; @@ -49,13 +49,13 @@ public class ZoneIndicatorsOverlay extends Overlay private Client client; @Inject - private ZoneIndicatorsPlugin plugin; + private MultiIndicatorsPlugin plugin; @Inject - private ZoneIndicatorsConfig config; + private MultiIndicatorsConfig config; @Inject - public ZoneIndicatorsOverlay() + public MultiIndicatorsOverlay() { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsPlugin.java similarity index 95% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsPlugin.java rename to runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsPlugin.java index 5f3397e900..8410d96d40 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsPlugin.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.zoneIndicators; +package net.runelite.client.plugins.multiindicators; import net.runelite.client.eventbus.Subscribe; import com.google.inject.Provides; @@ -52,12 +52,13 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( - name = "!MultiLines", + name = "Multi-Lines", description = "Show borders of multicombat and PvP safezones", tags = {"multicombat", "lines", "pvp", "deadman", "safezones", "bogla"}, - enabledByDefault = false + enabledByDefault = false, + type = "PVP" ) -public class ZoneIndicatorsPlugin extends Plugin +public class MultiIndicatorsPlugin extends Plugin { @Inject private Client client; @@ -66,13 +67,13 @@ public class ZoneIndicatorsPlugin extends Plugin private ClientThread clientThread; @Inject - private ZoneIndicatorsConfig config; + private MultiIndicatorsConfig config; @Inject - private ZoneIndicatorsOverlay overlay; + private MultiIndicatorsOverlay overlay; @Inject - private ZoneIndicatorsMinimapOverlay minimapOverlay; + private MultiIndicatorsMinimapOverlay minimapOverlay; @Inject private OverlayManager overlayManager; @@ -92,9 +93,9 @@ public class ZoneIndicatorsPlugin extends Plugin private int currentPlane; @Provides - ZoneIndicatorsConfig getConfig(ConfigManager configManager) + MultiIndicatorsConfig getConfig(ConfigManager configManager) { - return configManager.getConfig(ZoneIndicatorsConfig.class); + return configManager.getConfig(MultiIndicatorsConfig.class); } @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneVisibility.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/ZoneVisibility.java similarity index 96% rename from runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneVisibility.java rename to runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/ZoneVisibility.java index 9a457d9e50..93ca7e8e26 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zoneIndicators/ZoneVisibility.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/ZoneVisibility.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.zoneIndicators; +package net.runelite.client.plugins.multiindicators; import lombok.RequiredArgsConstructor; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/musicindicator/MusicIndicatorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/musicindicator/MusicIndicatorPlugin.java deleted file mode 100644 index 25584f3a88..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/musicindicator/MusicIndicatorPlugin.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2019, Shaun Dreclin - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.musicindicator; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import javax.inject.Inject; -import net.runelite.api.ChatMessageType; -import net.runelite.api.Client; -import net.runelite.api.EnumComposition; -import net.runelite.api.EnumID; -import net.runelite.api.VarPlayer; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.VarbitChanged; -import net.runelite.client.chat.ChatColorType; -import net.runelite.client.chat.ChatMessageBuilder; -import net.runelite.client.chat.ChatMessageManager; -import net.runelite.client.chat.QueuedMessage; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; - -@PluginDescriptor( - name = "Music Track Indicator", - description = "Show chat notifications when unlocking music tracks" -) -public class MusicIndicatorPlugin extends Plugin -{ - private static final List MUSIC_TRACK_VARPS = ImmutableList.of( - VarPlayer.MUSIC_TRACKS_UNLOCKED_1, VarPlayer.MUSIC_TRACKS_UNLOCKED_2, VarPlayer.MUSIC_TRACKS_UNLOCKED_3, - VarPlayer.MUSIC_TRACKS_UNLOCKED_4, VarPlayer.MUSIC_TRACKS_UNLOCKED_5, VarPlayer.MUSIC_TRACKS_UNLOCKED_6, - VarPlayer.MUSIC_TRACKS_UNLOCKED_7, VarPlayer.MUSIC_TRACKS_UNLOCKED_8, VarPlayer.MUSIC_TRACKS_UNLOCKED_9, - VarPlayer.MUSIC_TRACKS_UNLOCKED_10, VarPlayer.MUSIC_TRACKS_UNLOCKED_11, VarPlayer.MUSIC_TRACKS_UNLOCKED_12, - VarPlayer.MUSIC_TRACKS_UNLOCKED_13, VarPlayer.MUSIC_TRACKS_UNLOCKED_14, VarPlayer.MUSIC_TRACKS_UNLOCKED_15, - VarPlayer.MUSIC_TRACKS_UNLOCKED_16, VarPlayer.MUSIC_TRACKS_UNLOCKED_17, VarPlayer.MUSIC_TRACKS_UNLOCKED_18, - VarPlayer.MUSIC_TRACKS_UNLOCKED_19 - ); - - private static final Map VARP_INDEX_TO_VARPLAYER = MUSIC_TRACK_VARPS.stream() - .collect(Collectors.collectingAndThen(Collectors.toMap(VarPlayer::getId, Function.identity()), - ImmutableMap::copyOf)); - - @Inject - private Client client; - - @Inject - private ChatMessageManager chatMessageManager; - - // Mapping of relevant varps to their values, used to compare against new values - private final Map musicTrackVarpValues = new HashMap<>(); - - private boolean loggingIn; - - @Override - public void startUp() - { - loggingIn = true; - } - - @Override - public void shutDown() - { - musicTrackVarpValues.clear(); - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - switch (event.getGameState()) - { - case LOGGING_IN: - case CONNECTION_LOST: - case HOPPING: - musicTrackVarpValues.clear(); - loggingIn = true; - } - } - - @Subscribe - public void onGameTick(GameTick event) - { - if (!loggingIn) - { - return; - } - - loggingIn = false; - - for (VarPlayer musicTrackVarp : MUSIC_TRACK_VARPS) - { - int value = client.getVar(musicTrackVarp); - musicTrackVarpValues.put(musicTrackVarp, value); - } - } - - @Subscribe - public void onVarbitChanged(VarbitChanged event) - { - int idx = event.getIndex(); - - VarPlayer varPlayer = VARP_INDEX_TO_VARPLAYER.get(idx); - if (varPlayer == null) - { - return; - } - - // Old varplayer values have not been initialized yet - if (musicTrackVarpValues.isEmpty()) - { - return; - } - - assert musicTrackVarpValues.containsKey(varPlayer); - - int newValue = client.getVar(varPlayer); - int oldValue = musicTrackVarpValues.put(varPlayer, newValue); - int musicTracksUnlocked = ~oldValue & newValue; - - if (musicTracksUnlocked == 0) - { - return; - } - - final EnumComposition names = client.getEnum(EnumID.MUSIC_TRACK_NAMES); - final int varpId = MUSIC_TRACK_VARPS.indexOf(varPlayer) + 1; - - for (int bit = 0; bit < Integer.SIZE; ++bit) - { - if ((musicTracksUnlocked & (1 << bit)) == 0) - { - continue; - } - - int musicTrackId = getTrackId(varpId, bit); - String musicTrackName = names.getStringValue(musicTrackId); - - sendChatMessage("You have unlocked a new music track: " + musicTrackName + "."); - } - } - - /** - * Get the id for a track identified by the given varp and a bit index - * @param variableId - * @param bit - * @return - */ - private int getTrackId(int variableId, int bit) - { - // values are packed into a coordgrid - int packed = (variableId << 14) | bit; - EnumComposition ids = client.getEnum(EnumID.MUSIC_TRACK_IDS); - for (int key : ids.getKeys()) - { - int value = ids.getIntValue(key); - if (value == packed) - { - return key; - } - } - return -1; - } - - private void sendChatMessage(String chatMessage) - { - final String message = new ChatMessageBuilder() - .append(ChatColorType.HIGHLIGHT) - .append(chatMessage) - .build(); - - chatMessageManager.queue( - QueuedMessage.builder() - .type(ChatMessageType.CONSOLE) - .runeLiteFormattedMessage(message) - .build()); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierConfig.java deleted file mode 100644 index 8bce5b84b7..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierConfig.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.runelite.client.plugins.nexthitnotifier; - - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; - -@ConfigGroup("nexthitnotifier") -public interface NextHitNotifierConfig extends Config -{ - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierOverlay.java deleted file mode 100644 index fe47f37307..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierOverlay.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.runelite.client.plugins.nexthitnotifier; - -import net.runelite.api.Client; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; -import net.runelite.client.util.MiscUtils; - -import javax.inject.Inject; -import java.awt.*; - -public class NextHitNotifierOverlay extends Overlay -{ - private final Client client; - private final NextHitNotifierPlugin plugin; - private final NextHitNotifierConfig config; - - private final PanelComponent panelComponent = new PanelComponent(); - private final Dimension panelSize = new Dimension(48, 0); - - @Inject - private NextHitNotifierOverlay(Client client, NextHitNotifierPlugin plugin, NextHitNotifierConfig config) - { - setPosition(OverlayPosition.BOTTOM_LEFT); - //setPosition(OverlayPosition.DYNAMIC); - //setPosition(OverlayPosition.DETACHED); - - this.client = client; - this.plugin = plugin; - this.config = config; - } - - @Override - public Dimension render(Graphics2D graphics) - { - panelComponent.getChildren().clear(); - panelComponent.setPreferredSize(panelSize); - - String lastHitText = Integer.toString(plugin.lastHit); - int lastHit = plugin.lastHit; - - if (plugin.showTime < 0) - { - lastHitText = "0"; - lastHit = 0; - } - - int g = (int)MiscUtils.clamp((float)Math.floor(lastHit / 30.f) * 255.f, 0.f, 255.f); - int r = 255 - g; - - Color textColor = Color.getHSBColor(Color.RGBtoHSB(r, g, 0, null)[0], 1.f, 1.f); - - panelComponent.getChildren().add(TitleComponent.builder().text("Next hit:").color(Color.YELLOW).build()); - panelComponent.getChildren().add(TitleComponent.builder().text(lastHitText).color(textColor).build()); - - return panelComponent.render(graphics); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierPlugin.java deleted file mode 100644 index ccece4d4a4..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nexthitnotifier/NextHitNotifierPlugin.java +++ /dev/null @@ -1,116 +0,0 @@ -package net.runelite.client.plugins.nexthitnotifier; - -import net.runelite.client.eventbus.Subscribe; -import com.google.inject.Provides; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.Skill; -import net.runelite.api.events.ExperienceChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; - -import javax.inject.Inject; - -@PluginDescriptor( - name = "!Next Hit Notifier", - description = "Shows estimated next hit based on xp drop.", - tags = { "experience", "damage", "overlay", "pking", "bogla" }, - enabledByDefault = false -) -public class NextHitNotifierPlugin extends Plugin -{ - @Inject - private Client client; - - @Inject - private OverlayManager overlayManager; - - @Inject - private NextHitNotifierOverlay overlay; - - private int lastHpXp = 0; - int lastHit = 0; - int showTime = 0; - - @Provides - NextHitNotifierConfig getConfig(ConfigManager configManager) - { - return configManager.getConfig(NextHitNotifierConfig.class); - } - - @Override - protected void startUp() throws Exception - { - overlayManager.add(overlay); - } - - @Override - protected void shutDown() throws Exception - { - overlayManager.remove(overlay); - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - if (event.getGameState() == GameState.LOGGED_IN) - { - lastHpXp = client.getSkillExperience(Skill.HITPOINTS); - lastHit = 0; - showTime = 0; - } - else - { - lastHpXp = 0; - lastHit = 0; - showTime = 0; - } - } - - @Subscribe - public void onGameTick(GameTick event) - { - if (showTime > 0) - showTime--; - else - lastHit = 0; - } - - @Subscribe - public void onExperienceChanged(ExperienceChanged event) - { - if (client.getGameState() != GameState.LOGGED_IN) - { - lastHpXp = 0; - lastHit = 0; - showTime = 0; - return; - } - - final Skill skill = event.getSkill(); - - if (skill != Skill.HITPOINTS) - return; - - final int currentXp = client.getSkillExperience(skill); - - int gainedXp = currentXp - lastHpXp; - - //filter out big xp drops (such as login) - if (gainedXp > 1000) - { - lastHpXp = client.getSkillExperience(skill); - return; - } - - lastHit = (int)Math.rint(gainedXp / 1.33f); - lastHpXp = currentXp; - showTime = 3; - } - - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java index a0e4992e31..311e286b0b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java @@ -37,6 +37,7 @@ public interface NpcAggroAreaConfig extends Config String CONFIG_CENTER2 = "center2"; String CONFIG_LOCATION = "location"; String CONFIG_DURATION = "duration"; + String CONFIG_NOT_WORKING_OVERLAY = "overlay"; @ConfigItem( keyName = "npcUnaggroAlwaysActive", @@ -92,4 +93,15 @@ public interface NpcAggroAreaConfig extends Config { return Color.YELLOW; } + + @ConfigItem( + keyName = "npcUnaggroShowNotWorkingOverlay", + name = "Show not working hint", + description = "Show hint if plugin is enabled in unsupported area", + position = 6 + ) + default boolean showNotWorkingOverlay() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaPlugin.java index 79096a5b35..10dd5752f9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaPlugin.java @@ -128,6 +128,7 @@ public class NpcAggroAreaPlugin extends Plugin private WorldPoint previousUnknownCenter; private boolean loggingIn; private List npcNamePatterns; + private boolean notWorkingOverlayShown = false; @Provides NpcAggroAreaConfig provideConfig(ConfigManager configManager) @@ -139,7 +140,12 @@ public class NpcAggroAreaPlugin extends Plugin protected void startUp() throws Exception { overlayManager.add(overlay); - overlayManager.add(notWorkingOverlay); + if (config.showNotWorkingOverlay()) + { + overlayManager.add(notWorkingOverlay); + notWorkingOverlayShown = true; + } + npcNamePatterns = NAME_SPLITTER.splitToList(config.npcNamePatterns()); recheckActive(); } @@ -149,7 +155,11 @@ public class NpcAggroAreaPlugin extends Plugin { removeTimer(); overlayManager.remove(overlay); - overlayManager.remove(notWorkingOverlay); + if (notWorkingOverlayShown) + { + overlayManager.remove(notWorkingOverlay); + } + Arrays.fill(safeCenters, null); lastPlayerLocation = null; currentTimer = null; @@ -406,6 +416,7 @@ public class NpcAggroAreaPlugin extends Plugin configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER2); configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_LOCATION); configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_DURATION); + configManager.unsetConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_NOT_WORKING_OVERLAY); } private void saveConfig() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Game.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Game.java index db9659994f..6e9e4274bd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Game.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Game.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2017, Adam + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,97 +25,220 @@ */ package net.runelite.client.plugins.pestcontrol; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.List; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import static net.runelite.client.plugins.pestcontrol.Portal.BLUE; -import static net.runelite.client.plugins.pestcontrol.Portal.PURPLE; -import static net.runelite.client.plugins.pestcontrol.Portal.RED; -import static net.runelite.client.plugins.pestcontrol.Portal.YELLOW; +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.GameTick; @Slf4j -class Game +public class Game { + private Client client; + + private PestControlPlugin plugin; + + @Getter + private Portal bluePortal = new Portal(PortalColor.BLUE, WidgetPortal.BLUE); + + @Getter + private Portal purplePortal = new Portal(PortalColor.PURPLE, WidgetPortal.PURPLE); + + @Getter + private Portal yellowPortal = new Portal(PortalColor.YELLOW, WidgetPortal.YELLOW); + + @Getter + private Portal redPortal = new Portal(PortalColor.RED, WidgetPortal.RED); + + @Getter + private int shieldsDropped = 0; + // Game starts with all possible rotations - private Rotation[] possibleRotations = Rotation.values(); - // Number of shields dropped - private int shieldsDropped; + private PortalRotation[] possibleRotations = PortalRotation.values(); - @Getter - private final PortalContext purple = new PortalContext(PURPLE); - @Getter - private final PortalContext blue = new PortalContext(BLUE); - @Getter - private final PortalContext yellow = new PortalContext(YELLOW); - @Getter - private final PortalContext red = new PortalContext(RED); + private boolean portalLocationsSet = false; - void fall(String color) + + private Instant startTime = Instant.now(); + + public Game(Client client, PestControlPlugin plugin) { - switch (color.toLowerCase()) + this.client = client; + this.plugin = plugin; + } + + public void onGameTick(GameTick gameTickEvent) + { + if (!portalLocationsSet) + { + loadPortalLocations(); + } + + WidgetOverlay widgetOverlay = plugin.getWidgetOverlay(); + + if (!purplePortal.isDead() && widgetOverlay.getPortalHitpoints(PortalColor.PURPLE) == 0) + { + killPortal(purplePortal); + } + + if (!yellowPortal.isDead() && widgetOverlay.getPortalHitpoints(PortalColor.YELLOW) == 0) + { + killPortal(yellowPortal); + } + + if (!redPortal.isDead() && widgetOverlay.getPortalHitpoints(PortalColor.RED) == 0) + { + killPortal(redPortal); + } + + if (!bluePortal.isDead() && widgetOverlay.getPortalHitpoints(PortalColor.BLUE) == 0) + { + killPortal(bluePortal); + } + } + + public void lowerPortalShield(String portalColor) + { + switch (portalColor.toLowerCase()) { case "purple": - fall(purple); + lowerPortalShield(purplePortal); break; case "red": - fall(red); + lowerPortalShield(redPortal); break; case "yellow": - fall(yellow); + lowerPortalShield(yellowPortal); break; case "blue": - fall(blue); + lowerPortalShield(bluePortal); break; } } - private void fall(PortalContext portal) + private void lowerPortalShield(Portal portal) { if (!portal.isShielded()) { return; } - log.debug("Shield dropped for {}", portal.getPortal()); + log.debug("Shield dropped for {}", portal.getColor()); + + portal.setPortalState(PortalState.ACTIVE); - portal.setShielded(false); int shieldDrop = shieldsDropped++; // Remove impossible rotations - List rotations = new ArrayList<>(); + List rotations = new ArrayList<>(); - for (Rotation rotation : possibleRotations) + for (PortalRotation rotation : possibleRotations) { - if (rotation.getPortal(shieldDrop) == portal.getPortal()) + if (rotation.getPortal(this, shieldDrop) == portal) { rotations.add(rotation); } } - possibleRotations = rotations.toArray(new Rotation[rotations.size()]); + possibleRotations = rotations.toArray(new PortalRotation[rotations.size()]); } - void die(PortalContext portal) + public void killPortal(Portal portal) { if (portal.isDead()) { return; } - log.debug("Portal {} died", portal.getPortal()); + log.debug("Portal {} died", portal.getColor()); - portal.setDead(true); + portal.setPortalState(PortalState.DEAD); } - Collection getNextPortals() + private boolean loadPortalLocations() + { + NPC squire = null; + + for (NPC npc : client.getNpcs()) + { + if (PestControlNpc.isIngameSquireId(npc.getId())) + { + squire = npc; + break; + } + } + + if (squire != null) + { + log.debug("In-game Squire found: {}", squire); + setPortalLocations(squire.getWorldLocation()); + + return true; + } + + return false; + } + + public void setPortalLocations(WorldPoint squireLocation) + { + int x = squireLocation.getX(); + int y = squireLocation.getY(); + + purplePortal.setLocation(new WorldPoint(x - 26, y - 15, 0)); + bluePortal.setLocation(new WorldPoint(x + 26, y - 18, 0)); + yellowPortal.setLocation(new WorldPoint(x + 15, y - 36, 0)); + redPortal.setLocation(new WorldPoint(x - 9, y - 37, 0)); + + portalLocationsSet = true; + } + + public List getPortals() + { + List portalList = new ArrayList(); + + portalList.add(getPurplePortal()); + portalList.add(getBluePortal()); + portalList.add(getYellowPortal()); + portalList.add(getRedPortal()); + + return portalList; + } + + public Portal getPortal(PortalColor portalColor) + { + if (bluePortal.getColor() == portalColor) + { + return bluePortal; + } + if (redPortal.getColor() == portalColor) + { + return redPortal; + } + if (purplePortal.getColor() == portalColor) + { + return purplePortal; + } + if (yellowPortal.getColor() == portalColor) + { + return yellowPortal; + } + + return null; + } + + public Collection getNextPortals() { List portals = new ArrayList<>(); - for (Rotation rotation : possibleRotations) + for (PortalRotation rotation : possibleRotations) { - Portal portal = rotation.getPortal(shieldsDropped); + Portal portal = rotation.getPortal(this, shieldsDropped); if (portal != null && !portals.contains(portal)) { @@ -124,4 +248,40 @@ class Game return portals; } + + public Collection getActivePortals() + { + List portals = new ArrayList<>(); + + for (Portal portal : getPortals()) + { + if (portal.isActive()) + { + portals.add(portal); + } + } + + return portals; + } + + public Duration getTimeTillNextPortal() + { + Instant nextShieldDrop; + + if (shieldsDropped == 4) + { + return null; + } + + if (shieldsDropped == 0) + { + nextShieldDrop = Instant.ofEpochSecond(startTime.getEpochSecond() + 17); + } + else + { + nextShieldDrop = Instant.ofEpochSecond(startTime.getEpochSecond() + 17 + (30 * shieldsDropped)); + } + + return Duration.between(Instant.now(), nextShieldDrop); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/GangplankOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/GangplankOverlay.java new file mode 100644 index 0000000000..db8abe87b7 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/GangplankOverlay.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import com.google.inject.Inject; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Polygon; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.Player; +import net.runelite.api.Point; +import net.runelite.api.Tile; +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.tooltip.Tooltip; +import net.runelite.client.ui.overlay.tooltip.TooltipManager; +import net.runelite.client.util.ColorUtil; + +@Slf4j +public class GangplankOverlay extends Overlay +{ + private final Client client; + private final PestControlConfig config; + private final PestControlPlugin plugin; + private final TooltipManager tooltipManager; + + @Inject + GangplankOverlay(Client client, PestControlConfig config, PestControlPlugin plugin, TooltipManager toolTipManager) + { + this.config = config; + this.plugin = plugin; + this.client = client; + this.tooltipManager = toolTipManager; + + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!plugin.isOnPestControlMainIsland()) + { + return null; + } + + Player localPlayer = client.getLocalPlayer(); + + if (localPlayer == null) + { + return null; + } + + int combatLevel = localPlayer.getCombatLevel(); + + Color noviceCbColor = (combatLevel >= 40) ? Color.GREEN : Color.RED; + Color intermediateCbColor = (combatLevel >= 70) ? Color.GREEN : Color.RED; + Color veteranCbColor = (combatLevel >= 100) ? Color.GREEN : Color.RED; + + Tile noviceGangplankTile = plugin.getNoviceGangplankTile(); + Tile intermediateGangplankTile = plugin.getIntermediateGangplankTile(); + Tile veteranGangplankTile = plugin.getVeteranGangplankTile(); + + Point mousePosition = client.getMouseCanvasPosition(); + String tooltipString = null; + + if (noviceGangplankTile != null) + { + Polygon polygon = noviceGangplankTile.getGameObjects()[0].getConvexHull(); + if (polygon != null) + { + graphics.setColor(noviceCbColor); + graphics.setStroke(new BasicStroke(2)); + graphics.drawPolygon(polygon); + graphics.setColor(setColorAlpha(noviceCbColor, 45)); + graphics.fill(polygon); + + if (polygon.contains(mousePosition.getX(), mousePosition.getY())) + { + tooltipString = ColorUtil.wrapWithColorTag("Combat 40+", noviceCbColor) + " (3 points)"; + graphics.setColor(setColorAlpha(noviceCbColor, 65)); + graphics.fill(polygon); + } + } + } + + if (intermediateGangplankTile != null) + { + Polygon polygon = intermediateGangplankTile.getGameObjects()[0].getConvexHull(); + if (polygon != null) + { + graphics.setColor(intermediateCbColor); + graphics.setStroke(new BasicStroke(2)); + graphics.drawPolygon(polygon); + graphics.setColor(setColorAlpha(intermediateCbColor, 45)); + graphics.fill(polygon); + + if (polygon.contains(mousePosition.getX(), mousePosition.getY())) + { + tooltipString = ColorUtil.wrapWithColorTag("Combat 70+", intermediateCbColor) + " (4 points)"; + graphics.setColor(setColorAlpha(intermediateCbColor, 65)); + graphics.fill(polygon); + } + } + } + + if (veteranGangplankTile != null) + { + Polygon polygon = veteranGangplankTile.getGameObjects()[0].getConvexHull(); + if (polygon != null) + { + graphics.setColor(veteranCbColor); + graphics.setStroke(new BasicStroke(2)); + graphics.drawPolygon(polygon); + graphics.setColor(setColorAlpha(veteranCbColor, 45)); + graphics.fill(polygon); + + if (polygon.contains(mousePosition.getX(), mousePosition.getY())) + { + tooltipString = ColorUtil.wrapWithColorTag("Combat 100+", veteranCbColor) + " (5 points)"; + graphics.setColor(setColorAlpha(veteranCbColor, 65)); + graphics.fill(polygon); + } + } + } + + if (tooltipString != null) + { + tooltipManager.add(new Tooltip(tooltipString)); + } + + return null; + } + + private Color setColorAlpha(Color color, int alpha) + { + return new Color( + color.getRed(), + color.getGreen(), + color.getBlue(), + alpha + ); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/HintArrowOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/HintArrowOverlay.java new file mode 100644 index 0000000000..0d9660ed37 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/HintArrowOverlay.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.coords.WorldPoint; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; + +public class HintArrowOverlay extends Overlay +{ + private final PestControlConfig config; + private final PestControlPlugin plugin; + private final Client client; + + @Inject + HintArrowOverlay(PestControlConfig config, PestControlPlugin plugin, Client client) + { + this.config = config; + this.plugin = plugin; + this.client = client; + + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (plugin.getGame() == null) + { + return null; + } + + List visibleActivePortals = new ArrayList<>(); + List visibleShieldedPortals = new ArrayList<>(); + + for (NPC npc : client.getNpcs()) + { + if (PestControlNpc.isActivePortalId(npc.getId())) + { + visibleActivePortals.add(npc); + } + } + + if (!visibleActivePortals.isEmpty()) + { + NPC closestPortalNpc = getClosestNpc(visibleActivePortals); + + if (closestPortalNpc != null) + { + NPC currentHintArrowTarget = client.getHintArrowNpc(); + + if (currentHintArrowTarget == null || currentHintArrowTarget != closestPortalNpc) + { + client.setHintArrow(closestPortalNpc); + } + } + + return null; + } + + Portal closestActivePortal = getClosestPortal(PortalState.ACTIVE); + + if (closestActivePortal != null) + { + WorldPoint currentHintArrowLocation = client.getHintArrowPoint(); + WorldPoint closestActivePortalLocation = closestActivePortal.getLocation(); + + if (currentHintArrowLocation == null || currentHintArrowLocation != closestActivePortalLocation) + { + client.setHintArrow(closestActivePortalLocation); + } + + return null; + } + + Collection nextPortalList = plugin.getGame().getNextPortals(); + + if (nextPortalList.size() == 1) + { + client.setHintArrow(nextPortalList.iterator().next().getLocation()); + + return null; + } + + return null; + } + + private NPC getClosestNpc(List npcList) + { + WorldPoint currentLocation = client.getLocalPlayer().getWorldLocation(); + + NPC closestNpc = null; + int currentShortestDistance = 1337; + int distanceToNpc; + + for (NPC npc : npcList) + { + if (closestNpc != null) + { + distanceToNpc = npc.getWorldLocation().distanceTo(currentLocation); + + if (distanceToNpc < currentShortestDistance) + { + closestNpc = npc; + currentShortestDistance = distanceToNpc; + } + } + else + { + closestNpc = npc; + } + } + + return closestNpc; + } + + private Portal getClosestPortal(PortalState portalState) + { + WorldPoint currentLocation = client.getLocalPlayer().getWorldLocation(); + + Portal closestPortal = null; + int currentShortestDistance = 1337; + int distanceToWorldPoint; + + for (Portal portal : plugin.getGame().getPortals()) + { + if (portal.getPortalState() != portalState) + { + continue; + } + + distanceToWorldPoint = portal.getLocation().distanceTo(currentLocation); + + if (distanceToWorldPoint < currentShortestDistance) + { + closestPortal = portal; + currentShortestDistance = distanceToWorldPoint; + } + } + + return closestPortal; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/NpcHighlightContext.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/NpcHighlightContext.java new file mode 100644 index 0000000000..56c51fdd8d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/NpcHighlightContext.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import java.awt.Color; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import net.runelite.client.plugins.pestcontrol.config.NpcHighlightStyle; + +@AllArgsConstructor +@Getter +@Setter +public class NpcHighlightContext +{ + private NpcHighlightStyle npcRenderStyle; + private Color color; + private boolean showNpcName = false; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/NpcHighlightOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/NpcHighlightOverlay.java new file mode 100644 index 0000000000..bb8e94c175 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/NpcHighlightOverlay.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import com.google.inject.Inject; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.util.HashMap; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.Perspective; +import net.runelite.api.Point; +import net.runelite.client.plugins.pestcontrol.config.NpcHighlightStyle; +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.OverlayUtil; + +@Slf4j +public class NpcHighlightOverlay extends Overlay +{ + private final PestControlConfig config; + private final PestControlPlugin plugin; + private final Client client; + + @Inject + NpcHighlightOverlay(PestControlConfig config, PestControlPlugin plugin, Client client) + { + this.config = config; + this.plugin = plugin; + this.client = client; + + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (plugin.getGame() == null) + { + return null; + } + + HashMap highlightedNpcList = plugin.getHighlightedNpcList(); + + for (NPC npc : client.getNpcs()) + { + if (!highlightedNpcList.containsKey(npc.getId())) + { + continue; + } + + NpcHighlightContext npcHighlightContext = plugin.getHighlightedNpcList().get(npc.getId()); + + String name = npcHighlightContext.isShowNpcName() ? npc.getName() : null; + Color color = npcHighlightContext.getColor(); + NpcHighlightStyle highlightStyle = npcHighlightContext.getNpcRenderStyle(); + + switch (highlightStyle) + { + case HULL: + { + renderHullOverlay(graphics, npc, color); + break; + } + case TILE: + { + renderTileOverlay(graphics, npc, color); + break; + } + case BOTH: + { + renderHullOverlay(graphics, npc, color); + renderTileOverlay(graphics, npc, color); + break; + } + } + + if (name != null) + { + renderTextOverlay(graphics, npc, name, color); + } + } + + return null; + } + + private void renderTileOverlay(Graphics2D graphics, NPC npc, Color color) + { + Polygon polygon; + Color fillColor; + + // Double the polygon size if it's a Brawler + if (PestControlNpc.isBrawlerId(npc.getId())) + { + polygon = Perspective.getCanvasTileAreaPoly(client, npc.getLocalLocation(), 2); + fillColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), 35); + } + else + { + polygon = npc.getCanvasTilePoly(); + fillColor = new Color(0, 0, 0, 50); + } + + if (polygon != null) + { + graphics.setColor(color); + graphics.setStroke(new BasicStroke(2)); + graphics.drawPolygon(polygon); + graphics.setColor(fillColor); + graphics.fillPolygon(polygon); + } + } + + private void renderHullOverlay(Graphics2D graphics, NPC npc, Color color) + { + Polygon objectClickbox = npc.getConvexHull(); + if (objectClickbox != null) + { + graphics.setColor(color); + graphics.setStroke(new BasicStroke(2)); + graphics.draw(objectClickbox); + graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); + graphics.fill(objectClickbox); + } + } + + private void renderTextOverlay(Graphics2D graphics, NPC npc, String text, Color color) + { + Point textLocation = npc.getCanvasTextLocation(graphics, text, npc.getLogicalHeight() + 40); + if (textLocation != null) + { + OverlayUtil.renderTextLocation(graphics, textLocation, text, color); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlConfig.java new file mode 100644 index 0000000000..03162389ad --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlConfig.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import java.awt.Color; +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; +import net.runelite.client.plugins.pestcontrol.config.HighlightPortalOption; +import net.runelite.client.plugins.pestcontrol.config.NpcHighlightStyle; + +@ConfigGroup("pestcontrol") +public interface PestControlConfig extends Config +{ + @ConfigItem( + keyName = "showHintArrow", + name = "Show hint arrows", + description = "Show hint arrows to the portals that can be attacked.", + position = 1 + ) + default boolean showHintArrow() + { + return true; + } + + @ConfigItem( + keyName = "showPortalWeakness", + name = "Show portal weakness", + description = "Show the combat style weakness of the portals. For melee the attack styles are shown: Stab/Crush/Slash", + position = 2 + ) + default boolean showPortalWeakness() + { + return false; + } + + @ConfigItem( + keyName = "highlightGangplanks", + name = "Highlight gangplanks", + description = "Highlight the boarding gangplanks and show the required combat level.", + position = 3 + ) + default boolean highlightGangplanks() + { + return true; + } + + @ConfigItem( + keyName = "highlightPortals", + name = "Highlight portals", + description = "Highlight all, active or shielded portals.", + position = 4 + ) + default HighlightPortalOption portalHighlight() + { + return HighlightPortalOption.ACTIVE; + } + + @ConfigItem( + keyName = "activePortalColor", + name = "Active portal color", + description = "Color of the portals that can be attacked.", + position = 5 + ) + default Color activePortalColor() + { + return Color.GREEN; + } + + @ConfigItem( + keyName = "shieldedPortalColor", + name = "Shielded portal color", + description = "Color of the portals that are shielded.", + position = 6 + ) + default Color shieldedPortalColor() + { + return Color.BLUE; + } + + @ConfigItem( + keyName = "highlightSpinners", + name = "Highlight Spinners", + description = "Highlights Spinners. Highlighting them is recommended as Spinners heal the portals.", + position = 7 + ) + default NpcHighlightStyle highlightSpinners() + { + return NpcHighlightStyle.BOTH; + } + + @ConfigItem( + keyName = "spinnerColor", + name = "Spinner color", + description = "Color of highlighted Spinners.", + position = 8 + ) + default Color spinnerColor() + { + return Color.CYAN; + } + + @ConfigItem( + keyName = "highlightBrawlers", + name = "Highlight Brawlers", + description = "Highlights Brawlers.", + position = 9 + ) + default NpcHighlightStyle highlightBrawlers() + { + return NpcHighlightStyle.TILE; + } + + @ConfigItem( + keyName = "brawlerColor", + name = "Brawler color", + description = "Color of highlighted Brawlers.", + position = 10 + ) + default Color brawlerColor() + { + return Color.ORANGE; + } + + @ConfigItem( + keyName = "highlightRepairables", + name = "Highlight repairables", + description = "Highlight repairable barricades and gates.", + position = 11 + ) + default boolean highlightRepairables() + { + return false; + } + + @ConfigItem( + keyName = "repairableColor", + name = "Repairable color", + description = "Color of highlighted repairables.", + position = 12 + ) + /*default Color repairableColor() + { + return new Color(193, 141, 255); + }*/ + default Color repairableColor() + { + return Color.YELLOW; + } + + @ConfigItem( + keyName = "showPoints", + name = "Show points indicator", + description = "Always display your points when on the island or in the minigame.", + position = 13 + ) + default boolean showPoints() + { + return true; + } + + @ConfigItem( + keyName = "showTimeTillNextPortal", + name = "Show time till next portal", + description = "Show a timer that counts down till the next portal is attackable.", + position = 14 + ) + default boolean showTimeTillNextPortal() + { + return true; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlNpc.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlNpc.java new file mode 100644 index 0000000000..e1b9ef143e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlNpc.java @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import com.google.common.collect.ImmutableSet; +import java.util.Set; +import lombok.Getter; +import net.runelite.api.NpcID; + +@Getter +public class PestControlNpc +{ + @Getter + private static final Set splatterIdSet = ImmutableSet.of( + NpcID.SPLATTER, + NpcID.SPLATTER_1690, + NpcID.SPLATTER_1691, + NpcID.SPLATTER_1692, + NpcID.SPLATTER_1693 + ); + + @Getter + public static final Set shifterIdSet = ImmutableSet.of( + NpcID.SHIFTER, + NpcID.SHIFTER_1695, + NpcID.SHIFTER_1696, + NpcID.SHIFTER_1697, + NpcID.SHIFTER_1698, + NpcID.SHIFTER_1699, + NpcID.SHIFTER_1700, + NpcID.SHIFTER_1701, + NpcID.SHIFTER_1702, + NpcID.SHIFTER_1703 + ); + + @Getter + private static final Set spinnerIdSet = ImmutableSet.of( + NpcID.SPINNER, + NpcID.SPINNER_1710, + NpcID.SPINNER_1711, + NpcID.SPINNER_1712, + NpcID.SPINNER_1713 + ); + + @Getter + private static final Set torcherIdSet = ImmutableSet.of( + NpcID.TORCHER, + NpcID.TORCHER_1715, + NpcID.TORCHER_1716, + NpcID.TORCHER_1717, + NpcID.TORCHER_1718, + NpcID.TORCHER_1719, + NpcID.TORCHER_1720, + NpcID.TORCHER_1721, + NpcID.TORCHER_1722, + NpcID.TORCHER_1723 + ); + + @Getter + private static final Set defilerIdSet = ImmutableSet.of( + NpcID.DEFILER, + NpcID.DEFILER_1725, + NpcID.DEFILER_1726, + NpcID.DEFILER_1727, + NpcID.DEFILER_1728, + NpcID.DEFILER_1729, + NpcID.DEFILER_1730, + NpcID.DEFILER_1731, + NpcID.DEFILER_1732, + NpcID.DEFILER_1733 + ); + + @Getter + private static final Set brawlerIdSet = ImmutableSet.of( + NpcID.BRAWLER, + NpcID.BRAWLER_1735, + NpcID.BRAWLER_1736, + NpcID.BRAWLER_1737, + NpcID.BRAWLER_1738 + ); + + @Getter + private static final Set ravagerIdSet = ImmutableSet.of( + NpcID.RAVAGER, + NpcID.RAVAGER_1705, + NpcID.RAVAGER_1706, + NpcID.RAVAGER_1707, + NpcID.RAVAGER_1708 + ); + + @Getter + private static final Set activePortalIdSet = ImmutableSet.of( + NpcID.PORTAL_1747, // Novice Purple Active + NpcID.PORTAL_1748, // Novice Blue Active + NpcID.PORTAL_1749, // Novice Yellow Active + NpcID.PORTAL_1750, // Novice Red Active + NpcID.PORTAL, // Intermediate Purple Active + NpcID.PORTAL_1740, // Intermediate Blue Active + NpcID.PORTAL_1741, // Intermediate Yellow Active + NpcID.PORTAL_1742 // Intermediate Red Active + ); + + @Getter + private static final Set shieldedPortalIdSet = ImmutableSet.of( + NpcID.PORTAL_1751, // Novice Purple Shielded + NpcID.PORTAL_1752, // Novice Blue Shielded + NpcID.PORTAL_1753, // Novice Yellow Shielded + NpcID.PORTAL_1754, // Novice Red Shielded + NpcID.PORTAL_1743, // Intermediate Purple Shielded + NpcID.PORTAL_1744, // Intermediate Blue Shielded + NpcID.PORTAL_1745, // Intermediate Yellow Shielded + NpcID.PORTAL_1746 // Intermediate Red Shielded + ); + + @Getter + private static final Set purplePortalIdSet = ImmutableSet.of( + NpcID.PORTAL_1747, // Novice Purple Active + NpcID.PORTAL_1751, // Novice Purple Shielded + NpcID.PORTAL, // Intermediate Purple Active + NpcID.PORTAL_1743 // Intermediate Purple Shielded + ); + + @Getter + private static final Set bluePortalIdSet = ImmutableSet.of( + NpcID.PORTAL_1748, // Novice Blue Active + NpcID.PORTAL_1752, // Novice Blue Shielded + NpcID.PORTAL_1740, // Intermediate Blue Active + NpcID.PORTAL_1744 // Intermediate Blue Shielded + ); + + @Getter + private static final Set yellowPortalIdSet = ImmutableSet.of( + NpcID.PORTAL_1749, // Novice Yellow Active + NpcID.PORTAL_1753, // Novice Yellow Shielded + NpcID.PORTAL_1741, // Intermediate Yellow Active + NpcID.PORTAL_1745 // Intermediate Yellow Shielded + ); + + @Getter + private static final Set redPortalIdSet = ImmutableSet.of( + NpcID.PORTAL_1750, // Novice Red Active + NpcID.PORTAL_1754, // Novice Red Shielded + NpcID.PORTAL_1742, // Intermediate Red Active + NpcID.PORTAL_1746 // Intermediate Red Shielded + ); + + @Getter + private static final Set ingameVoidKnightIdSet = ImmutableSet.of( + NpcID.VOID_KNIGHT_2950, + NpcID.VOID_KNIGHT_2951, + NpcID.VOID_KNIGHT_2952, + NpcID.VOID_KNIGHT_2953 + ); + + @Getter + private static final Integer ingameSquireId = NpcID.SQUIRE_2949; + + public static boolean isSplatterId(int npcId) + { + return splatterIdSet.contains(npcId); + } + + public static boolean isShifterId(int npcId) + { + return shifterIdSet.contains(npcId); + } + + public static boolean isSpinnerId(int npcId) + { + return brawlerIdSet.contains(npcId); + } + + public static boolean isTorcherId(int npcId) + { + return torcherIdSet.contains(npcId); + } + + public static boolean isDefilerId(int npcId) + { + return defilerIdSet.contains(npcId); + } + + public static boolean isBrawlerId(int npcId) + { + return brawlerIdSet.contains(npcId); + } + + public static boolean isRavagerId(int npcId) + { + return ravagerIdSet.contains(npcId); + } + + public static boolean isIngameVoidKnightId(int npcId) + { + return ingameVoidKnightIdSet.contains(npcId); + } + + public static boolean isIngameSquireId(int npcId) + { + return ingameSquireId == npcId; + } + + public static boolean isPortalId(int npcId) + { + return (isActivePortalId(npcId) || isShieldedPortalId(npcId)); + } + + public static boolean isActivePortalId(int npcId) + { + return activePortalIdSet.contains(npcId); + } + + public static boolean isShieldedPortalId(int npcId) + { + return shieldedPortalIdSet.contains(npcId); + } + + public static boolean isPurplePortalId(int npcId) + { + return purplePortalIdSet.contains(npcId); + } + + public static boolean isBluePortalId(int npcId) + { + return bluePortalIdSet.contains(npcId); + } + + public static boolean isYellowPortalId(int npcId) + { + return yellowPortalIdSet.contains(npcId); + } + + public static boolean isRedPortalId(int npcId) + { + return redPortalIdSet.contains(npcId); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java index 960b589737..090874604a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2017, Kronos + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,29 +25,47 @@ */ package net.runelite.client.plugins.pestcontrol; -import com.google.common.collect.ImmutableSet; +import com.google.inject.Inject; +import com.google.inject.Provides; +import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.inject.Inject; -import lombok.AccessLevel; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameState; -import net.runelite.api.NPC; -import net.runelite.api.NpcID; +import net.runelite.api.ItemID; +import net.runelite.api.Tile; +import net.runelite.api.TileObject; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.GameObjectChanged; +import net.runelite.api.events.GameObjectDespawned; +import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.NpcDespawned; -import net.runelite.api.events.NpcSpawned; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.GroundObjectChanged; +import net.runelite.api.events.GroundObjectDespawned; +import net.runelite.api.events.GroundObjectSpawned; +import net.runelite.api.events.WidgetLoaded; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +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.plugins.pestcontrol.config.HighlightPortalOption; +import net.runelite.client.plugins.pestcontrol.config.NpcHighlightStyle; import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.ui.overlay.infobox.InfoBoxManager; +import net.runelite.client.util.Text; +@Slf4j @PluginDescriptor( name = "Pest Control", description = "Show helpful information for the Pest Control minigame", @@ -54,77 +73,598 @@ import net.runelite.client.ui.overlay.OverlayManager; ) public class PestControlPlugin extends Plugin { - private static final Set SPINNER_IDS = ImmutableSet.of( - NpcID.SPINNER, - NpcID.SPINNER_1710, - NpcID.SPINNER_1711, - NpcID.SPINNER_1712, - NpcID.SPINNER_1713 - ); + private final int NOVICE_GANGPLANK = 14315; // Combat 40+ (3 points) + private final int INTERMEDIATE_GANGPLANK = 25631; // Combat 70+ (4 points) + private final int VETERAN_GANGPLANK = 25632; // Combat 100+ (5 points) - private final Pattern SHIELD_DROP = Pattern.compile("The ([a-z]+), [^ ]+ portal shield has dropped!", Pattern.CASE_INSENSITIVE); + private final Pattern SHIELD_DROP_PATTERN = Pattern.compile("The ([a-z]+), [^ ]+ portal shield has dropped!"); + private final Pattern EXCHANGE_WINDOW_POINTS_PATTERN = Pattern.compile("Points: ([0-9]+)"); + private final Pattern BOAT_POINTS_PATTERN = Pattern.compile("Pest Points: ([0-9]+)"); + private final Pattern AWARDED_PATTERN = Pattern.compile("We've awarded you ([0-9]+) Void Knight Commendation points."); + private final Pattern PURCHASE_PATTERN = Pattern.compile("Remaining Void Knight Commendation Points: ([0-9]+)"); - @Getter(AccessLevel.PACKAGE) - private List spinners = new ArrayList<>(); + @Inject + @Getter + private Client client; @Inject private OverlayManager overlayManager; @Inject - private Client client; + private ConfigManager configManager; @Inject - private PestControlOverlay overlay; + private InfoBoxManager infoBoxManager; + + @Inject + @Getter + private ItemManager itemManager; + + @Inject + @Getter + private PestControlConfig config; + + @Inject + @Getter + private WidgetOverlay widgetOverlay; + + @Inject + private HintArrowOverlay hintArrowOverlay; + + @Inject + private NpcHighlightOverlay npcHighlightOverlay; + + @Inject + private RepairOverlay repairOverlay; + + @Inject + private GangplankOverlay gangplankOverlay; + + @Inject + private TimerOverlay timerOverlay; + + @Inject + private PortalWeaknessOverlay portalWeaknessOverlay; + + @Getter + private Game game; + + @Getter + private HashMap highlightedNpcList = new HashMap(); + + @Getter + private List highlightedRepairList = new ArrayList(); + + @Getter + private Tile noviceGangplankTile; + + @Getter + private Tile intermediateGangplankTile; + + @Getter + private Tile veteranGangplankTile; + + @Getter + private Integer commendationPoints; + + private String userConfigKey; + + private boolean checkForPointWidgets; + + private boolean pointsRewarded = false; + + private PointsInfoboxCounter pointsInfoboxCounter; + + + @Provides + PestControlConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(PestControlConfig.class); + } @Override protected void startUp() throws Exception { - overlayManager.add(overlay); + loadPlugin(); } @Override protected void shutDown() throws Exception { - overlayManager.remove(overlay); - spinners.clear(); + unloadPlugin(); + } + + @Subscribe + public void onConfigChanged(ConfigChanged configEvent) + { + if (configEvent.getGroup().equals("pestcontrol")) + { + unloadPlugin(); + loadPlugin(); + } + } + + private boolean loadLocalUserPoints() + { + if (userConfigKey != null) + { + String configKey = "points." + userConfigKey; + String pointString = configManager.getConfiguration("pestcontrol", configKey); + if (pointString != null) + { + commendationPoints = Integer.parseInt(pointString); + + return true; + } + } + + return false; + } + + private void loadPlugin() + { + if (loadLocalUserPoints()) + { + handlePointsInfoboxCounter(); + } + + overlayManager.add(widgetOverlay); + + if (config.highlightSpinners() != NpcHighlightStyle.OFF) + { + for (Integer npcId : PestControlNpc.getSpinnerIdSet()) + { + highlightedNpcList.put(npcId, new NpcHighlightContext( + config.highlightSpinners(), + config.spinnerColor(), + true + )); + } + } + + if (config.highlightBrawlers() != NpcHighlightStyle.OFF) + { + for (Integer npcId : PestControlNpc.getBrawlerIdSet()) + { + highlightedNpcList.put(npcId, new NpcHighlightContext( + config.highlightBrawlers(), + config.brawlerColor(), + false + )); + } + } + + if (config.portalHighlight() != HighlightPortalOption.OFF) + { + if (config.portalHighlight() == HighlightPortalOption.ACTIVE || + config.portalHighlight() == HighlightPortalOption.ALL) + { + for (Integer portalNpcId : PestControlNpc.getActivePortalIdSet()) + { + highlightedNpcList.put(portalNpcId, new NpcHighlightContext( + NpcHighlightStyle.HULL, + config.activePortalColor(), + false + )); + } + } + + if (config.portalHighlight() == HighlightPortalOption.SHIELDED || + config.portalHighlight() == HighlightPortalOption.ALL) + { + for (Integer portalNpcId : PestControlNpc.getShieldedPortalIdSet()) + { + highlightedNpcList.put(portalNpcId, new NpcHighlightContext( + NpcHighlightStyle.HULL, + config.shieldedPortalColor(), + false + )); + } + } + } + + if (!highlightedNpcList.isEmpty()) + { + overlayManager.add(npcHighlightOverlay); + } + + if (config.highlightRepairables()) + { + overlayManager.add(repairOverlay); + } + + if (config.showHintArrow()) + { + overlayManager.add(hintArrowOverlay); + + if (game != null && client.hasHintArrow()) + { + client.clearHintArrow(); + } + } + + if (config.highlightGangplanks()) + { + overlayManager.add(gangplankOverlay); + } + + if (config.showTimeTillNextPortal()) + { + overlayManager.add(timerOverlay); + } + + if (config.showPortalWeakness()) + { + overlayManager.add(portalWeaknessOverlay); + } + } + + private void unloadPlugin() + { + overlayManager.remove(widgetOverlay); + overlayManager.remove(npcHighlightOverlay); + overlayManager.remove(repairOverlay); + overlayManager.remove(gangplankOverlay); + overlayManager.remove(hintArrowOverlay); + overlayManager.remove(timerOverlay); + overlayManager.remove(portalWeaknessOverlay); + + infoBoxManager.removeInfoBox(pointsInfoboxCounter); + pointsInfoboxCounter = null; + + highlightedNpcList.clear(); + + if (game != null && config.showHintArrow() && client.hasHintArrow()) + { + client.clearHintArrow(); + } } @Subscribe public void onGameStateChanged(GameStateChanged event) { - GameState gameState = event.getGameState(); - if (gameState == GameState.CONNECTION_LOST || gameState == GameState.LOGIN_SCREEN || gameState == GameState.HOPPING) + // LOGGED_IN also triggers when teleporting to the island + if (event.getGameState() == GameState.LOGGED_IN) { - spinners.clear(); + handlePointsInfoboxCounter(); } } + public void handlePointsInfoboxCounter() + { + if (!config.showPoints()) + { + return; + } + + if (!isOnPestControlMainIsland() && !isInPestControlInstance()) + { + infoBoxManager.removeInfoBox(pointsInfoboxCounter); + pointsInfoboxCounter = null; + + return; + } + + if (commendationPoints == null) + { + if (pointsInfoboxCounter != null) + { + infoBoxManager.removeInfoBox(pointsInfoboxCounter); + pointsInfoboxCounter = null; + } + + return; + } + + if (pointsInfoboxCounter != null) + { + pointsInfoboxCounter.setCount(commendationPoints); + } + else + { + BufferedImage image = itemManager.getImage(ItemID.VOID_SEAL1); + pointsInfoboxCounter = new PointsInfoboxCounter(image, this, commendationPoints); + pointsInfoboxCounter.setTooltip("Void Knight Commendation Points"); + infoBoxManager.addInfoBox(pointsInfoboxCounter); + } + } + + + public void getPointsFromWidgets() + { + + // Get points from dialog after the game + Widget npcDialog = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT); + if (npcDialog != null) + { + String npcText = Text.sanitizeMultilineText(npcDialog.getText()); + Matcher matcher = AWARDED_PATTERN.matcher(npcText); + + if (matcher.find()) + { + int newPoints = Integer.parseInt(matcher.group(1)); + + if (commendationPoints != null) + { + newPoints += commendationPoints; + } + + setCommendationPoints(newPoints); + log.debug("PEST CONTROL [POINTS REWARDED] UPDATE: {}", commendationPoints); + return; + } + } + + // Get points from dialog after purchase + Widget pestControlDialog = client.getWidget(WidgetInfo.PEST_CONTROL_DIALOG_TEXT); + if (pestControlDialog != null) + { + String pestControlDialogText = Text.sanitizeMultilineText(pestControlDialog.getText()); + Matcher matcher = PURCHASE_PATTERN.matcher(pestControlDialogText); + + if (matcher.find()) + { + setCommendationPoints(Integer.parseInt(matcher.group(1))); + log.debug("PEST CONTROL [DIALOG] POINTS UPDATE: {}", commendationPoints); + return; + } + } + + // Get points from exchange window + Widget exchangeWindowPointsWidget = client.getWidget(WidgetInfo.PEST_CONTROL_EXCHANGE_WINDOW_POINTS); + if (exchangeWindowPointsWidget != null) + { + String pointsString = exchangeWindowPointsWidget.getText(); + + Matcher matcher = EXCHANGE_WINDOW_POINTS_PATTERN.matcher(pointsString); + if (matcher.lookingAt()) + { + setCommendationPoints(Integer.parseInt(matcher.group(1))); + log.debug("PEST CONTROL [EXCHANGE WINDOW] POINTS UPDATE: {}", commendationPoints); + return; + } + } + + // Get points in boat + // NOTE: The boat info widget is still active right after the game + // We should therefor only check for point updates if there are no dialogs + Widget boatPointsWidget = client.getWidget(WidgetInfo.PEST_CONTROL_BOAT_INFO_POINTS); + if (boatPointsWidget != null && npcDialog == null && pestControlDialog == null) + { + String pointsString = boatPointsWidget.getText(); + Matcher matcher = BOAT_POINTS_PATTERN.matcher(pointsString); + + if (matcher.lookingAt()) + { + log.debug(matcher.toString()); + log.debug("MATCHER GROUP 1: {}", matcher.group(1)); + setCommendationPoints(Integer.parseInt(matcher.group(1))); + log.debug("PEST CONTROL [BOAT] POINTS UPDATE: {}", commendationPoints); + } + } + } + + public void setCommendationPoints(int newPoints) + { + if (userConfigKey == null) + { + return; + } + + if (commendationPoints == null || commendationPoints != newPoints) + { + commendationPoints = newPoints; + + configManager.setConfiguration( + "pestcontrol", + "points." + userConfigKey, + String.valueOf(commendationPoints) + ); + } + + handlePointsInfoboxCounter(); + } + + @Subscribe + public void onGameTick(GameTick gameTickEvent) + { + // Check for widgets on main island + if (game == null && isOnPestControlMainIsland()) + { + // This must be synchronized for some reason + synchronized (this) + { + if (checkForPointWidgets) + { + checkForPointWidgets = false; + getPointsFromWidgets(); + } + } + } + + // Load the points of the user + if (userConfigKey == null) + { + String username = client.getUsername(); + + if (username == null) + { + return; + } + + userConfigKey = String.valueOf(username.hashCode()); + + log.debug("USER CONFIG SCOPE: {}", userConfigKey); + + if (loadLocalUserPoints()) + { + handlePointsInfoboxCounter(); + } + } + + // Check if the game has started + if (game == null && isInPestControlInstance()) + { + log.debug("Pest control game has started"); + game = new Game(client, this); + pointsRewarded = false; + } + + // Check if we are in a game + if (game == null) + { + return; + } + + // Check if we left the game + if (!isInPestControlInstance()) + { + if (game != null) + { + log.debug("Pest control game has ended"); + game = null; + } + + return; + } + + game.onGameTick(gameTickEvent); + } + @Subscribe public void onChatMessage(ChatMessage chatMessage) { - if (overlay.getGame() != null && chatMessage.getType() == ChatMessageType.GAMEMESSAGE) + if (game != null && chatMessage.getType() == ChatMessageType.GAMEMESSAGE) { - Matcher matcher = SHIELD_DROP.matcher(chatMessage.getMessage()); + Matcher matcher = SHIELD_DROP_PATTERN.matcher(chatMessage.getMessage()); if (matcher.lookingAt()) { - overlay.getGame().fall(matcher.group(1)); + game.lowerPortalShield(matcher.group(1)); } } } @Subscribe - public void onNpcSpawned(NpcSpawned event) + public void onWidgetLoaded(WidgetLoaded event) { - final NPC npc = event.getNpc(); - if (SPINNER_IDS.contains(npc.getId())) + if (game != null) { - spinners.add(npc); + log.debug(event.toString()); + } + + if (isOnPestControlMainIsland() && game == null) + { + checkForPointWidgets = true; + } + } + + private void unlistTileObject(TileObject tileObject) + { + int tileObjectId = tileObject.getId(); + + if (PestControlRepairObject.isRepairableBarricadeId(tileObjectId) || + PestControlRepairObject.isRepairableGateId(tileObjectId)) + { + highlightedRepairList.remove(tileObject); + return; + } + + switch (tileObjectId) + { + case NOVICE_GANGPLANK: + { + noviceGangplankTile = null; + break; + } + case INTERMEDIATE_GANGPLANK: + { + intermediateGangplankTile = null; + break; + } + case VETERAN_GANGPLANK: + { + veteranGangplankTile = null; + break; + } + } + } + + private void handleTileObject(Tile tile, TileObject tileObject) + { + int tileObjectId = tileObject.getId(); + + if (PestControlRepairObject.isRepairableBarricadeId(tileObjectId) || + PestControlRepairObject.isRepairableGateId(tileObjectId)) + { + highlightedRepairList.add(tileObject); + return; + } + + switch (tileObjectId) + { + case NOVICE_GANGPLANK: + { + noviceGangplankTile = tile; + break; + } + case INTERMEDIATE_GANGPLANK: + { + intermediateGangplankTile = tile; + break; + } + case VETERAN_GANGPLANK: + { + veteranGangplankTile = tile; + break; + } } } @Subscribe - public void onNpcDespawned(NpcDespawned event) + public void onGameObjectSpawned(GameObjectSpawned event) { - spinners.remove(event.getNpc()); + handleTileObject(event.getTile(), event.getGameObject()); + } + + @Subscribe + public void onGameObjectChanged(GameObjectChanged event) + { + unlistTileObject(event.getPrevious()); + handleTileObject(event.getTile(), event.getGameObject()); + } + + @Subscribe + public void onGameObjectDespawned(GameObjectDespawned event) + { + unlistTileObject(event.getGameObject()); + } + + @Subscribe + public void onGroundObjectSpawned(GroundObjectSpawned event) + { + handleTileObject(event.getTile(), event.getGroundObject()); + } + + @Subscribe + public void onGroundObjectChanged(GroundObjectChanged event) + { + unlistTileObject(event.getPrevious()); + handleTileObject(event.getTile(), event.getGroundObject()); + } + + @Subscribe + public void onGroundObjectDespawned(GroundObjectDespawned event) + { + unlistTileObject(event.getGroundObject()); + } + + public boolean isInPestControlInstance() + { + return client.getWidget(WidgetInfo.PEST_CONTROL_BLUE_SHIELD) != null; + } + + public boolean isOnPestControlMainIsland() + { + return client.getLocalPlayer().getWorldLocation().getRegionID() == 10537; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSessionRockStats.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlRepairObject.java similarity index 53% rename from runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSessionRockStats.java rename to runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlRepairObject.java index 523b1b18d1..f3a8d457dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningSessionRockStats.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlRepairObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Craftiii4 + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,66 +22,54 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.mining; +package net.runelite.client.plugins.pestcontrol; -import lombok.AccessLevel; +import com.google.common.collect.ImmutableSet; +import java.util.Set; import lombok.Getter; +import net.runelite.api.ObjectID; -import java.time.Duration; -import java.time.Instant; - -public class MiningSessionRockStats +@Getter +public class PestControlRepairObject { + @Getter + private static final Set repairableBarricades = ImmutableSet.of( + //ObjectID.BARRICADE_14224, + ObjectID.BARRICADE_14227, + ObjectID.BARRICADE_14228, + ObjectID.BARRICADE_14229, + ObjectID.BARRICADE_14230, + ObjectID.BARRICADE_14231, + ObjectID.BARRICADE_14232 + ); - private static final Duration HOUR = Duration.ofHours(1); + @Getter + private static final Set repairableGates = ImmutableSet.of( + ObjectID.GATE_14238, + ObjectID.GATE_14239, + ObjectID.GATE_14240, + ObjectID.GATE_14241, + ObjectID.GATE_14242, + ObjectID.GATE_14243, + ObjectID.GATE_14244, + ObjectID.GATE_14245, + ObjectID.GATE_14246, + ObjectID.GATE_14247, + ObjectID.GATE_14248 + ); - @Getter(AccessLevel.PACKAGE) - private Instant lastOreMined; - - @Getter(AccessLevel.PACKAGE) - private Instant recentOreMined; - - @Getter(AccessLevel.PACKAGE) - private int totalMined; - - @Getter(AccessLevel.PACKAGE) - private int perHour; - - @Getter(AccessLevel.PACKAGE) - private int recentMined; - - public MiningSessionRockStats() + public static boolean isRepairableBarricadeId(int objectId) { - lastOreMined = null; - recentOreMined = null; - totalMined = 0; - perHour = 0; - recentMined = 0; + return repairableBarricades.contains(objectId); } - public void clearSession() + public static boolean isRepairableGateId(int objectId) { - recentOreMined = null; - perHour = 0; - recentMined = 0; + return repairableGates.contains(objectId); } - public void increaseMined() + public static boolean isRepairableId(int objectId) { - Instant now = Instant.now(); - lastOreMined = now; - totalMined++; - if (recentOreMined == null) - { - recentOreMined = now; - } - recentMined++; - - Duration timeSinceStart = Duration.between(recentOreMined, now); - if (!timeSinceStart.isZero()) - { - perHour = (int) ((double) recentMined * (double) HOUR.toMillis() / (double) timeSinceStart.toMillis()); - } + return isRepairableBarricadeId(objectId) || isRepairableGateId(objectId); } - -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WayPointWorldMapPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PointsInfoboxCounter.java similarity index 72% rename from runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WayPointWorldMapPoint.java rename to runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PointsInfoboxCounter.java index 058665a256..1fa3155625 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WayPointWorldMapPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PointsInfoboxCounter.java @@ -22,28 +22,18 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.worldmap; +package net.runelite.client.plugins.pestcontrol; import java.awt.image.BufferedImage; +import net.runelite.client.ui.overlay.infobox.Counter; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; -import net.runelite.client.util.ImageUtil; - -class WayPointWorldMapPoint extends WorldMapPoint +public class PointsInfoboxCounter extends Counter { + private final PestControlPlugin plugin; - WayPointWorldMapPoint(final WorldPoint worldPoint) + PointsInfoboxCounter(BufferedImage image, PestControlPlugin plugin, int count) { - super(worldPoint, null); - - BufferedImage markerImage = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "waypoint_marker.png"); - - this.setSnapToEdge(true); - this.setJumpOnClick(true); - - this.setImage(markerImage); - - setTooltip("Waypoint"); + super(image, plugin, count); + this.plugin = plugin; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Portal.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Portal.java index 2807ff9fcb..2ad85a24ea 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Portal.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Portal.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2017, Adam + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,22 +24,39 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package net.runelite.client.plugins.pestcontrol; -import lombok.AllArgsConstructor; + import lombok.Getter; -import lombok.ToString; -import net.runelite.api.widgets.WidgetInfo; +import lombok.Setter; +import net.runelite.api.coords.WorldPoint; -@AllArgsConstructor @Getter -@ToString -enum Portal +@Setter +class Portal { - PURPLE(WidgetInfo.PEST_CONTROL_PURPLE_SHIELD, WidgetInfo.PEST_CONTROL_PURPLE_HEALTH, WidgetInfo.PEST_CONTROL_PURPLE_ICON), - BLUE(WidgetInfo.PEST_CONTROL_BLUE_SHIELD, WidgetInfo.PEST_CONTROL_BLUE_HEALTH, WidgetInfo.PEST_CONTROL_BLUE_ICON), - YELLOW(WidgetInfo.PEST_CONTROL_YELLOW_SHIELD, WidgetInfo.PEST_CONTROL_YELLOW_HEALTH, WidgetInfo.PEST_CONTROL_YELLOW_ICON), - RED(WidgetInfo.PEST_CONTROL_RED_SHIELD, WidgetInfo.PEST_CONTROL_RED_HEALTH, WidgetInfo.PEST_CONTROL_RED_ICON); + private PortalColor color; + private WidgetPortal widget; + private WorldPoint location; - private final WidgetInfo shield; - private final WidgetInfo hitpoints; - private final WidgetInfo icon; + private PortalState portalState = PortalState.SHIELDED; + + public Portal(PortalColor color, WidgetPortal widget) + { + this.color = color; + this.widget = widget; + } + + public boolean isShielded() + { + return portalState == PortalState.SHIELDED; + } + + public boolean isDead() + { + return portalState == PortalState.DEAD; + } + + public boolean isActive() + { + return (!isShielded() && !isDead()); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalContext.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalColor.java similarity index 84% rename from runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalContext.java rename to runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalColor.java index 6ad91ea6e3..07e7336c0b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalContext.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalColor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Adam + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,15 +25,12 @@ package net.runelite.client.plugins.pestcontrol; import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; -@RequiredArgsConstructor @Getter -@Setter -class PortalContext +public enum PortalColor { - private final Portal portal; - private boolean isShielded = true; - private boolean isDead; + BLUE, + PURPLE, + YELLOW, + RED } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Rotation.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalRotation.java similarity index 72% rename from runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Rotation.java rename to runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalRotation.java index e761edf383..b49d536bb8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/Rotation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalRotation.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2017, Adam + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,12 +25,12 @@ */ package net.runelite.client.plugins.pestcontrol; -import static net.runelite.client.plugins.pestcontrol.Portal.BLUE; -import static net.runelite.client.plugins.pestcontrol.Portal.PURPLE; -import static net.runelite.client.plugins.pestcontrol.Portal.RED; -import static net.runelite.client.plugins.pestcontrol.Portal.YELLOW; +import static net.runelite.client.plugins.pestcontrol.PortalColor.BLUE; +import static net.runelite.client.plugins.pestcontrol.PortalColor.PURPLE; +import static net.runelite.client.plugins.pestcontrol.PortalColor.RED; +import static net.runelite.client.plugins.pestcontrol.PortalColor.YELLOW; -enum Rotation +enum PortalRotation { PBYR(PURPLE, BLUE, YELLOW, RED), PYBR(PURPLE, YELLOW, BLUE, RED), @@ -38,23 +39,23 @@ enum Rotation YRPB(YELLOW, RED, PURPLE, BLUE), YPRB(YELLOW, PURPLE, RED, BLUE); - private final Portal[] portals; + private final PortalColor[] portals; - Rotation(Portal first, Portal second, Portal third, Portal fourth) + PortalRotation(PortalColor first, PortalColor second, PortalColor third, PortalColor fourth) { - portals = new Portal[] - { - first, second, third, fourth - }; + portals = new PortalColor[] + { + first, second, third, fourth + }; } - public Portal getPortal(int index) + public Portal getPortal(Game game, int index) { if (index < 0 || index >= portals.length) { return null; } - return portals[index]; + return game.getPortal(portals[index]); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalState.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalState.java new file mode 100644 index 0000000000..0a569d54b3 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalState.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +public enum PortalState +{ + ACTIVE, + SHIELDED, + DEAD +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalWeaknessOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalWeaknessOverlay.java new file mode 100644 index 0000000000..ff0deee9c2 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalWeaknessOverlay.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import com.google.inject.Inject; +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.ItemID; +import net.runelite.api.Perspective; +import net.runelite.api.Point; +import net.runelite.api.Skill; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.coords.WorldPoint; +import net.runelite.client.game.ItemManager; +import net.runelite.client.game.SkillIconManager; +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.OverlayUtil; + +@Slf4j +public class PortalWeaknessOverlay extends Overlay +{ + private int zOffset = 100; + + private final PestControlConfig config; + private final PestControlPlugin plugin; + private final Client client; + + private BufferedImage magicImage; + private BufferedImage rangedImage; + private BufferedImage stabImage; + private BufferedImage slashImage; + private BufferedImage crushImage; + + @Inject + PortalWeaknessOverlay( + PestControlConfig config, + PestControlPlugin plugin, + Client client, + ItemManager itemManager, + SkillIconManager skillIconManager + ) + { + this.config = config; + this.plugin = plugin; + this.client = client; + + this.magicImage = skillIconManager.getSkillImage(Skill.MAGIC); + this.rangedImage = skillIconManager.getSkillImage(Skill.RANGED); + + this.stabImage = itemManager.getImage(ItemID.WHITE_DAGGER); + this.slashImage = itemManager.getImage(ItemID.WHITE_SCIMITAR); + this.crushImage = itemManager.getImage(ItemID.WHITE_WARHAMMER); + + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.UNDER_WIDGETS); + } + + private Point getPortalPoint(Portal portal) + { + WorldPoint portalLocation = portal.getLocation(); + LocalPoint localLocation = LocalPoint.fromWorld(client, portalLocation); + + if (localLocation == null) + { + return null; + } + + // We can use any image here as it's only needed to calculate the position + Point imageLocation = Perspective.getCanvasImageLocation(client, localLocation, magicImage, zOffset); + + if (imageLocation != null) + { + return imageLocation; + } + + return null; + } + + private void renderPortalWeakness(Graphics2D graphics, Portal portal, BufferedImage image) + { + Point portalPoint = getPortalPoint(portal); + + if (portalPoint != null) + { + Composite originalComposite = graphics.getComposite(); + Composite translucentComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f); + graphics.setComposite(translucentComposite); + + OverlayUtil.renderImageLocation(graphics, portalPoint, image); + + graphics.setComposite(originalComposite); + } + } + + private void renderDoublePortalWeakness( + Graphics2D graphics, + Portal portal, + BufferedImage imageLeft, + BufferedImage imageRight + ) + { + Point portalPoint = getPortalPoint(portal); + + if (portalPoint != null) + { + Point portalLeft = new Point( + portalPoint.getX() - (imageLeft.getWidth() / 2) - 5, + portalPoint.getY() + ); + + Point portalRight = new Point( + portalPoint.getX() + (imageRight.getWidth() / 2) + 5, + portalPoint.getY() + ); + + Composite originalComposite = graphics.getComposite(); + Composite translucentComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); + graphics.setComposite(translucentComposite); + + OverlayUtil.renderImageLocation(graphics, portalLeft, imageLeft); + OverlayUtil.renderImageLocation(graphics, portalPoint, imageRight); + + graphics.setComposite(originalComposite); + } + } + + @Override + public Dimension render(Graphics2D graphics) + { + Game game = plugin.getGame(); + + if (game == null) + { + return null; + } + + for (Portal portal : game.getPortals()) + { + if (!portal.isDead()) + { + switch (portal.getColor()) + { + case BLUE: + { + renderPortalWeakness(graphics, portal, magicImage); + break; + } + case YELLOW: + { + renderDoublePortalWeakness(graphics, portal, stabImage, slashImage); + break; + } + case RED: + { + renderPortalWeakness(graphics, portal, crushImage); + break; + } + case PURPLE: + { + renderPortalWeakness(graphics, portal, rangedImage); + break; + } + } + } + } + + return null; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/RepairOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/RepairOverlay.java new file mode 100644 index 0000000000..a0ee3bf09f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/RepairOverlay.java @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import com.google.inject.Inject; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.geom.Area; +import net.runelite.api.Client; +import net.runelite.api.Constants; +import net.runelite.api.GameObject; +import net.runelite.api.GroundObject; +import net.runelite.api.Player; +import net.runelite.api.Point; +import net.runelite.api.Scene; +import net.runelite.api.Tile; +import net.runelite.api.WallObject; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; + +public class RepairOverlay extends Overlay +{ + private final PestControlConfig config; + private final PestControlPlugin plugin; + private final Client client; + + private static final int MAX_DISTANCE = 2400; + + @Inject + RepairOverlay(PestControlConfig config, PestControlPlugin plugin, Client client) + { + this.config = config; + this.plugin = plugin; + this.client = client; + + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (plugin.getGame() == null) + { + return null; + } + + Point mousePosition = client.getMouseCanvasPosition(); + Scene scene = client.getScene(); + Color color = config.repairableColor(); + Tile[][][] tiles = scene.getTiles(); + int z = client.getPlane(); + + for (int x = 0; x < Constants.SCENE_SIZE; ++x) + { + for (int y = 0; y < Constants.SCENE_SIZE; ++y) + { + Tile tile = tiles[z][x][y]; + + if (tile == null) + { + continue; + } + + Player player = client.getLocalPlayer(); + if (player == null) + { + continue; + } + + // Render GameObjects + GameObject[] gameObjects = tile.getGameObjects(); + if (gameObjects != null) + { + for (GameObject gameObject : gameObjects) + { + if (gameObject == null) + { + continue; + } + + if (PestControlRepairObject.isRepairableId(gameObject.getId())) + { + + if (player.getLocalLocation().distanceTo(gameObject.getLocalLocation()) <= MAX_DISTANCE) + { + renderObjectOverlay(graphics, gameObject.getClickbox(), color, mousePosition); + } + } + } + } + + // Render GameObject + GroundObject groundObject = tile.getGroundObject(); + if (groundObject != null) + { + if (groundObject == null) + { + continue; + } + + if (PestControlRepairObject.isRepairableId(groundObject.getId())) + { + + if (player.getLocalLocation().distanceTo(groundObject.getLocalLocation()) <= MAX_DISTANCE) + { + renderObjectOverlay(graphics, groundObject.getClickbox(), color, mousePosition); + } + } + } + + // Render WallObject + WallObject wallObject = tile.getWallObject(); + if (wallObject != null) + { + if (wallObject == null) + { + continue; + } + + if (PestControlRepairObject.isRepairableId(wallObject.getId())) + { + + if (player.getLocalLocation().distanceTo(wallObject.getLocalLocation()) <= MAX_DISTANCE) + { + renderObjectOverlay(graphics, wallObject.getClickbox(), color, mousePosition); + } + } + } + } + } + + + + + + + + /*if(plugin.getGame() == null) + { + return null; + } + + Point mousePosition = client.getMouseCanvasPosition(); + + List repairList = plugin.getHighlightedRepairList(); + + for(TileObject tileObject: repairList) + { + //tileObject.getWorldLocation().distanceTo(client.getLocalPlayer().getWorldLocation()); + + Polygon polygon = tileObject.getCanvasTilePoly(); + + if(polygon != null) + { + graphics.setColor(color); + graphics.setStroke(new BasicStroke(2)); + graphics.drawPolygon(polygon); + graphics.setColor(setColorAlpha(color, 40)); + graphics.fill(polygon); + + if(polygon.contains(mousePosition.getX(), mousePosition.getY())) + { + graphics.setColor(setColorAlpha(color, 65)); + graphics.fill(polygon); + } + } + } +*/ + return null; + } + + private void renderObjectOverlay(Graphics2D graphics, Area area, Color color, Point mousePosition) + { + if (area == null) + { + return; + } + + graphics.setColor(color); + graphics.setStroke(new BasicStroke(2)); + graphics.draw(area); + graphics.setColor(setColorAlpha(color, 50)); + graphics.fill(area); + + if (area.contains(mousePosition.getX(), mousePosition.getY())) + { + graphics.setColor(setColorAlpha(color, 60)); + graphics.fill(area); + } + } + + private Color setColorAlpha(Color color, int alpha) + { + return new Color( + color.getRed(), + color.getGreen(), + color.getBlue(), + alpha + ); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/TimerOverlay.java similarity index 54% rename from runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxOverlay.java rename to runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/TimerOverlay.java index 1a227b7ec5..be45fc728e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/TimerOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Jacky + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,58 +22,67 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.cox; +package net.runelite.client.plugins.pestcontrol; +import com.google.inject.Inject; +import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; -import javax.inject.Inject; +import java.time.Duration; import net.runelite.api.Client; +import net.runelite.api.Point; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.OverlayUtil; -public class CoxOverlay extends Overlay +public class TimerOverlay extends Overlay { + private final PestControlConfig config; + private final PestControlPlugin plugin; private final Client client; - private final CoxPlugin plugin; - - private final PanelComponent panelComponent = new PanelComponent(); @Inject - public CoxOverlay(Client client, CoxPlugin plugin) + TimerOverlay(PestControlConfig config, PestControlPlugin plugin, Client client) { - this.client = client; + this.config = config; this.plugin = plugin; - setPosition(OverlayPosition.TOP_LEFT); + this.client = client; + + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); } @Override public Dimension render(Graphics2D graphics) { - if (!client.isInInstancedRegion()) return null; - - panelComponent.getChildren().clear(); + if (plugin.getGame() == null) { - if (plugin.getOlm() != null) - { - if (plugin.getAttackStyle() == 0) - { - panelComponent.getChildren().add(LineComponent.builder() - .left("Pray: ") - .right("Mage") - .build()); - } - - if (plugin.getAttackStyle() == 1) - { - panelComponent.getChildren().add(LineComponent.builder() - .left("Pray: ") - .right("Ranged") - .build()); - } - } + return null; } - return panelComponent.render(graphics); + + Widget timeWidget = client.getWidget(WidgetInfo.PEST_CONTROL_INFO_TIME); + + if (timeWidget == null) + { + return null; + } + + int x = timeWidget.getCanvasLocation().getX() + 38; + int y = timeWidget.getCanvasLocation().getY() + 11; + + Duration timeTillNextPortal = plugin.getGame().getTimeTillNextPortal(); + + if (timeTillNextPortal != null) + { + String firstOrNext = (plugin.getGame().getShieldsDropped() == 0) ? "first" : "next"; + String string = String.format("- %s portal: %ds", firstOrNext, timeTillNextPortal.getSeconds()); + + OverlayUtil.renderTextLocation(graphics, new Point(x, y), string, new Color(204, 204, 204)); + } + + return null; } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetOverlay.java similarity index 62% rename from runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlOverlay.java rename to runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetOverlay.java index d8126c966e..4633128d6d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetOverlay.java @@ -1,6 +1,7 @@ /* * Copyright (c) 2017, Kronos * Copyright (c) 2017, Adam + * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,151 +32,107 @@ import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import javax.inject.Inject; -import lombok.AccessLevel; -import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; -import net.runelite.api.NPC; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; -import static net.runelite.client.plugins.pestcontrol.Portal.BLUE; -import static net.runelite.client.plugins.pestcontrol.Portal.PURPLE; -import static net.runelite.client.plugins.pestcontrol.Portal.RED; -import static net.runelite.client.plugins.pestcontrol.Portal.YELLOW; 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.OverlayUtil; @Slf4j -public class PestControlOverlay extends Overlay +public class WidgetOverlay extends Overlay { - private final PestControlPlugin plugin; private final Client client; - // Pest control game - @Getter(AccessLevel.PACKAGE) - private Game game; + private final PestControlPlugin plugin; @Inject - public PestControlOverlay(PestControlPlugin plugin, Client client) + public WidgetOverlay(Client client, PestControlPlugin plugin) { - setPosition(OverlayPosition.DYNAMIC); this.plugin = plugin; this.client = client; + + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + public Integer getPortalHitpoints(PortalColor color) + { + if (plugin.getGame() == null) + { + return null; + } + + WidgetInfo healthWidgetInfo = null; + + switch (color) + { + case RED: + { + healthWidgetInfo = WidgetPortal.RED.getHitpoints(); + break; + } + case BLUE: + { + healthWidgetInfo = WidgetPortal.BLUE.getHitpoints(); + break; + } + case PURPLE: + { + healthWidgetInfo = WidgetPortal.PURPLE.getHitpoints(); + break; + } + case YELLOW: + { + healthWidgetInfo = WidgetPortal.YELLOW.getHitpoints(); + break; + } + } + + if (healthWidgetInfo == null) + { + return null; + } + + Widget healthWidget = client.getWidget(healthWidgetInfo); + + if (healthWidget == null) + { + return null; + } + + return Integer.parseInt(healthWidget.getText().trim()); } @Override public Dimension render(Graphics2D graphics) { - // See if we are in a game or not - if (client.getWidget(WidgetInfo.PEST_CONTROL_BLUE_SHIELD) == null) + if (plugin.getGame() == null) { - if (game != null) - { - log.debug("Pest control game has ended"); - game = null; - } - return null; } - if (game == null) - { - log.debug("Pest control game has started"); - game = new Game(); - } - - renderSpinners(graphics); - renderPortalWidgets(graphics); - - return null; - } - - private void renderSpinners(Graphics2D graphics) - { - for (NPC npc : plugin.getSpinners()) - { - OverlayUtil.renderActorOverlay(graphics, npc, npc.getName(), Color.CYAN); - } - } - - private void renderPortalWidgets(Graphics2D graphics) - { - PortalContext purple = game.getPurple(); - PortalContext blue = game.getBlue(); - PortalContext yellow = game.getYellow(); - PortalContext red = game.getRed(); - - Widget purpleHealth = client.getWidget(PURPLE.getHitpoints()); - Widget blueHealth = client.getWidget(BLUE.getHitpoints()); - Widget yellowHealth = client.getWidget(YELLOW.getHitpoints()); - Widget redHealth = client.getWidget(RED.getHitpoints()); - - // Check for dead portals - if (isZero(purpleHealth)) - { - game.die(purple); - } - if (isZero(blueHealth)) - { - game.die(blue); - } - if (isZero(yellowHealth)) - { - game.die(yellow); - } - if (isZero(redHealth)) - { - game.die(red); - } - - // display "ATK" overlay on recorded portals without shields - renderAttack(graphics, purple); - renderAttack(graphics, blue); - renderAttack(graphics, yellow); - renderAttack(graphics, red); - - // display "NEXT" overlay on predicted portals - for (Portal portal : game.getNextPortals()) + for (Portal portal : plugin.getGame().getNextPortals()) { renderWidgetOverlay(graphics, portal, "NEXT", Color.ORANGE); } - renderProgressWidget(graphics); - } - - private void renderProgressWidget(Graphics2D graphics) - { - Widget bar = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_BAR).getChild(0); - Rectangle2D bounds = bar.getBounds().getBounds2D(); - - Widget prgs = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_PROGRESS).getChild(0); - int perc = (int) ((prgs.getBounds().getWidth() / bounds.getWidth()) * 100); - - Color color = Color.GREEN; - if (perc < 25) + for (Portal portal : plugin.getGame().getActivePortals()) { - color = Color.RED; + renderWidgetOverlay(graphics, portal, "ATT", Color.RED); } - String text = String.valueOf(perc) + "%"; + renderProgressWidget(graphics); - FontMetrics fm = graphics.getFontMetrics(); - Rectangle2D textBounds = fm.getStringBounds(text, graphics); - int x = (int) (bounds.getX() - textBounds.getWidth()); - int y = (int) (bounds.getY() + fm.getHeight() - 2); - - graphics.setColor(Color.BLACK); - graphics.drawString(text, x + 1, y + 1); - graphics.setColor(color); - graphics.drawString(text, x, y); + return null; } private void renderWidgetOverlay(Graphics2D graphics, Portal portal, String text, Color color) { - Widget shield = client.getWidget(portal.getShield()); - Widget icon = client.getWidget(portal.getIcon()); - Widget hp = client.getWidget(portal.getHitpoints()); + Widget shield = client.getWidget(portal.getWidget().getShield()); + Widget icon = client.getWidget(portal.getWidget().getIcon()); + Widget hp = client.getWidget(portal.getWidget().getHitpoints()); Widget bar = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_BAR).getChild(0); @@ -199,6 +156,45 @@ public class PestControlOverlay extends Overlay graphics.drawString(text, x, y + 4); } + private void renderProgressWidget(Graphics2D graphics) + { + String text; + int percentage; + + Widget bar = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_BAR).getChild(0); + Rectangle2D bounds = bar.getBounds().getBounds2D(); + + Widget prgs = client.getWidget(WidgetInfo.PEST_CONTROL_ACTIVITY_PROGRESS).getChild(0); + + // At 0% the inner widget changes and your progress will not increase anymore + if ((int) (prgs.getBounds().getX()) - bounds.getX() != 2) + { + percentage = 0; + text = "FAILED"; + } + else + { + percentage = (int) ((prgs.getBounds().getWidth() / bounds.getWidth()) * 100); + text = String.valueOf(percentage) + "%"; + } + + Color color = Color.GREEN; + if (percentage < 25) + { + color = Color.RED; + } + + FontMetrics fm = graphics.getFontMetrics(); + Rectangle2D textBounds = fm.getStringBounds(text, graphics); + int x = (int) (bounds.getX() - textBounds.getWidth() - 4); + int y = (int) (bounds.getY() + fm.getHeight() - 2); + + graphics.setColor(Color.BLACK); + graphics.drawString(text, x + 1, y + 1); + graphics.setColor(color); + graphics.drawString(text, x, y); + } + private static Rectangle2D union(Rectangle2D src1, Rectangle2D src2) { double x1 = Math.min(src1.getMinX(), src2.getMinX()); @@ -211,19 +207,4 @@ public class PestControlOverlay extends Overlay return result; } - - private void renderAttack(Graphics2D graphics, PortalContext portal) - { - if (portal.isShielded() || portal.isDead()) - { - return; - } - - renderWidgetOverlay(graphics, portal.getPortal(), "ATK", Color.RED); - } - - private static boolean isZero(Widget widget) - { - return widget.getText().trim().equals("0"); - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetPortal.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetPortal.java new file mode 100644 index 0000000000..7570cfb87f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetPortal.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; +import net.runelite.api.widgets.WidgetInfo; + +@AllArgsConstructor +@Getter +@ToString +enum WidgetPortal +{ + PURPLE(WidgetInfo.PEST_CONTROL_PURPLE_SHIELD, WidgetInfo.PEST_CONTROL_PURPLE_HEALTH, WidgetInfo.PEST_CONTROL_PURPLE_ICON), + BLUE(WidgetInfo.PEST_CONTROL_BLUE_SHIELD, WidgetInfo.PEST_CONTROL_BLUE_HEALTH, WidgetInfo.PEST_CONTROL_BLUE_ICON), + YELLOW(WidgetInfo.PEST_CONTROL_YELLOW_SHIELD, WidgetInfo.PEST_CONTROL_YELLOW_HEALTH, WidgetInfo.PEST_CONTROL_YELLOW_ICON), + RED(WidgetInfo.PEST_CONTROL_RED_SHIELD, WidgetInfo.PEST_CONTROL_RED_HEALTH, WidgetInfo.PEST_CONTROL_RED_ICON); + + private final WidgetInfo shield; + private final WidgetInfo hitpoints; + private final WidgetInfo icon; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/config/HighlightPortalOption.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/config/HighlightPortalOption.java new file mode 100644 index 0000000000..8e169edde9 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/config/HighlightPortalOption.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol.config; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum HighlightPortalOption +{ + OFF("Off"), + ACTIVE("Active"), + SHIELDED("Shielded"), + ALL("All"); + + private final String option; + + @Override + public String toString() + { + return option; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/config/NpcHighlightStyle.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/config/NpcHighlightStyle.java new file mode 100644 index 0000000000..af60c7b789 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/config/NpcHighlightStyle.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019, Yani + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.pestcontrol.config; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum NpcHighlightStyle +{ + OFF("Off"), + TILE("Tile"), + HULL("Hull"), + BOTH("Hull + Tile"); + + private final String style; + + @Override + public String toString() + { + return style; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionConfig.java deleted file mode 100644 index 74a733a7eb..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionConfig.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.runelite.client.plugins.pkvision; - -import java.awt.Color; -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("pkvision") -public interface PKVisionConfig extends Config -{ - @ConfigItem(position = 0, keyName = "drawOwnName", name = "Highlight own player", description = "Configures whether or not your own player should be highlighted") - default boolean highlightOwnPlayer() - { - return false; - } - - @ConfigItem(position = 1, keyName = "ownNameColor", name = "Own player color", description = "Color of your own player") - default Color getOwnPlayerColor() - { - return new Color(0, 184, 212); - } - - @ConfigItem(position = 2, keyName = "drawFriendNames", name = "Highlight friends", description = "Configures whether or not friends should be highlighted") - default boolean highlightFriends() - { - return true; - } - - @ConfigItem(position = 3, keyName = "friendNameColor", name = "Friend color", description = "Color of friend names" ) - default Color getFriendColor() - { - return new Color(0, 200, 80); - } - - @ConfigItem(position = 4, keyName = "drawPlayerTiles", name = "Draw tiles under players", description = "Configures whether or not tiles under highlighted players should be drawn") - default boolean drawTiles() - { - return false; - } - - @ConfigItem(position = 5, keyName = "drawPlayerNames", name = "Draw names above players", description = "Configures whether or not player names should be drawn above players") - default boolean drawPlayerNames() { return true; } - - @ConfigItem(position = 6, keyName = "drawPlayerLevels", name = "Draw levels above players", description = "Configures whether or not player levels should be drawn above players") - default boolean drawPlayerLevels() - { - return true; - } - - //@ConfigItem(position = 7, keyName = "drawPlayerHealth", name = "Draw health above players", description = "Configures whether or not player levels should be drawn above players") - //default boolean drawPlayerHealth() - //{ - // return true; - //} -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionMinimapOverlay.java deleted file mode 100644 index fc844eb734..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionMinimapOverlay.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.runelite.client.plugins.pkvision; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import javax.inject.Inject; -import javax.inject.Singleton; -import net.runelite.api.Player; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; - -@Singleton -public class PKVisionMinimapOverlay extends Overlay -{ - private final PKVisionService pkVisionService; - - @Inject - private PKVisionMinimapOverlay(PKVisionService pkVisionService) - { - this.pkVisionService = pkVisionService; - setLayer(OverlayLayer.ABOVE_WIDGETS); - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.HIGH); - } - - @Override - public Dimension render(Graphics2D graphics) - { - pkVisionService.forEachPlayer((player, color) -> renderPlayerOverlay(graphics, player, color)); - return null; -} - - private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) - { - final net.runelite.api.Point minimapLocation = actor.getMinimapLocation(); - - if (minimapLocation != null) - OverlayUtil.renderTextLocation(graphics, minimapLocation, Integer.toString(actor.getCombatLevel()), color); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionOverlay.java deleted file mode 100644 index b36b91da7b..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionOverlay.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.runelite.client.plugins.pkvision; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import javax.inject.Inject; -import javax.inject.Singleton; - -import net.runelite.api.Player; -import net.runelite.api.Point; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; - -@Singleton -public class PKVisionOverlay extends Overlay -{ - private final PKVisionService pkVisionService; - private final PKVisionConfig config; - - @Inject - private PKVisionOverlay(PKVisionConfig config, PKVisionService pkVisionService, PKVisionPlugin pkVisionPlugin) - { - this.config = config; - this.pkVisionService = pkVisionService; - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.MED); - } - - @Override - public Dimension render(Graphics2D graphics) - { - pkVisionService.forEachPlayer((player, color) -> renderPlayerOverlay(graphics, player, color)); - return null; - } - - private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) - { - if (!config.drawPlayerNames() && !config.drawPlayerLevels()) - return; - - String text = ""; - if (config.drawPlayerLevels()) - text += "(" + actor.getCombatLevel() + ") "; - - if (config.drawPlayerNames()) - text += actor.getName().replace('\u00A0', ' '); - - Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight() + 40); - - if (textLocation != null) - OverlayUtil.renderTextLocation(graphics, textLocation, text, color); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionPlugin.java deleted file mode 100644 index 6fc74fb2c2..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionPlugin.java +++ /dev/null @@ -1,135 +0,0 @@ -package net.runelite.client.plugins.pkvision; - -import net.runelite.client.eventbus.Subscribe; -import com.google.inject.Provides; -import java.awt.Color; -import javax.inject.Inject; -import net.runelite.api.Client; -import static net.runelite.api.MenuAction.*; -import net.runelite.api.MenuEntry; -import net.runelite.api.Player; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.client.util.ColorUtil; -import net.runelite.client.util.MiscUtils; -import net.runelite.client.util.Text; - -@PluginDescriptor( - name = "!PK Vision", - description = "Highlight players on-screen and/or on the minimap", - tags = {"highlight", "minimap", "overlay", "players", "pk", "helper", "vision", "bogla"}, - enabledByDefault = false -) -public class PKVisionPlugin extends Plugin -{ - @Inject - private OverlayManager overlayManager; - - @Inject - private PKVisionConfig config; - - @Inject - private PKVisionOverlay pkVisionOverlay; - - @Inject - private PKVisionTileOverlay pkVisionTileOverlay; - - @Inject - private PKVisionMinimapOverlay pkVisionMinimapOverlay; - - @Inject - private Client client; - - @Provides - PKVisionConfig provideConfig(ConfigManager configManager) - { - return configManager.getConfig(PKVisionConfig.class); - } - - @Override - protected void startUp() throws Exception - { - overlayManager.add(pkVisionOverlay); - overlayManager.add(pkVisionTileOverlay); - overlayManager.add(pkVisionMinimapOverlay); - } - - @Override - protected void shutDown() throws Exception - { - overlayManager.remove(pkVisionOverlay); - overlayManager.remove(pkVisionTileOverlay); - overlayManager.remove(pkVisionMinimapOverlay); - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) - { - int type = menuEntryAdded.getType(); - String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase(); - - if (type >= 2000) - type -= 2000; - - int identifier = menuEntryAdded.getIdentifier(); - if (type == FOLLOW.getId() || type == TRADE.getId() - || type == ITEM_USE_ON_PLAYER.getId() || type == PLAYER_FIRST_OPTION.getId() - || type == PLAYER_SECOND_OPTION.getId() || type == PLAYER_THIRD_OPTION.getId() - || type == PLAYER_FOURTH_OPTION.getId() || type == PLAYER_FIFTH_OPTION.getId() - || type == PLAYER_SIXTH_OPTION.getId() || type == PLAYER_SEVENTH_OPTION.getId() - || type == PLAYER_EIGTH_OPTION.getId() || type == SPELL_CAST_ON_PLAYER.getId() - || type == RUNELITE.getId()) - { - final Player localPlayer = client.getLocalPlayer(); - Player[] players = client.getCachedPlayers(); - Player player = null; - - if (identifier >= 0 && identifier < players.length) - player = players[identifier]; - - if (player == null) - return; - - Color color = null; - - if (config.highlightFriends() && (player.isFriend() || player.isClanMember())) - { - color = config.getFriendColor(); - } - else if (!player.isFriend() && !player.isClanMember()) - { - int lvlDelta = player.getCombatLevel() - localPlayer.getCombatLevel(); - int wildyLvl = MiscUtils.getWildernessLevelFrom(client, player.getWorldLocation()); - - if (wildyLvl <= 0) - return; - - int R = MiscUtils.clamp((int)(((float)(lvlDelta + wildyLvl) / (float)(wildyLvl * 2)) * 255.f), 0, 255); - int G = MiscUtils.clamp(255 - R, 0, 255); - - if (Math.abs(lvlDelta) <= wildyLvl) - color = Color.getHSBColor(Color.RGBtoHSB(R, G, 0, null)[0], 1.f, 1.f); - } - - if (color != null) - { - MenuEntry[] menuEntries = client.getMenuEntries(); - MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; - - // strip out existing '); - if (idx != -1) - target = target.substring(idx + 1); - - lastEntry.setTarget(ColorUtil.prependColorTag(target, color)); - - - client.setMenuEntries(menuEntries); - } - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionService.java b/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionService.java deleted file mode 100644 index 770cbd6505..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionService.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.runelite.client.plugins.pkvision; - -import java.awt.Color; -import java.util.function.BiConsumer; -import javax.inject.Inject; -import javax.inject.Singleton; -import net.runelite.api.Client; -import net.runelite.api.Player; -import net.runelite.client.util.MiscUtils; - -@Singleton -public class PKVisionService -{ - private final Client client; - private final PKVisionConfig config; - - @Inject - private PKVisionService(Client client, PKVisionConfig config) - { - this.config = config; - this.client = client; - } - - public void forEachPlayer(final BiConsumer consumer) - { - final Player localPlayer = client.getLocalPlayer(); - - for (Player player : client.getPlayers()) - { - if (player == null || player.getName() == null) - continue; - - if (player == localPlayer) - { - if (config.highlightOwnPlayer()) - consumer.accept(player, config.getOwnPlayerColor()); - - continue; - } - - if (config.highlightFriends() && (player.isFriend() || player.isClanMember())) - { - consumer.accept(player, config.getFriendColor()); - } - else if (player != localPlayer && !player.isFriend() && !player.isClanMember()) - { - int lvlDelta = player.getCombatLevel() - localPlayer.getCombatLevel(); - int wildyLvl = MiscUtils.getWildernessLevelFrom(client, player.getWorldLocation()); - - if (wildyLvl <= 0) - continue; - - if (Math.abs(lvlDelta) > wildyLvl) - continue; - - int R = MiscUtils.clamp((int)(((float)(lvlDelta + wildyLvl) / (float)(wildyLvl * 2)) * 255.f), 0, 255); - int G = MiscUtils.clamp(255 - R, 0, 255); - - consumer.accept(player, Color.getHSBColor(Color.RGBtoHSB(R, G, 0, null)[0], 1.f, 1.f)); - } - } - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionTileOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionTileOverlay.java deleted file mode 100644 index aba6c3fad6..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pkvision/PKVisionTileOverlay.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.runelite.client.plugins.pkvision; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Polygon; -import javax.inject.Inject; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; - -public class PKVisionTileOverlay extends Overlay -{ - private final PKVisionService pkVisionService; - private final PKVisionConfig config; - - @Inject - private PKVisionTileOverlay(PKVisionConfig config, PKVisionService pkVisionService) - { - this.config = config; - this.pkVisionService = pkVisionService; - setLayer(OverlayLayer.ABOVE_SCENE); - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.MED); - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (!config.drawTiles()) - return null; - - pkVisionService.forEachPlayer((player, color) -> - { - final Polygon poly = player.getCanvasTilePoly(); - - if (poly != null) - OverlayUtil.renderPolygon(graphics, poly, color); - }); - - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/plankmakehelper/PlankMakeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/plankmakehelper/PlankMakeOverlay.java deleted file mode 100644 index 8295f294b1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/plankmakehelper/PlankMakeOverlay.java +++ /dev/null @@ -1,88 +0,0 @@ -package net.runelite.client.plugins.plankmakehelper; - -import net.runelite.api.*; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetItem; -import net.runelite.client.ui.overlay.*; - -import javax.inject.Inject; -import java.awt.*; - -public class PlankMakeOverlay extends Overlay { - - private final PlankMakePlugin plugin; - private final Client client; - - @Inject - public PlankMakeOverlay(final PlankMakePlugin plugin, final Client client) { - super(plugin); - this.plugin = plugin; - this.client = client; - - setPosition(OverlayPosition.DETACHED); - setLayer(OverlayLayer.ALWAYS_ON_TOP); - setPriority(OverlayPriority.MED); - } - - @Override - public Dimension render(Graphics2D graphics) { - if (hasPlankableItems()) { - renderInventory(graphics); - renderPlankMakeSpell(graphics); - } - return null; - } - - private void renderInventory(Graphics2D graphics) { - Widget inventory = client.getWidget(WidgetInfo.INVENTORY); - - int firstItemSeenIndex = -1; - - if (inventory != null) { - for (WidgetItem item : inventory.getWidgetItems()) { - if (PlankMakePlugin.isLogAndPlankable(item.getId())) { - if (firstItemSeenIndex == -1) { - firstItemSeenIndex = item.getIndex(); - } - if (!inventory.isHidden()) { - if (item.getIndex() != firstItemSeenIndex) { - OverlayUtil.renderPolygon(graphics, RectangleToPolygon(item.getCanvasBounds()), Color.BLUE); - } - } - } - } - if (firstItemSeenIndex != -1) { - OverlayUtil.renderPolygon(graphics, RectangleToPolygon(inventory.getWidgetItem(firstItemSeenIndex).getCanvasBounds()), Color.CYAN); - } - } - } - - private void renderPlankMakeSpell(Graphics2D graphics) { - Widget plankMakeSpell = client.getWidget(218,128); - if (plankMakeSpell != null && (plankMakeSpell.getCanvasLocation().getX() != 29 & plankMakeSpell.getCanvasLocation().getY() != 32)) { - OverlayUtil.renderPolygon(graphics, RectangleToPolygon(plankMakeSpell.getBounds()), Color.CYAN); - } - } - - private boolean hasPlankableItems() { - ItemContainer invo = client.getItemContainer(InventoryID.INVENTORY); - if (invo != null) { - if (invo.getItems().length > 0) { - for (Item item : invo.getItems()) { - if (PlankMakePlugin.isLogAndPlankable(item.getId())) { - return true; - } - } - } - } - return false; - } - - static Polygon RectangleToPolygon(Rectangle rect) { - int[] xpoints = {rect.x, rect.x + rect.width, rect.x + rect.width, rect.x}; - int[] ypoints = {rect.y, rect.y, rect.y + rect.height, rect.y + rect.height}; - return new Polygon(xpoints, ypoints, 4); - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/plankmakehelper/PlankMakePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/plankmakehelper/PlankMakePlugin.java deleted file mode 100644 index 4c5a72001e..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/plankmakehelper/PlankMakePlugin.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.runelite.client.plugins.plankmakehelper; - -import net.runelite.api.Client; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; - -import javax.inject.Inject; - -@PluginDescriptor( - name = "Plank Make Helper", - description = "Highlights planks and plank make spell", - tags = {"overlay", "plankmaking", "lunar", "money", "moneymaking", "gp"} -) - -public class PlankMakePlugin extends Plugin { - - @Inject - private OverlayManager overlayManager; - - @Inject - private Client client; - - @Inject - private PlankMakeOverlay overlay; - - @Override - protected void startUp() { - overlayManager.add(overlay); - } - - @Override - protected void shutDown() { - overlayManager.remove(overlay); - } - - static boolean isLogAndPlankable(int itemID) { - switch (itemID) { - case 6332: //mahogany - case 1521: //oak - case 6333: //teak - case 1511: //plain - return true; - default: - return false; - } - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java index a0d6bf7223..f218bf5cbf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java @@ -137,13 +137,48 @@ public interface PlayerIndicatorsConfig extends Config name = "Non-clan member color", description = "Color of non-clan member names" ) - default Color getNonClanMemberColor() + default Color getNonClanMemberColor() { return Color.RED; } + + @ConfigItem( + position = 10, + keyName = "drawAttackerNames", + name = "Highlight attacker players", + description = "Configures whether or not attacker players should be highlighted" + ) + default boolean highlightAttackerPlayers() { - return Color.RED; + return false; } @ConfigItem( - position = 10, + position = 11, + keyName = "attackerColor", + name = "Attacker player color", + description = "Color of attacking player names" + ) + default Color getAttackerPlayerColor() { return new Color(241, 0, 108); } + + @ConfigItem( + position = 12, + keyName = "drawAttackableNames", + name = "Highlight attackable players", + description = "Configures whether or not attackable players should be highlighted" + ) + default boolean highlightAttackablePlayers() + { + return false; + } + + @ConfigItem( + position = 13, + keyName = "attackableColor", + name = "Attackable player color", + description = "Color of attackable player names" + ) + default Color getAttackablePlayerColor() { return new Color(231, 122,- 0); } + + @ConfigItem( + position = 14, keyName = "drawPlayerTiles", name = "Draw tiles under players", description = "Configures whether or not tiles under highlighted players should be drawn" @@ -154,18 +189,29 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 11, - keyName = "playerNamePosition", - name = "Name position", - description = "Configures the position of drawn player names, or if they should be disabled" + position = 15, + keyName = "drawOverheadPlayerNames", + name = "Draw names above players", + description = "Configures whether or not player names should be drawn above players" ) - default PlayerNameLocation playerNamePosition() + default boolean drawOverheadPlayerNames() { - return PlayerNameLocation.ABOVE_HEAD; + return true; } @ConfigItem( - position = 12, + position = 16, + keyName = "drawOverheadLevels", + name = "Draw combat levels above players", + description = "Configures whether or not combat levels should be drawn above players" + ) + default boolean drawOverheadLevels() + { + return false; + } + + @ConfigItem( + position = 17, keyName = "drawMinimapNames", name = "Draw names on minimap", description = "Configures whether or not minimap names for players with rendered names should be drawn" @@ -176,7 +222,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 13, + position = 18, keyName = "colorPlayerMenu", name = "Colorize player menu", description = "Color right click menu for players" @@ -187,7 +233,7 @@ public interface PlayerIndicatorsConfig extends Config } @ConfigItem( - position = 14, + position = 19, keyName = "clanMenuIcons", name = "Show clan ranks", description = "Add clan rank to right click menu and next to player names" @@ -197,14 +243,108 @@ public interface PlayerIndicatorsConfig extends Config return true; } + @ConfigItem( + position = 20, + keyName = "showOfflineFriends", + name = "Show offline friends", + description = "Draw friends names even if they're offline" + ) + default boolean showOfflineFriends() + { + return true; + } + @ConfigItem( - position = 15, - keyName = "showCombatLevels", - name = "Show combat levels", - description = "Add combat level to overhead name" + position = 21, + keyName = "drawHighlightedNames", + name = "Draw highlighted player names", + description = "Configures whether or not highlighted player names should be drawn" ) - default boolean showCombatLevels() + default boolean drawHighlightedNames() { - return true; + return false; } + + @ConfigItem( + keyName = "highlightedNames", + name = "Highlighted names", + description = "Clan caller names separated by a comma" + ) + default String getHighlightedNames() + { + return ""; + } + + @ConfigItem( + keyName = "highlightedNamesColor", + name = "Highlighted names color", + description = "Color of highlighted names" + ) + default Color getHighlightedNamesColor() + { + return Color.ORANGE; + } + + @ConfigItem( + position = 22, + keyName = "drawHighlightedTargetNames", + name = "Draw highlighted target names", + description = "Configures whether or not highlighted target names should be drawn" + ) + default boolean drawHighlightedTargetNames() + { + return false; + } + + @ConfigItem( + position = 23, + keyName = "highlightedTargetColor", + name = "Highlighted target color", + description = "Color of highlighted target names" + ) + default Color getHighlightedTargetColor() + { + return new Color(255, 100, 183); + } + + @ConfigItem( + position = 24, + keyName = "limitLevel", + name = "Limit Level", + description = "Limit the players to show +-x your level. Useful for BH" + ) + default boolean limitLevel() + { + return false; + } + + @ConfigItem( + position = 25, + keyName = "level", + name = "Level", + description = "The level to limit players shown +-x" + ) + default int intLevel() + { + return 5; + } + + @ConfigItem( + position = 26, + keyName = "wildernessOnly", + name = "Show only in wilderness", + description = "Toggle whether or not to only show player indicators in the wilderness" + ) + default boolean showInWildernessOnly() + { + return false; + } + + @ConfigItem( + position = 27, + keyName="rightClickOverhead", + name="Add Overheads to Right Click Menu", + description="Feature shows a player's overhead prayer in the right click menu. Useful for DDs, or extremely crowded areas.") + + default boolean rightClickOverhead() { return false; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 98d88168a6..e582694a9f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -1,6 +1,5 @@ /* * Copyright (c) 2018, Tomas Slusny - * Copyright (c) 2019, Jordan Atwood * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,6 +31,7 @@ import java.awt.image.BufferedImage; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.ClanMemberRank; +import net.runelite.api.Client; import net.runelite.api.Player; import net.runelite.api.Point; import net.runelite.client.game.ClanManager; @@ -39,17 +39,17 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; -import net.runelite.client.util.Text; @Singleton public class PlayerIndicatorsOverlay extends Overlay { - private static final int ACTOR_OVERHEAD_TEXT_MARGIN = 40; - private static final int ACTOR_HORIZONTAL_TEXT_MARGIN = 10; private final PlayerIndicatorsService playerIndicatorsService; private final PlayerIndicatorsConfig config; private final ClanManager clanManager; + @Inject + private Client client; + @Inject private PlayerIndicatorsOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService, ClanManager clanManager) @@ -70,82 +70,68 @@ public class PlayerIndicatorsOverlay extends Overlay private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) { - final PlayerNameLocation drawPlayerNamesConfig = config.playerNamePosition(); - if (drawPlayerNamesConfig == PlayerNameLocation.DISABLED) + if (!config.drawOverheadPlayerNames() && !config.drawOverheadLevels()) { return; } - final int zOffset; - switch (drawPlayerNamesConfig) + String namee = actor.getName().replace('\u00A0', ' '); + String combatLevel = Integer.toString(actor.getCombatLevel()); + String playerInfo = ""; + + if (config.drawOverheadPlayerNames()) { - case MODEL_CENTER: - case MODEL_RIGHT: - zOffset = actor.getLogicalHeight() / 2; - break; - default: - zOffset = actor.getLogicalHeight() + ACTOR_OVERHEAD_TEXT_MARGIN; + playerInfo = namee; } - String name = Text.sanitize(actor.getName()); - if (config.showCombatLevels()) + if (config.drawOverheadLevels()) { - name = name + " (" + actor.getCombatLevel() + ")"; + if (!playerInfo.isEmpty()) + { + playerInfo = playerInfo.concat("(" + combatLevel + ")"); + } + else + { + playerInfo = combatLevel; + } } - Point textLocation = actor.getCanvasTextLocation(graphics, name, zOffset); - if (drawPlayerNamesConfig == PlayerNameLocation.MODEL_RIGHT) + if (config.limitLevel()) { - textLocation = actor.getCanvasTextLocation(graphics, "", zOffset); - - if (textLocation == null) + if (!(client.getLocalPlayer().getCombatLevel() >= actor.getCombatLevel() - config.intLevel() && client.getLocalPlayer().getCombatLevel() <= actor.getCombatLevel() + config.intLevel())) { return; } - - textLocation = new Point(textLocation.getX() + ACTOR_HORIZONTAL_TEXT_MARGIN, textLocation.getY()); } - if (textLocation == null) - { - return; - } + String name = actor.getName().replace('\u00A0', ' ') + (config.limitLevel() ? " Lvl: " + actor.getCombatLevel() : ""); + int offset = actor.getLogicalHeight() + 40; + Point textLocation = actor.getCanvasTextLocation(graphics, playerInfo, offset); - if (config.showClanRanks() && actor.isClanMember()) + if (textLocation != null) { - ClanMemberRank rank = clanManager.getRank(actor.getName()); - - if (rank != ClanMemberRank.UNRANKED) + if (config.showClanRanks() && actor.isClanMember()) { - final BufferedImage clanchatImage = clanManager.getClanImage(rank); + ClanMemberRank rank = clanManager.getRank(name); - if (clanchatImage != null) + if (rank != ClanMemberRank.UNRANKED) { - final int clanImageWidth = clanchatImage.getWidth(); - final int clanImageTextMargin; - final int clanImageNegativeMargin; + BufferedImage clanchatImage = clanManager.getClanImage(rank); - if (drawPlayerNamesConfig == PlayerNameLocation.MODEL_RIGHT) + if (clanchatImage != null) { - clanImageTextMargin = clanImageWidth; - clanImageNegativeMargin = 0; - } - else - { - clanImageTextMargin = clanImageWidth / 2; - clanImageNegativeMargin = clanImageWidth / 2; - } + int width = clanchatImage.getWidth(); + int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent(); + Point imageLocation = new Point(textLocation.getX() - width / 2 - 1, textLocation.getY() - textHeight / 2 - clanchatImage.getHeight() / 2); + OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); - final int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent(); - final Point imageLocation = new Point(textLocation.getX() - clanImageNegativeMargin - 1, textLocation.getY() - textHeight / 2 - clanchatImage.getHeight() / 2); - OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); - - // move text - textLocation = new Point(textLocation.getX() + clanImageTextMargin, textLocation.getY()); + // move text + textLocation = new Point(textLocation.getX() + width / 2, textLocation.getY()); + } } } - } - OverlayUtil.renderTextLocation(graphics, textLocation, name, color); + OverlayUtil.renderTextLocation(graphics, textLocation, playerInfo, color); + } } -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index d1c65649ad..fd56c88fea 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -24,31 +24,45 @@ */ package net.runelite.client.plugins.playerindicators; -import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; import java.awt.Color; import javax.inject.Inject; -import net.runelite.api.ClanMemberRank; + +import net.runelite.api.*; + import static net.runelite.api.ClanMemberRank.UNRANKED; -import net.runelite.api.Client; import static net.runelite.api.MenuAction.*; -import net.runelite.api.MenuEntry; -import net.runelite.api.Player; + +import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.MenuEntryAdded; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.ClanManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ColorUtil; +import com.google.common.base.Splitter; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.InteractChanged; +import net.runelite.client.util.WildcardMatcher; + @PluginDescriptor( - name = "!Player Indicators", + name = "Player Indicators", description = "Highlight players on-screen and/or on the minimap", - tags = {"highlight", "minimap", "overlay", "players"} + tags = {"highlight", "minimap", "overlay", "players"}, + type = "utility" ) public class PlayerIndicatorsPlugin extends Plugin { + private static final Splitter COMMA_SPLITTER = Splitter.on(Pattern.compile("\\s*,\\s*")); @Inject private OverlayManager overlayManager; @@ -70,6 +84,8 @@ public class PlayerIndicatorsPlugin extends Plugin @Inject private ClanManager clanManager; + private Map highlightedPlayers = new HashMap<>(); + @Provides PlayerIndicatorsConfig provideConfig(ConfigManager configManager) { @@ -82,6 +98,7 @@ public class PlayerIndicatorsPlugin extends Plugin overlayManager.add(playerIndicatorsOverlay); overlayManager.add(playerIndicatorsTileOverlay); overlayManager.add(playerIndicatorsMinimapOverlay); + updateHighlightList(); } @Override @@ -93,8 +110,59 @@ public class PlayerIndicatorsPlugin extends Plugin } @Subscribe - public void onMenuEntryAdd(MenuEntryAdded menuEntryAdded) + public void onInteractChanged(InteractChanged event) { + Actor actor = event.getActor(); + if (actor != null + && actor.getName() != null + && isHighlighted(actor)) + { + highlightedPlayers.put(actor.getName().toLowerCase(), actor.getInteracting()); + } + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("playerindicators") && event.getKey().equals("highlightedNames")) + { + updateHighlightList(); + } + } + + private void updateHighlightList() + { + highlightedPlayers.clear(); + for (String player : COMMA_SPLITTER.splitToList(config.getHighlightedNames().toLowerCase().trim())) + { + highlightedPlayers.put(player, null); + } + } + + boolean isHighlighted(Actor player) + { + for (Map.Entry map : highlightedPlayers.entrySet()) + { + if (WildcardMatcher.matches(map.getKey(), player.getName())) + { + return true; + } + } + return false; + } + + boolean isHighlightedTarget(Player player) + { + return highlightedPlayers.containsValue(player); + } + + @Subscribe + public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) + { + if (config.showInWildernessOnly() && client.getVar(Varbits.IN_THE_WILDERNESS) != 1) + { + return; + } int type = menuEntryAdded.getType(); if (type >= 2000) @@ -132,7 +200,7 @@ public class PlayerIndicatorsPlugin extends Plugin int image = -1; Color color = null; - if (config.highlightFriends() && client.isFriended(player.getName(), false)) + if (config.highlightFriends() && player.isFriend()) { color = config.getFriendColor(); } @@ -154,6 +222,37 @@ public class PlayerIndicatorsPlugin extends Plugin { color = config.getNonClanMemberColor(); } + else if (config.drawHighlightedNames() && isHighlighted(player)) + { + color = config.getHighlightedNamesColor(); + } + else if (config.drawHighlightedTargetNames() && isHighlightedTarget(player)) + { + color = config.getHighlightedTargetColor(); + } + else if (config.highlightAttackerPlayers() && player.getInteracting() == localPlayer) + { + color = config.getAttackerPlayerColor(); + } + else if (config.highlightAttackablePlayers() && isWithinLevelRange(player.getCombatLevel())) + { + color = config.getAttackablePlayerColor(); + } + if (this.config.rightClickOverhead() && !player.isClanMember() && player.getOverheadIcon() != null) { // NEEDS TESTING + if (player.getOverheadIcon().equals((Object)HeadIcon.MAGIC)) { + image = 29; + } else if (player.getOverheadIcon().equals((Object)HeadIcon.RANGED)) { + image = 30; + } else if (player.getOverheadIcon().equals((Object)HeadIcon.MELEE)) { + image = 31; + } else if (player.getOverheadIcon().equals((Object)HeadIcon.REDEMPTION)) { + image = 32; + } else if (player.getOverheadIcon().equals((Object)HeadIcon.RETRIBUTION)) { + image = 33; + } else if (player.getOverheadIcon().equals((Object)HeadIcon.SMITE)) { + image = 34; + } + } if (image != -1 || color != null) { @@ -182,4 +281,57 @@ public class PlayerIndicatorsPlugin extends Plugin } } } + + public boolean isWithinLevelRange(int playerCombatLevel) + { + Widget levelRangeWidget = client.getWidget(WidgetInfo.PVP_ATTACK_RANGE); + Widget wildernessLevelWidget = client.getWidget(WidgetInfo.PVP_WILDERNESS_LEVEL); + + int localPlayerLevel = client.getLocalPlayer().getCombatLevel(); + int lowerLevelBound = localPlayerLevel - 15; + int upperLevelBound = localPlayerLevel + 15; + + if (levelRangeWidget == null && wildernessLevelWidget == null) + { + return false; + } + + if (!levelRangeWidget.isHidden() && !wildernessLevelWidget.isHidden()) + { + int wildernessLevel = calculateWildernessLevel(client.getLocalPlayer().getWorldLocation()); + lowerLevelBound = localPlayerLevel - wildernessLevel - 15; + upperLevelBound = localPlayerLevel + wildernessLevel + 15; + return (playerCombatLevel >= lowerLevelBound && playerCombatLevel <= upperLevelBound); + } + else if (levelRangeWidget.isHidden() && !wildernessLevelWidget.isHidden()) + { + int wildernessLevel = calculateWildernessLevel(client.getLocalPlayer().getWorldLocation()); + lowerLevelBound = localPlayerLevel - wildernessLevel; + upperLevelBound = localPlayerLevel + wildernessLevel; + return (playerCombatLevel >= lowerLevelBound && playerCombatLevel <= upperLevelBound); + } + else + { + return (playerCombatLevel >= lowerLevelBound && playerCombatLevel <= upperLevelBound); + } + } + + public static int calculateWildernessLevel(WorldPoint userLocation) + { + int wildernessLevel = 0; + if (WorldPoint.isInZone(new WorldPoint(2944, 3520, 0), new WorldPoint(3391, 4351, 3), userLocation)) + { + wildernessLevel = ((userLocation.getY() - (55 * 64)) / 8) + 1; + } + else if (WorldPoint.isInZone(new WorldPoint(3008, 10112, 0), new WorldPoint(3071, 10175, 3), userLocation)) + { + wildernessLevel = ((userLocation.getY() - (155 * 64)) / 8) - 1; + } + else if (WorldPoint.isInZone(new WorldPoint(2944, 9920, 0), new WorldPoint(3391, 10879, 3), userLocation)) + { + wildernessLevel = ((userLocation.getY() - (155 * 64)) / 8) + 1; + } + return wildernessLevel; + } + } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index 769c7e3aed..74b1c5a58b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -30,62 +30,96 @@ import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Player; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.api.Varbits; + + +import static net.runelite.client.plugins.playerindicators.PlayerIndicatorsPlugin.calculateWildernessLevel; @Singleton -public class PlayerIndicatorsService -{ +public class PlayerIndicatorsService { private final Client client; private final PlayerIndicatorsConfig config; @Inject - private PlayerIndicatorsService(Client client, PlayerIndicatorsConfig config) - { + private PlayerIndicatorsService(Client client, PlayerIndicatorsConfig config) { this.config = config; this.client = client; } - public void forEachPlayer(final BiConsumer consumer) - { - if (!config.highlightOwnPlayer() && !config.drawClanMemberNames() - && !config.highlightFriends() && !config.highlightNonClanMembers()) + public void forEachPlayer(final BiConsumer consumer) { + + if (config.showInWildernessOnly() && client.getVar(Varbits.IN_THE_WILDERNESS) != 1) { return; } + if (!config.highlightOwnPlayer() && !config.drawClanMemberNames() + && !config.highlightFriends() && !config.highlightNonClanMembers() + && !config.highlightAttackablePlayers() && !config.highlightAttackerPlayers()) { + return; + } + final Player localPlayer = client.getLocalPlayer(); - for (Player player : client.getPlayers()) - { - if (player == null || player.getName() == null) - { + for (Player player : client.getPlayers()) { + if (player == null || player.getName() == null) { continue; } boolean isClanMember = player.isClanMember(); - if (player == localPlayer) - { - if (config.highlightOwnPlayer()) - { + if (player == localPlayer) { + if (config.highlightOwnPlayer()) { consumer.accept(player, config.getOwnPlayerColor()); } - } - else if (config.highlightFriends() && player.isFriend()) - { + } else if (config.highlightFriends() && player.isFriend()) { consumer.accept(player, config.getFriendColor()); - } - else if (config.drawClanMemberNames() && isClanMember) - { + } else if (config.drawClanMemberNames() && isClanMember) { consumer.accept(player, config.getClanMemberColor()); - } - else if (config.highlightTeamMembers() && localPlayer.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) - { + } else if (config.highlightTeamMembers() && localPlayer.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) { consumer.accept(player, config.getTeamMemberColor()); - } - else if (config.highlightNonClanMembers() && !isClanMember) - { + } else if (config.highlightNonClanMembers() && !isClanMember) { consumer.accept(player, config.getNonClanMemberColor()); - } + } else if (config.highlightAttackerPlayers() && player.getInteracting() == localPlayer) { + consumer.accept(player, config.getAttackerPlayerColor()); + } else if (config.highlightAttackablePlayers() && isWithinLevelRange(player.getCombatLevel())) { + consumer.accept(player, config.getAttackablePlayerColor()); + } + } + } + + public boolean isWithinLevelRange(int playerCombatLevel) + { + Widget levelRangeWidget = client.getWidget(WidgetInfo.PVP_ATTACK_RANGE); + Widget wildernessLevelWidget = client.getWidget(WidgetInfo.PVP_WILDERNESS_LEVEL); + + int localPlayerLevel = client.getLocalPlayer().getCombatLevel(); + int lowerLevelBound = localPlayerLevel - 15; + int upperLevelBound = localPlayerLevel + 15; + + if (levelRangeWidget == null && wildernessLevelWidget == null) + { + return false; + } + + if (!levelRangeWidget.isHidden() && !wildernessLevelWidget.isHidden()) + { + lowerLevelBound = Integer.parseInt(levelRangeWidget.getText().split("-")[0]); + upperLevelBound = Integer.parseInt(levelRangeWidget.getText().split("-")[1]); + return (playerCombatLevel >= lowerLevelBound && playerCombatLevel <= upperLevelBound); + } + else if (levelRangeWidget.isHidden() && !wildernessLevelWidget.isHidden()) + { + int wildernessLevel = calculateWildernessLevel(client.getLocalPlayer().getWorldLocation()); + lowerLevelBound = localPlayerLevel - wildernessLevel; + upperLevelBound = localPlayerLevel + wildernessLevel; + return (playerCombatLevel >= lowerLevelBound && playerCombatLevel <= upperLevelBound); + } + else + { + return (playerCombatLevel >= lowerLevelBound && playerCombatLevel <= upperLevelBound); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pluginsorter/PluginSorterConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/pluginsorter/PluginSorterConfig.java new file mode 100644 index 0000000000..2477c8070a --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pluginsorter/PluginSorterConfig.java @@ -0,0 +1,71 @@ +package net.runelite.client.plugins.pluginsorter; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +import java.awt.*; + +@ConfigGroup("runelit") +public interface PluginSorterConfig extends Config { + + Color rlDefault = new Color(250, 155, 23); + + boolean pluginsHidden = false; + + @ConfigItem( + position = 0, + keyName = "hidePlugins", + name = "Hide Plugins", + description = "Hides all 3rd party plugins if checked" + ) + default boolean hidePlugins() + { + return pluginsHidden; + } + + @ConfigItem( + position = 1, + keyName = "externalColor", + name = "External color", + description = "Configure the color of external plugins" + ) + default Color externalColor() + { + return Color.MAGENTA; + } + + @ConfigItem( + position = 2, + keyName = "pvmColor", + name = "PVM color", + description = "Configure the color of PVM related plugins" + ) + default Color pvmColor() + { + return Color.GREEN; + } + + @ConfigItem( + position = 3, + keyName = "pvpColor", + name = "PVP color", + description = "Configure the color of PVP related plugins" + ) + default Color pvpColor() + { + return Color.RED; + } + + @ConfigItem( + position = 4, + keyName = "utilityColor", + name = "Utility color", + description = "Configure the color of utility related plugins" + ) + default Color utilityColor() + { + return Color.CYAN; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pluginsorter/PluginSorterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pluginsorter/PluginSorterPlugin.java new file mode 100644 index 0000000000..ba31160a32 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pluginsorter/PluginSorterPlugin.java @@ -0,0 +1,132 @@ +package net.runelite.client.plugins.pluginsorter; + +import com.google.inject.Provides; +import net.runelite.api.GameState; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.GameStateChanged; +import net.runelite.client.config.ConfigItemDescriptor; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.config.ConfigPanel; +import net.runelite.client.plugins.config.PluginListItem; + +import javax.inject.Inject; +import java.awt.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +@PluginDescriptor( + name = "Plugin Organizer", + description = "Hides and colors 3rd party plugins for better control", + tags = {"Fuck RL","Abex is shit :p"}, + type = "pluginOrganizer" +) +public class PluginSorterPlugin extends Plugin { + + //Cache the hidden plugins + public static List removedPlugins = new ArrayList<>(); + + @Inject + private PluginSorterConfig config; + + @Provides + PluginSorterConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(PluginSorterConfig.class); + } + + @Override + protected void startUp() throws Exception + { + updateColors(); + } + + @Override + protected void shutDown() throws Exception + { + + } + + @Subscribe + public void onGameStateChanged (GameStateChanged gameStateChanged) + { + if (gameStateChanged.getGameState()== GameState.LOGIN_SCREEN) { + if (config.hidePlugins()) + hidePlugins(); + updateColors(); + } + } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) { + if (configChanged.getKey().equals("hidePlugins")) { + if (config.hidePlugins()) { + hidePlugins(); + } else { + showPlugins(); + } + } + updateColors(); + } + + public void updateColors() { + for (PluginListItem pli : ConfigPanel.pluginList) { + if (pli.getPlugin()!=null) { + if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type()!=null) + if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("external")) + pli.nameLabel.setForeground(config.externalColor()); + else if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("PVM")) + pli.nameLabel.setForeground(config.pvmColor()); + else if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("PVP")) + pli.nameLabel.setForeground(config.pvpColor()); + else if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("utility")) + pli.nameLabel.setForeground(config.utilityColor()); + else + pli.nameLabel.setForeground(Color.WHITE); + } + } + } + + public void hidePlugins() { + Iterator iter = ConfigPanel.pluginList.iterator(); + while (iter.hasNext()) { + PluginListItem pli = iter.next(); + if (pli.getPlugin() != null) { + if (!pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("")) + if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("external")) { + iter.remove(); + removedPlugins.add(pli); + } + if (!pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("")) + if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("PVM")) { + iter.remove(); + removedPlugins.add(pli); + } + if (!pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("")) + if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("PVP")) { + iter.remove(); + removedPlugins.add(pli); + } + if (!pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("")) + if (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type().equals("utility")) { + iter.remove(); + removedPlugins.add(pli); + } + } + } + } + + public void showPlugins() { + List tempList = new ArrayList<>(); + for (PluginListItem pli : removedPlugins) { + tempList.add(pli); + } + for (PluginListItem pli : ConfigPanel.pluginList) { + tempList.add(pli); + } + ConfigPanel.pluginList = tempList; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerPlugin.java index 5664621b60..c0dc2644a1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerPlugin.java @@ -42,9 +42,10 @@ import java.util.ArrayList; import java.util.Arrays; @PluginDescriptor( - name = "!Pray Against Player", + name = "Pray Against Player", description = "Use plugin in PvP situations for best results!!", - tags = {"highlight", "pvp", "overlay", "players"} + tags = {"highlight", "pvp", "overlay", "players"}, + type = "PVP" ) /** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java index 876d27ff55..cf27d2b78d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java @@ -6,28 +6,19 @@ package net.runelite.client.plugins.profiles; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Container; import java.awt.Dimension; -import java.awt.Image; -import java.awt.LayoutManager; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import javax.swing.BorderFactory; -import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import net.runelite.api.Client; import net.runelite.api.GameState; -import net.runelite.client.plugins.profiles.ProfilesConfig; -import net.runelite.client.plugins.profiles.ProfilesPanel; -import net.runelite.client.plugins.profiles.ProfilesPlugin; import net.runelite.client.ui.ColorScheme; import net.runelite.client.util.ImageUtil; import org.slf4j.Logger; @@ -123,7 +114,7 @@ extends JPanel { } static { - BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(ProfilesPlugin.class, "delete_icon.png"); + BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(ProfilesPlugin.class, "net/runelite/client/plugins/profiles/delete_icon.png"); DELETE_ICON = new ImageIcon(deleteImg); DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100)); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java index 467c2b820f..4128adba44 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java @@ -3,10 +3,8 @@ */ package net.runelite.client.plugins.profiles; -import com.google.inject.Injector; import com.google.inject.Provides; import java.awt.image.BufferedImage; -import java.security.GeneralSecurityException; import java.security.InvalidKeyException; import java.security.Key; import java.security.NoSuchAlgorithmException; @@ -18,18 +16,13 @@ import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.SecretKeySpec; import javax.inject.Inject; import net.runelite.api.Client; -import net.runelite.api.GameState; import net.runelite.api.events.ConfigChanged; -import net.runelite.api.events.GameStateChanged; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.profiles.ProfilesConfig; -import net.runelite.client.plugins.profiles.ProfilesPanel; import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.NavigationButton; -import net.runelite.client.ui.PluginPanel; import net.runelite.client.util.ImageUtil; @PluginDescriptor(name="Account Switcher", description="Allow for a allows you to easily switch between multiple OSRS Accounts", tags={"profile", "account", "login", "log in"}) @@ -55,7 +48,7 @@ extends Plugin { @Override protected void startUp() throws Exception { this.panel = this.injector.getInstance(ProfilesPanel.class); - BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "profiles_icon.png"); + BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "/net/runelite/client/plugins/profiles/profiles_icon.png"); this.navButton = NavigationButton.builder().tooltip("Profiles").icon(icon).priority(8).panel(this.panel).build(); this.clientToolbar.addNavigation(this.navButton); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/delete_icon.png b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/delete_icon.png deleted file mode 100644 index 18b67f23f3..0000000000 Binary files a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/delete_icon.png and /dev/null differ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/profiles_icon.png b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/profiles_icon.png deleted file mode 100644 index a733eaf4a1..0000000000 Binary files a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/profiles_icon.png and /dev/null differ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderConfig.java deleted file mode 100644 index 6385326ec6..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.runelite.client.plugins.protectitemreminder; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("protectitemreminder") -public interface ProtectItemReminderConfig extends Config -{ - @ConfigItem(position = 0, keyName = "skulledOnly", name = "Only when skulled", description = "Only show the reminder when you are skulled") - default boolean skulledOnly() { return false; } - - @ConfigItem(position = 1, keyName = "getHeight", name = "Text Height", description = "Sets the reminder text height") - default int getHeight() { return 60; } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderOverlay.java deleted file mode 100644 index 499bfa5efb..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderOverlay.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.runelite.client.plugins.protectitemreminder; - -import net.runelite.api.Client; -import net.runelite.api.Player; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; - -import javax.inject.Inject; -import java.awt.*; - -public class ProtectItemReminderOverlay extends Overlay -{ - private final Client client; - private final ProtectItemReminderPlugin plugin; - private final ProtectItemReminderConfig config; - - private final String protItemString = "ENABLE PROTECT ITEM"; - - @Inject - private ProtectItemReminderOverlay(Client client, ProtectItemReminderPlugin plugin, ProtectItemReminderConfig config) - { - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.HIGHEST); - this.client = client; - this.plugin = plugin; - this.config = config; - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (!plugin.shouldRemind) - return null; - - Player localPlayer = client.getLocalPlayer(); - - if (localPlayer == null) - return null; - - net.runelite.api.Point drawPos = localPlayer.getCanvasTextLocation(graphics, protItemString, localPlayer.getLogicalHeight() + config.getHeight()); - - if (drawPos != null) - OverlayUtil.renderTextLocation(graphics, drawPos, protItemString, Color.RED); - - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderPlugin.java deleted file mode 100644 index bebdcb96c1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/protectitemreminder/ProtectItemReminderPlugin.java +++ /dev/null @@ -1,99 +0,0 @@ -package net.runelite.client.plugins.protectitemreminder; - -import net.runelite.client.eventbus.Subscribe; -import com.google.inject.Provides; -import net.runelite.api.*; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.util.MiscUtils; - -import javax.inject.Inject; - -@PluginDescriptor( - name = "!Protect Item Reminder", - description = "Reminds you to protect item when in the wilderness.", - tags = { "wilderness", "prayer", "protect", "item", "pking" }, - enabledByDefault = false -) -public class ProtectItemReminderPlugin extends Plugin -{ - @Inject - private Client client; - - @Inject - private OverlayManager overlayManager; - - @Inject - private ProtectItemReminderOverlay overlay; - - @Inject - private ProtectItemReminderConfig config; - - private Player localPlayer; - - public boolean shouldRemind = false; - - @Provides - ProtectItemReminderConfig getConfig(ConfigManager configManager) - { - return configManager.getConfig(ProtectItemReminderConfig.class); - } - - @Override - protected void startUp() throws Exception - { - overlayManager.add(overlay); - } - - @Override - protected void shutDown() throws Exception - { - overlayManager.remove(overlay); - shouldRemind = false; - localPlayer = null; - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - if (event.getGameState() == GameState.LOGGED_IN) - { - localPlayer = client.getLocalPlayer(); - } - } - - @Subscribe - public void onGameTick(GameTick event) - { - if (client.getGameState() == GameState.LOGIN_SCREEN) - return; - - if (localPlayer == null) - { - shouldRemind = false; - return; - } - if (config.skulledOnly() && localPlayer.getSkullIcon() != SkullIcon.SKULL) - { - shouldRemind = false; - return; - } - if (MiscUtils.getWildernessLevelFrom(client, localPlayer.getWorldLocation()) <= 0) - { - shouldRemind = false; - return; - } - - int value = client.getVar(Prayer.PROTECT_ITEM.getVarbit()); - - if (value == 0) - shouldRemind = true; - else - shouldRemind = false; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java new file mode 100644 index 0000000000..e55b528c11 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.pvptools; + +import net.runelite.api.Client; +import net.runelite.client.ui.FontManager; + +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionListener; +import java.util.List; + +public class CurrentPlayersJFrame extends JFrame +{ + + public JList currentPlayersJList; + + CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) + { + super(); + int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); + int y = client.getCanvas().getLocationOnScreen().y; + JPanel scrollContainerCurrent = new JPanel(new BorderLayout()); + + JScrollPane jScrollPane = new JScrollPane(scrollContainerCurrent); + JButton refreshJButton = new JButton("Refresh"); + refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener); + JButton copyJButton = new JButton("Copy List"); + currentPlayersJList = new JList(list.toArray()); + ActionListener copyButtonActionListener = e -> + { + StringSelection stringSelection; + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuilder stringBuilder = new StringBuilder(); + list.forEach(s -> + { + stringBuilder.append(s); + stringBuilder.append(System.getProperty("line.separator")); + }); + stringSelection = new StringSelection(stringBuilder.toString()); + clipboard.setContents(stringSelection, stringSelection); + }; + copyJButton.addActionListener(copyButtonActionListener); + this.setTitle("Current CC Members"); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + JLabel titleLabel = new JLabel("Current CC Members"); + titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18)); + currentPlayersJList.setFont(new Font("Arial", Font.PLAIN, 14)); + scrollContainerCurrent.add(refreshJButton, BorderLayout.NORTH); + scrollContainerCurrent.add(titleLabel, BorderLayout.CENTER); + JPanel footerPanel = new JPanel(new BorderLayout()); + footerPanel.add(currentPlayersJList, BorderLayout.NORTH); + footerPanel.add(copyJButton, BorderLayout.CENTER); + scrollContainerCurrent.add(footerPanel, BorderLayout.SOUTH); + this.add(jScrollPane); + this.setLocation(x, y); + this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); + this.pack(); + this.setVisible(true); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java new file mode 100644 index 0000000000..a30dd9a04e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.pvptools; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionListener; +import java.util.List; +import java.util.Vector; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import net.runelite.api.ClanMember; +import net.runelite.api.Client; +import net.runelite.client.ui.FontManager; + +public class MissingPlayersJFrame extends JFrame +{ + + public JList missingPlayersJList; + + MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) + { + super(); + int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); + int y = client.getCanvas().getLocationOnScreen().y; + JPanel scrollConatiner = new JPanel(new BorderLayout()); + + JScrollPane jScrollPane = new JScrollPane(scrollConatiner); + JButton refreshJButton = new JButton("Refresh"); + refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener); + JButton copyJButton = new JButton("Copy List"); + missingPlayersJList = new JList(list.toArray()); + ActionListener copyButtonActionListener = e -> + { + StringSelection stringSelection; + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuilder stringBuilder = new StringBuilder(); + list.forEach(s -> + { + stringBuilder.append(s); + stringBuilder.append(System.getProperty("line.separator")); + }); + stringSelection = new StringSelection(stringBuilder.toString()); + clipboard.setContents(stringSelection, stringSelection); + }; + copyJButton.addActionListener(copyButtonActionListener); + this.setTitle("Missing CC Members"); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + JLabel titleLabel = new JLabel("Missing CC Members"); + titleLabel.setFont(FontManager.getRunescapeFont().deriveFont(Font.BOLD, 18)); + missingPlayersJList.setFont(new Font("Arial", Font.PLAIN, 14)); + scrollConatiner.add(refreshJButton, BorderLayout.NORTH); + scrollConatiner.add(titleLabel, BorderLayout.CENTER); + JPanel footerPanel = new JPanel(new BorderLayout()); + footerPanel.add(missingPlayersJList, BorderLayout.NORTH); + footerPanel.add(copyJButton, BorderLayout.CENTER); + scrollConatiner.add(footerPanel, BorderLayout.SOUTH); + this.add(jScrollPane); + this.setLocation(x, y); + this.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize()); + this.pack(); + this.setVisible(true); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java new file mode 100644 index 0000000000..a6a1392763 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsConfig.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.pvptools; + +import java.awt.Color; +import java.security.Key; +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Keybind; + +@ConfigGroup("pvptools") +public interface PvpToolsConfig extends Config +{ + @ConfigItem( + keyName = "countPlayers", + name = "Count Players", + description = "When in PvP zones, counts the attackable players in and not in player's CC", + position = 3 + ) + default boolean countPlayers() + { + return true; + } + + @ConfigItem( + keyName = "countOverHeads", + name = "Count Enemy Overheads", + description = "Counts the number of each protection prayer attackable targets not in your CC are currently" + + " using", + position = 4 + ) + default boolean countOverHeads() + { + return true; + } + + @ConfigItem( + keyName = "fallInHelper", + name = "Fall In Helper", + description = "Hides all non-friendly player entities other than the one that is attacking you.", + position = 5 + ) + default boolean fallInHelper() + { + return true; + } + + @ConfigItem( + keyName = "hotkey", + name = "Fall In Hotkey", + description = "Turns the fall in helper on or off when you press this hotkey", + position = 6 + ) + default Keybind hotkey() + { + return Keybind.NOT_SET; + } + + @ConfigItem( + keyName = "attackOptionsClan", + name = "Move CC Attack Option", + description = "Moves the attack option for people in the same CC", + position = 7, + group = "Right-Click Attack Options" + ) + default boolean attackOptionsClan() + { + return false; + } + + @ConfigItem( + keyName = "attackOptionsFriend", + name = "Move Friend Attack Options", + description = "Moves the attack option for people on your friends list", + position = 8, + group = "Right-Click Attack Options" + ) + default boolean attackOptionsFriend() + { + return false; + } + + @ConfigItem( + keyName = "attackOptionsHotkey", + name = "Attack Option Hotkey", + description = "Enables a hotkey for attack options to disable or enable hiding quickly", + position = 10, + group = "Right-Click Attack Options" + ) + default Keybind attackOptionsHotkey() + { + return Keybind.CTRL; + } + + @ConfigItem( + keyName = "levelRangeAttackOptions", + name = "Moves Other Attack Options", + description = "Moves the attack option for people that are outside your level range", + position = 9, + group = "Right-Click Attack Options" + ) + default boolean levelRangeAttackOptions() + { + return false; + } + + @ConfigItem( + keyName = "riskCalculator", + name = "Risk Calculator", + description = "Enables a panel in the PvP Tools Panel that shows the players current risk", + position = 13 + ) + default boolean riskCalculatorEnabled() + { + return true; + } + + @ConfigItem( + keyName = "missingPlayers", + name = "Missing CC Players", + description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at" + + " the current players location", + position = 14 + ) + default 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; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java new file mode 100644 index 0000000000..f9abf719c7 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.pvptools; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import javax.inject.Inject; + +import net.runelite.api.Actor; +import net.runelite.api.Client; +import net.runelite.api.Player; +import net.runelite.api.Point; +import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.OverlayUtil; + +public class PvpToolsOverlay extends Overlay +{ + private PvpToolsPlugin pvpToolsPlugin; + private PvpToolsConfig pvpToolsConfig; + private Client client; + + @Inject + private PvpToolsOverlay(PvpToolsConfig pvpToolsConfig, PvpToolsPlugin pvpToolsPlugin, Client client) + { + this.pvpToolsPlugin = pvpToolsPlugin; + this.pvpToolsConfig = pvpToolsConfig; + this.client = client; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DYNAMIC); +} + + + @Override + public Dimension render(Graphics2D graphics) + { + if (pvpToolsConfig.fallInHelper()) + { + if (pvpToolsPlugin.fallinHelperEnabled) + { + graphics.setFont(FontManager.getRunescapeFont().deriveFont(28)); + OverlayUtil.renderTextLocation(graphics, new Point(200, 80), "FALL IN HELPER ENABLED", Color.YELLOW); + } + } + return null; + } + + private void renderPoly(Graphics2D graphics, Color color, Polygon polygon) + { + if (polygon != null) + { + graphics.setColor(color); + graphics.setStroke(new BasicStroke(2)); + graphics.draw(polygon); + graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); + graphics.fill(polygon); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java new file mode 100644 index 0000000000..9d82932fa2 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.pvptools; + +import com.google.common.base.MoreObjects; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.GridLayout; +import javax.inject.Inject; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import lombok.extern.slf4j.Slf4j; +import net.runelite.client.RuneLiteProperties; +import net.runelite.client.plugins.info.JRichTextPane; +import net.runelite.client.ui.ColorScheme; +import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.PluginPanel; + +@Slf4j +public class PvpToolsPanel extends PluginPanel +{ + + private final JLabel loggedLabel = new JLabel(); + private final JRichTextPane emailLabel = new JRichTextPane(); + public JLabel numCC = new JLabel(); + public JLabel numOther = new JLabel(); + public JLabel numMageJLabel = new JLabel(" "); + public JLabel numRangeJLabel = new JLabel(" "); + public JLabel numMeleeJLabel = new JLabel(" "); + public JLabel totalRiskLabel = new JLabel(" "); + public JLabel riskProtectingItem = new JLabel(" "); + public JLabel biggestItemLabel = new JLabel("Protected Item: "); + public JButton missingPlayers = new JButton("Show missing CC members"); + public JButton currentPlayers = new JButton("Show current CC members"); + public JLabel numBrews = new JLabel(); + @Inject + private JPanel pvpToolsPanel = new JPanel(new GridLayout(11, 1)); + private JPanel missingPlayersPanel = new JPanel(); + private JPanel currentPlayersPanel = new JPanel(); + + + public static String htmlLabel(String key, String value) + { + return "" + key + "" + value + ""; + } + + void init() + { + setLayout(new BorderLayout()); + setBackground(ColorScheme.DARK_GRAY_COLOR); + setBorder(new EmptyBorder(10, 10, 10, 10)); + + + + JPanel versionPanel = new JPanel(); + versionPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + versionPanel.setLayout(new GridLayout(0, 1)); + + JPanel riskPanel = new JPanel(); + riskPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + riskPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + riskPanel.setLayout(new GridLayout(0, 1)); + + final Font smallFont = FontManager.getRunescapeSmallFont(); + + numCC.setText(htmlLabel("Friendly Player Count: ", "0")); + numOther.setText(htmlLabel("Other Player Count: ", "0")); + numBrews.setText(htmlLabel("Player brew count: ", "0")); + numMageJLabel.setText(htmlLabel("Enemies Praying Mage: ", "0")); + numMageJLabel.setFont(FontManager.getRunescapeFont()); + numRangeJLabel.setText(htmlLabel("Enemies Praying Range: ", "0")); + numRangeJLabel.setFont(FontManager.getRunescapeFont()); + numMeleeJLabel.setText(htmlLabel("Enemies Praying Melee: ", "0")); + numMeleeJLabel.setFont(FontManager.getRunescapeFont()); + + totalRiskLabel.setText(htmlLabel("Total risk: ", "0")); + totalRiskLabel.setFont(FontManager.getRunescapeFont()); + riskProtectingItem.setText(htmlLabel("Risk Protecting Item: ", "0")); + riskProtectingItem.setFont(FontManager.getRunescapeFont()); + biggestItemLabel.setText("Most Valuable Item: "); + + + JLabel revision = new JLabel(); + revision.setFont(smallFont); + + revision.setText("Oldschool revision: "); + + JLabel launcher = new JLabel(htmlLabel("Launcher version: ", MoreObjects + .firstNonNull(RuneLiteProperties.getLauncherVersion(), "Unknown"))); + launcher.setFont(smallFont); + + loggedLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR); + loggedLabel.setFont(smallFont); + + emailLabel.setForeground(Color.WHITE); + emailLabel.setFont(smallFont); + + versionPanel.add(numCC); + versionPanel.add(numOther); + versionPanel.add(numBrews); + versionPanel.add(numMageJLabel); + versionPanel.add(numRangeJLabel); + versionPanel.add(numMeleeJLabel); + + versionPanel.add(Box.createGlue()); + versionPanel.add(loggedLabel); + versionPanel.add(emailLabel); + + riskPanel.add(totalRiskLabel); + riskPanel.add(riskProtectingItem); + riskPanel.add(biggestItemLabel); + + add(versionPanel, BorderLayout.NORTH); + add(riskPanel, BorderLayout.CENTER); + + currentPlayers.setVisible(false); + missingPlayers.setVisible(false); + missingPlayersPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + missingPlayersPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + missingPlayersPanel.setLayout(new GridLayout(0, 1)); + missingPlayersPanel.add(missingPlayers, BorderLayout.AFTER_LAST_LINE); + missingPlayersPanel.add(currentPlayers, BorderLayout.AFTER_LAST_LINE); + add(missingPlayersPanel, BorderLayout.AFTER_LAST_LINE); + + } + + public void disablePlayerCount() + { + this.numOther.setText("Disabled"); + this.numCC.setText("Disabled"); + this.numCC.repaint(); + this.numOther.repaint(); + } + + public void disablePrayerCount() + { + this.numMageJLabel.setText("disabled"); + this.numRangeJLabel.setText("disabled"); + this.numMeleeJLabel.setText("disabled"); + this.numMageJLabel.repaint(); + this.numRangeJLabel.repaint(); + this.numMeleeJLabel.repaint(); + } + + public void disableRiskCalculator() + { + this.totalRiskLabel.setText("disabled"); + this.riskProtectingItem.setText("disabled"); + this.biggestItemLabel.setText("disabled"); + this.totalRiskLabel.repaint(); + this.riskProtectingItem.repaint(); + this.biggestItemLabel.repaint(); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java new file mode 100644 index 0000000000..47aee1f8b6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java @@ -0,0 +1,692 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.pvptools; + +import com.google.inject.Provides; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.NavigableMap; +import java.util.Objects; +import java.util.TreeMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ScheduledExecutorService; +import java.util.stream.Collectors; +import javax.inject.Inject; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import net.runelite.api.ClanMember; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.InventoryID; +import net.runelite.api.Item; +import net.runelite.api.ItemComposition; +import net.runelite.api.MenuEntry; +import net.runelite.api.Player; +import net.runelite.api.SkullIcon; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.FocusChanged; +import net.runelite.api.events.GameStateChanged; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.api.events.MenuEntryAdded; +import net.runelite.api.events.PlayerDespawned; +import net.runelite.api.events.PlayerSpawned; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.game.AsyncBufferedImage; +import net.runelite.client.game.ClanManager; +import net.runelite.client.game.ItemManager; +import net.runelite.client.input.KeyManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginManager; +import net.runelite.client.plugins.clanchat.ClanChatPlugin; +import static net.runelite.client.plugins.pvptools.PvpToolsPanel.htmlLabel; +import net.runelite.client.ui.ClientToolbar; +import net.runelite.client.ui.NavigationButton; +import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.util.HotkeyListener; +import net.runelite.client.util.ImageUtil; +import net.runelite.client.util.PvPUtil; +import static net.runelite.client.util.StackFormatter.quantityToRSDecimalStack; +import net.runelite.client.util.Text; +import org.apache.commons.lang3.ArrayUtils; + +@PluginDescriptor( + name = "PvP Tools", + description = "Enable the PvP Tools panel", + tags = {"panel", "pvp", "pk", "pklite"}, + type = "PVP" +) +public class PvpToolsPlugin extends Plugin +{ + @Inject + PvpToolsOverlay pvpToolsOverlay; + boolean fallinHelperEnabled = false; + private PvpToolsPanel panel; + private MissingPlayersJFrame missingPlayersJFrame; + private CurrentPlayersJFrame currentPlayersJFrame; + private NavigationButton navButton; + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) + private boolean attackHotKeyPressed; + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) + private boolean hideAll; + @Inject + private ScheduledExecutorService executorService; + @Inject + private OverlayManager overlayManager; + @Inject + private Client client; + @Inject + private ItemManager itemManager; + private PvpToolsPlugin uhPvpToolsPlugin = this; + + /** + * 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 + private ClientToolbar clientToolbar; + + @Inject + private KeyManager keyManager; + + @Inject + private PvpToolsConfig config; + + @Inject + private PluginManager pluginManager; + + @Inject + private ClanManager clanManager; + + + private ClanChatPlugin clanChatPlugin; + /** + * The HotKeyListener for the hot key assigned in the config that triggers the Fall In Helper feature + */ + private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey()) + { + public void hotkeyPressed() + { + toggleFallinHelper(); + } + }; + + + 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 itemPriceComparator = new Comparator() + { + @Override + public int compare(Item o1, Item o2) + { + return (itemManager.getItemPrice(itemManager.getItemComposition(o1.getId()).getPrice()) + - itemManager.getItemPrice(itemManager.getItemComposition(o2.getId()).getPrice())); + } + }; + private String mtarget; + + public List getMissingMembers() + { + CopyOnWriteArrayList ccMembers = ClanChatPlugin.getClanMembers(); + ArrayList missingMembers = new ArrayList(); + for (ClanMember clanMember:client.getClanMembers()) + { + if (!Objects.isNull(clanMember)) + { + List arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList()); + if (!arrayList.contains(Text.removeTags(Text.standardize(clanMember.getUsername())))) + { + if (!missingMembers.contains(clanMember.getUsername())) + { + missingMembers.add("[W" + clanMember.getWorld() + "] - " + clanMember.getUsername()); + } + } + } + } + + return missingMembers; + + //Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername) + //.toArray()).collect(Collectors.toList()); + } + + public List getCurrentMembers() + { + CopyOnWriteArrayList ccMembers = ClanChatPlugin.getClanMembers(); + ArrayList currentMembers = new ArrayList(); + for (ClanMember clanMember:client.getClanMembers()) + { + if (!Objects.isNull(clanMember)) + { + List arrayList = ccMembers.stream().map(player -> Text.removeTags(Text.standardize(player.getName()))).collect(Collectors.toList()); + if (arrayList.contains(Text.removeTags(Text.standardize(clanMember.getUsername())))) + { + if (!currentMembers.contains(clanMember.getUsername())) + { + currentMembers.add(clanMember.getUsername()); + } + } + } + } + + return currentMembers; + + //Arrays.stream(Arrays.stream(client.getClanMembers()).filter(Objects::nonNull).map(ClanMember::getUsername) + //.toArray()).collect(Collectors.toList()); + } + + + + @Provides + PvpToolsConfig config(ConfigManager configManager) + { + return configManager.getConfig(PvpToolsConfig.class); + } + + @Override + protected void startUp() throws Exception + { + + overlayManager.add(pvpToolsOverlay); + + keyManager.registerKeyListener(hotkeyListener); + final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "skull.png"); + + panel = new PvpToolsPanel(); + panel.init(); + + navButton = NavigationButton.builder() + .tooltip("PvP Tools") + .icon(icon) + .priority(5) + .panel(panel) + .build(); + + panel.missingPlayers.addActionListener(playersButtonActionListener); + panel.currentPlayers.addActionListener(currentPlayersActionListener); + clientToolbar.addNavigation(navButton); + + + keyManager.registerKeyListener(attackOptionsHotKeyListener); + + if (config.missingPlayersEnabled()) + { + panel.missingPlayers.setVisible(true); + } + + if (config.currentPlayersEnabled()) + { + panel.currentPlayers.setVisible(true); + } + } + + @Override + protected void shutDown() throws Exception + { + overlayManager.remove(pvpToolsOverlay); + keyManager.unregisterKeyListener(hotkeyListener); + keyManager.unregisterKeyListener(attackOptionsHotKeyListener); + clientToolbar.removeNavigation(navButton); + } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (configChanged.getGroup().equals("pvptools")) + { + switch (configChanged.getKey()) + { + case "countPlayers": + if (config.countPlayers()) + { + updatePlayers(); + } + if (!config.countPlayers()) + { + panel.disablePlayerCount(); + } + break; + case "countOverHeads": + if (config.countOverHeads()) + { + countOverHeads(); + } + if (!config.countOverHeads()) + { + panel.disablePrayerCount(); + } + break; + case "riskCalculator": + if (config.riskCalculatorEnabled()) + { + getCarriedWealth(); + } + if (!config.riskCalculatorEnabled()) + { + panel.disableRiskCalculator(); + } + break; + case "missingPlayers": + if (config.missingPlayersEnabled()) + { + panel.missingPlayers.setVisible(true); + } + break; + case "currentPlayers": + if (config.currentPlayersEnabled()) + { + panel.currentPlayers.setVisible(true); + } + break; + default: + break; + } + } + } + + @Subscribe + public void onItemContainerChanged(ItemContainerChanged event) + { + if (event.getItemContainer().equals(client.getItemContainer(InventoryID.INVENTORY)) && + config.riskCalculatorEnabled()) + { + getCarriedWealth(); + } + } + + @Subscribe + public void onGameStateChanged(GameStateChanged event) + { + if (event.getGameState().equals(GameState.LOGGED_IN) && config.riskCalculatorEnabled()) + { + getCarriedWealth(); + } + if (event.getGameState().equals(GameState.LOGGED_IN)) + { + if (config.countPlayers()) + { + updatePlayers(); + } + } + } + + @Subscribe + public void onPlayerSpawned(PlayerSpawned event) + { + if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer())) + { + updatePlayers(); + } + if (config.countOverHeads()) + { + countOverHeads(); + } + } + + @Subscribe + public void onPlayerDespawned(PlayerDespawned event) + { + if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer())) + { + updatePlayers(); + } + if (config.countOverHeads()) + { + countOverHeads(); + } + } + + @Subscribe + public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) + { + if (!attackHotKeyPressed) + { + if (config.attackOptionsFriend() || config.attackOptionsClan() || config.levelRangeAttackOptions()) + { + if (client.getGameState() != GameState.LOGGED_IN) + { + return; + } + Player[] players = client.getCachedPlayers(); + Player player = null; + int identifier = menuEntryAdded.getIdentifier(); + if (identifier >= 0 && identifier < players.length) + { + player = players[identifier]; + } + if (player == null) + { + return; + } + final String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase(); + final String mtarget = Text.removeTags(menuEntryAdded.getTarget()).toLowerCase(); + if (attackHotKeyPressed && config.attackOptionsClan() || config.attackOptionsFriend() || + config.levelRangeAttackOptions()) + { + if (config.attackOptionsFriend() && player.isFriend()) + { + moveEntry(mtarget); + } + if (config.attackOptionsClan() && player.isClanMember()) + { + moveEntry(mtarget); + } + if (config.levelRangeAttackOptions() && !PvPUtil.isAttackable(client, player)) + { + moveEntry(mtarget); + } + } + } + } + } + + + private void moveEntry(String mtarget) + { + this.mtarget = mtarget; + MenuEntry[] menuEntries = client.getMenuEntries(); + MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; + + // strip out existing '); + if (idx != -1) + { + target = target.substring(idx + 1); + } + /*System.out.println("Contents : " + lastEntry.getTarget()); + System.out.println("Contents : " + lastEntry.getIdentifier()); + System.out.println("Contents : " + lastEntry.getOption()); + System.out.println("length : " + menuEntries.length);*/ + if (menuEntries[menuEntries.length - 1] != null) + { + //System.out.println(menuEntries.length + ": " + menuEntries[menuEntries.length-1]); + } + if (lastEntry.getOption().contains("attack".toLowerCase())) + { + ArrayUtils.shift(menuEntries, 1); + //ArrayUtils.add(menuEntries, menuEntries.length - 2); + //menuEntries = ArrayUtils.remove(menuEntries, menuEntries.length - 1); + //menuEntrySwapperPlugin.swap("attack", option, mtarget, false); + } + if (lastEntry.getOption().equals("Attack")) + { + ArrayUtils.shift(menuEntries, 1); + + //menuEntries = ArrayUtils.sremove(menuEntries, menuEntries.length - 1); + //menuEntrySwapperPlugin.swap("attack", option, mtarget, false); + } + client.setMenuEntries(menuEntries); + + } + + @Subscribe + public void onFocusChanged(FocusChanged focusChanged) + { + if (!focusChanged.isFocused()) + { + setAttackHotKeyPressed(false); + } + } + + /** + * Enables or disables the fall in helper feature + */ + private void toggleFallinHelper() + { + if (!fallinHelperEnabled) + { + client.setIsHidingEntities(true); + client.setPlayersHidden(true); + fallinHelperEnabled = true; + } + else + { + client.setIsHidingEntities(false); + client.setPlayersHidden(false); + fallinHelperEnabled = false; + } + + } + + /** + * Updates the PvP Tools panel with the numbers for enemy protection prayers + */ + private void updatePrayerNumbers() + { + panel.numMageJLabel.setText(htmlLabel("Enemies Praying Mage: ", String.valueOf(overheadCount[0]))); + panel.numRangeJLabel.setText(htmlLabel("Enemies Praying Range: ", String.valueOf(overheadCount[1]))); + panel.numMeleeJLabel.setText(htmlLabel("Enemies Praying Melee: ", String.valueOf(overheadCount[2]))); + panel.numMageJLabel.repaint(); + panel.numRangeJLabel.repaint(); + panel.numMeleeJLabel.repaint(); + } + + /** + * + */ + private void updatePlayers() + { + if (config.countPlayers()) + { + int cc = 0; + int other = 0; + for (Player p : client.getPlayers()) + { + if (Objects.nonNull(p)) + { + if (PvPUtil.isAttackable(client, p)) + { + if (p.isClanMember()) + { + cc++; + } + else + { + other++; + } + } + } + } + + panel.numOther.setText(htmlLabel("Other Player Count: ", String.valueOf(other))); + panel.numCC.setText(htmlLabel("Friendly Player Count: ", String.valueOf(cc))); + panel.numCC.repaint(); + panel.numOther.repaint(); + } + } + + private void countOverHeads() + { + overheadCount = new int[]{0, 0, 0}; + for (Player p : client.getPlayers()) + { + if (Objects.nonNull(p)) + { + if (PvPUtil.isAttackable(client, p)) + { + if (!p.isClanMember() && !(p.getOverheadIcon() == null)) + { + switch (p.getOverheadIcon()) + { + case MAGIC: + overheadCount[0]++; + break; + case RANGED: + overheadCount[1]++; + break; + case MELEE: + overheadCount[2]++; + break; + } + } + } + } + } + updatePrayerNumbers(); + } + + /** + * Calculates the player's risk based on Item Price of all items in their inventory and equipment + */ + private void getCarriedWealth() + { + if (!config.riskCalculatorEnabled()) + { + return; + } + if (client.getItemContainer(InventoryID.EQUIPMENT) == null) + { + return; + } + if (client.getItemContainer(InventoryID.INVENTORY).getItems() == null) + { + return; + } + Item[] items = ArrayUtils.addAll(Objects.requireNonNull(client.getItemContainer(InventoryID.EQUIPMENT)).getItems(), + Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()); + TreeMap priceMap = new TreeMap<>(Comparator.comparingInt(Integer::intValue)); + int wealth = 0; + for (Item i : items) + { + int value = (itemManager.getItemPrice(i.getId()) * i.getQuantity()); + + final ItemComposition itemComposition = itemManager.getItemComposition(i.getId()); + if (!itemComposition.isTradeable() && value == 0) + { + value = itemComposition.getPrice() * i.getQuantity(); + priceMap.put(value, i); + } + else + { + value = itemManager.getItemPrice(i.getId()) * i.getQuantity(); + if (i.getId() > 0 && value > 0) + { + priceMap.put(value, i); + } + } + wealth += value; + } + panel.totalRiskLabel.setText(htmlLabel("Total risk: ", quantityToRSDecimalStack(wealth))); + panel.totalRiskLabel.repaint(); + + int itemLimit = 0; + if (client.getLocalPlayer().getSkullIcon() != null) + { + if (client.getLocalPlayer().getSkullIcon() == SkullIcon.SKULL) + { + itemLimit = 1; + } + } + if (client.getLocalPlayer().getSkullIcon() == null) + { + itemLimit = 4; + } + + AsyncBufferedImage itemImage = null; + + NavigableMap descendingMap = priceMap.descendingMap(); + + for (int i = 0; i < itemLimit; i++) + { + if (i == 0) + { + if (!descendingMap.isEmpty()) + { + itemImage = itemManager.getImage(descendingMap.pollFirstEntry().getValue().getId()); + } + } + else + { + if (!descendingMap.isEmpty()) + { + itemManager.getItemComposition(priceMap.descendingMap().pollFirstEntry().getValue().getId()) + .getName(); + } + } + } + panel.riskProtectingItem.setText(htmlLabel("Risk Protecting Item: ", + quantityToRSDecimalStack(descendingMap.keySet().stream().mapToInt(Integer::intValue).sum()))); + panel.riskProtectingItem.repaint(); + + panel.biggestItemLabel.setText("Most Valuable Item: "); + if (itemImage != null) + { + itemImage.addTo(panel.biggestItemLabel); + } + panel.biggestItemLabel.repaint(); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/skull.png b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/skull.png new file mode 100644 index 0000000000..09869ea0e1 Binary files /dev/null and b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/skull.png differ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java index 58a19463f3..c54ac589ab 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java @@ -178,39 +178,6 @@ public interface RaidsConfig extends Config return false; } - @ConfigItem( - position = 13, - keyName = "enableSharableImage", - name = "Enable sharable image", - description = "Use the specified hotkey to capture the raid scouter" - ) - default boolean enableSharableImage() - { - return false; - } - - @ConfigItem( - position = 14, - keyName = "hotkey", - name = "Capture hotkey", - description = "Hotkey used to capture the scouter" - ) - default Keybind hotkey() - { - return new Keybind(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK); - } - - @ConfigItem( - position = 15, - keyName = "enableTrayNotification", - name = "Enable tray notification", - description = "Adds a system tray notification on successful screen capture" - ) - default boolean enableTrayNotification() - { - return false; - } - @ConfigItem( position = 16, keyName = "showRecommendedItems", @@ -320,4 +287,15 @@ public interface RaidsConfig extends Config { return true; } + + @ConfigItem( + position = 26, + keyName = "displayFloorBreak", + name = "Layout floor break", + description = "Displays floor break in layout" + ) + default boolean displayFloorBreak() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java index 9c851e5dc6..fc149415b1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java @@ -125,6 +125,16 @@ public class RaidsOverlay extends Overlay Color color = Color.WHITE; String layout = plugin.getRaid().getLayout().toCodeString(); + String displayLayout; + if (config.displayFloorBreak()) + { + displayLayout = plugin.getRaid().getLayout().toCode(); + displayLayout = displayLayout.substring(0, displayLayout.length() - 1).replaceAll("#", "").replaceFirst("¤", " | "); + } + else + { + displayLayout = layout; + } if (config.enableLayoutWhitelist() && !plugin.getLayoutWhitelist().contains(layout.toLowerCase())) { @@ -196,7 +206,7 @@ public class RaidsOverlay extends Overlay } scouterActive = true; - layout = (config.enhanceScouterTitle() ? "" + combatCount + "c " + puzzles + " " : "") + layout; + displayLayout = (config.enhanceScouterTitle() ? "" + combatCount + "c " + puzzles + " " : "") + displayLayout; for (Integer i : iceRooms) { @@ -212,7 +222,7 @@ public class RaidsOverlay extends Overlay } int lastScavs = scavRooms.get(scavRooms.size() - 1); panelComponent.getChildren().add(TitleComponent.builder() - .text(layout) + .text(displayLayout) .color(color) .build()); color = Color.ORANGE; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 80723bd0f5..4e1689eaee 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -59,7 +59,9 @@ import net.runelite.api.Varbits; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.VarbitChanged; +import net.runelite.api.events.WidgetHiddenChanged; import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatMessageBuilder; @@ -79,7 +81,6 @@ import net.runelite.client.ui.DrawManager; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; -import net.runelite.client.util.ScreenCapture; import net.runelite.client.util.Text; import net.runelite.client.util.HotkeyListener; @@ -128,6 +129,9 @@ public class RaidsPlugin extends Plugin @Inject private RaidsOverlay overlay; + @Inject + private RaidsPointsOverlay pointsOverlay; + @Inject private LayoutSolver layoutSolver; @@ -140,9 +144,6 @@ public class RaidsPlugin extends Plugin @Inject private KeyManager keyManager; - @Inject - private ScreenCapture screenCapture; - @Getter private final ArrayList roomWhitelist = new ArrayList<>(); @@ -182,20 +183,26 @@ public class RaidsPlugin extends Plugin protected void startUp() throws Exception { overlayManager.add(overlay); + overlayManager.add(pointsOverlay); updateLists(); clientThread.invokeLater(() -> checkRaidPresence(true)); - keyManager.registerKeyListener(hotkeyListener); } @Override protected void shutDown() throws Exception { overlayManager.remove(overlay); + overlayManager.remove(pointsOverlay); infoBoxManager.removeInfoBox(timer); inRaidChambers = false; raid = null; timer = null; - keyManager.unregisterKeyListener(hotkeyListener); + + final Widget widget = client.getWidget(WidgetInfo.RAIDS_POINTS_INFOBOX); + if (widget != null) + { + widget.setHidden(false); + } } @Subscribe @@ -216,6 +223,22 @@ public class RaidsPlugin extends Plugin clientThread.invokeLater(() -> checkRaidPresence(true)); } + @Subscribe + public void onWidgetHiddenChanged(WidgetHiddenChanged event) + { + if (!inRaidChambers || event.isHidden()) + { + return; + } + + Widget widget = event.getWidget(); + + if (widget == client.getWidget(WidgetInfo.RAIDS_POINTS_INFOBOX)) + { + widget.setHidden(true); + } + } + @Subscribe public void onVarbitChanged(VarbitChanged event) { @@ -675,42 +698,4 @@ public class RaidsPlugin extends Plugin return room; } - - private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey()) - { - @Override - public void hotkeyPressed() - { - initiateCopyImage(); - } - }; - - private void initiateCopyImage() - { - if (!config.enableSharableImage() || !overlay.isScouterActive()) - return; - - Rectangle overlaySize = overlay.getBounds(); - if (overlaySize.width <= 0 || overlaySize.height <= 0) - return; - if (!config.alwaysShowWorldAndCC()) - overlaySize.height += LINE_COMPONENT_HEIGHT; - - BufferedImage bim = new BufferedImage(overlaySize.width, overlaySize.height, BufferedImage.TYPE_INT_ARGB); - overlay.setSharable(true); - Graphics2D g = bim.createGraphics(); - g.setFont(FontManager.getRunescapeFont()); - - //this is needed to update the PanelComponent childDimensions, because they are a frame behind - if (!config.alwaysShowWorldAndCC()) - overlay.render(g); - g.setColor(Color.BLACK); - g.fillRect(0, 0, overlaySize.width, overlaySize.height); - - overlay.render(g); - screenCapture.takeScreenshot(bim, config.enableTrayNotification(), "Chambers"); - g.dispose(); - - overlay.setSharable(false); - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPointsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPointsOverlay.java new file mode 100644 index 0000000000..3c2cc3e5f1 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPointsOverlay.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2018, Kamiel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.raids; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.text.NumberFormat; +import java.util.Locale; +import javax.inject.Inject; +import net.runelite.api.Client; +import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; +import net.runelite.api.Varbits; +import static net.runelite.client.plugins.raids.RaidsPlugin.POINTS_FORMAT; +import net.runelite.client.ui.overlay.Overlay; +import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; +import net.runelite.client.ui.overlay.OverlayMenuEntry; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; + +public class RaidsPointsOverlay extends Overlay +{ + @Inject + private Client client; + + @Inject + private RaidsPlugin plugin; + + private final PanelComponent panel = new PanelComponent(); + + private static final NumberFormat UNIQUE_FORMAT = NumberFormat.getPercentInstance(Locale.ENGLISH); + static + { + UNIQUE_FORMAT.setMaximumFractionDigits(2); + UNIQUE_FORMAT.setMinimumFractionDigits(2); + } + + @Inject + private RaidsPointsOverlay(RaidsPlugin plugin) + { + super(plugin); + setPosition(OverlayPosition.TOP_RIGHT); + setPriority(OverlayPriority.HIGH); + getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Raids overlay")); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!plugin.isInRaidChambers()) + { + return null; + } + + int totalPoints = client.getVar(Varbits.TOTAL_POINTS); + int personalPoints = client.getVar(Varbits.PERSONAL_POINTS); + int partySize = client.getVar(Varbits.RAID_PARTY_SIZE); + double uniqueChance = totalPoints / 867500f; + + panel.getChildren().clear(); + panel.getChildren().add(LineComponent.builder() + .left("Total:") + .right(POINTS_FORMAT.format(totalPoints)) + .build()); + + panel.getChildren().add(LineComponent.builder() + .left(client.getLocalPlayer().getName() + ":") + .right(POINTS_FORMAT.format(personalPoints)) + .build()); + + + if (partySize > 1) + { + panel.getChildren().add(LineComponent.builder() + .left("Party size:") + .right(String.valueOf(partySize)) + .build()); + } + + panel.getChildren().add(LineComponent.builder() + .left("Unique:") + .right(UNIQUE_FORMAT.format(uniqueChance)) + .build()); + + if (partySize > 1) + { + double personalChance = uniqueChance * (personalPoints / totalPoints); + + panel.getChildren().add(LineComponent.builder() + .left("Personal:") + .right(UNIQUE_FORMAT.format(personalChance)) + .build()); + } + + return panel.render(graphics); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/RaidsThievingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/RaidsThievingPlugin.java index d9f7de646c..10873e02d8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/RaidsThievingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/RaidsThievingPlugin.java @@ -53,9 +53,10 @@ import java.util.Map; @Slf4j @PluginDescriptor( - name = "!Raids Bat Finder", + name = "Raids Bat Finder", description = "Tracks which chests need to be searched for bats and which poison", - tags = {"overlay", "skilling", "raid"} + tags = {"overlay", "skilling", "raid"}, + type = "PVM" ) public class RaidsThievingPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/rememberclan/RememberClanPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/rememberclan/RememberClanPlugin.java index 35d209a4f7..2b5dd54b35 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/rememberclan/RememberClanPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/rememberclan/RememberClanPlugin.java @@ -43,8 +43,10 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @PluginDescriptor( - name = "!Remember Clan", - description = "Remembers a specific clan!" + name = "Remember Clan", + description = "Remember a specific clan!", + type = "utility", + enabledByDefault = false ) public class RememberClanPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java index 17486efe0d..a7e2fd86d7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchOverlay.java @@ -69,6 +69,8 @@ public class RunepouchOverlay extends WidgetItemOverlay this.tooltipManager = tooltipManager; this.client = client; this.config = config; + showOnInventory(); + showOnBank(); } @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java index d225410209..a0c1214a0d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPanel.java @@ -139,7 +139,7 @@ class ScreenMarkerPanel extends JPanel INVISIBLE_ICON = new ImageIcon(invisibleImg); INVISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -100)); - final BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "delete_icon.png"); + final BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "net/runelite/client/plugins/profiles/delete_icon.png"); DELETE_ICON = new ImageIcon(deleteImg); DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100)); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryPlugin.java index f4ff6078f1..954eb72b56 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryPlugin.java @@ -42,7 +42,8 @@ import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( name = "Shayzien Infirmary", description = "Shows the status of wounded soldiers", - tags = {"shayzien", "infirmary", "soldiers"} + tags = {"shayzien", "infirmary", "soldiers"}, + type = "utility" ) public class ShayzienInfirmaryPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerPlugin.java index aef2adb45e..cedc212d04 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerPlugin.java @@ -41,10 +41,11 @@ import javax.inject.Inject; * Shift Walker Plugin. Credit to MenuEntrySwapperPlugin for code some code structure used here. */ @PluginDescriptor( - name = "!Shift To Walk Here", + name = "Shift To Walk", description = "Use Shift to toggle the Walk Here menu option. While pressed you will Walk rather than interact with objects.", tags = {"npcs", "items", "objects"}, - enabledByDefault = false + enabledByDefault = false, + type = "utility" ) public class ShiftWalkerPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skybox/Skybox.java b/runelite-client/src/main/java/net/runelite/client/plugins/skybox/Skybox.java index e513166143..aa770f37f8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skybox/Skybox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skybox/Skybox.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.skybox; +import java.awt.Color; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.IOException; @@ -447,7 +448,7 @@ class Skybox } // Convert back to int range values, and bounds check while we are at it - byte ay = (byte) Math.min(Math.max(Math.round(Math.pow(ty / t, brightness) * 255.d), 0), 255); + byte ay = (byte) Math.min(Math.max(Math.round(ty / t * 255.d), 0), 255); byte aco = (byte) Math.min(Math.max(Math.round(tco * 128.d / t), -128), 127); byte acg = (byte) Math.min(Math.max(Math.round(tcg * 128.d / t), -128), 127); @@ -457,7 +458,11 @@ class Skybox int r = (tmp - (aco >> 1)) & 0xFF; int b = (r + aco) & 0xFF; - return r << 16 | g << 8 | b; + // increase brightness with HSB + float[] hsb = Color.RGBtoHSB(r, g, b, null); + hsb[2] = (float) Math.pow(hsb[2], brightness); + + return 0xFFFFFF & Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]); } /** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java index e8c49b20a0..97a191d608 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java @@ -87,6 +87,8 @@ class SlayerOverlay extends WidgetItemOverlay { this.plugin = plugin; this.config = config; + showOnInventory(); + showOnEquipment(); } @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayermusiq/QuestGuideLinks.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayermusiq/QuestGuideLinks.java deleted file mode 100644 index 078491bb4d..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayermusiq/QuestGuideLinks.java +++ /dev/null @@ -1,207 +0,0 @@ -package net.runelite.client.plugins.slayermusiq; - -import net.runelite.client.util.LinkBrowser; -import net.runelite.api.ChatMessageType; -import net.runelite.api.events.ChatMessage; -import net.runelite.client.chat.ChatColorType; -import net.runelite.client.chat.ChatMessageBuilder; -import net.runelite.client.chat.ChatMessageManager; -import net.runelite.client.chat.QueuedMessage; - -public class QuestGuideLinks { - private static final Link[] QUEST_GUIDE_LINKS = { - // Free Quests - new Link("Cook's Assistant", "https://www.youtube.com/watch?v=ehmtDRelj3c"), - new Link("Romeo & Juliet", "https://www.youtube.com/watch?v=rH_biWSNWVY"), - new Link("Demon Slayer", "https://www.youtube.com/watch?v=hgACrzJSiQk"), - new Link("Shield of Arrav", "https://www.youtube.com/watch?v=a_imLDKUdzg"), - new Link("Sheep Shearer", "https://www.youtube.com/watch?v=XFG3aNwK68s"), - new Link("The Restless Ghost", "https://www.youtube.com/watch?v=UkWNcsG_pXM"), - new Link("Ernest the Chicken", "https://www.youtube.com/watch?v=cq8NIVhSqh4"), - new Link("Vampire Slayer", "https://www.youtube.com/watch?v=FcEuxsDJWCU"), - new Link("Imp Catcher", "https://www.youtube.com/watch?v=LHgnl0FbOzk"), - new Link("Prince Ali Rescue", "https://www.youtube.com/watch?v=hrSPl1GfFaw"), - new Link("Doric's Quest", "https://www.youtube.com/watch?v=5TYyxHU27a4"), - new Link("Black Knights' Fortress", "https://www.youtube.com/watch?v=aekoZi3f9cU"), - new Link("Witch's Potion", "https://www.youtube.com/watch?v=XV4i5sPUvXo"), - new Link("The Knight's Sword", "https://www.youtube.com/watch?v=UkBWaI0rOqE"), - new Link("Goblin Diplomacy", "https://www.youtube.com/watch?v=P9BKOb_dLoY"), - new Link("Pirate's Treasure", "https://www.youtube.com/watch?v=zcD87PQW8Qk"), - new Link("Dragon Slayer", "https://www.youtube.com/watch?v=bMtCjlFOaBI"), - new Link("Rune Mysteries", "https://www.youtube.com/watch?v=l8ZhaN8uoS0"), - new Link("Misthalin Mystery", "https://www.youtube.com/watch?v=QlFqVAobAlQ"), - new Link("The Corsair Curse", "https://www.youtube.com/watch?v=wi7mUAHExz4"), - new Link("X Marks the Spot", "https://www.youtube.com/watch?v=GhRgvEG5jxQ"), - // Members Quests - new Link("Druidic Ritual", "https://www.youtube.com/watch?v=QIfU6HSmH4w"), - new Link("Lost City", "https://www.youtube.com/watch?v=T-kQNUSjFZI"), - new Link("Witch's House", "https://www.youtube.com/watch?v=TLsg7Wa-LUA"), - new Link("Merlin's Crystal", "https://www.youtube.com/watch?v=ESX-qriNtCE"), - new Link("Heroes' Quest", "https://www.youtube.com/watch?v=hK2N0WLKviE"), - new Link("Scorpion Catcher", "https://www.youtube.com/watch?v=xpqdec7_ZWg"), - new Link("Family Crest", "https://www.youtube.com/watch?v=0mk_Cgjr738"), - new Link("Monk's Friend", "https://www.youtube.com/watch?v=avi4y4G3Hcw"), - new Link("Temple of Ikov", "https://www.youtube.com/watch?v=5K7jDgr_4Z4"), - new Link("Clock Tower", "https://www.youtube.com/watch?v=GUCkkQFzyDw"), - new Link("Holy Grail", "https://www.youtube.com/watch?v=cgXoV1QlYco"), - new Link("Tree Gnome Village", "https://www.youtube.com/watch?v=T6Su__yuyRI"), - new Link("Fight Arena", "https://www.youtube.com/watch?v=4Nqjep2E5pw"), - new Link("Hazeel Cult", "https://www.youtube.com/watch?v=2_fhFJW6cNY"), - new Link("Sheep Herder", "https://www.youtube.com/watch?v=akC9FeYCG1Q"), - new Link("Plague City", "https://www.youtube.com/watch?v=Hf2wQQZL5CU"), - new Link("Waterfall Quest", "https://www.youtube.com/watch?v=xWBSnGkQTi4"), - new Link("Jungle Potion", "https://www.youtube.com/watch?v=xqLKsFz08As"), - new Link("The Grand Tree", "https://www.youtube.com/watch?v=N5e_Jus_E-Y"), - new Link("Underground Pass", "https://www.youtube.com/watch?v=5klGJg1wY8k"), - new Link("Observatory Quest", "https://www.youtube.com/watch?v=yxa9B6svv44"), - new Link("Watchtower", "https://www.youtube.com/watch?v=Vb10GoYP7FE"), - new Link("Dwarf Cannon", "https://www.youtube.com/watch?v=pROFg5jcCR0"), - new Link("Murder Mystery", "https://www.youtube.com/watch?v=P1IDGCA2f9o"), - new Link("The Dig Site", "https://www.youtube.com/watch?v=TOdcWV4MzuU"), - new Link("Gertrude's Cat", "https://www.youtube.com/watch?v=g7S09wA8EAY"), - new Link("Legends' Quest", "https://www.youtube.com/watch?v=Lid8enDEF_U"), - new Link("Death Plateau", "https://www.youtube.com/watch?v=SIQFmTvnb6w"), - new Link("Big Chompy Bird Hunting", "https://www.youtube.com/watch?v=s2fytMOHJXI"), - new Link("Elemental Workshop I", "https://www.youtube.com/watch?v=tbZD2RDqvfQ"), - new Link("Nature Spirit", "https://www.youtube.com/watch?v=Enf8vUWb5o0"), - new Link("Priest in Peril", "https://www.youtube.com/watch?v=fyYri6wUQIU"), - new Link("Regicide", "https://www.youtube.com/watch?v=KkWM-ok3C4Y"), - new Link("Tai Bwo Wannai Trio", "https://www.youtube.com/watch?v=Mdair5mvZL0"), - new Link("Troll Stronghold", "https://www.youtube.com/watch?v=zqmUs-f3AKA"), - new Link("Horror from the Deep", "https://www.youtube.com/watch?v=9htK8kb6DR8"), - new Link("Throne of Miscellania", "https://www.youtube.com/watch?v=fzGMnv2skBE"), - new Link("Monkey Madness I", "https://www.youtube.com/watch?v=VnoRfeBnPFA"), - new Link("Haunted Mine", "https://www.youtube.com/watch?v=cIc6loJHm9Q"), - new Link("Troll Romance", "https://www.youtube.com/watch?v=j2zifZVu7Gc"), - new Link("In Search of the Myreque", "https://www.youtube.com/watch?v=5nmYFHdAXAQ"), - new Link("Creature of Fenkenstrain", "https://www.youtube.com/watch?v=swqUVIs7B7M"), - new Link("Roving Elves", "https://www.youtube.com/watch?v=J3qf9DnT9cA"), - new Link("One Small Favour", "https://www.youtube.com/watch?v=ix_0-W3e9ps"), - new Link("Mountain Daughter", "https://www.youtube.com/watch?v=HETx_LX7aiY"), - new Link("Between a Rock...", "https://www.youtube.com/watch?v=cB11I45EGgA"), - new Link("The Golem", "https://www.youtube.com/watch?v=qpEHpiO6lLw"), - new Link("Desert Treasure", "https://www.youtube.com/watch?v=BuIqulIsICo"), - new Link("Icthlarin's Little Helper", "https://www.youtube.com/watch?v=wpNKm8_vUOM"), - new Link("Tears of Guthix", "https://www.youtube.com/watch?v=EMonDNI0uPk"), - new Link("The Lost Tribe", "https://www.youtube.com/watch?v=spZErjRnCdc"), - new Link("The Giant Dwarf", "https://www.youtube.com/watch?v=Z7PsGpOYgxY"), - new Link("Recruitment Drive", "https://www.youtube.com/watch?v=sOuzMpA_xtw"), - new Link("Mourning's Ends Part I", "https://www.youtube.com/watch?v=vuzAdk-h3c0"), - new Link("Garden of Tranquillity", "https://www.youtube.com/watch?v=7hbCzYnLCsQ"), - new Link("A Tail of Two Cats", "https://www.youtube.com/watch?v=SgN9Yw_YqHk"), - new Link("Wanted!", "https://www.youtube.com/watch?v=ZHZAKDCfXGs"), - new Link("Mourning's Ends Part II", "https://www.youtube.com/watch?v=FK5sLogGbU8"), - new Link("Rum Deal", "https://www.youtube.com/watch?v=I14CIu5x2S8"), - new Link("Shadow of the Storm", "https://www.youtube.com/watch?v=5ZvWd3XCQjI"), - new Link("Ratcatchers", "https://www.youtube.com/watch?v=s7G22fEuhTc"), - new Link("Spirits of the Elid", "https://www.youtube.com/watch?v=A1zAX55hZC0"), - new Link("Devious Minds", "https://www.youtube.com/watch?v=_UtlFmrWt1w"), - new Link("Enakhra's Lament", "https://www.youtube.com/watch?v=Y3kEIPYVaVE"), - new Link("Cabin Fever", "https://www.youtube.com/watch?v=k5DtxNXhOaw"), - new Link("Fairytale I - Growing Pains", "https://www.youtube.com/watch?v=cfGI9qFOmsg"), - new Link("Recipe for Disaster", "https://www.youtube.com/watch?v=hrAyyInJaTA"), - new Link("In Aid of the Myreque", "https://www.youtube.com/watch?v=O2Ru2NmuTaA"), - new Link("A Soul's Bane", "https://www.youtube.com/watch?v=dp8dp79qp6I"), - new Link("Rag and Bone Man", "https://www.youtube.com/watch?v=3owXSeN56W8"), - new Link("Swan Song", "https://www.youtube.com/watch?v=IpmERThXv2g"), - new Link("Royal Trouble", "https://www.youtube.com/watch?v=bVWUlKzNXEg"), - new Link("Death to the Dorgeshuun", "https://www.youtube.com/watch?v=2XJHuLhig98"), - new Link("Fairytale II - Cure a Queen", "https://www.youtube.com/watch?v=P6KkRk4_e3U"), - new Link("Lunar Diplomacy", "https://www.youtube.com/watch?v=vmeSKb7IBgQ"), - new Link("The Eyes of Glouphrie", "https://www.youtube.com/watch?v=0YCPwmZcxKA"), - new Link("Darkness of Hallowvale", "https://www.youtube.com/watch?v=QziKl99qdtU"), - new Link("Elemental Workshop II", "https://www.youtube.com/watch?v=Bb4E7ecIgv0"), - new Link("My Arm's Big Adventure", "https://www.youtube.com/watch?v=xa1KWOewgYA"), - new Link("Enlightened Journey", "https://www.youtube.com/watch?v=XAPthC8d7k0"), - new Link("Eagles' Peak", "https://www.youtube.com/watch?v=KDxIrrwXp7U"), - new Link("Animal Magnetism", "https://www.youtube.com/watch?v=kUyjXA7TaFU"), - new Link("Contact!", "https://www.youtube.com/watch?v=czn-yWABBWs"), - new Link("Cold War", "https://www.youtube.com/watch?v=0m1KpP-qKWI"), - new Link("The Fremennik Isles", "https://www.youtube.com/watch?v=EvxhiOWmraY"), - new Link("The Great Brain Robbery", "https://www.youtube.com/watch?v=ImHFASuNUN8"), - new Link("What Lies Below", "https://www.youtube.com/watch?v=f_9nVMGTtuo"), - new Link("Olaf's Quest", "https://www.youtube.com/watch?v=mXV5bM1NFMM"), - new Link("Dream Mentor", "https://www.youtube.com/watch?v=XDLUu0Kf0sE"), - new Link("Grim Tales", "https://www.youtube.com/watch?v=dFB0Q6v8Apw"), - new Link("King's Ransom", "https://www.youtube.com/watch?v=UJz9ZfF3uCY"), - new Link("Shilo Village", "https://www.youtube.com/watch?v=bDvBi8FT-QI"), - new Link("Biohazard", "https://www.youtube.com/watch?v=n9k87LwOGMk"), - new Link("Tower of Life", "https://www.youtube.com/watch?v=KReMcWpeY3k"), - new Link("Rag and Bone Man II", "https://www.youtube.com/watch?v=KGdHiDDUX_U"), - new Link("Zogre Flesh Eaters", "https://www.youtube.com/watch?v=vzm4949kXP4"), - new Link("Monkey Madness II", "https://www.youtube.com/watch?v=ykE5LbjABaI"), - new Link("Client of Kourend", "https://www.youtube.com/watch?v=Y-KIHF-cL9w"), - new Link("The Queen of Thieves", "https://www.youtube.com/watch?v=W94zFZVrHkQ"), - new Link("Bone Voyage", "https://www.youtube.com/watch?v=-VTR4p8kPmI"), - new Link("Dragon Slayer II", "https://www.youtube.com/watch?v=4BMb3Zwzk_U"), - new Link("The Depths of Despair", "https://www.youtube.com/watch?v=CaVUk2eAsKs"), - new Link("A Taste of Hope", "https://www.youtube.com/watch?v=VjdgEIizdSc"), - new Link("Tale of the Righteous", "https://www.youtube.com/watch?v=99yiv0tPl58"), - new Link("Making Friends with My Arm", "https://www.youtube.com/watch?v=DltzzhIsM_Q"), - new Link("The Ascent of Arceuus", "https://www.youtube.com/watch?v=4VQnfrv6S18"), - new Link("The Forsaken Tower", "https://www.youtube.com/watch?v=con0sXl5NBY"), - new Link("Fishing Contest", "https://www.youtube.com/watch?v=XYSv37A_l5w"), - new Link("Tribal Totem", "https://www.youtube.com/watch?v=XkUEIjr886M"), - new Link("Sea Slug", "https://www.youtube.com/watch?v=oOZVfa5SkVQ"), - new Link("The Tourist Trap", "https://www.youtube.com/watch?v=0bmSCCepMvo"), - new Link("Eadgar's Ruse", "https://www.youtube.com/watch?v=aVQ3DjTElXg"), - new Link("Shades of Mort'ton", "https://www.youtube.com/watch?v=eF05R8OMxgg"), - new Link("The Fremennik Trials", "https://www.youtube.com/watch?v=YUIvEgcvl5c"), - new Link("Ghosts Ahoy", "https://www.youtube.com/watch?v=aNBkLOywDfM"), - new Link("The Feud", "https://www.youtube.com/watch?v=nlBSc9IUklA"), - new Link("Forgettable Tale...", "https://www.youtube.com/watch?v=3HvFd6AxNU0"), - new Link("Making History", "https://www.youtube.com/watch?v=bOTGi2zAuhs"), - new Link("The Hand in the Sand", "https://www.youtube.com/watch?v=gdNLcZ-l1Lw"), - new Link("The Slug Menace", "https://www.youtube.com/watch?v=BRQbdr3JEZ8"), - new Link("Another Slice of H.A.M.", "https://www.youtube.com/watch?v=Yq3db7827Lk") - }; - - private static class Link { - - private String questName; - private String url; - - public Link(String questName, String url) { - this.questName = questName; - this.url = url; - } - - public String getQuestName() { - return questName; - } - - public void openURL() { - LinkBrowser.browse(this.url); - } - - } - - private static boolean openGuide(String questName) { - for (Link link : QUEST_GUIDE_LINKS) { - if (link.getQuestName().equals(questName)) { - link.openURL(); - return true; - } - } - return false; - } - - private static void logQuestNotFoundError(String questName, ChatMessageManager chatMessageManager) { - String chatMessage = new ChatMessageBuilder() - .append(ChatColorType.HIGHLIGHT) - .append("Could not find Slayermusiq1 guide for " + questName) - .build(); - - chatMessageManager.queue(QueuedMessage.builder() - .type(ChatMessageType.CONSOLE) - .runeLiteFormattedMessage(chatMessage) - .build()); - } - - public static void tryOpenGuide(String questName, ChatMessageManager chatMessageManager) { - boolean success = openGuide(questName); - if (!success) { - logQuestNotFoundError(questName, chatMessageManager); - } - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayermusiq/SlayermusiqPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayermusiq/SlayermusiqPlugin.java deleted file mode 100644 index 7e07a0564d..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayermusiq/SlayermusiqPlugin.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2018, Jeremy Berchtold - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -// Based off RuneLite's Wiki Plugin -/* - * Copyright (c) 2018 Abex - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.slayermusiq; - -import com.google.inject.Provides; -import com.google.common.primitives.Ints; -import java.awt.Dimension; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.inject.Inject; -import javax.swing.SwingUtilities; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.MenuAction; -import net.runelite.api.MenuEntry; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.events.MenuEntryAdded; -import net.runelite.api.events.MenuOptionClicked; -import net.runelite.client.util.Text; -import net.runelite.client.chat.ChatMessageManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; - -@PluginDescriptor( - name = "!Slayermusiq1 Guides", - description = "Adds a right-click option to go to Slayermusiq1's guides from the quest tab", - tags = {"quest", "guide", "slayermusiq"} -) -@Slf4j -public class SlayermusiqPlugin extends Plugin -{ - - private static final int[] QUESTLIST_WIDGET_IDS = new int[] - { - WidgetInfo.QUESTLIST_FREE_CONTAINER.getId(), - WidgetInfo.QUESTLIST_MEMBERS_CONTAINER.getId(), - WidgetInfo.QUESTLIST_MINIQUEST_CONTAINER.getId(), - }; - - private static final String MENUOP_SLAYERMUSIQ = "Slayermusiq"; - - @Inject - private Client client; - - @Inject - private ChatMessageManager chatMessageManager; - - @Override - protected void startUp() throws Exception - { - // - } - - @Override - protected void shutDown() throws Exception - { - // - } - - @Subscribe - public void onMenuEntryAdded(MenuEntryAdded event) - { - int widgetID = event.getActionParam1(); - if (Ints.contains(QUESTLIST_WIDGET_IDS, widgetID) && "Read Journal:".equals(event.getOption())) { - MenuEntry[] menuEntries = client.getMenuEntries(); - - MenuEntry newMenuEntry = createSlayermusiqOptionMenuEntry(event); - menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); - menuEntries[menuEntries.length - 1] = newMenuEntry; - - client.setMenuEntries(menuEntries); - } - } - - @Subscribe - private void onMenuOptionClicked(MenuOptionClicked ev) { - if (ev.getMenuAction() == MenuAction.RUNELITE && ev.getMenuOption().equals(MENUOP_SLAYERMUSIQ)) { - ev.consume(); - String quest = Text.removeTags(ev.getMenuTarget()); - QuestGuideLinks.tryOpenGuide(quest, chatMessageManager); - } - } - - private MenuEntry createSlayermusiqOptionMenuEntry(MenuEntryAdded event) { - int widgetIndex = event.getActionParam0(); - int widgetID = event.getActionParam1(); - - MenuEntry menuEntry = new MenuEntry(); - menuEntry.setTarget(event.getTarget()); - menuEntry.setOption(MENUOP_SLAYERMUSIQ); - menuEntry.setParam0(widgetIndex); - menuEntry.setParam1(widgetID); - menuEntry.setType(MenuAction.RUNELITE.getId()); - - return menuEntry; - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingConfig.java similarity index 70% rename from runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekConfig.java rename to runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingConfig.java index 090d1a9cab..611960ffe5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Frosty Fridge + * Copyright (c) 2019, Stephen * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,34 +22,24 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.templetrek; +package net.runelite.client.plugins.smelting; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -@ConfigGroup("templetrek") -public interface TempleTrekConfig extends Config +@ConfigGroup("smelting") +public interface SmeltingConfig extends Config { @ConfigItem( - keyName = "bogMapActive", - name = "Bog Map", - description = "Marks out a safe route through the bog event", - position = 0 + position = 1, + keyName = "statTimeout", + name = "Reset stats (minutes)", + description = "The time it takes for the current smelting session to be reset" ) - default boolean bogMapActive() + default int statTimeout() { - return true; + return 5; } - @ConfigItem( - keyName = "pointTrackerActive", - name = "Point Tracker", - description = "Track your Temple Trek reward points, which determine the size of your reward.", - position = 1 - ) - default boolean pointTrackerActive() - { - return true; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingOverlay.java new file mode 100644 index 0000000000..b1c93b09bb --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingOverlay.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2019, Stephen + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.smelting; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.time.Instant; +import java.time.Duration; +import javax.inject.Inject; +import static net.runelite.api.AnimationID.SMITHING_SMELTING; +import static net.runelite.api.AnimationID.SMITHING_CANNONBALL; +import net.runelite.api.Client; +import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; +import net.runelite.api.Skill; +import net.runelite.client.plugins.xptracker.XpTrackerService; +import net.runelite.client.ui.overlay.Overlay; +import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; +import net.runelite.client.ui.overlay.OverlayMenuEntry; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; + +class SmeltingOverlay extends Overlay +{ + private static final int SMELT_TIMEOUT = 5; + + private final Client client; + private final SmeltingPlugin plugin; + private final SmeltingConfig config; + private final XpTrackerService xpTrackerService; + + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + public SmeltingOverlay(Client client, SmeltingPlugin plugin, SmeltingConfig config, XpTrackerService xpTrackerService) + { + super(plugin); + setPosition(OverlayPosition.TOP_LEFT); + this.client = client; + this.plugin = plugin; + this.config = config; + this.xpTrackerService = xpTrackerService; + getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Smelting overlay")); + } + + @Override + public Dimension render(Graphics2D graphics) + { + SmeltingSession session = plugin.getSession(); + + if (session!=null) + if (session.getLastItemSmelted() == null) + { + return null; + } + + panelComponent.getChildren().clear(); + + if (session!=null) + if (isSmelting() || Duration.between(session.getLastItemSmelted(), Instant.now()).getSeconds() < SMELT_TIMEOUT) + { + panelComponent.getChildren().add(TitleComponent.builder() + .text("Smelting") + .color(Color.GREEN) + .build()); + } + else + { + panelComponent.getChildren().add(TitleComponent.builder() + .text("NOT smelting") + .color(Color.RED) + .build()); + } + + int actions = xpTrackerService.getActions(Skill.SMITHING); + if (actions > 0) + { + if (plugin.getSession().getBarsSmelted() > 0) + { + panelComponent.getChildren().add(LineComponent.builder() + .left("Bars:") + .right(Integer.toString(session.getBarsSmelted())) + .build()); + } + if (plugin.getSession().getCannonBallsSmelted() > 0) + { + panelComponent.getChildren().add(LineComponent.builder() + .left("Cannonballs:") + .right(Integer.toString(session.getCannonBallsSmelted())) + .build()); + } + if (actions > 2) + { + panelComponent.getChildren().add(LineComponent.builder() + .left("Actions/hr:") + .right(Integer.toString(xpTrackerService.getActionsHr(Skill.SMITHING))) + .build()); + } + } + + return panelComponent.render(graphics); + + } + private boolean isSmelting() + { + switch (client.getLocalPlayer().getAnimation()) + { + case SMITHING_SMELTING: + case SMITHING_CANNONBALL: + return true; + default: + return false; + } + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java similarity index 53% rename from runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxPlugin.java rename to runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java index afc3d095a7..9534129ad1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cox/CoxPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Jacky + * Copyright (c) 2019, Stephen * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,108 +22,109 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.client.plugins.cox; +package net.runelite.client.plugins.smelting; import com.google.inject.Provides; -import java.util.List; +import java.time.Duration; +import java.time.Instant; import javax.inject.Inject; +import lombok.AccessLevel; import lombok.Getter; -import net.runelite.api.Client; -import net.runelite.api.NPC; -import net.runelite.api.Projectile; +import net.runelite.api.ChatMessageType; +import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameTick; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDependency; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.xptracker.XpTrackerPlugin; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( - name = "Cox", - description = "COX Helper", - tags = {"combat", "overlay", "pve", "pvm"} + name = "Smelting", + description = "Show Smelting stats", + tags = {"overlay", "skilling"} ) -public class CoxPlugin extends Plugin +@PluginDependency(XpTrackerPlugin.class) +public class SmeltingPlugin extends Plugin { - @Getter - private NPC olm = null; - - @Getter - private int attackStyle = 0; // 0 - mage // 1 - range @Inject - private Client client; + private SmeltingConfig config; + + @Inject + private SmeltingOverlay overlay; @Inject private OverlayManager overlayManager; - @Inject - private CoxOverlay coxOverlay; - - @Inject CoxOverlayAbove coxOverlayAbove; - - @Inject - private CoxConfig config; - + @Getter(AccessLevel.PACKAGE) + private SmeltingSession session; @Provides - CoxConfig provideConfig(ConfigManager configManager) + SmeltingConfig getConfig(ConfigManager configManager) { - return configManager.getConfig(CoxConfig.class); + return configManager.getConfig(SmeltingConfig.class); } @Override protected void startUp() throws Exception { - overlayManager.add(coxOverlay); - overlayManager.add(coxOverlayAbove); + session = null; + overlayManager.add(overlay); } @Override protected void shutDown() throws Exception { - overlayManager.remove(coxOverlay); - overlayManager.remove(coxOverlayAbove); + overlayManager.remove(overlay); + session = null; + } + + @Subscribe + public void onChatMessage(ChatMessage event) + { + if (event.getType() != ChatMessageType.SPAM) + { + return; + } + + if (event.getMessage().contains("You retrieve a bar of")) + { + if (session == null) + { + session = new SmeltingSession(); + } + session.setLastItemSmelted(Instant.now()); + session.increaseBarsSmelted(); + } + else if (event.getMessage().contains("You remove the cannonballs from the mould")) + { + if (session == null) + { + session = new SmeltingSession(); + } + session.setLastItemSmelted(Instant.now()); + session.increaseCannonBallsSmelted(); + + } } @Subscribe public void onGameTick(GameTick event) { - if (!client.isInInstancedRegion()) + if (session!=null) + if (session.getLastItemSmelted() != null) { - olm = null; - return; - } + final Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + final Duration sinceCaught = Duration.between(session.getLastItemSmelted(), Instant.now()); - if (client.getPlane() != 0) return; - - List npcs = client.getNpcs(); - - for (NPC npc : npcs) - { - if (npc.getId() == 7554) + if (sinceCaught.compareTo(statTimeout) >= 0) { - olm = npc; - } - } - - if (olm == null) return; - - List projectiles = client.getProjectiles(); - - for (Projectile projectile : projectiles) - { - if (projectile.getId() == 1339) - { - // mage - attackStyle = 0; - } - - if (projectile.getId() == 1340) - { - // range - attackStyle = 1; + session.setLastItemSmelted(null); } } } } + diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingSession.java new file mode 100644 index 0000000000..c6b04acabc --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingSession.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019, Stephen + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.smelting; + +import java.time.Instant; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; + +class SmeltingSession +{ + @Getter(AccessLevel.PACKAGE) + @Setter + private Instant lastItemSmelted; + + @Getter(AccessLevel.PACKAGE) + private int barsSmelted; + + @Getter(AccessLevel.PACKAGE) + private int cannonBallsSmelted; + + void increaseBarsSmelted() + { + barsSmelted++; + } + + void increaseCannonBallsSmelted() + { + cannonBallsSmelted += 4; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbookfixer/SpellbookFixerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbookfixer/SpellbookFixerConfig.java deleted file mode 100644 index bb16cd3709..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbookfixer/SpellbookFixerConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package net.runelite.client.plugins.spellbookfixer; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("spellbookfixer") -public interface SpellbookFixerConfig extends Config -{ - @ConfigItem(position = 0, keyName = "shouldHideOthers", name = "Hide Others", description = "Toggle on to hide spells not useful for pking that cannot be filtered otherwise.") - default boolean shouldHideOthers() - { - return false; - } - - //ice blitz - @ConfigItem(position = 1, keyName = "shouldModifyIceBlitz", name = "Ice Blitz", description = "Toggle on to enable Ice Blitz modifications.") - default boolean shouldModifyIceBlitz() { return false; } - @ConfigItem(position = 2, keyName = "getBlitzPositionX", name = "Ice Blitz Pos X", description = "Modifies the X-axis position of Ice Blitz.") - default int getBlitzPositionX() - { - return 0; - } - @ConfigItem(position = 3, keyName = "getBlitzPositionY", name = "Ice Blitz Pos Y", description = "Modifies the Y-axis position of Ice Blitz.") - default int getBlitzPositionY() - { - return 118; - } - @ConfigItem(position = 4, keyName = "getBlitzSize", name = "Ice Blitz Size", description = "Modifies the width of Ice Blitz.") - default int getBlitzSize() - { - return 80; - } - - //ice barrage - @ConfigItem(position = 5, keyName = "shouldModifyIceBarrage", name = "Ice Barrage", description = "Toggle on to enable Ice Barrage modifications.") - default boolean shouldModifyIceBarrage() { return false; } - @ConfigItem(position = 6, keyName = "getBarragePositionX", name = "Ice Barrage Pos X", description = "Modifies the X-axis position of Ice Barrage.") - default int getBarragePositionX() - { - return 0; - } - @ConfigItem(position = 7, keyName = "getBarragePositionY", name = "Ice Barrage Pos X", description = "Modifies the X-axis position of Ice Barrage.") - default int getBarragePositionY() - { - return 0; - } - @ConfigItem(position = 8, keyName = "getBarrageSize", name = "Ice Barrage Size", description = "Modifies the width position of Ice Barrage.") - default int getBarrageSize() - { - return 80; - } - - //vengeance - @ConfigItem(position = 9, keyName = "shouldModifyVengeance", name = "Vengeance", description = "Toggle on to enable Vengeance modifications.") - default boolean shouldModifyVengeance() { return false; } - @ConfigItem(position = 10, keyName = "getVengeancePositionX", name = "Vengeance Pos X", description = "Modifies the X-axis position of Vengeance.") - default int getVengeancePositionX() - { - return 0; - } - @ConfigItem(position = 11, keyName = "getVengeancePositionY", name = "Vengeance Pos X", description = "Modifies the X-axis position of Vengeance.") - default int getVengeancePositionY() - { - return 0; - } - @ConfigItem(position = 12, keyName = "getVengeanceSize", name = "Vengeance Size", description = "Modifies the width position of Vengeance.") - default int getVengeanceSize() - { - return 80; - } - - //teleblock - @ConfigItem(position = 13, keyName = "shouldModifyTeleBlock", name = "TeleBlock", description = "Toggle on to enable TeleBlock modifications.") - default boolean shouldModifyTeleBlock() { return false; } - @ConfigItem(position = 14, keyName = "getTeleBlockPositionX", name = "TeleBlock Pos X", description = "Modifies the X-axis position of TeleBlock.") - default int getTeleBlockPositionX() - { - return 0; - } - @ConfigItem(position = 15, keyName = "getTeleBlockPositionY", name = "TeleBlock Pos X", description = "Modifies the X-axis position of TeleBlock.") - default int getTeleBlockPositionY() - { - return 0; - } - @ConfigItem(position = 16, keyName = "getTeleBlockSize", name = "TeleBlock Size", description = "Modifies the width position of TeleBlock.") - default int getTeleBlockSize() - { - return 80; - } - - //entangle - @ConfigItem(position = 17, keyName = "shouldModifyEntangle", name = "Entangle", description = "Toggle on to enable Entangle modifications.") - default boolean shouldModifyEntangle() { return false; } - @ConfigItem(position = 18, keyName = "getEntanglePositionX", name = "Entangle Pos X", description = "Modifies the X-axis position of Entangle.") - default int getEntanglePositionX() - { - return 0; - } - @ConfigItem(position = 19, keyName = "getEntanglePositionY", name = "Entangle Pos X", description = "Modifies the X-axis position of Entangle.") - default int getEntanglePositionY() - { - return 118; - } - @ConfigItem(position = 20, keyName = "getEntangleSize", name = "Entangle Size", description = "Modifies the width position of Entangle.") - default int getEntangleSize() - { - return 80; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbookfixer/SpellbookFixerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbookfixer/SpellbookFixerPlugin.java deleted file mode 100644 index 7d71cef371..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbookfixer/SpellbookFixerPlugin.java +++ /dev/null @@ -1,170 +0,0 @@ -package net.runelite.client.plugins.spellbookfixer; - -import com.google.inject.Provides; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.WidgetLoaded; -import net.runelite.api.widgets.Widget; -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.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; - -import javax.inject.Inject; - - -@PluginDescriptor( - name = "Spellbook Fixer", - description = "Resize and filter spellbook for PKing", - tags = {"resize", "spellbook", "magic", "spell", "pk", "book", "filter", "bogla"} -) -@Slf4j -public class SpellbookFixerPlugin extends Plugin -{ - @Inject - private Client client; - - @Inject - SpellbookFixerConfig config; - - @Provides - SpellbookFixerConfig provideConfig(ConfigManager configManager) { return configManager.getConfig(SpellbookFixerConfig.class); } - - @Override - protected void startUp() throws Exception - { - adjustSpellbook(); - } - - @Override - protected void shutDown() throws Exception - { - resetSpellbook(); - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - if (event.getGameState() == GameState.LOGGED_IN) - adjustSpellbook(); - } - - @Subscribe - public void onWidgetLoaded(WidgetLoaded event) - { - if (event.getGroupId() == WidgetID.SPELLBOOK_GROUP_ID) - adjustSpellbook(); - } - - @Subscribe - public void onGameTick(GameTick event) - { - adjustSpellbook(); - } - - private void adjustSpellbook() - { - if (client.getGameState() != GameState.LOGGED_IN) - return; - - try - { - if (config.shouldModifyIceBarrage()) - modifySpell(WidgetInfo.SPELL_ICE_BARRAGE, config.getBarragePositionX(), config.getBarragePositionY(), config.getBarrageSize()); - - if (config.shouldModifyIceBlitz()) - modifySpell(WidgetInfo.SPELL_ICE_BLITZ, config.getBlitzPositionX(), config.getBlitzPositionY(), config.getBlitzSize()); - - if (config.shouldModifyVengeance()) - modifySpell(WidgetInfo.SPELL_VENGEANCE, config.getVengeancePositionX(), config.getVengeancePositionY(), config.getVengeanceSize()); - - if (config.shouldModifyTeleBlock()) - modifySpell(WidgetInfo.SPELL_TELE_BLOCK, config.getTeleBlockPositionX(), config.getTeleBlockPositionY(), config.getTeleBlockSize()); - - if (config.shouldModifyEntangle()) - modifySpell(WidgetInfo.SPELL_ENTANGLE, config.getEntanglePositionX(), config.getEntanglePositionY(), config.getEntangleSize()); - - setSpellHidden(WidgetInfo.SPELL_BLOOD_BLITZ, config.shouldHideOthers()); - setSpellHidden(WidgetInfo.SPELL_VENGEANCE_OTHER, config.shouldHideOthers()); - setSpellHidden(WidgetInfo.SPELL_BIND, config.shouldHideOthers()); - setSpellHidden(WidgetInfo.SPELL_SNARE, config.shouldHideOthers()); - } - catch (Exception e) - { - //swallow - } - - - } - - private void resetSpellbook() - { - if (client.getGameState() != GameState.LOGGED_IN) - return; - - try - { - if (config.shouldModifyIceBarrage()) - modifySpell(WidgetInfo.SPELL_ICE_BARRAGE, config.getBarragePositionX(), config.getBarragePositionY(), 24); - - if (config.shouldModifyIceBlitz()) - modifySpell(WidgetInfo.SPELL_ICE_BLITZ, config.getBlitzPositionX(), config.getBlitzPositionY(), 24); - - if (config.shouldModifyVengeance()) - modifySpell(WidgetInfo.SPELL_VENGEANCE, config.getVengeancePositionX(), config.getVengeancePositionY(), 24); - - if (config.shouldModifyTeleBlock()) - modifySpell(WidgetInfo.SPELL_TELE_BLOCK, config.getTeleBlockPositionX(), config.getTeleBlockPositionY(), 24); - - if (config.shouldModifyEntangle()) - modifySpell(WidgetInfo.SPELL_ENTANGLE, config.getEntanglePositionX(), config.getEntanglePositionY(), 24); - - setSpellHidden(WidgetInfo.SPELL_BLOOD_BLITZ, false); - setSpellHidden(WidgetInfo.SPELL_VENGEANCE_OTHER, false); - setSpellHidden(WidgetInfo.SPELL_BIND, false); - setSpellHidden(WidgetInfo.SPELL_SNARE, false); - } - catch (Exception e) - { - //swallow - } - } - - private void modifySpell(WidgetInfo widgetInfo, int posX, int posY, int size) - { - Widget widget = client.getWidget(widgetInfo); - - if (widget == null) - return; - - try - { - widget.setOriginalX(posX); - widget.setOriginalY(posY); - widget.setOriginalWidth(size); - widget.setOriginalHeight(size); - widget.revalidate(); - } - catch (Exception e) - { - //swallow - } - - } - - private void setSpellHidden(WidgetInfo widgetInfo, boolean hidden) - { - Widget widget = client.getWidget(widgetInfo); - - if (widget == null) - return; - - widget.setHidden(hidden); - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java index f7034af63f..9212432d7e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPlugin.java @@ -63,6 +63,7 @@ import java.awt.image.BufferedImage; name = "Supplies Used Tracker", description = "Tracks supplies used during the session", tags = {"cost"}, + type = "PVM", enabledByDefault = false ) @Slf4j diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekOverlay.java deleted file mode 100644 index afbf4c88a5..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekOverlay.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2018, Frosty Fridge - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.templetrek; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import javax.inject.Inject; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; - -public class TempleTrekOverlay extends Overlay -{ - private final TempleTrekConfig config; - private final TempleTrekPlugin plugin; - - private final PanelComponent panelComponent = new PanelComponent(); - - @Inject - private TempleTrekOverlay(TempleTrekConfig config, TempleTrekPlugin plugin) - { - super(plugin); - this.config = config; - this.plugin = plugin; - setPosition(OverlayPosition.TOP_LEFT); - setPriority(OverlayPriority.LOW); - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (config.pointTrackerActive() && plugin.isInTrek()) - { - int points = plugin.getRewardPoints(); - double percentage = plugin.getRewardPercentage() * 100; - panelComponent.getChildren().clear(); - panelComponent.getChildren().add(LineComponent.builder() - .left("Trek Points: ") - .right(Integer.toString(points)) - .rightColor(percentage < 25 ? Color.RED : percentage >= 25 && percentage < 50 ? Color.YELLOW : - percentage >= 50 && percentage < 75 ? Color.BLUE : Color.GREEN) - .build()); - panelComponent.getChildren().add(LineComponent.builder() - .left("Reward %: ") - .right(String.format("%.2f", percentage) + "%") - .rightColor(percentage < 25 ? Color.RED : percentage >= 25 && percentage < 50 ? Color.YELLOW : - percentage >= 50 && percentage < 75 ? Color.BLUE : Color.GREEN) - .build()); - return panelComponent.render(graphics); - } - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekPlugin.java deleted file mode 100644 index 99fd1d4286..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/templetrek/TempleTrekPlugin.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2018, Frosty Fridge - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.templetrek; - -import com.google.inject.Provides; -import java.util.HashSet; -import java.util.Set; -import javax.inject.Inject; -import lombok.Getter; -import net.runelite.api.Client; -import net.runelite.api.GroundObject; -import net.runelite.api.ObjectID; -import net.runelite.api.Varbits; -import net.runelite.api.events.GroundObjectSpawned; -import net.runelite.api.events.VarbitChanged; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; - -@PluginDescriptor( - name = "Temple Trekking", - description = "Helpers for the Temple Trek minigame", - tags = {"minigame", "overlay", "temple trek"} -) -public class TempleTrekPlugin extends Plugin -{ - - @Inject - private Client client; - - @Inject - private OverlayManager overlayManager; - - @Inject - private TempleTrekOverlay overlay; - - @Inject - private TempleTrekBogOverlay bogOverlay; - - @Inject - private TempleTrekConfig config; - - @Getter - private final Set bogList = new HashSet(); - - @Getter - private boolean inTrek = false; - - @Provides - TempleTrekConfig getConfig(ConfigManager configManager) - { - return configManager.getConfig(TempleTrekConfig.class); - } - - @Override - protected void startUp() - { - overlayManager.add(overlay); - overlayManager.add(bogOverlay); - } - - @Override - protected void shutDown() - { - overlayManager.remove(overlay); - overlayManager.remove(bogOverlay); - bogList.clear(); - } - - @Subscribe - public void onGroundObjectSpawned(GroundObjectSpawned event) - { - GroundObject obj = event.getGroundObject(); - if (obj.getId() == ObjectID.BOG) - { - bogList.add(obj); - } - } - - //onGroundObjectDespawned is having issues handling this, so bogmap removal is here instead. - @Subscribe - public void onVarbitChanged(VarbitChanged event) - { - if (!bogList.isEmpty() && client.getVar(Varbits.TREK_EVENT) == 0) - { - bogList.clear(); - } - if (!inTrek && client.getVar(Varbits.TREK_STARTED) == 1) - { - inTrek = true; - } - else if (inTrek) - { - if (client.getVar(Varbits.TREK_STATUS) == 0 && client.getVar(Varbits.TREK_POINTS) == 0) - { - inTrek = false; - } - } - } - - protected int getRewardPoints() - { - return client.getVar(Varbits.TREK_POINTS); - } - - protected double getRewardPercentage() - { - double percentage = 0.000126945 * getRewardPoints() - 0.0357188951; - return Math.max(percentage, 0); - } - -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java index fe2130285c..4e40b23ff3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java @@ -21,9 +21,10 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; -@PluginDescriptor(name = "!Tick Counter", +@PluginDescriptor(name = "Tick Counter", description = "Counts combat activity for nearby players", - enabledByDefault = false + enabledByDefault = false, + type = "utility" ) public class TickCounterPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java index 03473991f5..f187d27043 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java @@ -78,7 +78,8 @@ enum GameTimer STAFF_OF_THE_DEAD(ItemID.STAFF_OF_THE_DEAD, GameTimerImageType.ITEM, "Staff of the Dead", 1, ChronoUnit.MINUTES), ABYSSAL_SIRE_STUN(ItemID.ABYSSAL_ORPHAN, GameTimerImageType.ITEM, "Abyssal Sire Stun", 30, ChronoUnit.SECONDS, true), HOME_TELEPORT(SpriteID.SPELL_LUMBRIDGE_HOME_TELEPORT, GameTimerImageType.SPRITE, "Home Teleport", 30, ChronoUnit.MINUTES), - MINIGAME_TELEPORT(SpriteID.TAB_QUESTS_RED_MINIGAMES, GameTimerImageType.SPRITE, "Minigame Teleport", 20, ChronoUnit.MINUTES); + MINIGAME_TELEPORT(SpriteID.TAB_QUESTS_RED_MINIGAMES, GameTimerImageType.SPRITE, "Minigame Teleport", 20, ChronoUnit.MINUTES), + SKULL(SpriteID.PLAYER_KILLER_SKULL_523, GameTimerImageType.SPRITE, "Skull", 20, ChronoUnit.MINUTES); @Getter private final Duration duration; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index 5672ffdd31..18a97e0f00 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -43,6 +43,7 @@ import net.runelite.api.NPC; import net.runelite.api.NpcID; import net.runelite.api.Player; import net.runelite.api.Prayer; +import net.runelite.api.SkullIcon; import net.runelite.api.Varbits; import net.runelite.api.WorldType; import net.runelite.api.coords.WorldPoint; @@ -120,6 +121,7 @@ public class TimersPlugin extends Plugin private int lastAnimation; private boolean loggedInRace; private boolean widgetHiddenChangedOnPvpWorld; + private boolean skulledLastTick = false; @Inject private ItemManager itemManager; @@ -608,6 +610,21 @@ public class TimersPlugin extends Plugin Player player = client.getLocalPlayer(); WorldPoint currentWorldPoint = player.getWorldLocation(); + final boolean isSkulled = player.getSkullIcon() != null && player.getSkullIcon() != SkullIcon.SKULL_FIGHT_PIT; + + if (isSkulled != skulledLastTick) + { + skulledLastTick = isSkulled; + if (isSkulled) + { + createGameTimer(SKULL); + } + else + { + removeGameTimer(SKULL); + } + } + if (freezeTimer != null) { // assume movement means unfrozen diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java index 96cf62c6fc..520dcb0f3b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewItemPanel.java @@ -50,7 +50,7 @@ class OverviewItemPanel extends JPanel static { - ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "/util/arrow_right.png")); + ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(TimeTrackingPlugin.class, "/net/runelite/client/plugins/timetracking/arrow_right.png")); } OverviewItemPanel(ItemManager itemManager, TimeTrackingPanel pluginPanel, Tab tab, String title) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeTrackingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeTrackingPlugin.java index b49e461025..9279883311 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeTrackingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TimeTrackingPlugin.java @@ -111,7 +111,7 @@ public class TimeTrackingPlugin extends Plugin birdHouseTracker.loadFromConfig(); farmingTracker.loadCompletionTimes(); - final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "watch.png"); + final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "/net/runelite/client/plugins/timetracking/watch.png"); panel = new TimeTrackingPanel(itemManager, config, farmingTracker, birdHouseTracker, clockManager); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockManager.java index 42686dae70..3be9dc053b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/clocks/ClockManager.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.timetracking.clocks; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.inject.Singleton; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -34,11 +35,13 @@ import javax.inject.Inject; import javax.swing.SwingUtilities; import joptsimple.internal.Strings; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.timetracking.TimeTrackingConfig; @Singleton +@Slf4j public class ClockManager { @Inject @@ -57,7 +60,19 @@ public class ClockManager private final List stopwatches = new ArrayList<>(); @Getter - private ClockTabPanel clockTabPanel = new ClockTabPanel(this); + private ClockTabPanel clockTabPanel; + + ClockManager() + { + try + { + SwingUtilities.invokeAndWait(() -> clockTabPanel = new ClockTabPanel(this)); + } + catch (InterruptedException | InvocationTargetException e) + { + log.error("Error constructing ClockManager", e); + } + } void addTimer() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tobdamagecount/DamageCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tobdamagecount/DamageCounterPlugin.java index d7cda5adff..7b49a30ece 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tobdamagecount/DamageCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tobdamagecount/DamageCounterPlugin.java @@ -56,6 +56,7 @@ import net.runelite.client.eventbus.Subscribe; description = "Gives you an estimation damage on a boss and taken after the fight is done" + "the damage will be posted in the chat", tags = {"combat", "npcs", "tob", "damage"}, + type = "PVM", enabledByDefault = false ) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardOverlay.java new file mode 100644 index 0000000000..a4a74ad8a6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardOverlay.java @@ -0,0 +1,119 @@ + +package net.runelite.client.plugins.vanguards; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; + +import net.runelite.api.Actor; +import net.runelite.api.NPC; +import net.runelite.api.Player; +import net.runelite.api.Client; +import net.runelite.client.game.NPCManager; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; + +import net.runelite.client.plugins.opponentinfo.OpponentInfoPlugin; +//import net.runelite.client.plugins.opponentinfo.OpponentInfoOverlay; + +import javax.inject.Inject; + +public class VanguardOverlay extends Overlay { + + private VanguardPlugin plugin; + private final PanelComponent panelComponent = new PanelComponent(); + + private static final int MAGE_VANGUARD_ID = 7529; + private static final int RANGE_VANGUARD_ID = 7528; + private static final int MELEE_VANGUARD_ID = 7527; + //private final NPCManager npcManager; + + private int mageHp = -1; + private float magePercent = 0; + + private int rangeHp = -1; + private float rangePercent = 0; + + private int meleeHp = -1; + private float meleePercent = 0; + + public String right_mage_str, right_range_str, right_melee_str = ""; + + @Inject + private Client client; + + + @Inject + public VanguardOverlay(VanguardPlugin plugin) { + super(plugin);//? + this.plugin = plugin; + + setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT); + //this.opponentInfoPlugin = opponentInfoPlugin; + } + + @Override + public Dimension render(Graphics2D graphics) + { + Player p = client.getLocalPlayer(); //local player aka me + Actor opponent = p.getInteracting(); //get entity i am interacting with + //how to find its Id since it's an Actor not NPC specifically + //if(opponent.getName().equals("Vanguard") && opponent.getHealth() > 0)//might wana double check the name + //{ + if(opponent instanceof NPC) + { + int id = ((NPC) opponent).getId(); + String name = opponent.getName(); + + if(id == MAGE_VANGUARD_ID) //maybe check name.equals("Vanguard") + { + magePercent = (float)opponent.getHealthRatio() / opponent.getHealth() * 100; + mageHp = (int)magePercent; + right_mage_str = Integer.toString(mageHp); + System.out.println("mager"); + } + else if (id == RANGE_VANGUARD_ID) + { + rangePercent = (float)opponent.getHealthRatio() / opponent.getHealth() * 100; + rangeHp = (int)rangePercent; + right_range_str = Integer.toString(rangeHp); + + System.out.println("ranger"); + } + else if (id == MELEE_VANGUARD_ID) + { + meleePercent = (float)opponent.getHealthRatio()/opponent.getHealth() * 100; + meleeHp = (int)meleePercent; + right_melee_str = Integer.toString(meleeHp); + + + System.out.println("meleer"); + } + } + //} + + + //if (opponent == null) { + //} + + + panelComponent.getChildren().clear(); + String overlayTitle = "Vanguard HP"; + //title + panelComponent.getChildren().add(TitleComponent.builder().text(overlayTitle).color(Color.RED).build()); + + //size (width) + panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(overlayTitle) + 30, 0)); + + panelComponent.getChildren().add(LineComponent.builder().left("Mage:").right(right_mage_str).build()); + + panelComponent.getChildren().add(LineComponent.builder().left("Range:").right(right_range_str).build()); + + panelComponent.getChildren().add(LineComponent.builder().left("Melee:").right(right_melee_str).build()); + + return panelComponent.render(graphics); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardPlugin.java new file mode 100644 index 0000000000..88cb075867 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardPlugin.java @@ -0,0 +1,45 @@ + +package net.runelite.client.plugins.vanguards; + +import javax.inject.Inject; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.OverlayManager; + +@PluginDescriptor( + name= "Vanguard HP Overlay", + description= "tracks HP of all three vanguards", + tags= {"overlay", "vangs", "cox"}, + enabledByDefault = false, + type = "PVM" +) +public class VanguardPlugin extends Plugin { + private static final int MAGE_VANGUARD_ID = 7526; //i think + private static final int RANGE_VANGUARD_ID = 7527; + private static final int MELEE_VANGUARD_ID = 7528; + + + @Inject + private OverlayManager overlayManager; + + @Inject + private VanguardOverlay overlay; + + @Override + protected void startUp() throws Exception + { + overlayManager.add(overlay); + } + + @Override + protected void shutDown() throws Exception + { + overlayManager.remove(overlay); + overlay.right_mage_str = "-"; + overlay.right_range_str = "-"; + overlay.right_melee_str = "-"; + } + + +} + diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vetion/VetionPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/vetion/VetionPlugin.java index 9df9a4fa57..847c1f3678 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vetion/VetionPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vetion/VetionPlugin.java @@ -40,9 +40,10 @@ import java.util.HashMap; import java.util.Map; @PluginDescriptor( - name = "!Vetion", + name = "Vetion", description = "Tracks Vet'ion's special attacks", - tags = {"bosses", "combat", "pve", "overlay"} + tags = {"bosses", "combat", "pve", "overlay"}, + type = "PVM" ) public class VetionPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java index 1ba5e4b0e7..060a9d2246 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathPlugin.java @@ -14,9 +14,10 @@ import net.runelite.client.ui.overlay.OverlayManager; import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( - name = "!Vorkath", + name = "Vorkath", description = "Vorkath Helper", - tags = {"Vorkath", "Helper"} + tags = {"Vorkath", "Helper"}, + type = "PVM" ) public class VorkathPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorPlugin.java index af7cf94ab7..9dc378547c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorPlugin.java @@ -54,9 +54,10 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( - name = "!War", + name = "War calling indicators", description = "War War War.", tags = {"skill", "total", "max", "PVP"}, + type = "PVP", enabledByDefault = false ) public class WarIndicatorPlugin extends Plugin diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersConfig.java new file mode 100644 index 0000000000..9da7fa9ece --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersConfig.java @@ -0,0 +1,68 @@ +package net.runelite.client.plugins.whalewatchers; + +import java.awt.Color; +import net.runelite.client.config.Alpha; +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("WhaleWatchers") +public interface WhaleWatchersConfig extends Config +{ + + @ConfigItem( + position = 1, + keyName = "protectItemWarning", + name = "Protect Item Warning", + description = "Warns you when you are skulled and don't have protect item turned on." + ) + default boolean protectItemWarning() + { + return false; + } + + @ConfigItem( + position = 2, + keyName = "showDamageCounter", + name = "Damage Counter", + description = "Shows damage you've done and damage your opponent has done to you while in a fight" + ) + default boolean showDamageCounter() + { + return true; + } + + @Alpha + @ConfigItem( + position = 3, + keyName = "damageBackgroundColor", + name = "Counter Background Color", + description = "The background color for the damage counter overlay" + ) + default Color damageBackgroundColor() + { + return Color.darkGray; + } + + @ConfigItem( + position = 4, + keyName = "smiteableWarning", + name = "Smite Warning", + description = "Displays a warning overlay when your prayer is at a smiteable level" + ) + default boolean smiteableWarning() + { + return true; + } + + @ConfigItem( + position = 5, + keyName = "gloryWarning", + name = "Glory Warning", + description = "Displays a warning box while you are wearing an uncharged glory" + ) + default boolean gloryWarning() + { + return true; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java new file mode 100644 index 0000000000..61bfaf0d47 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java @@ -0,0 +1,72 @@ +package net.runelite.client.plugins.whalewatchers; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.ItemID; +import net.runelite.api.kit.KitType; +import net.runelite.client.game.AsyncBufferedImage; +import net.runelite.client.game.ItemManager; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.components.ImageComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TextComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; +import org.apache.commons.lang3.ObjectUtils; + +public class WhaleWatchersGloryOverlay extends Overlay +{ + private Client client; + private final WhaleWatchersConfig config; + private WhaleWatchersPlugin plugin; + private PanelComponent panelComponent; + + @Inject + private ItemManager itemManager; + + @Inject + public WhaleWatchersGloryOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DETACHED); + panelComponent = new PanelComponent(); + } + + @Override + public Dimension render(Graphics2D graphics) + { + panelComponent.getChildren().clear(); + int amuletID = 0; + try + { + amuletID = client.getLocalPlayer().getPlayerComposition().getEquipmentId(KitType.AMULET); + } + catch (NullPointerException e) + { + + } + if (config.gloryWarning() && amuletID == ItemID.AMULET_OF_GLORY) + { + panelComponent.setBackgroundColor(Color.lightGray); + final AsyncBufferedImage gloryImage = itemManager.getImage(ItemID.AMULET_OF_GLORY); + + panelComponent.getChildren().add(TitleComponent.builder() + .text("Uncharged Glory") + .color(Color.BLACK) + .build()); + + panelComponent.getChildren().add(new ImageComponent(gloryImage)); + } + + return panelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java new file mode 100644 index 0000000000..a21d4cbaae --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java @@ -0,0 +1,79 @@ +package net.runelite.client.plugins.whalewatchers; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; + +public class WhaleWatchersOverlay extends Overlay +{ + private Client client; + private final WhaleWatchersConfig config; + private WhaleWatchersPlugin plugin; + private PanelComponent panelComponent; + private String lastOpponent = "-"; + + @Inject + public WhaleWatchersOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DETACHED); + panelComponent = new PanelComponent(); + } + + @Override + public Dimension render(Graphics2D graphics) + { + panelComponent.getChildren().clear(); + + if (plugin.inCombat && config.showDamageCounter()) + { + panelComponent.setBackgroundColor(config.damageBackgroundColor()); + String opp = client.getLocalPlayer().getInteracting() != null ? + client.getLocalPlayer().getInteracting().getName() : lastOpponent; + if (client.getLocalPlayer().getInteracting() != null) + { + lastOpponent = client.getLocalPlayer().getInteracting().getName(); + } + final String opponent = "Fight vs " + opp; + String damageTaken = "Damage Taken: " + plugin.damageTaken; + String damageDealt = "Damage Dealt: " + plugin.damageDone; + + panelComponent.getChildren().add(TitleComponent.builder() + .text(opponent) + .color(Color.BLACK) + .build()); + + panelComponent.getChildren().add(TitleComponent.builder() + .text(damageDealt) + .color(Color.BLACK) + .build()); + + panelComponent.getChildren().add(TitleComponent.builder() + .text(damageTaken) + .color(Color.BLACK) + .build()); + + panelComponent.setPreferredSize(new Dimension( + graphics.getFontMetrics().stringWidth(damageDealt) + + + graphics.getFontMetrics().stringWidth(opponent) + 10,0)); + + } + else + { + panelComponent.getChildren().clear(); + } + return panelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java new file mode 100644 index 0000000000..b08d7e4ca4 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java @@ -0,0 +1,316 @@ +package net.runelite.client.plugins.whalewatchers; + +import com.google.inject.Provides; +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import javax.inject.Inject; +import lombok.Getter; +import net.runelite.api.Actor; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.InventoryID; +import net.runelite.api.ItemContainer; +import net.runelite.api.ItemID; +import net.runelite.api.MenuAction; +import net.runelite.api.Player; +import net.runelite.api.PlayerComposition; +import net.runelite.api.Skill; +import net.runelite.api.SkullIcon; +import net.runelite.api.VarPlayer; +import net.runelite.api.Varbits; +import net.runelite.api.WorldType; +import static net.runelite.api.WorldType.*; +import net.runelite.api.events.ExperienceChanged; +import net.runelite.api.events.GameStateChanged; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.HitsplatApplied; +import net.runelite.api.events.InteractingChanged; +import net.runelite.api.events.ItemContainerChanged; +import net.runelite.api.events.MenuOptionClicked; +import net.runelite.api.events.PlayerMenuOptionClicked; +import net.runelite.api.events.VarbitChanged; +import net.runelite.api.kit.KitType; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.game.ItemManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.util.WorldUtil; +import org.apache.commons.lang3.ObjectUtils; +import org.jetbrains.annotations.NotNull; + +@PluginDescriptor( + name = "Whale Watchers", + description = "A Plugin to save help whales in the wild", + tags = {"whale watchers", "whale", "protect item", "warning", "pklite"}, + enabledByDefault = true, + hidden = false, + developerPlugin = false, + type = "PVP", + loadWhenOutdated = false +) +public class WhaleWatchersPlugin extends Plugin +{ + + @Inject + private Client client; + + @Inject + private WhaleWatchersConfig config; + + @Inject + private WhaleWatchersOverlay overlay; + + @Inject + private WhaleWatchersProtOverlay whaleWatchersProtOverlay; + + @Inject + private WhaleWatchersSmiteableOverlay whaleWatchersSmiteableOverlay; + + @Inject + private WhaleWatchersGloryOverlay whaleWatchersGloryOverlay; + + @Inject + private OverlayManager overlayManager; + + @Inject + private ItemManager itemManager; + + public boolean enableOverlay = false; + private int lastXP = 0; + public int damageDone = 0; + public int damageTaken = 0; + public boolean inCombat = false; + private int tickCountdown = 0; + @Getter + private boolean displaySmiteOverlay; + @Getter + private boolean displayGloryOverlay; + + @Provides + WhaleWatchersConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(WhaleWatchersConfig.class); + } + + @Override + protected void startUp() throws Exception + { + overlayManager.add(overlay); + overlayManager.add(whaleWatchersProtOverlay); + overlayManager.add(whaleWatchersSmiteableOverlay); + overlayManager.add(whaleWatchersGloryOverlay); + } + + @Override + protected void shutDown() throws Exception + { + overlayManager.remove(overlay); + overlayManager.remove(whaleWatchersProtOverlay); + overlayManager.remove(whaleWatchersSmiteableOverlay); + overlayManager.remove(whaleWatchersGloryOverlay); + } + + + @Subscribe + public void onHitsplatApplied(HitsplatApplied event) + { + if (config.showDamageCounter()) + { + if (!(event.getActor() == client.getLocalPlayer() | + event.getActor() == client.getLocalPlayer().getInteracting())) + { + return; + } + if (isAttackingPlayer(client) || inCombat) + { + inCombat = true; + + if (event.getActor() == client.getLocalPlayer()) + { + damageTaken += event.getHitsplat().getAmount(); + + } + if (event.getActor() == client.getLocalPlayer().getInteracting()) + { + damageDone += event.getHitsplat().getAmount(); + } + } + } + } + + + /** + * final Player target = (Player) event.getTarget(); + * if (lastInteracting == null) + * { + * lastInteracting = target; + * inCombat = true; + * interactingStarted = System.currentTimeMillis(); + * } + * List optionsList = Arrays.asList(client.getPlayerOptions()); + *

+ * if (target == lastInteracting || target == null) + * { + * inCombat = true; + * lastInteracting = target; + * interactingStarted = System.currentTimeMillis(); + * } + * if (target != lastInteracting && target != null && lastInteracting != null) + * { + * damageDone = 0; + * damageTaken = 0; + * interactingStarted = System.currentTimeMillis(); + * inCombat = true; + * } + **/ + + @Subscribe + public void onItemContainerChanged(ItemContainerChanged event) + { + if (config.gloryWarning() && event.getItemContainer().equals(InventoryID.EQUIPMENT)) + { + final int amuletID = ObjectUtils.defaultIfNull(client.getLocalPlayer() + .getPlayerComposition().getEquipmentId(KitType.AMULET), 0); + if (amuletID == ItemID.AMULET_OF_GLORY) + { + displayGloryOverlay = true; + } + else + { + displayGloryOverlay = false; + } + } + else + { + displayGloryOverlay = false; + } + } + + @Subscribe + public void onExperienceChanged(ExperienceChanged event) + { + final Skill skill = event.getSkill(); + final Player player = client.getLocalPlayer(); + if (skill.equals(Skill.HITPOINTS)) + { + if (player.getInteracting() instanceof Player) + { + //lient.getLogger().info(String.valueOf(Math.round((client.getSkillExperience(skill) - lastXP) / 1.33)) + 2); + lastXP = client.getSkillExperience(skill); + } + } + } + + @Subscribe + public void onMenuOptionClicked(MenuOptionClicked event) + { + if (config.showDamageCounter() && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER)) + { + inCombat = true; + } + } + + @Subscribe + public void onVarbitChanged(VarbitChanged event) + { + if (config.showDamageCounter()) + { + if (client.getVar(VarPlayer.ATTACKING_PLAYER) == -1) + { + if (inCombat) + { + //damageTaken = 0; + //damageDone = 0; + tickCountdown = 10; + } + } + } + + if (config.protectItemWarning()) + { + try + { + if (client.getLocalPlayer().getSkullIcon() == (SkullIcon.SKULL)) + { + if (client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 0 && client.getVar(Varbits.IN_WILDERNESS) == 1 || + client.getWorldType().contains(PVP)) + { + enableOverlay = true; + } + if (client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 1 || client.getVar(Varbits.IN_WILDERNESS) == 0 || + client.getWorldType().contains(PVP_HIGH_RISK) || client.getWorld() == 365) + { + enableOverlay = false; + } + } + else + { + enableOverlay = false; + } + } + catch (NullPointerException e) + { + + } + } + } + + @Subscribe + public void onGameTick(GameTick event) + { + + if (tickCountdown > 0 && tickCountdown < 11) + { + tickCountdown--; + if (tickCountdown == 1) + { + if (!isAttackingPlayer(client)) + { + inCombat = false; + damageDone = 0; + damageTaken = 0; + return; + } + } + } + + if (config.smiteableWarning() && (client.getVar(Varbits.IN_WILDERNESS) == 1 || isPvpWorld(client.getWorldType()))) + { + if (client.getLocalPlayer().getSkullIcon() != null && client.getLocalPlayer().getSkullIcon().equals(SkullIcon.SKULL)) + { + final int currentHealth = client.getLocalPlayer().getHealth(); + final int currentPrayer = client.getBoostedSkillLevel(Skill.PRAYER); + if (currentPrayer <= (Math.ceil(currentHealth / 4))) + { + displaySmiteOverlay = true; + } + else + { + displaySmiteOverlay = false; + } + } + else + { + displaySmiteOverlay = false; + } + } + else + { + displaySmiteOverlay = false; + } + } + + public boolean isAttackingPlayer(@NotNull Client c) + { + if (client.getVar(Varbits.IN_WILDERNESS) == 1 && client.getLocalPlayer().getInteracting() != null) + { + return true; + } + int varp = c.getVar(VarPlayer.ATTACKING_PLAYER); + return varp != -1; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java new file mode 100644 index 0000000000..9e6e081931 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java @@ -0,0 +1,59 @@ +package net.runelite.client.plugins.whalewatchers; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Stroke; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.Point; +import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.OverlayUtil; +import net.runelite.client.ui.overlay.components.PanelComponent; + +public class WhaleWatchersProtOverlay extends Overlay +{ + + private Client client; + private final WhaleWatchersConfig config; + private WhaleWatchersPlugin plugin; + + @Inject + public WhaleWatchersProtOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.DYNAMIC); + + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (plugin.enableOverlay && config.protectItemWarning()) + { + Rectangle rectangle = new Rectangle(); + rectangle.setBounds(client.getCanvas().getBounds()); + rectangle.setLocation(client.getCanvas().getLocation()); + Stroke oldStroke = graphics.getStroke(); + graphics.setStroke(new BasicStroke(10)); + graphics.setColor(Color.RED); + graphics.draw(rectangle); + Font font = FontManager.getRunescapeBoldFont().deriveFont(Font.BOLD, 72); + graphics.setFont(font); + OverlayUtil.renderTextLocation(graphics, new Point((int) rectangle.getCenterX() - 50, font.getSize()), "Protect item prayer disabled!!!", Color.red); + graphics.setStroke(oldStroke); + } + return null; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java new file mode 100644 index 0000000000..6e4d502851 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java @@ -0,0 +1,59 @@ +package net.runelite.client.plugins.whalewatchers; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; + +public class WhaleWatchersSmiteableOverlay extends Overlay +{ + private Client client; + private WhaleWatchersPlugin plugin; + private PanelComponent panelComponent; + + + @Inject + public WhaleWatchersSmiteableOverlay( WhaleWatchersPlugin plugin) + { + this.plugin = plugin; + setLayer(OverlayLayer.ABOVE_WIDGETS); + setPriority(OverlayPriority.HIGH); + setPosition(OverlayPosition.BOTTOM_RIGHT); + + panelComponent = new PanelComponent(); + } + + @Override + public Dimension render(Graphics2D graphics) + { + String subText = "You could be smited in 1 tick"; + panelComponent.getChildren().clear(); + if (plugin.isDisplaySmiteOverlay()) + { + panelComponent.setBackgroundColor(Color.WHITE); + panelComponent.getChildren().add(TitleComponent.builder() + .text("LOW PRAYER WARNING") + .color(Color.BLACK) + .build()); + panelComponent.getChildren().add(TitleComponent.builder() + .text(subText) + .color(Color.BLACK) + .build()); + + panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(subText) + + 20 , 0)); + } + else + { + panelComponent.getChildren().clear(); + } + return panelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsPlugin.java index 0020f384f4..c698e5894a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsPlugin.java @@ -25,7 +25,8 @@ import net.runelite.client.util.WildernessLocation; @PluginDescriptor(name="PvP Wild Locations", description="Indicates the players current location in the wild", - tags={"Wildy,", "Wilderness Location", "location", "loc", "pvp", "pklite"}) + tags={"Wildy,", "Wilderness Location", "location", "loc", "pvp", "pklite"}, + type = "PVP") public class WildernessLocationsPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java index f7a75781fd..a88c9510b6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java @@ -112,4 +112,15 @@ public interface WorldHopperConfig extends Config { return SubscriptionFilterMode.BOTH; } + + @ConfigItem( + keyName = "showHistory", + name = "Show history tab", + description = "Shows the history tab", + position = 5 + ) + default boolean showHistory() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java index a6d52f7025..88b6089f4a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java @@ -258,10 +258,49 @@ public class WorldHopperPlugin extends Plugin panel.setFilterMode(config.subscriptionFilter()); updateList(); break; + case "showHistory": + panel.updateLayout(); + break; } } } + boolean showHistory() + { + return config.showHistory(); + } + + Map getHistory() + { + Map history = configManager.getConfiguration(WorldHopperConfig.GROUP, "history", Map.class); + if (history == null) + { + history = new HashMap(); + } + + return history; + } + + void clearHistory() + { + Map history = getHistory(); + history.clear(); + configManager.setConfiguration(WorldHopperConfig.GROUP, "history", history); + } + + void addToHistory() + { + addToHistory(client.getWorld()); + } + + void addToHistory(int world) + { + long unixTime = System.currentTimeMillis() / 1000L; + Map history = getHistory(); + history.put(String.valueOf(world), String.valueOf(unixTime)); + configManager.setConfiguration(WorldHopperConfig.GROUP, "history", history); + } + private void setFavoriteConfig(int world) { configManager.setConfiguration(WorldHopperConfig.GROUP, "favorite_" + world, true); @@ -408,6 +447,12 @@ public class WorldHopperPlugin extends Plugin lastWorld = newWorld; } } + + if (gameStateChanged.getGameState() == GameState.LOGGED_IN) + { + addToHistory(client.getWorld()); + panel.updateList(); + } } @Subscribe @@ -644,6 +689,8 @@ public class WorldHopperPlugin extends Plugin quickHopTargetWorld = rsWorld; displaySwitcherAttempts = 0; + + addToHistory(worldId); } @Subscribe diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java index b27f356dac..28f299ed0e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java @@ -1,399 +1,645 @@ -/* - * Copyright (c) 2018, Psikoi - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.worldhopper; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import lombok.AccessLevel; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import net.runelite.client.ui.ColorScheme; -import net.runelite.client.ui.DynamicGridLayout; -import net.runelite.client.ui.PluginPanel; -import net.runelite.http.api.worlds.World; -import net.runelite.http.api.worlds.WorldType; - -@Slf4j -class WorldSwitcherPanel extends PluginPanel -{ - private static final Color ODD_ROW = new Color(44, 44, 44); - - private static final int WORLD_COLUMN_WIDTH = 60; - private static final int PLAYERS_COLUMN_WIDTH = 40; - private static final int PING_COLUMN_WIDTH = 47; - - private final JPanel listContainer = new JPanel(); - - private WorldTableHeader worldHeader; - private WorldTableHeader playersHeader; - private WorldTableHeader activityHeader; - private WorldTableHeader pingHeader; - - private WorldOrder orderIndex = WorldOrder.WORLD; - private boolean ascendingOrder = true; - - private ArrayList rows = new ArrayList<>(); - private WorldHopperPlugin plugin; - @Setter(AccessLevel.PACKAGE) - private SubscriptionFilterMode filterMode; - - WorldSwitcherPanel(WorldHopperPlugin plugin) - { - this.plugin = plugin; - - setBorder(null); - setLayout(new DynamicGridLayout(0, 1)); - - JPanel headerContainer = buildHeader(); - - listContainer.setLayout(new GridLayout(0, 1)); - - add(headerContainer); - add(listContainer); - } - - void switchCurrentHighlight(int newWorld, int lastWorld) - { - for (WorldTableRow row : rows) - { - if (row.getWorld().getId() == newWorld) - { - row.recolour(true); - } - else if (row.getWorld().getId() == lastWorld) - { - row.recolour(false); - } - } - } - - void updateListData(Map worldData) - { - for (WorldTableRow worldTableRow : rows) - { - World world = worldTableRow.getWorld(); - Integer playerCount = worldData.get(world.getId()); - if (playerCount != null) - { - worldTableRow.updatePlayerCount(playerCount); - } - } - - // If the list is being ordered by player count, then it has to be re-painted - // to properly display the new data - if (orderIndex == WorldOrder.PLAYERS) - { - updateList(); - } - } - - void updatePing(int world, int ping) - { - for (WorldTableRow worldTableRow : rows) - { - if (worldTableRow.getWorld().getId() == world) - { - worldTableRow.setPing(ping); - - // If the panel is sorted by ping, re-sort it - if (orderIndex == WorldOrder.PING) - { - updateList(); - } - break; - } - } - } - - void hidePing() - { - for (WorldTableRow worldTableRow : rows) - { - worldTableRow.hidePing(); - } - } - - void showPing() - { - for (WorldTableRow worldTableRow : rows) - { - worldTableRow.showPing(); - } - } - - void updateList() - { - rows.sort((r1, r2) -> - { - switch (orderIndex) - { - case PING: - return Integer.compare(r1.getPing(), r2.getPing()) * (ascendingOrder ? 1 : -1); - case WORLD: - return Integer.compare(r1.getWorld().getId(), r2.getWorld().getId()) * (ascendingOrder ? 1 : -1); - case PLAYERS: - return Integer.compare(r1.getUpdatedPlayerCount(), r2.getUpdatedPlayerCount()) * (ascendingOrder ? 1 : -1); - case ACTIVITY: - return r1.getWorld().getActivity().compareTo(r2.getWorld().getActivity()) * -1 * (ascendingOrder ? 1 : -1); - default: - return 0; - } - }); - - // Leave empty activity worlds on the bottom of the list - if (orderIndex == WorldOrder.ACTIVITY) - { - rows.sort((r1, r2) -> r1.getWorld().getActivity().equals("-") ? 1 : -1); - } - - rows.sort((r1, r2) -> - { - boolean b1 = plugin.isFavorite(r1.getWorld()); - boolean b2 = plugin.isFavorite(r2.getWorld()); - return Boolean.compare(b2, b1); - }); - - listContainer.removeAll(); - - for (int i = 0; i < rows.size(); i++) - { - WorldTableRow row = rows.get(i); - row.setBackground(i % 2 == 0 ? ODD_ROW : ColorScheme.DARK_GRAY_COLOR); - listContainer.add(row); - } - - listContainer.revalidate(); - listContainer.repaint(); - } - - void updateFavoriteMenu(int world, boolean favorite) - { - for (WorldTableRow row : rows) - { - if (row.getWorld().getId() == world) - { - row.setFavoriteMenu(favorite); - } - } - } - - void resetAllFavoriteMenus() - { - for (WorldTableRow row : rows) - { - row.setFavoriteMenu(false); - } - - } - - void populate(List worlds) - { - rows.clear(); - - for (int i = 0; i < worlds.size(); i++) - { - World world = worlds.get(i); - - switch (filterMode) - { - case FREE: - if (world.getTypes().contains(WorldType.MEMBERS)) - { - continue; - } - break; - case MEMBERS: - if (!world.getTypes().contains(WorldType.MEMBERS)) - { - continue; - } - break; - } - - rows.add(buildRow(world, i % 2 == 0, world.getId() == plugin.getCurrentWorld() && plugin.getLastWorld() != 0, plugin.isFavorite(world))); - } - - updateList(); - } - - private void orderBy(WorldOrder order) - { - pingHeader.highlight(false, ascendingOrder); - worldHeader.highlight(false, ascendingOrder); - playersHeader.highlight(false, ascendingOrder); - activityHeader.highlight(false, ascendingOrder); - - switch (order) - { - case PING: - pingHeader.highlight(true, ascendingOrder); - break; - case WORLD: - worldHeader.highlight(true, ascendingOrder); - break; - case PLAYERS: - playersHeader.highlight(true, ascendingOrder); - break; - case ACTIVITY: - activityHeader.highlight(true, ascendingOrder); - break; - } - - orderIndex = order; - updateList(); - } - - /** - * Builds the entire table header. - */ - private JPanel buildHeader() - { - JPanel header = new JPanel(new BorderLayout()); - JPanel leftSide = new JPanel(new BorderLayout()); - JPanel rightSide = new JPanel(new BorderLayout()); - - pingHeader = new WorldTableHeader("Ping", orderIndex == WorldOrder.PING, ascendingOrder, plugin::refresh); - pingHeader.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0)); - pingHeader.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent mouseEvent) - { - if (SwingUtilities.isRightMouseButton(mouseEvent)) - { - return; - } - ascendingOrder = orderIndex != WorldOrder.PING || !ascendingOrder; - orderBy(WorldOrder.PING); - } - }); - - worldHeader = new WorldTableHeader("World", orderIndex == WorldOrder.WORLD, ascendingOrder, plugin::refresh); - worldHeader.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0)); - worldHeader.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent mouseEvent) - { - if (SwingUtilities.isRightMouseButton(mouseEvent)) - { - return; - } - ascendingOrder = orderIndex != WorldOrder.WORLD || !ascendingOrder; - orderBy(WorldOrder.WORLD); - } - }); - - playersHeader = new WorldTableHeader("#", orderIndex == WorldOrder.PLAYERS, ascendingOrder, plugin::refresh); - playersHeader.setPreferredSize(new Dimension(PLAYERS_COLUMN_WIDTH, 0)); - playersHeader.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent mouseEvent) - { - if (SwingUtilities.isRightMouseButton(mouseEvent)) - { - return; - } - ascendingOrder = orderIndex != WorldOrder.PLAYERS || !ascendingOrder; - orderBy(WorldOrder.PLAYERS); - } - }); - - activityHeader = new WorldTableHeader("Activity", orderIndex == WorldOrder.ACTIVITY, ascendingOrder, plugin::refresh); - activityHeader.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent mouseEvent) - { - if (SwingUtilities.isRightMouseButton(mouseEvent)) - { - return; - } - ascendingOrder = orderIndex != WorldOrder.ACTIVITY || !ascendingOrder; - orderBy(WorldOrder.ACTIVITY); - } - }); - - leftSide.add(worldHeader, BorderLayout.WEST); - leftSide.add(playersHeader, BorderLayout.CENTER); - - rightSide.add(activityHeader, BorderLayout.CENTER); - rightSide.add(pingHeader, BorderLayout.EAST); - - header.add(leftSide, BorderLayout.WEST); - header.add(rightSide, BorderLayout.CENTER); - - return header; - } - - /** - * Builds a table row, that displays the world's information. - */ - private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite) - { - WorldTableRow row = new WorldTableRow(world, current, favorite, - world1 -> - { - plugin.hopTo(world1); - }, - (world12, add) -> - { - if (add) - { - plugin.addToFavorites(world12); - } - else - { - plugin.removeFromFavorites(world12); - } - - updateList(); - } - ); - row.setBackground(stripe ? ODD_ROW : ColorScheme.DARK_GRAY_COLOR); - return row; - } - - /** - * Enumerates the multiple ordering options for the world list. - */ - private enum WorldOrder - { - WORLD, - PLAYERS, - ACTIVITY, - PING - } -} +/* + * Copyright (c) 2018, Psikoi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.worldhopper; + +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridLayout; +import java.awt.GridBagLayout; +import java.awt.Color; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.HashMap; +import java.util.stream.Collectors; +import javax.swing.JPanel; +import javax.swing.JButton; +import javax.swing.JTabbedPane; +import javax.swing.border.Border; +import javax.swing.BorderFactory; +import javax.swing.SwingUtilities; +import lombok.AccessLevel; +import lombok.Setter; + +import lombok.extern.slf4j.Slf4j; +import net.runelite.client.ui.ColorScheme; +import net.runelite.client.ui.DynamicGridLayout; +import net.runelite.client.ui.PluginPanel; +import net.runelite.http.api.worlds.World; +import net.runelite.http.api.worlds.WorldType; + +@Slf4j +class WorldSwitcherPanel extends PluginPanel +{ + private static final Color ODD_ROW = new Color(44, 44, 44); + + private static final int WORLD_COLUMN_WIDTH = 60; + private static final int PLAYERS_COLUMN_WIDTH = 40; + private static final int PING_COLUMN_WIDTH = 47; + + private final JPanel headerContainer; + private final JPanel headerHistContainer; + private final JPanel listContainer = new JPanel(); + private final JPanel histContainer = new JPanel(); + + private WorldTableHeader worldHeader; + private WorldTableHeader playersHeader; + private WorldTableHeader activityHeader; + private WorldTableHeader pingHeader; + + private WorldOrder orderIndex = WorldOrder.WORLD; + private boolean ascendingOrder = true; + + private ArrayList rows = new ArrayList<>(); + private ArrayList histRows = new ArrayList<>(); + private WorldHopperPlugin plugin; + @Setter(AccessLevel.PACKAGE) + private SubscriptionFilterMode filterMode; + + WorldSwitcherPanel(WorldHopperPlugin plugin) + { + this.plugin = plugin; + + setBorder(null); + setLayout(new DynamicGridLayout(0, 1)); + + headerContainer = buildHeader(); + headerHistContainer = buildHistoryHeader(); + + listContainer.setLayout(new GridLayout(0, 1)); + histContainer.setLayout(new GridLayout(0, 1)); + + updateLayout(); + } + + void updateLayout() + { + if (this.getComponentCount() > 0) + { + for (Component c : this.getComponents()) + { + this.remove(c); + } + } + + if (plugin.showHistory()) + { + Component tabs = createTabs(); + add(tabs); + } + else + { + add(headerContainer); + add(listContainer); + } + } + + void switchCurrentHighlight(int newWorld, int lastWorld) + { + for (WorldTableRow row : rows) + { + if (row.getWorld().getId() == newWorld) + { + row.recolour(true); + } + else if (row.getWorld().getId() == lastWorld) + { + row.recolour(false); + } + } + + for (WorldTableRow row : histRows) + { + if (row.getWorld().getId() == newWorld) + { + row.recolour(true); + } + else if (row.getWorld().getId() == lastWorld) + { + row.recolour(false); + } + } + } + + void updateListData(Map worldData) + { + for (WorldTableRow worldTableRow : rows) + { + World world = worldTableRow.getWorld(); + Integer playerCount = worldData.get(world.getId()); + if (playerCount != null) + { + worldTableRow.updatePlayerCount(playerCount); + } + } + + for (WorldTableRow worldTableRow : histRows) + { + World world = worldTableRow.getWorld(); + Integer playerCount = worldData.get(world.getId()); + if (playerCount != null) + { + worldTableRow.updatePlayerCount(playerCount); + } + } + + // If the list is being ordered by player count, then it has to be re-painted + // to properly display the new data + if (orderIndex == WorldOrder.PLAYERS) + { + updateList(); + } + } + + void updatePing(int world, int ping) + { + for (WorldTableRow worldTableRow : rows) + { + if (worldTableRow.getWorld().getId() == world) + { + worldTableRow.setPing(ping); + + // If the panel is sorted by ping, re-sort it + if (orderIndex == WorldOrder.PING) + { + updateList(); + } + break; + } + } + + for (WorldTableRow worldTableRow : histRows) + { + if (worldTableRow.getWorld().getId() == world) + { + worldTableRow.setPing(ping); + + // If the panel is sorted by ping, re-sort it + if (orderIndex == WorldOrder.PING) + { + updateList(); + } + break; + } + } + } + + void hidePing() + { + for (WorldTableRow worldTableRow : rows) + { + worldTableRow.hidePing(); + } + + for (WorldTableRow worldTableRow : histRows) + { + worldTableRow.hidePing(); + } + } + + void showPing() + { + for (WorldTableRow worldTableRow : rows) + { + worldTableRow.showPing(); + } + + for (WorldTableRow worldTableRow : histRows) + { + worldTableRow.showPing(); + } + } + + void updateList() + { + rows.sort((r1, r2) -> + { + switch (orderIndex) + { + case PING: + return Integer.compare(r1.getPing(), r2.getPing()) * (ascendingOrder ? 1 : -1); + case WORLD: + return Integer.compare(r1.getWorld().getId(), r2.getWorld().getId()) * (ascendingOrder ? 1 : -1); + case PLAYERS: + return Integer.compare(r1.getUpdatedPlayerCount(), r2.getUpdatedPlayerCount()) * (ascendingOrder ? 1 : -1); + case ACTIVITY: + return r1.getWorld().getActivity().compareTo(r2.getWorld().getActivity()) * -1 * (ascendingOrder ? 1 : -1); + default: + return 0; + } + }); + + // Leave empty activity worlds on the bottom of the list + if (orderIndex == WorldOrder.ACTIVITY) + { + rows.sort((r1, r2) -> r1.getWorld().getActivity().equals("-") ? 1 : -1); + } + + rows.sort((r1, r2) -> + { + boolean b1 = plugin.isFavorite(r1.getWorld()); + boolean b2 = plugin.isFavorite(r2.getWorld()); + return Boolean.compare(b2, b1); + }); + + listContainer.removeAll(); + histContainer.removeAll(); + + Map history = plugin.getHistory(); + Map matchedHist = new HashMap<>(); + for (int i = 0; i < rows.size(); i++) + { + WorldTableRow row = rows.get(i); + row.setBackground(i % 2 == 0 ? ODD_ROW : ColorScheme.DARK_GRAY_COLOR); + listContainer.add(row); + + String worldNum = String.valueOf(row.getWorld().getId()); + if (history.containsKey(worldNum)) + { + // Add toa list that we can sort later + matchedHist.put(worldNum, history.get(worldNum)); + } + } + + // Sort by ascending + matchedHist = matchedHist.entrySet().stream() + .sorted(Map.Entry.comparingByValue().reversed()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, + (e1, e2) -> e1, LinkedHashMap::new)); + + // Add matched rows to history list + Iterator it = matchedHist.entrySet().iterator(); + int histRowCount = 0; + while (it.hasNext()) + { + Map.Entry pair = (Map.Entry)it.next(); + for (WorldTableRow r : rows) + { + WorldTableRow histRow = r; + histRow.setBackground(histRowCount % 2 == 0 ? ODD_ROW : ColorScheme.DARK_GRAY_COLOR); + if (String.valueOf(r.getWorld().getId()).equals(pair.getKey())) + { + histContainer.add(r); + histRowCount++; + break; + } + } + it.remove(); + } + + listContainer.revalidate(); + listContainer.repaint(); + histContainer.revalidate(); + histContainer.repaint(); + } + + Component createTabs() + { + // Constraints for GB Layout + GridBagConstraints listConst = new GridBagConstraints(); + listConst.gridx = 0; + listConst.gridy = 1; + listConst.fill = GridBagConstraints.HORIZONTAL; + GridBagConstraints headConst = new GridBagConstraints(); + headConst.gridx = 0; + headConst.gridy = 0; + headConst.fill = GridBagConstraints.HORIZONTAL; + GridBagConstraints resetConst = new GridBagConstraints(); + resetConst.gridx = 0; + resetConst.gridy = 2; + resetConst.fill = GridBagConstraints.HORIZONTAL; + + // Border so that the scrollbar doesn't go over ping + Border paddingBorder = BorderFactory.createEmptyBorder(0, 0, 0, 5); + + // Clear history button + JButton resetBtn = new JButton("Clear History"); + resetBtn.addActionListener(e -> + { + plugin.clearHistory(); + plugin.addToHistory(); + updateList(); + }); + + // World Selector page + JPanel worldPanel = new JPanel(); + worldPanel.setBorder(paddingBorder); + worldPanel.setLayout(new GridBagLayout()); + worldPanel.add(headerContainer, headConst); + worldPanel.add(listContainer, listConst); + + // History page + JPanel histPanel = new JPanel(); + histPanel.setBorder(paddingBorder); + histPanel.setLayout(new GridBagLayout()); + histPanel.add(headerHistContainer, headConst); + histPanel.add(histContainer, listConst); + histPanel.add(resetBtn, resetConst); + + JTabbedPane worldTabs = new JTabbedPane(); + worldTabs.setName("tabs"); + worldTabs.addTab("Worlds", worldPanel); + worldTabs.addTab("History", histPanel); + + // This is a fix for preventing stretching of WorldTableRows + worldTabs.addChangeListener(e -> + { + switch (worldTabs.getSelectedIndex()) + { + case 0: + histPanel.remove(histContainer); + if (worldPanel.getComponentCount() < 2) + { + worldPanel.add(listContainer, listConst); + } + break; + case 1: + worldPanel.remove(listContainer); + if (histPanel.getComponentCount() < 3) + { + histPanel.add(histContainer, listConst); + } + break; + } + }); + + return worldTabs; + } + + void updateFavoriteMenu(int world, boolean favorite) + { + for (WorldTableRow row : rows) + { + if (row.getWorld().getId() == world) + { + row.setFavoriteMenu(favorite); + } + } + + for (WorldTableRow row : histRows) + { + if (row.getWorld().getId() == world) + { + row.setFavoriteMenu(favorite); + } + } + } + + void resetAllFavoriteMenus() + { + for (WorldTableRow row : rows) + { + row.setFavoriteMenu(false); + } + + for (WorldTableRow row : histRows) + { + row.setFavoriteMenu(false); + } + } + + void populate(List worlds) + { + Map pingHistory = new HashMap<>(); + + for (WorldTableRow row : rows) + { + pingHistory.put(row.getWorld().getId(), row.getPing()); + } + + rows.clear(); + + for (int i = 0; i < worlds.size(); i++) + { + World world = worlds.get(i); + + switch (filterMode) + { + case FREE: + if (world.getTypes().contains(WorldType.MEMBERS)) + { + continue; + } + break; + case MEMBERS: + if (!world.getTypes().contains(WorldType.MEMBERS)) + { + continue; + } + break; + } + + Integer ping = pingHistory.getOrDefault(world.getId(), 0); + rows.add(buildRow(world, i % 2 == 0, world.getId() == plugin.getCurrentWorld() && plugin.getLastWorld() != 0, plugin.isFavorite(world), ping)); + } + + updateList(); + } + + private void orderBy(WorldOrder order) + { + pingHeader.highlight(false, ascendingOrder); + worldHeader.highlight(false, ascendingOrder); + playersHeader.highlight(false, ascendingOrder); + activityHeader.highlight(false, ascendingOrder); + + switch (order) + { + case PING: + pingHeader.highlight(true, ascendingOrder); + break; + case WORLD: + worldHeader.highlight(true, ascendingOrder); + break; + case PLAYERS: + playersHeader.highlight(true, ascendingOrder); + break; + case ACTIVITY: + activityHeader.highlight(true, ascendingOrder); + break; + } + + orderIndex = order; + updateList(); + } + + /** + * Builds the entire table header. + */ + private JPanel buildHistoryHeader() + { + JPanel header = new JPanel(new BorderLayout()); + JPanel leftSide = new JPanel(new BorderLayout()); + JPanel rightSide = new JPanel(new BorderLayout()); + + WorldTableHeader pingHeader = new WorldTableHeader("Ping", false, ascendingOrder, plugin::refresh); + pingHeader.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0)); + + WorldTableHeader worldHeader = new WorldTableHeader("World", false, ascendingOrder, plugin::refresh); + worldHeader.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0)); + + WorldTableHeader playersHeader = new WorldTableHeader("#", false, ascendingOrder, plugin::refresh); + playersHeader.setPreferredSize(new Dimension(PLAYERS_COLUMN_WIDTH, 0)); + + WorldTableHeader activityHeader = new WorldTableHeader("Activity", false, ascendingOrder, plugin::refresh); + + leftSide.add(worldHeader, BorderLayout.WEST); + leftSide.add(playersHeader, BorderLayout.CENTER); + + rightSide.add(activityHeader, BorderLayout.CENTER); + rightSide.add(pingHeader, BorderLayout.EAST); + + header.add(leftSide, BorderLayout.WEST); + header.add(rightSide, BorderLayout.CENTER); + + return header; + } + + private JPanel buildHeader() + { + JPanel header = new JPanel(new BorderLayout()); + JPanel leftSide = new JPanel(new BorderLayout()); + JPanel rightSide = new JPanel(new BorderLayout()); + + pingHeader = new WorldTableHeader("Ping", orderIndex == WorldOrder.PING, ascendingOrder, plugin::refresh); + pingHeader.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0)); + pingHeader.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + if (SwingUtilities.isRightMouseButton(mouseEvent)) + { + return; + } + ascendingOrder = orderIndex != WorldOrder.PING || !ascendingOrder; + orderBy(WorldOrder.PING); + } + }); + + worldHeader = new WorldTableHeader("World", orderIndex == WorldOrder.WORLD, ascendingOrder, plugin::refresh); + worldHeader.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0)); + worldHeader.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + if (SwingUtilities.isRightMouseButton(mouseEvent)) + { + return; + } + ascendingOrder = orderIndex != WorldOrder.WORLD || !ascendingOrder; + orderBy(WorldOrder.WORLD); + } + }); + + playersHeader = new WorldTableHeader("#", orderIndex == WorldOrder.PLAYERS, ascendingOrder, plugin::refresh); + playersHeader.setPreferredSize(new Dimension(PLAYERS_COLUMN_WIDTH, 0)); + playersHeader.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + if (SwingUtilities.isRightMouseButton(mouseEvent)) + { + return; + } + ascendingOrder = orderIndex != WorldOrder.PLAYERS || !ascendingOrder; + orderBy(WorldOrder.PLAYERS); + } + }); + + activityHeader = new WorldTableHeader("Activity", orderIndex == WorldOrder.ACTIVITY, ascendingOrder, plugin::refresh); + activityHeader.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent mouseEvent) + { + if (SwingUtilities.isRightMouseButton(mouseEvent)) + { + return; + } + ascendingOrder = orderIndex != WorldOrder.ACTIVITY || !ascendingOrder; + orderBy(WorldOrder.ACTIVITY); + } + }); + + leftSide.add(worldHeader, BorderLayout.WEST); + leftSide.add(playersHeader, BorderLayout.CENTER); + + rightSide.add(activityHeader, BorderLayout.CENTER); + rightSide.add(pingHeader, BorderLayout.EAST); + + header.add(leftSide, BorderLayout.WEST); + header.add(rightSide, BorderLayout.CENTER); + + return header; + } + + /** + * Builds a table row, that displays the world's information. + */ + private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite, Integer ping) + { + WorldTableRow row = new WorldTableRow(world, current, favorite, + world1 -> + { + plugin.hopTo(world1); + }, + (world12, add) -> + { + if (add) + { + plugin.addToFavorites(world12); + } + else + { + plugin.removeFromFavorites(world12); + } + + updateList(); + } + ); + row.setBackground(stripe ? ODD_ROW : ColorScheme.DARK_GRAY_COLOR); + return row; + } + + /** + * Enumerates the multiple ordering options for the world list. + */ + private enum WorldOrder + { + WORLD, + PLAYERS, + ACTIVITY, + PING + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java index 2d7ef01406..2b62fa4d88 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableHeader.java @@ -31,12 +31,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import javax.annotation.Nonnull; -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; +import javax.swing.*; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import net.runelite.client.ui.ColorScheme; @@ -121,7 +116,7 @@ class WorldTableHeader extends JPanel add(textLabel, BorderLayout.WEST); add(arrowLabel, BorderLayout.EAST); - } +} /** * The labels inherit the parent's mouse listeners. diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java index c23face9ba..a497da60e7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java @@ -96,6 +96,7 @@ class WorldTableRow extends JPanel this.world = world; this.onFavorite = onFavorite; this.updatedPlayerCount = world.getPlayers(); + this. setLayout(new BorderLayout()); setBorder(new EmptyBorder(2, 0, 2, 0)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java index 1a3e1cba4f..b49a56a2a0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java @@ -27,141 +27,141 @@ package net.runelite.client.plugins.worldmap; import lombok.Getter; import net.runelite.api.coords.WorldPoint; -import net.runelite.api.Quest; enum QuestStartLocation { //Free Quests - COOKS_ASSISTANT_RFD(Quest.COOKS_ASSISTANT, new WorldPoint(3211, 3216, 0)), - THE_CORSAIR_CURSE(Quest.THE_CORSAIR_CURSE, new WorldPoint(3029, 3273, 0)), - DEMON_SLAYER(Quest.DEMON_SLAYER, new WorldPoint(3204, 3424, 0)), - DORICS_QUEST(Quest.DORICS_QUEST, new WorldPoint(2952, 3450, 0)), - DRAGON_SLAYER(Quest.DRAGON_SLAYER, new WorldPoint(3190, 3362, 0)), - ERNEST_THE_CHICKEN(Quest.ERNEST_THE_CHICKEN, new WorldPoint(3109, 3330, 0)), - GOBLIN_DIPLOMACY(Quest.GOBLIN_DIPLOMACY, new WorldPoint(2957, 3509, 0)), - IMP_CATCHER(Quest.IMP_CATCHER, new WorldPoint(3108, 3160, 0)), - THE_KNIGHTS_SWORD(Quest.THE_KNIGHTS_SWORD, new WorldPoint(2976, 3342, 0)), - MISTHALIN_MYSTERY(Quest.MISTHALIN_MYSTERY, new WorldPoint(3234, 3155, 0)), - PIRATES_TREASURE(Quest.PIRATES_TREASURE, new WorldPoint(3051, 3252, 0)), - PRINCE_ALI_RESCUE(Quest.PRINCE_ALI_RESCUE, new WorldPoint(3301, 3163, 0)), - THE_RESTLESS_GHOST(Quest.THE_RESTLESS_GHOST, new WorldPoint(3240, 3210, 0)), - RUNE_MYSTERIES(Quest.RUNE_MYSTERIES, new WorldPoint(3210, 3220, 0)), - SHEEP_SHEARER(Quest.SHEEP_SHEARER, new WorldPoint(3190, 3272, 0)), - SHIELD_OF_ARRAV(Quest.SHIELD_OF_ARRAV, new WorldPoint(3208, 3495, 0)), - VAMPIRE_SLAYER(Quest.VAMPIRE_SLAYER, new WorldPoint(3096, 3266, 0)), - WITCHS_POTION(Quest.WITCHS_POTION, new WorldPoint(2967, 3203, 0)), + COOKS_ASSISTANT_RFD("Cook's Assistant", new WorldPoint(3211, 3216, 0)), + THE_CORSAIR_CURSE("The Corsair Curse", new WorldPoint(3029, 3273, 0)), + DEMON_SLAYER("Demon Slayer", new WorldPoint(3204, 3424, 0)), + DORICS_QUEST("Doric's Quest", new WorldPoint(2952, 3450, 0)), + DRAGON_SLAYER("Dragon Slayer", new WorldPoint(3190, 3362, 0)), + ERNEST_THE_CHICKEN("Ernest the Chicken", new WorldPoint(3109, 3330, 0)), + GOBLIN_DIPLOMACY("Goblin Diplomacy", new WorldPoint(2957, 3509, 0)), + IMP_CATCHER("Imp Catcher", new WorldPoint(3108, 3160, 0)), + THE_KNIGHTS_SWORD("The Knight's Sword", new WorldPoint(2976, 3342, 0)), + MISTHALIN_MYSTERY("Misthalin Mystery", new WorldPoint(3234, 3155, 0)), + PIRATES_TREASURE("Pirate's Treasure", new WorldPoint(3051, 3252, 0)), + PRINCE_ALI_RESCUE("Prince Ali Rescue", new WorldPoint(3301, 3163, 0)), + THE_RESTLESS_GHOST("The Restless Ghost", new WorldPoint(3240, 3210, 0)), + RUNE_MYSTERIES("Rune Mysteries", new WorldPoint(3210, 3220, 0)), + SHEEP_SHEARER("Sheep Shearer", new WorldPoint(3190, 3272, 0)), + SHIELD_OF_ARRAV_PHOENIX_GANG("Shield of Arrav (Phoenix Gang)", new WorldPoint(3208, 3495, 0)), + SHIELD_OF_ARRAV_BLACK_ARM_GANG("Shield of Arrav (Black Arm Gang)", new WorldPoint(3208, 3392, 0)), + VAMPIRE_SLAYER("Vampire Slayer", new WorldPoint(3096, 3266, 0)), + WITCHS_POTION("Witch's Potion", new WorldPoint(2967, 3203, 0)), X_MARKS_THE_SPOT("X Marks the Spot", new WorldPoint(3227, 3242, 0)), //Members' Quests - ANIMAL_MAGNETISM(Quest.ANIMAL_MAGNETISM, new WorldPoint(3094, 3360, 0)), - ANOTHER_SLICE_OF_HAM(Quest.ANOTHER_SLICE_OF_HAM, new WorldPoint(2799, 5428, 0)), - THE_ASCENT_OF_ARCEUUS(Quest.THE_ASCENT_OF_ARCEUUS, new WorldPoint(1700, 3742, 0)), - BETWEEN_A_ROCK(Quest.BETWEEN_A_ROCK, new WorldPoint(2823, 10168, 0)), - BIG_CHOMPY_BIRD_HUNTING(Quest.BIG_CHOMPY_BIRD_HUNTING, new WorldPoint(2629, 2981, 0)), - BIOHAZARD(Quest.BIOHAZARD, new WorldPoint(2591, 3335, 0)), - BONE_VOYAGE(Quest.BONE_VOYAGE, new WorldPoint(3259, 3450, 0)), - CABIN_FEVER(Quest.CABIN_FEVER, new WorldPoint(3674, 3496, 0)), - CLIENT_OF_KOUREND(Quest.CLIENT_OF_KOUREND, new WorldPoint(1823, 3690, 0)), - CLOCK_TOWER(Quest.CLOCK_TOWER, new WorldPoint(2568, 3249, 0)), - COLD_WAR(Quest.COLD_WAR, new WorldPoint(2593, 3265, 0)), - CONTACT(Quest.CONTACT, new WorldPoint(3280, 2770, 0)), - CREATURE_OF_FENKENSTRAIN(Quest.CREATURE_OF_FENKENSTRAIN, new WorldPoint(3487, 3485, 0)), - DARKNESS_OF_HALLOWVALE(Quest.DARKNESS_OF_HALLOWVALE, new WorldPoint(3494, 9628, 0)), - DEATH_PLATEAU_TROLL_STRONGHOLD("Death plateau & Troll stronghold", new WorldPoint(2895, 3528, 0)), - DEATH_TO_THE_DORGESHUUN(Quest.DEATH_TO_THE_DORGESHUUN, new WorldPoint(3316, 9613, 0)), - THE_DEPTHS_OF_DESPAIR(Quest.THE_DEPTHS_OF_DESPAIR, new WorldPoint(1846, 3556, 0)), - DESERT_TREASURE(Quest.DESERT_TREASURE, new WorldPoint(3177, 3043, 0)), - DEVIOUS_MINDS(Quest.DEVIOUS_MINDS, new WorldPoint(3405, 3492, 0)), - THE_DIG_SITE(Quest.THE_DIG_SITE, new WorldPoint(3363, 3337, 0)), - DRAGON_SLAYER_II(Quest.DRAGON_SLAYER_II, new WorldPoint(2456, 2868, 0)), - DREAM_MENTOR(Quest.DREAM_MENTOR, new WorldPoint(2144, 10346, 0)), - DRUIDIC_RITUAL(Quest.DRUIDIC_RITUAL, new WorldPoint(2916, 3484, 0)), - DWARF_CANNON(Quest.DWARF_CANNON, new WorldPoint(2566, 3461, 0)), - EADGARS_RUSE(Quest.EADGARS_RUSE, new WorldPoint(2896, 3426, 0)), - EAGLES_PEAK(Quest.EAGLES_PEAK, new WorldPoint(2605, 3264, 0)), - ELEMENTAL_WORKSHOP("Elemental I & II", new WorldPoint(2714, 3482, 0)), - ENAKHRAS_LAMENT(Quest.ENAKHRAS_LAMENT, new WorldPoint(3190, 2926, 0)), - ENLIGHTENED_JOURNEY(Quest.ENLIGHTENED_JOURNEY, new WorldPoint(2809, 3356, 0)), - THE_EYES_OF_GLOUPHRIE(Quest.THE_EYES_OF_GLOUPHRIE, new WorldPoint(2400, 3419, 0)), + ANIMAL_MAGNETISM("Animal Magnetism", new WorldPoint(3094, 3360, 0)), + ANOTHER_SLICE_OF_HAM("Another Slice of H.A.M.", new WorldPoint(2799, 5428, 0)), + THE_ASCENT_OF_ARCEUUS("The Ascent of Arceuus", new WorldPoint(1700, 3742, 0)), + BETWEEN_A_ROCK("Between a Rock...", new WorldPoint(2823, 10168, 0)), + BIG_CHOMPY_BIRD_HUNTING("Big Chompy Bird Hunting", new WorldPoint(2629, 2981, 0)), + BIOHAZARD("Biohazard", new WorldPoint(2591, 3335, 0)), + BONE_VOYAGE("Bone Voyage", new WorldPoint(3259, 3450, 0)), + CABIN_FEVER("Cabin Fever", new WorldPoint(3674, 3496, 0)), + CLIENT_OF_KOUREND("Client of Kourend", new WorldPoint(1823, 3690, 0)), + CLOCK_TOWER("Clock Tower", new WorldPoint(2568, 3249, 0)), + COLD_WAR("Cold War", new WorldPoint(2593, 3265, 0)), + CONTACT("Contact!", new WorldPoint(3280, 2770, 0)), + CREATURE_OF_FENKENSTRAIN("Creature of Fenkenstrain", new WorldPoint(3487, 3485, 0)), + DARKNESS_OF_HALLOWVALE("Darkness of Hallowvale", new WorldPoint(3494, 9628, 0)), + DEATH_PLATEAU_TROLL_STRONGHOLD("Death Plateau & Troll Stronghold", new WorldPoint(2895, 3528, 0)), + DEATH_TO_THE_DORGESHUUN("Death to the Dorgeshuun", new WorldPoint(3316, 9613, 0)), + THE_DEPTHS_OF_DESPAIR("The Depths of Despair", new WorldPoint(1846, 3556, 0)), + DESERT_TREASURE("Desert Treasure", new WorldPoint(3177, 3043, 0)), + DEVIOUS_MINDS("Devious Minds", new WorldPoint(3405, 3492, 0)), + THE_DIG_SITE("The Dig Site", new WorldPoint(3363, 3337, 0)), + DRAGON_SLAYER_II("Dragon Slayer II", new WorldPoint(2456, 2868, 0)), + DREAM_MENTOR("Dream Mentor", new WorldPoint(2144, 10346, 0)), + DRUIDIC_RITUAL("Druidic Ritual", new WorldPoint(2916, 3484, 0)), + DWARF_CANNON("Dwarf Cannon", new WorldPoint(2566, 3461, 0)), + EADGARS_RUSE("Eadgar's Ruse", new WorldPoint(2896, 3426, 0)), + EAGLES_PEAK("Eagles' Peak", new WorldPoint(2605, 3264, 0)), + ELEMENTAL_WORKSHOP("Elemental Workshop I & II", new WorldPoint(2714, 3482, 0)), + ENAKHRAS_LAMENT("Enakhra's Lament", new WorldPoint(3190, 2926, 0)), + ENLIGHTENED_JOURNEY("Enlightened Journey", new WorldPoint(2809, 3356, 0)), + THE_EYES_OF_GLOUPHRIE("The Eyes of Glouphrie", new WorldPoint(2400, 3419, 0)), FAIRYTALE("Fairytale I & II", new WorldPoint(3077, 3258, 0)), - FAMILY_CREST(Quest.FAMILY_CREST, new WorldPoint(3278, 3404, 0)), - THE_FEUD(Quest.THE_FEUD, new WorldPoint(3301, 3211, 0)), - FIGHT_ARENA(Quest.FIGHT_ARENA, new WorldPoint(2565, 3199, 0)), - FISHING_CONTEST_1(Quest.FISHING_CONTEST, new WorldPoint(2875, 3483, 0)), - FISHING_CONTEST_2(Quest.FISHING_CONTEST, new WorldPoint(2820, 3487, 0)), - FORGETTABLE_TALE(Quest.FORGETTABLE_TALE, new WorldPoint(2826, 10215, 0)), - THE_FORSAKEN_TOWER(Quest.THE_FORSAKEN_TOWER, new WorldPoint(1484, 3747, 0)), - THE_FREMENNIK_ISLES(Quest.THE_FREMENNIK_ISLES, new WorldPoint(2645, 3711, 0)), - THE_FREMENNIK_TRIALS(Quest.THE_FREMENNIK_TRIALS, new WorldPoint(2657, 3669, 0)), - GARDEN_OF_TRANQUILLITY(Quest.GARDEN_OF_TRANQUILLITY, new WorldPoint(3227, 3477, 0)), - GERTRUDES_CAT_RATCATCHERS(Quest.GERTRUDES_CAT, new WorldPoint(3150, 3411, 0)), - GHOSTS_AHOY(Quest.GHOSTS_AHOY, new WorldPoint(3677, 3510, 0)), - THE_GIANT_DWARF(Quest.THE_GIANT_DWARF, new WorldPoint(2841, 10129, 0)), - THE_GOLEM(Quest.THE_GOLEM, new WorldPoint(3487, 3089, 0)), + FAMILY_CREST("Family Crest", new WorldPoint(3278, 3404, 0)), + THE_FEUD("The Feud", new WorldPoint(3301, 3211, 0)), + FIGHT_ARENA("Fight Arena", new WorldPoint(2565, 3199, 0)), + FISHING_CONTEST_1("Fishing Contest", new WorldPoint(2875, 3483, 0)), + FISHING_CONTEST_2("Fishing Contest", new WorldPoint(2820, 3487, 0)), + FORGETTABLE_TALE("Forgettable Tale...", new WorldPoint(2826, 10215, 0)), + THE_FORSAKEN_TOWER("The Forsaken Tower", new WorldPoint(1484, 3747, 0)), + THE_FREMENNIK_ISLES("The Fremennik Isles", new WorldPoint(2645, 3711, 0)), + THE_FREMENNIK_TRIALS("The Fremennik Trials", new WorldPoint(2657, 3669, 0)), + GARDEN_OF_TRANQUILLITY("Garden of Tranquillity", new WorldPoint(3227, 3477, 0)), + GERTRUDES_CAT_RATCATCHERS("Gertrude's Cat & Ratcatchers", new WorldPoint(3150, 3411, 0)), + GHOSTS_AHOY("Ghosts Ahoy", new WorldPoint(3677, 3510, 0)), + THE_GIANT_DWARF("The Giant Dwarf", new WorldPoint(2841, 10129, 0)), + THE_GOLEM("The Golem", new WorldPoint(3487, 3089, 0)), THE_GRAND_TREE_MONKEY_MADNESS("The Grand Tree & Monkey Madness I & II", new WorldPoint(2466, 3497, 0)), - THE_GREAT_BRAIN_ROBBERY(Quest.THE_GREAT_BRAIN_ROBBERY, new WorldPoint(3681, 2963, 0)), - GRIM_TALES(Quest.GRIM_TALES, new WorldPoint(2890, 3454, 0)), - THE_HAND_IN_THE_SAND(Quest.THE_HAND_IN_THE_SAND, new WorldPoint(2552, 3101, 0)), - HAUNTED_MINE(Quest.HAUNTED_MINE, new WorldPoint(3443, 3258, 0)), - HAZEEL_CULT(Quest.HAZEEL_CULT, new WorldPoint(2565, 3271, 0)), - HEROES_QUEST(Quest.HEROES_QUEST, new WorldPoint(2903, 3511, 0)), + THE_GREAT_BRAIN_ROBBERY("The Great Brain Robbery", new WorldPoint(3681, 2963, 0)), + GRIM_TALES("Grim Tales", new WorldPoint(2890, 3454, 0)), + THE_HAND_IN_THE_SAND("The Hand in the Sand", new WorldPoint(2552, 3101, 0)), + HAUNTED_MINE("Haunted Mine", new WorldPoint(3443, 3258, 0)), + HAZEEL_CULT("Hazeel Cult", new WorldPoint(2565, 3271, 0)), + HEROES_QUEST("Heroes' Quest", new WorldPoint(2903, 3511, 0)), HOLY_GRAIL("Holy Grail & Merlin's Crystal", new WorldPoint(2763, 3515, 0)), - HORROR_FROM_THE_DEEP(Quest.HORROR_FROM_THE_DEEP, new WorldPoint(2507, 3635, 0)), - ICTHLARINS_LITTLE_HELPER(Quest.ICTHLARINS_LITTLE_HELPER, new WorldPoint(3314, 2849, 0)), - IN_SEARCH_OF_THE_MYREQUE(Quest.IN_SEARCH_OF_THE_MYREQUE, new WorldPoint(3502, 3477, 0)), - JUNGLE_POTION(Quest.JUNGLE_POTION, new WorldPoint(2809, 3086, 0)), - KINGS_RANSOM(Quest.KINGS_RANSOM, new WorldPoint(2741, 3554, 0)), - LEGENDS_QUEST(Quest.LEGENDS_QUEST, new WorldPoint(2725, 3367, 0)), - LOST_CITY(Quest.LOST_CITY, new WorldPoint(3149, 3205, 0)), - THE_LOST_TRIBE(Quest.THE_LOST_TRIBE, new WorldPoint(3211, 3224, 0)), - LUNAR_DIPLOMACY(Quest.LUNAR_DIPLOMACY, new WorldPoint(2619, 3689, 0)), - MAKING_FRIENDS_WITH_MY_ARM(Quest.MAKING_FRIENDS_WITH_MY_ARM, new WorldPoint(2904, 10092, 0)), - MAKING_HISTORY(Quest.MAKING_HISTORY, new WorldPoint(2435, 3346, 0)), - MONKS_FRIEND(Quest.MONKS_FRIEND, new WorldPoint(2605, 3209, 0)), - MOUNTAIN_DAUGHTER(Quest.MOUNTAIN_DAUGHTER, new WorldPoint(2810, 3672, 0)), - MOURNINGS_ENDS_PART_I(Quest.MOURNINGS_ENDS_PART_I, new WorldPoint(2289, 3149, 0)), - MOURNINGS_ENDS_PART_II(Quest.MONKEY_MADNESS_II, new WorldPoint(2352, 3172, 0)), - MURDER_MYSTERY(Quest.MURDER_MYSTERY, new WorldPoint(2740, 3562, 0)), - MY_ARMS_BIG_ADVENTURE(Quest.MY_ARMS_BIG_ADVENTURE, new WorldPoint(2908, 10088, 0)), - NATURE_SPIRIT(Quest.NATURE_SPIRIT, new WorldPoint(3440, 9894, 0)), - OBSERVATORY_QUEST(Quest.OBSERVATORY_QUEST, new WorldPoint(2438, 3185, 0)), - OLAFS_QUEST(Quest.OLAFS_QUEST, new WorldPoint(2723, 3729, 0)), - ONE_SMALL_FAVOUR(Quest.ONE_SMALL_FAVOUR, new WorldPoint(2834, 2985, 0)), - PLAGUE_CITY(Quest.PLAGUE_CITY, new WorldPoint(2567, 3334, 0)), - PRIEST_IN_PERIL(Quest.PRIEST_IN_PERIL, new WorldPoint(3219, 3473, 0)), - THE_QUEEN_OF_THIEVES(Quest.THE_QUEEN_OF_THIEVES, new WorldPoint(1795, 3782, 0)), + HORROR_FROM_THE_DEEP("Horror from the Deep", new WorldPoint(2507, 3635, 0)), + ICTHLARINS_LITTLE_HELPER("Icthlarin's Little Helper", new WorldPoint(3314, 2849, 0)), + IN_SEARCH_OF_THE_MYREQUE("In Search of the Myreque", new WorldPoint(3502, 3477, 0)), + JUNGLE_POTION("Jungle Potion", new WorldPoint(2809, 3086, 0)), + KINGS_RANSOM("King's Ransom", new WorldPoint(2741, 3554, 0)), + LEGENDS_QUEST("Legends' Quest", new WorldPoint(2725, 3367, 0)), + LOST_CITY("Lost City", new WorldPoint(3149, 3205, 0)), + THE_LOST_TRIBE("The Lost Tribe", new WorldPoint(3211, 3224, 0)), + LUNAR_DIPLOMACY("Lunar Diplomacy", new WorldPoint(2619, 3689, 0)), + MAKING_FRIENDS_WITH_MY_ARM("Making Friends with My Arm", new WorldPoint(2904, 10092, 0)), + MAKING_HISTORY("Making History", new WorldPoint(2435, 3346, 0)), + MONKS_FRIEND("Monk's Friend", new WorldPoint(2605, 3209, 0)), + MOUNTAIN_DAUGHTER("Mountain Daughter", new WorldPoint(2810, 3672, 0)), + MOURNINGS_ENDS_PART_I("Mourning's Ends Part I", new WorldPoint(2289, 3149, 0)), + MOURNINGS_ENDS_PART_II("Mourning's Ends Part II", new WorldPoint(2352, 3172, 0)), + MURDER_MYSTERY("Murder Mystery", new WorldPoint(2740, 3562, 0)), + MY_ARMS_BIG_ADVENTURE("My Arm's Big Adventure", new WorldPoint(2908, 10088, 0)), + NATURE_SPIRIT("Nature Spirit", new WorldPoint(3440, 9894, 0)), + OBSERVATORY_QUEST("Observatory Quest", new WorldPoint(2438, 3185, 0)), + OLAFS_QUEST("Olaf's Quest", new WorldPoint(2723, 3729, 0)), + ONE_SMALL_FAVOUR("One Small Favour", new WorldPoint(2834, 2985, 0)), + PLAGUE_CITY("Plague City", new WorldPoint(2567, 3334, 0)), + PRIEST_IN_PERIL("Priest in Peril", new WorldPoint(3219, 3473, 0)), + THE_QUEEN_OF_THIEVES("The Queen of Thieves", new WorldPoint(1795, 3782, 0)), RAG_AND_BONE_MAN("Rag and Bone Man I & II", new WorldPoint(3359, 3504, 0)), RECRUITMENT_DRIVE_BLACK_KNIGHTS_FORTRESS("Recruitment Drive & Black Knights' Fortress", new WorldPoint(2959, 3336, 0)), - ROVING_ELVES(Quest.ROVING_ELVES, new WorldPoint(2289, 3146, 0)), - RUM_DEAL(Quest.RUM_DEAL, new WorldPoint(3679, 3535, 0)), - SCORPION_CATCHER(Quest.SCORPION_CATCHER, new WorldPoint(2701, 3399, 0)), - SEA_SLUG(Quest.SEA_SLUG, new WorldPoint(2715, 3302, 0)), - SHADES_OF_MORTTON(Quest.SHADES_OF_MORTTON, new WorldPoint(3463, 3308, 0)), - SHADOW_OF_THE_STORM(Quest.SHADES_OF_MORTTON, new WorldPoint(3270, 3159, 0)), - SHEEP_HERDER(Quest.SHEEP_HERDER, new WorldPoint(2616, 3299, 0)), - SHILO_VILLAGE(Quest.SHILO_VILLAGE, new WorldPoint(2882, 2951, 0)), - A_SOULS_BANE(Quest.A_SOULS_BANE, new WorldPoint(3307, 3454, 0)), - SPIRITS_OF_THE_ELID(Quest.SPIRITS_OF_THE_ELID, new WorldPoint(3441, 2911, 0)), - SWAN_SONG(Quest.SWAN_SONG, new WorldPoint(2345, 3652, 0)), - TAI_BWO_WANNAI_TRIO(Quest.TAI_BWO_WANNAI_TRIO, new WorldPoint(2779, 3087, 0)), - A_TAIL_OF_TWO_CATS(Quest.A_TAIL_OF_TWO_CATS, new WorldPoint(2917, 3557, 0)), - TALE_OF_THE_RIGHTEOUS(Quest.TALE_OF_THE_RIGHTEOUS, new WorldPoint(1511, 3631, 0)), - A_TASTE_OF_HOPE(Quest.A_TASTE_OF_HOPE, new WorldPoint(3668, 3216, 0)), - TEARS_OF_GUTHIX(Quest.TEARS_OF_GUTHIX, new WorldPoint(3251, 9517, 0)), - TEMPLE_OF_IKOV(Quest.TEMPLE_OF_IKOV, new WorldPoint(2574, 3320, 0)), + ROVING_ELVES("Roving Elves", new WorldPoint(2289, 3146, 0)), + RUM_DEAL("Rum Deal", new WorldPoint(3679, 3535, 0)), + SCORPION_CATCHER("Scorpion Catcher", new WorldPoint(2701, 3399, 0)), + SEA_SLUG("Sea Slug", new WorldPoint(2715, 3302, 0)), + SHADES_OF_MORTTON("Shades of Mort'ton", new WorldPoint(3463, 3308, 0)), + SHADOW_OF_THE_STORM("Shadow of the Storm", new WorldPoint(3270, 3159, 0)), + SHEEP_HERDER("Sheep Herder", new WorldPoint(2616, 3299, 0)), + SHILO_VILLAGE("Shilo Village", new WorldPoint(2882, 2951, 0)), + A_SOULS_BANE("A Soul's Bane", new WorldPoint(3307, 3454, 0)), + SPIRITS_OF_THE_ELID("Spirits of the Elid", new WorldPoint(3441, 2911, 0)), + SWAN_SONG("Swan Song", new WorldPoint(2345, 3652, 0)), + TAI_BWO_WANNAI_TRIO("Tai Bwo Wannai Trio", new WorldPoint(2779, 3087, 0)), + A_TAIL_OF_TWO_CATS("A Tail of Two Cats", new WorldPoint(2917, 3557, 0)), + TALE_OF_THE_RIGHTEOUS("Tale of the Righteous", new WorldPoint(1511, 3631, 0)), + A_TASTE_OF_HOPE("A Taste of Hope", new WorldPoint(3668, 3216, 0)), + TEARS_OF_GUTHIX("Tears of Guthix", new WorldPoint(3251, 9517, 0)), + TEMPLE_OF_IKOV("Temple of Ikov", new WorldPoint(2574, 3320, 0)), THRONE_OF_MISCELLANIA_ROYAL_TROUBLE("Throne of Miscellania & Royal Trouble", new WorldPoint(2497, 3859, 0)), - THE_TOURIST_TRAP(Quest.THE_TOURIST_TRAP, new WorldPoint(3302, 3113, 0)), - TOWER_OF_LIFE(Quest.TOWER_OF_LIFE, new WorldPoint(2640, 3218, 0)), - TREE_GNOME_VILLAGE(Quest.TREE_GNOME_VILLAGE, new WorldPoint(2541, 3169, 0)), - TRIBAL_TOTEM(Quest.TRIBAL_TOTEM, new WorldPoint(2790, 3182, 0)), - TROLL_ROMANCE(Quest.TROLL_ROMANCE, new WorldPoint(2890, 10097, 0)), + THE_TOURIST_TRAP("The Tourist Trap", new WorldPoint(3302, 3113, 0)), + TOWER_OF_LIFE("Tower of Life", new WorldPoint(2640, 3218, 0)), + TREE_GNOME_VILLAGE("Tree Gnome Village", new WorldPoint(2541, 3169, 0)), + TRIBAL_TOTEM("Tribal Totem", new WorldPoint(2790, 3182, 0)), + TROLL_ROMANCE("Troll Romance", new WorldPoint(2890, 10097, 0)), UNDERGROUND_PASS_REGICIDE("Underground Pass & Regicide", new WorldPoint(2575, 3293, 0)), WANTED_SLUG_MENACE("Wanted! & The Slug Menace", new WorldPoint(2996, 3373, 0)), - WATCHTOWER(Quest.WATCHTOWER, new WorldPoint(2545, 3112, 0)), - WATERFALL_QUEST(Quest.WATERFALL_QUEST, new WorldPoint(2521, 3498, 0)), - WHAT_LIES_BELOW(Quest.WHAT_LIES_BELOW, new WorldPoint(3265, 3333, 0)), - WITCHS_HOUSE(Quest.WITCHS_HOUSE, new WorldPoint(2927, 3456, 0)), - ZOGRE_FLESH_EATERS(Quest.ZOGRE_FLESH_EATERS, new WorldPoint(2442, 3051, 0)); + WATCHTOWER("Watchtower", new WorldPoint(2545, 3112, 0)), + WATERFALL_QUEST("Waterfall Quest", new WorldPoint(2521, 3498, 0)), + WHAT_LIES_BELOW("What Lies Below", new WorldPoint(3265, 3333, 0)), + WITCHS_HOUSE("Witch's House", new WorldPoint(2927, 3456, 0)), + ZOGRE_FLESH_EATERS("Zogre Flesh Eaters", new WorldPoint(2442, 3051, 0)); @Getter private final String tooltip; @@ -169,20 +169,9 @@ enum QuestStartLocation @Getter private final WorldPoint location; - @Getter - private final Quest quest; - QuestStartLocation(String description, WorldPoint location) { - this.tooltip = description; + this.tooltip = "Quest Start - " + description; this.location = location; - this.quest = null; - } - - QuestStartLocation(Quest quest, WorldPoint location) - { - this.tooltip = quest.getName(); - this.location = location; - this.quest = quest; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartPoint.java index fe53b045f8..14f1842f62 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartPoint.java @@ -30,10 +30,10 @@ import java.awt.image.BufferedImage; class QuestStartPoint extends WorldMapPoint { - QuestStartPoint(QuestStartLocation data, BufferedImage icon, String toolTip) + QuestStartPoint(QuestStartLocation data, BufferedImage icon) { super(data.getLocation(), icon); - setTooltip("Quest start" + toolTip); + setTooltip(data.getTooltip()); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPoint.java index 836ce6f388..57fce253e9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPoint.java @@ -1,5 +1,7 @@ /* - * Copyright (c) 2019, Kyle Sergio , , Bryce Altomare + * Copyright (c) 2019, Kyle Sergio + * Copyright (c) 2019, Bryce Altomare + * Copyright (c) 2019, Kyle Stead * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,13 +30,11 @@ package net.runelite.client.plugins.worldmap; import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; import java.awt.image.BufferedImage; -public class TransportationPoint extends WorldMapPoint +class TransportationPoint extends WorldMapPoint { - TransportationPoint(TransportationPointLocation data, BufferedImage icon) - { - super(data.getLocation(), icon); - - setTooltip(data.getTooltip()); - } - -} \ No newline at end of file + TransportationPoint(TransportationPointLocation data, BufferedImage icon) + { + super(data.getLocation(), icon); + setTooltip(data.getTooltip()); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java index 7d2dd76e0a..54bd7adfdc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java @@ -1,5 +1,7 @@ /* - * Copyright (c) 2019, Kyle Sergio , Bryce Altomare + * Copyright (c) 2019, Kyle Sergio + * Copyright (c) 2019, Bryce Altomare + * Copyright (c) 2019, Kyle Stead * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,177 +27,167 @@ */ package net.runelite.client.plugins.worldmap; +import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.coords.WorldPoint; -import net.runelite.http.api.worlds.World; -enum TransportationPointLocation { +@Getter +@AllArgsConstructor +enum TransportationPointLocation +{ + //Ships + ARDOUGNE_TO_BRIMHAVEN("Ship to Brimhaven", new WorldPoint(2675, 3275, 0)), + ARDOUGNE_TO_FISHINGPLAT("Ship to Fishing Platform", new WorldPoint(2722, 3304, 0)), + BRIMHAVEN_TO_ARDOUGNE("Ship to Ardougne", new WorldPoint(2772, 3234, 0)), + CATHERBY_TO_KEEP_LE_FAYE("Ship to Keep Le Faye", new WorldPoint(2804, 3421, 0)), + CORSAIR_TO_RIMMINGTON("Ship to Rimmington", new WorldPoint(2577, 2839, 0)), + DRAGONTOOTH_TO_PHASMATYS("Ship to Port Phasmatys", new WorldPoint(3791, 3561, 0)), + DIGSITE_TO_FOSSIL("Ship to Fossil Island", new WorldPoint(3361, 3448, 0)), + ENTRANA_TO_PORTSARIM("Ship to Port Sarim", new WorldPoint(2833, 3334, 0)), + FISHINGPLAT_TO_ARDOUGNE("Ship to Ardougne", new WorldPoint(2779, 3271, 0)), + HARMLESS_TO_PORT_PHASMATYS("Ship to Port Phasmatys", new WorldPoint(3682, 2951, 0)), + ICEBERG_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2657, 3988, 0)), + ISLAND_TO_APE_ATOLL("Ship to Ape Atoll", new WorldPoint(2891, 2726, 0)), + JATIZSO_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2420, 3780, 0)), + KARAMJA_TO_PORT_SARIM("Ship to Port Sarim", new WorldPoint(2955, 3144, 0)), + KARAMJA_TO_PORT_KHAZARD("Ship to Port Khazard", new WorldPoint(2763, 2957, 0)), + LANDSEND_TO_PORTSARIM_PORTPISCARILIUS("Ship to Port Sarim/Port Piscarilius", new WorldPoint(1503, 3398, 0)), + LUNAR_ISLE_TO_PIRATES_COVE("Ship to Pirates' Cove", new WorldPoint(2137, 3899, 0)), + MISCELLANIA_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2579, 3846, 0)), + NEITIZNOT_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2310, 3779, 0)), + PESTCONTROL_TO_PORTSARIM("Ship to Port Sarim", new WorldPoint(2659, 2675, 0)), + PIRATES_COVE_TO_LUNAR_ISLE("Ship to Lunar Isle", new WorldPoint(2223, 3796, 0)), + PIRATES_COVE_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2212, 3794, 0)), + PORT_PHASMATYS_TO_DRAGONTOOTH("Ship to Dragontooth Island", new WorldPoint(3703, 3487, 0)), + PORT_PHASMATYS_TO_HARMLESS("Ship to Mos Le'Harmless", new WorldPoint(3709, 3497, 0)), + PORT_PISCARILIUS_TO_PORTSARIM_LANDSEND("Ship to Port Sarim/Land's End", new WorldPoint(1823, 3692, 0)), + PORTSARIM_TO_GREAT_KOUREND("Ship to Great Kourend", new WorldPoint(3054, 3244, 0)), + PORTSARIM_TO_ENTRANA("Ship to Entrana", new WorldPoint(3046, 3233, 0)), + PORTSARIM_TO_KARAMJA("Ship to Karamja", new WorldPoint(3029, 3218, 0)), + PORTSARIM_TO_CRANDOR("Ship to Crandor", new WorldPoint(3045, 3205, 0)), + PORTSARIM_TO_PEST_CONTROL("Ship to Pest Control", new WorldPoint(3039, 3201, 0)), + RELLEKKA_TO_JATIZSO_NEITIZNOT("Ship to Jatizso/Neitiznot", new WorldPoint(2639, 3710, 0)), + RELLEKKA_TO_MISCELLANIA("Ship to Miscellania", new WorldPoint(2627, 3692, 0)), + RELLEKKA_TO_WATERBIRTH("Ship to Waterbirth", new WorldPoint(2621, 3683, 0)), + RELLEKKA_TO_WEISS_ICEBERG("Ship to Weiss/Iceberg", new WorldPoint(2707, 3735, 0)), + RELLEKKA_TO_UNGAEL("Ship to Ungael", new WorldPoint(2638, 3698, 0)), + RIMMINGTON_TO_CORSAIR_COVE("Ship to Corsair Cove", new WorldPoint(2909, 3227, 0 )), + WATERBIRTH_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2549, 3758, 0)), + WEISS_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2847, 3967, 0)), + UNGAEL_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2276, 4034, 0)), - //Ships - ARDOUGNE_TO_BRIMHAVEN("Ship to - Brimhaven", new WorldPoint(2675,3275,0)), - ARDOUGNE_TO_FISHINGPLAT("Ship to - Fishing Platform", new WorldPoint(2722,3304,0)), - BRIMHAVEN_TO_ARDOUGNE("Ship to - Ardougne", new WorldPoint(2772,3234,0)), - CATHERBY_TO_KEEP_LE_FAYE("Ship to - Keep Le Faye", new WorldPoint(2804,3421,0)), - CORSAIR_TO_RIMMINGTON("Ship to - Rimmington", new WorldPoint(2577,2839,0)), - DRAGONTOOTH_TO_PHASMATYS("Ship to - Port Phasmatys", new WorldPoint(3791,3561,0)), - DIGSITE_TO_FOSSIL("Ship to - Fossil island", new WorldPoint(3361,3448,0)), - ENTRANA_TO_PORTSARIM("Ship to - Port Sarim", new WorldPoint(2833,3334,0)), - FISHINGPLAT_TO_ARDOUGNE("Ship to - Ardougne", new WorldPoint(2779,3271,0)), - HARMLESS_TO_PORT_PHASMATYS("Ship to - Port Phasmatys", new WorldPoint(3682,2951,0)), - ICEBERG_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2657,3988,0)), - ISLAND_TO_APETOLL("Ship to - Ape Toll", new WorldPoint(2891,2726,0)), - JATIZZO_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2420,3780,0)), - KARAMJA_TO_PORT_SARIM("Ship to - Port Sarim", new WorldPoint(2955,3144,0)), - KARAMJA_TO_KHAZARD_PORT("Ship to - Khazard Port", new WorldPoint(2763,2957,0)), - KHAZARD_TO_SHILO("Ship to - Shilo", new WorldPoint(2673,3143,0)), - LANDSEND_TO_PORTSARIM_PORTPISCARILLUS("Ship to Port Sarim/Port Piscarillus", new WorldPoint(1503,3398,0)), - LUNAR_ISLE_TO_PIRATES_COVE("Ship to - Pirates Cove", new WorldPoint(2137,3899,0)), - MISCELLANIA_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2579,3846,0)), - NEITZNOT_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2310,3779,0)), - PESTCONTROL_TO_PORTSARIM("Ship to - Port Sarim", new WorldPoint(2659,2675,0)), - PIRATES_COVE_TO_LUNAR_ISLE("Ship to - Lunar isle", new WorldPoint(2223,3796,0)), - PIRATES_COVER_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2212,3794,0)), - PORT_PHASMATYS_TO_DRAGONTOOTH("Ship to - Dragontooth island", new WorldPoint(3703,3487,0)), - PORT_PHASMATYS_TO_HARMLESS("Ship to - Mos le Harmless", new WorldPoint(3709,3497,0)), - PORT_PISCARILIUS_TO_PORTSARIM_lANDSEND("Ship to - Port Sarim/Lands end", new WorldPoint(1823,3692,0)), - PORTSARIM_TO_GREAT_KOUREND("Ship to - Great Kourend", new WorldPoint(3054,3244,0)), - PORTSARIM_TO_ENTRANA("Ship to - Entrana", new WorldPoint(3046,3233,0)), - PORTSARIM_TO_KARAMJA("Ship to - Karamja", new WorldPoint(3029,3218,0)), - PORTSARIM_TO_CRANDOR("Ship to - Crandor", new WorldPoint(3045,3205,0)), - PORTSARIM_TO_PEST_CONTROL("Ship to - Pest Control", new WorldPoint(3039,3201,0)), - RELLEKKA_TO_JATIZZO_NEITIZNOT("Ship to - Jatizzo/Neitiznot", new WorldPoint(2639,3710,0)), - RELLEKKA_TO_MISCELLANIA("Ship to - Miscellania", new WorldPoint(2627,3692,0)), - RELLEKKA_TO_WATERBIRTH("Ship to - Waterbirth", new WorldPoint(2621,3683,0)), - RELLEKKA_TO_WEISS_ICEBERG("Ship to - Weiss/Iceberg", new WorldPoint(2707,3735,0)), - RELLEKKA_TO_UNGAEL("Ship to - Ungael", new WorldPoint(2638,3698,0)), - RIMMINGTON_TO_CORSAIR_COVE("Ship to - Corsair Cove", new WorldPoint(2909,3227,0 )), - WATERBIRTH_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2549,3758,0)), - WEISS_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2847,3967,0)), - UNGAEL_TO_RELLEKKA("Ship to - Rellekka", new WorldPoint(2276,4034,0)), + //Row Boats + ROW_BOAT_BATTLEFRONT("Rowboat to Molch/Molch Island/Shayzien", new WorldPoint(1383, 3663, 0)), + ROW_BOAT_BRAIN_DEATH("Rowboat to Port Phasmatys", new WorldPoint(2161, 5117, 0)), + ROW_BOAT_BURGH_DE_ROTT("Rowboat to Meiyerditch", new WorldPoint(3522, 3168, 0)), + ROW_BOAT_CRABCLAW("Rowboat to Hosidius", new WorldPoint(1780, 3417, 0)), + ROW_BOAT_DIVING_ISLAND("Rowboat to Barge/Camp/North of Island", new WorldPoint(3764, 3901, 0)), + ROW_BOAT_FISHING_GUILD("Rowboat to Hemenster", new WorldPoint(2598, 3426, 0)), + ROW_BOAT_GNOME_STRONGHOLD("Rowboat to Fishing Colony", new WorldPoint(2368, 3487, 0)), + ROW_BOAT_FISHING_COLONY("Rowboat to Gnome Stronghold", new WorldPoint(2356, 3641, 0)), + ROW_BOAT_HEMENSTER("Rowboat to Fishing Guild", new WorldPoint(2613, 3439, 0)), + ROW_BOAT_HOSIDIUS("Rowboat to Crabclaw Isle", new WorldPoint(1779, 3457, 0)), + ROW_BOAT_LITHKREN("Rowboat to Mushroom Forest", new WorldPoint(3582, 3973, 0)), + ROW_BOAT_LUMBRIDGE("Rowboat to Misthalin Mystery", new WorldPoint(3238, 3141, 0)), + ROW_BOAT_MOLCH("Rowboat to Molch Island/Shayzien/Battlefront", new WorldPoint(1343, 3646, 0)), + ROW_BOAT_MOLCH_ISLAND("Rowboat to Molch/Shayzien/Battlefront", new WorldPoint(1368, 3641, 0)), + ROW_BOAT_MORT("Rowboat to Mort Myre", new WorldPoint(3518, 3284, 0)), + ROW_BOAT_MORT_SWAMP("Rowboat to Mort'ton", new WorldPoint(3498, 3380, 0)), + ROW_BOAT_MUSEUM_CAMP("Rowboat to Barge/Digsite/North of Island", new WorldPoint(3723, 3807, 0)), + ROW_BOAT_MUSHROOM_FOREST_WEST("Rowboat to Lithkren", new WorldPoint(3659, 3849, 0)), + ROW_BOAT_MUSHROOM_FOREST_NE("Rowboat to Barge/Camp/Sea", new WorldPoint(3733, 3894, 0)), + ROW_BOAT_PORT_PHASMATYS_NORTH("Rowboat to Slepe", new WorldPoint(3670, 3545, 0)), + ROW_BOAT_PORT_PHASMATYS_EAST("Rowboat to Braindeath Island", new WorldPoint(3680, 3538, 0)), + ROW_BOAT_SHAYZIEN("Rowboat to Molch/Molch Island/Battlefront", new WorldPoint(1405, 3612, 0)), + ROW_BOAT_SLEPE("Rowboat to Port Phasmatys", new WorldPoint(3661, 3279, 0)), + OGRE_BOAT_FELDIP("Ogre Boat to Karamja", new WorldPoint(2653, 2964, 0)), + OGRE_BOAT_KARAMJA("Ogre Boat to Feldip", new WorldPoint(2757, 3085, 0)), - //Row Boats - ROW_BOAT_BATTLEFRONT("Rowboat", new WorldPoint(1383,3663,0)), - ROW_BOAT_BRAIN_DEATH("Rowboat", new WorldPoint(2161,5117,0)), - ROW_BOAT_BURGH_DE_ROTT("Rowboat", new WorldPoint(3522,3168,0)), - ROW_BOAT_CRABCLAW("Rowboat", new WorldPoint(1780,3417,0)), - ROW_BOAT_DIVING_ISLAND("Rowboat", new WorldPoint(3764,3901,0)), - ROW_BOAT_FISHING_GUILD("Rowboat", new WorldPoint(2598,3426,0)), - ROW_BOAT_GNOME_STRONGHOLD("Rowboat", new WorldPoint(2368,3487,0)), - ROW_BOAT_FISHING_COLONY("Rowboat", new WorldPoint(2356,3641,0)), - ROW_BOAT_HEMENSTER("Rowboat", new WorldPoint(2613,3439,0)), - ROW_BOAT_HOSIDIUS("Rowboat", new WorldPoint(1779,3457,0)), - ROW_BOAT_LITHKREN("Rowboat", new WorldPoint(3582,3973,0)), - ROW_BOAT_LUMBRIDGE("Rowboat", new WorldPoint(3238,3141,0)), - ROW_BOAT_MOLCH("Rowboat", new WorldPoint(1343,3646,0)), - ROW_BOAT_MOLCH_ISLAND("Rowboat", new WorldPoint(1368,3641,0)), - ROW_BOAT_MORT("Rowboat", new WorldPoint(3518,3284,0)), - ROW_BOAT_MORT_SWAMP("Rowboat", new WorldPoint(3498,3380,0)), - ROW_BOAT_MUSEUM_CAMP("Rowboat", new WorldPoint(3723,3807,0)), - ROW_BOAT_MUSHROOM_FOREST_WEST("Rowboat", new WorldPoint(3659,3849,0)), - ROW_BOAT_MUSHROOM_FOREST_NE("Rowboat", new WorldPoint(3733,3894,0)), - ROW_BOAT_PORT_PHASMATYS_NORTH("Rowboat", new WorldPoint(3670,3545,0)), - ROW_BOAT_PORT_PHASMATYS_EAST("Rowboat", new WorldPoint(3680,3538,0)), - ROW_BOAT_SHAYZIEN("Rowboat", new WorldPoint(1405,3612,0)), - ROW_BOAT_SLEPE("Rowboat", new WorldPoint(3661,3279,0)), - OGRE_BOAT_FELDIP("Ogre Boat", new WorldPoint(2653,2964,0)), - OGRE_BOAT_KARAMJA("Ogre Boat", new WorldPoint(2757,3085,0)), + //Charter ships + CHARTER_BRIMHAVEN("Charter Ship", new WorldPoint(2760, 3238, 0)), + CHARTER_CATHERBY("Charter Ship", new WorldPoint(2791, 3415, 0)), + CHARTER_CORSAIR_("Charter Ship", new WorldPoint(2589, 2851, 0)), + CHARTER_KARAMJA_NORTH("Charter Ship", new WorldPoint(2954, 3159, 0)), + CHARTER_KARAMJA_EAST("Charter Ship", new WorldPoint(2999, 3032, 0)), + CHARTER_KHAZARD("Charter Ship", new WorldPoint(2673, 3143, 0)), + CHARTER_MOSLE_HARMLESS("Charter Ship", new WorldPoint(3669, 2931, 0)), + CHARTER_PORT_PHASMATYS("Charter Ship", new WorldPoint(3702, 3503, 0)), + CHARTER_PORTSARIM("Charter Ship", new WorldPoint(3037, 3191, 0)), + CHARTER_TYRAS("Charter Ship", new WorldPoint(2141, 3123, 0)), - //Charter ships - CHARTER_BRIMHAVEN("Charter Ship", new WorldPoint(2760,3238,0)), - CHARTER_CATHERBY("Charter ship", new WorldPoint(2791,3415,0)), - CHARTER_CORSAIR_("Charter Ship", new WorldPoint(2589,2851,0)), - CHARTER_KARAMJA_NORTH("Charter Ship", new WorldPoint(2954,3159,0)), - CHARTER_KARAMJA_EAST("Charter Ship", new WorldPoint(2999,3032,0)), - CHARTER_MOSLE_HARMLESS("Charter Ship", new WorldPoint(3669,2931,0)), - CHARTER_PORT_PHASMATYS("Charter Ship", new WorldPoint(3702,3503,0)), - CHARTER_PORTSARIM("Charter ship", new WorldPoint(3037,3191,0)), - CHARTER_TYRAS("Charter Ship", new WorldPoint(2141,3123,0)), + //Minecarts/Carts + MINE_CART_ARCEUUS("Minecart", new WorldPoint(1673, 3832, 0)), + MINE_CART_GRANDEXCHANGE("Minecart to Keldagrim", new WorldPoint(3139, 3504, 0)), + MINE_CART_HOSIDIUS("Minecart", new WorldPoint(1656, 3542, 0)), + MINE_CART_KELDAGRIM("Minecart", new WorldPoint(2908, 10170, 0)), + MINE_CART_LOVAKENGJ("Minecart", new WorldPoint(1524, 3721, 0)), + MINE_CART_PORT_PISCARILIUS("Minecart", new WorldPoint(1760, 3708, 0)), + MINE_CART_QUIDAMORTEM("Minecart", new WorldPoint(1253, 3550, 0)), + MINE_CART_SHAYZIEN("Minecart", new WorldPoint(1586, 3622, 0)), + MINE_CART_TAVERLEY_UNDERGROUND("Minecart", new WorldPoint(2874, 9870, 0)), + CART_TO_BRIMHAVEN("Cart to Brimhaven", new WorldPoint(2833, 2958, 0)), + CART_TO_SHILO("Cart to Shilo", new WorldPoint(2780, 3214, 0)), - //Minecarts/Carts - MINE_CART_ARCEUUS("Mine cart", new WorldPoint(1673,3832,0)), - MINE_CART_GRANDEXCHANGE("Minecart to - Keldagrim", new WorldPoint(3139,3504,0)), - MINE_CART_HOSIDIUS("Minecart", new WorldPoint(1656,3542,0)), - MINE_CART_KELDAGRIM("Minecart", new WorldPoint(2908,10170,0)), - MINE_CART_LOVAKENGJ("Minecart", new WorldPoint(1524,3721,0)), - MINE_CART_PORT_PISCARILIUS("Minecart", new WorldPoint(1760,3708,0)), - MINE_CART_QUIDAMORTEM("Minecart", new WorldPoint(1253,3550,0)), - MINE_CART_SHAYZIEN("Minecart", new WorldPoint(1586,3622,0)), - MINE_CART_TAVERLEY_UNDERGROUND("Minecart", new WorldPoint(2874,9870,0)), - CART_TO_BRIMHAVEN("Cart to - Brimhaven", new WorldPoint(2833,2958,0)), - CART_TO_SHILO("Cart to - Shilo", new WorldPoint(2780,3214,0)), + //Canoes + CANOE_BARBVILLAGE("Canoe", new WorldPoint(3111, 3409, 0)), + CANOE_CHAMPIONSGUILD("Canoe", new WorldPoint(3202, 3344, 0)), + CANOE_EDGEVILLE("Canoe", new WorldPoint(3130, 3509, 0)), + CANOE_LUMBRIDGE("Canoe", new WorldPoint(3241, 3238, 0)), - //Canoes - CANOE_BARBVILLAGE("Canoe", new WorldPoint(3111,3409,0)), - CANOE_CHAMPIONSGUILD("Canoe", new WorldPoint(3202,3344,0)), - CANOE_EDGEVILLE("Canoe", new WorldPoint(3130,3509,0)), - CANOE_LUMBRIDGE("Canoe ", new WorldPoint(3241,3238,0)), + //Gnome Gliders + GNOME_GLIDER_KHARID("Gnome Glider", new WorldPoint(3278, 3213, 0)), + GNOME_GLIDER_APE_ATOLL("Gnome Glider", new WorldPoint(2712, 2804, 0)), + GNOME_GLIDER_KARAMJA("Gnome Glider", new WorldPoint(2971, 2974, 0)), + GNOME_GLIDER_FELDIP("Gnome Glider", new WorldPoint(2540, 2969, 0)), + GNOME_GLIDER_GNOMESTRONGHOLD("Gnome Glider", new WorldPoint(2460, 3502, 0)), + GNOME_GLIDER_WHITEWOLF("Gnome Glider", new WorldPoint(2845, 3501, 0)), - //Gnome Gliders - GNOME_GLIDER_KHARID("Gnome Glider", new WorldPoint(3278,3213,0)), - GNOME_GLIDER_APETOLL("Gnome Glider", new WorldPoint(2712,2804,0)), - GNOME_GLIDER_KARAMJA("Gnome Glider", new WorldPoint(2971,2974,0)), - GNOME_GLIDER_FELDIP("Gnome Glider", new WorldPoint(2540,2969,0)), - GNOME_GLIDER_GNOMESTRONGHOLD("Gnome Glider", new WorldPoint(2460,3502,0)), - GNOME_GLIDER_WHITEWOLF("Gnome Glider", new WorldPoint(2845,3501,0)), + //Balloons + BALLOON_VARROCK("Hot Air Balloon", new WorldPoint(3298, 3480, 0)), + BALLOON_YANILLE("Hot Air Balloon", new WorldPoint(2458, 3108, 0)), + BALLOON_GNOMESTRONGHOLD("Hot Air Balloon", new WorldPoint(2478, 3459, 0)), + BALLOON_TAVERLEY("Hot Air Balloon", new WorldPoint(2936, 3422, 0)), + BALLOON_FALADOR("Hot Air Balloon", new WorldPoint(2921, 3301, 0)), - //Balloons - BALLOON_VARROCK("Hot air Balloon", new WorldPoint(3298,3480,0)), - BALLOON_YANILLE("Hot air Balloon", new WorldPoint(2458,3108,0)), - BALLOON_GNOMESTRONGHOLD("Hot air Balloon", new WorldPoint(2478,3459,0)), - BALLOON_TAVERLEY("Hot air Balloon", new WorldPoint(2936,3422,0)), - BALLOON_FALADOR("Hot air Balloon", new WorldPoint(2921,3301,0)), + //Spirit Tree + SPIRITTREE_ARDOUGNE("Spirit Tree", new WorldPoint(2554, 3259, 0)), + SPIRITTREE_CORSAIR("Spirit Tree", new WorldPoint(2485, 2850, 0)), + SPIRITTREE_GNOMESTRONGHOLD("Spirit Tree", new WorldPoint(2459, 3446, 0)), + SPIRITTREE_GNOMEVILLAGE("Spirit Tree", new WorldPoint(2538, 3166, 0)), + SPIRITTREE_GRANDEXCHANGE("Spirit Tree", new WorldPoint(3184, 3510, 0)), - //Spirit Tree - SPIRITTREE_ARDOUGNE("Spirit Tree", new WorldPoint(2554,3259,0)), - SPIRITTREE_CORSAIR("Spirit Tree", new WorldPoint(2485,2850,0)), - SPIRITTREE_GNOMESTRONGHOLD("Spirit Tree", new WorldPoint(2459,3446,0)), - SPIRITTREE_GNOMEVILLAGE("Spirit Tree", new WorldPoint(2538,3166,0)), - SPIRITTREE_GRANDEXCHANGE("Spirit Tree", new WorldPoint(3184,3510,0)), + //Carpets + CARPET_KHARID("Carpet to Bedabin/Pollnivneach/Uzer", new WorldPoint(3311, 3107, 0)), + CARPET_BEDABIN("Carpet to Shantay Pass", new WorldPoint(3183, 3042, 0)), + CARPET_POLLNIVNEACH_NORTH("Carpet to Shantay Pass", new WorldPoint(3351, 3001, 0)), + CARPET_POLLNIVNEACH_SOUTH("Carpet to Nardah/Sophanem/Menaphos", new WorldPoint(3345, 2943, 0)), + CARPET_NARDAH("Carpet to Pollnivneach", new WorldPoint(3399, 2916, 0)), + CARPET_SOPHANEM("Carpet to Pollnivneach", new WorldPoint(3288, 2814, 0)), + CARPET_MENAPHOS("Carpet to Pollnivneach", new WorldPoint(3244, 2812, 0)), + CARPET_UZER("Carpet to Shantay Pass", new WorldPoint(3468, 3111, 0)), + //Teleports + TELEPORT_ARCHIVE_FROM_ARCEUUS("Teleport to Library Archive", new WorldPoint(1623, 3808, 0)), + TELEPORT_HARMLESS_FROM_HARMONY("Teleport to Mos Le'Harmless", new WorldPoint(3784, 2828, 0)), + TELEPORT_RUNE_ARDOUGNE("Teleport to Rune Essence", new WorldPoint(2681, 3325, 0)), + TELEPORT_RUNE_YANILLE("Teleport to Rune Essence", new WorldPoint(2592, 3089, 0)), + TELEPORT_SORCERESS_GARDEN("Teleport to Sorceress's Garden", new WorldPoint(3320, 3141, 0)), - //Carpets - CARPET_KHARID("Carpet", new WorldPoint(3311,3107,0)), - CARPET_BEDABIN("Carpet",new WorldPoint(3183,3042,0)), - CARPET_POLLNIVNEACH_NORTH("Carpet", new WorldPoint(3351,3001,0)), - CARPET_POLLNIVNEACH_SOUTH("Carpet", new WorldPoint(3345,2943,0)), - CARPET_NARDAH("Carpet", new WorldPoint(3399,2916,0)), - CARPET_SOPHANEM("Carpet", new WorldPoint(3288,2814,0)), - CARPET_MENAPHOS("Carpet", new WorldPoint(3244,2812,0)), - CARPET_UZER("Carpet", new WorldPoint(3468,3111,0)), + //Other + ALTER_KOUREND_UNDERGROUND("Altar to Skotizo", new WorldPoint(1662, 10047, 0)), + FAIRY_RING_ZANARIS_TO_KHARID("Fairy Ring to Al Kharid", new WorldPoint(2483, 4471, 0)), + FAIRY_RING_ZANARIS_TO_SHACK("Fairy Ring to Shack", new WorldPoint(2451, 4471, 0)), + MOUNTAIN_GUIDE_QUIDAMORTEM("Mountain Guide", new WorldPoint(1275, 3559, 0)), + MOUNTAIN_GUIDE_WALL("Mountain Guide", new WorldPoint(1400, 3538, 0)), + MUSHTREE_MUSHROOM_FOREST("Mushtree", new WorldPoint(3674, 3871, 0)), + MUSHTREE_TAR_SWAMP("Mushtree", new WorldPoint(3676, 3755, 0)), + MUSHTREE_VERDANT_VALLEY("Mushtree", new WorldPoint(3757, 3756, 0)), + MYTHS_GUILD_PORTAL("Portal to Guilds", new WorldPoint(2456, 2856, 0)), + TRAIN_KELDAGRIM("Railway Station", new WorldPoint(2941, 10179, 0)), + WILDERNESS_LEVER_ARDOUGNE("Wilderness Lever", new WorldPoint(2559, 3309, 0)), + WILDERNESS_LEVER_EDGEVILLE("Wilderness Lever", new WorldPoint(3088, 3474, 0)), + WILDERNESS_LEVER_WILDERNESS("Wilderness Lever", new WorldPoint(3154, 3924, 0)); - //Teleports - TELEPORT_ARCHIVE_FROM_ARCEUUS("Teleport to - Library archive", new WorldPoint(1623,3808,0)), - TELEPORT_HARMELSS_FROM_HARMONY("Teleport to - Mos le Harmless", new WorldPoint(3784,2828,0)), - TELEPORT_RUNE_FROM_ARDOUGNE("Teleport to - Rune Eccense", new WorldPoint(2681,3325,0)), - TELEPORT_RUNE_FROM_YANILLE("Teleport to - Rune Eccense", new WorldPoint(2592,3089,0)), - TELEPORT_SORCERESS_GARDEN("Teleport to - Sorceress`s garden", new WorldPoint(3320,3141,0)), - - //Other - ALTER_KOUREND_UNDERGROUND("Altar", new WorldPoint(1662,10047,0)), - FAIRY_RING_ZANRIS_TO_KHARID("Fairy Ring to - Al Kharid", new WorldPoint(2483,4471,0)), - FAIRY_RING_ZANRIS_TO_SHACK("Fairy Ring to - Shack", new WorldPoint(2451,4471,0)), - MOUNTAIN_GUIDE_QUIDAMORTEM("Mountain Guide", new WorldPoint(1275,3559,0)), - MOUNTAIN_GUIDE_WALL("Mountain Guide", new WorldPoint(1400,3538,0)), - MUSHTREE_MUSHROOM_FOREST("Mushtree", new WorldPoint(3674,3871,0)), - MUSHTREE_TAR_SWAMP("Mushtree", new WorldPoint(3676,3755,0)), - MUSHTREE_VERDANT_VALLEY("Mushtree", new WorldPoint(3757,3756,0)), - MYTHS_GUILD_PORTAL("Portal", new WorldPoint(2456,2856,0)), - TRAINSTATION_KELDAGRIM("Trainstation", new WorldPoint(2941,10179,0)), - WILDERNESS_LEVER_ARDOUGNE("Wilderness Lever", new WorldPoint(2559,3309,0)), - WILDERNESS_LEVER_EDGEVILLE("Wilderness Lever", new WorldPoint(3088,3474,0)), - WILDERNESS_LEVER_WILDERNESS("Wilderness Lever", new WorldPoint(3154,3924,0)); - - - @Getter - private final String tooltip; - - @Getter - private final WorldPoint location; - - TransportationPointLocation(String description, WorldPoint location) - { - this.tooltip = description; - this.location = location; - } - -} \ No newline at end of file + private final String tooltip; + private final WorldPoint location; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WayPointWorldMapListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WayPointWorldMapListener.java deleted file mode 100644 index 5540a2a0fb..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WayPointWorldMapListener.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2019, Yani - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.worldmap; - -import net.runelite.api.*; -import net.runelite.api.Point; -import net.runelite.api.coords.WorldPoint; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.input.MouseAdapter; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseEvent; - -@Singleton -public class WayPointWorldMapListener extends MouseAdapter -{ - - private final Client client; - - private final WorldMapConfig config; - private final WorldMapPlugin plugin; - - @Inject - private WayPointWorldMapListener(Client client, WorldMapPlugin plugin, WorldMapConfig config) - { - this.client = client; - this.plugin = plugin; - this.config = config; - } - - @Override - public MouseEvent mouseClicked(MouseEvent e) - { - if (!SwingUtilities.isLeftMouseButton(e)) - { - return e; - } - - if (!config.isWaypointEnabled()) - { - return e; - } - - if (e.getClickCount() % 2 != 0) - { - return e; - } - - Widget mapWidget = client.getWidget(WidgetInfo.WORLD_MAP_VIEW); - - if (mapWidget == null) - { - return e; - } - - Rectangle worldMapRect = mapWidget.getBounds(); - Point mousePos = client.getMouseCanvasPosition(); - - if (!worldMapRect.contains(mousePos.getX(), mousePos.getY())) - { - return e; - } - - if (plugin.hasWayPoint()) - { - plugin.removeWayPoint(); - return e; - } - - RenderOverview ro = client.getRenderOverview(); - Float pixelsPerTile = ro.getWorldMapZoom(); - - // Get mouse location in world map window - int xMouseInBounds = mousePos.getX() - (int) worldMapRect.getX(); - int yMouseInBounds = mousePos.getY() - (int) worldMapRect.getY(); - - // Get center pixel because that's where we calculate the offset from - int xCenterPixel = (int) (worldMapRect.getWidth() / 2); - int yCenterPixel = (int) (worldMapRect.getHeight() / 2); - - // Get offset in amount of pixels and tiles - int xOffset = xMouseInBounds - xCenterPixel; - int yOffset = yCenterPixel - yMouseInBounds; - int xTileOffset = (int) (xOffset / pixelsPerTile); - int yTileOffset = (int) (yOffset / pixelsPerTile); - - // Get actual tile position - int xPos = ro.getWorldMapPosition().getX() + xTileOffset; - int yPos = ro.getWorldMapPosition().getY() + yTileOffset; - - plugin.setWayPoint(new WorldPoint(xPos, yPos, 0)); - - return e; - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapConfig.java index 036c69d6a6..ca62df484d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapConfig.java @@ -1,16 +1,16 @@ /* * Copyright (c) 2018, Morgan Lewis - * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. + * * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -33,10 +33,10 @@ import net.runelite.client.config.ConfigItem; public interface WorldMapConfig extends Config { @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_FAIRY_RING_TOOLTIPS, - name = "Show fairy ring codes in tooltip", - description = "Display the code for fairy rings in the icon tooltip", - position = 1 + keyName = WorldMapPlugin.CONFIG_KEY_FAIRY_RING_TOOLTIPS, + name = "Show fairy ring codes in tooltip", + description = "Display the code for fairy rings in the icon tooltip", + position = 1 ) default boolean fairyRingTooltips() { @@ -44,10 +44,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_FAIRY_RING_ICON, - name = "Show fairy ring travel icon", - description = "Override the travel icon for fairy rings", - position = 2 + keyName = WorldMapPlugin.CONFIG_KEY_FAIRY_RING_ICON, + name = "Show fairy ring travel icon", + description = "Override the travel icon for fairy rings", + position = 2 ) default boolean fairyRingIcon() { @@ -55,10 +55,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_AGILITY_SHORTCUT_TOOLTIPS, - name = "Show agility level requirement", - description = "Display the required Agility level in the icon tooltip", - position = 3 + keyName = WorldMapPlugin.CONFIG_KEY_AGILITY_SHORTCUT_TOOLTIPS, + name = "Show agility level requirement", + description = "Display the required Agility level in the icon tooltip", + position = 3 ) default boolean agilityShortcutTooltips() { @@ -66,10 +66,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_AGILITY_SHORTCUT_LEVEL_ICON, - name = "Indicate inaccessible shortcuts", - description = "Indicate shortcuts you do not have the level to use on the icon", - position = 4 + keyName = WorldMapPlugin.CONFIG_KEY_AGILITY_SHORTCUT_LEVEL_ICON, + name = "Indicate inaccessible shortcuts", + description = "Indicate shortcuts you do not have the level to use on the icon", + position = 4 ) default boolean agilityShortcutLevelIcon() { @@ -77,10 +77,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_NORMAL_TELEPORT_ICON, - name = "Show Standard Spellbook destinations", - description = "Show icons at the destinations for teleports in the Standard Spellbook", - position = 5 + keyName = WorldMapPlugin.CONFIG_KEY_NORMAL_TELEPORT_ICON, + name = "Show Standard Spellbook destinations", + description = "Show icons at the destinations for teleports in the Standard Spellbook", + position = 5 ) default boolean normalTeleportIcon() { @@ -88,10 +88,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_MINIGAME_TOOLTIP, - name = "Show minigame name in tooltip", - description = "Display the name of the minigame in the icon tooltip", - position = 6 + keyName = WorldMapPlugin.CONFIG_KEY_MINIGAME_TOOLTIP, + name = "Show minigame name in tooltip", + description = "Display the name of the minigame in the icon tooltip", + position = 6 ) default boolean minigameTooltip() { @@ -99,10 +99,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_ANCIENT_TELEPORT_ICON, - name = "Show Ancient Magicks destinations", - description = "Show icons at the destinations for teleports in the Ancient Spellbook", - position = 7 + keyName = WorldMapPlugin.CONFIG_KEY_ANCIENT_TELEPORT_ICON, + name = "Show Ancient Magicks destinations", + description = "Show icons at the destinations for teleports in the Ancient Spellbook", + position = 7 ) default boolean ancientTeleportIcon() { @@ -110,10 +110,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_LUNAR_TELEPORT_ICON, - name = "Show Lunar Spellbook destinations", - description = "Show icons at the destinations for teleports in the Lunar Spellbook", - position = 8 + keyName = WorldMapPlugin.CONFIG_KEY_LUNAR_TELEPORT_ICON, + name = "Show Lunar Spellbook destinations", + description = "Show icons at the destinations for teleports in the Lunar Spellbook", + position = 8 ) default boolean lunarTeleportIcon() { @@ -121,10 +121,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_ARCEUUS_TELEPORT_ICON, - name = "Show Arceuus Spellbook destinations", - description = "Show icons at the destinations for teleports in the Arceuus Spellbook", - position = 9 + keyName = WorldMapPlugin.CONFIG_KEY_ARCEUUS_TELEPORT_ICON, + name = "Show Arceuus Spellbook destinations", + description = "Show icons at the destinations for teleports in the Arceuus Spellbook", + position = 9 ) default boolean arceuusTeleportIcon() { @@ -132,10 +132,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_JEWELLERY_TELEPORT_ICON, - name = "Show jewellery teleport locations", - description = "Show icons at the destinations for teleports from jewellery", - position = 10 + keyName = WorldMapPlugin.CONFIG_KEY_JEWELLERY_TELEPORT_ICON, + name = "Show jewellery teleport locations", + description = "Show icons at the destinations for teleports from jewellery", + position = 10 ) default boolean jewelleryTeleportIcon() { @@ -143,10 +143,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_SCROLL_TELEPORT_ICON, - name = "Show teleport scroll locations", - description = "Show icons at the destinations for teleports from scrolls", - position = 11 + keyName = WorldMapPlugin.CONFIG_KEY_SCROLL_TELEPORT_ICON, + name = "Show teleport scroll locations", + description = "Show icons at the destinations for teleports from scrolls", + position = 11 ) default boolean scrollTeleportIcon() { @@ -154,10 +154,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_MISC_TELEPORT_ICON, - name = "Show misc teleport locations", - description = "Show icons at the destinations for miscellaneous teleport items", - position = 12 + keyName = WorldMapPlugin.CONFIG_KEY_MISC_TELEPORT_ICON, + name = "Show misc teleport locations", + description = "Show icons at the destinations for miscellaneous teleport items", + position = 12 ) default boolean miscellaneousTeleportIcon() { @@ -165,10 +165,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_QUEST_START_TOOLTIPS, - name = "Show quest names", - description = "Indicates the names of quests and highlights incomplete ones", - position = 13 + keyName = WorldMapPlugin.CONFIG_KEY_QUEST_START_TOOLTIPS, + name = "Show quest names", + description = "Indicates the names of quests and highlights incomplete ones", + position = 13 ) default boolean questStartTooltips() { @@ -176,21 +176,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_QUEST_PROGRESS_ICON, - name = "Show quest progress", - description = "Indicates your quest progress", - position = 14 - ) - default boolean questProgressIcon() - { - return true; - } - - @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_FARMING_PATCH_TOOLTIPS, - name = "Show farming patch type", - description = "Display the type of farming patches in the icon tooltip", - position = 15 + keyName = WorldMapPlugin.CONFIG_KEY_FARMING_PATCH_TOOLTIPS, + name = "Show farming patch type", + description = "Display the type of farming patches in the icon tooltip", + position = 14 ) default boolean farmingPatchTooltips() { @@ -198,10 +187,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_RARE_TREE_TOOLTIPS, - name = "Show rare tree type", - description = "Display the type of rare tree in the icon tooltip", - position = 16 + keyName = WorldMapPlugin.CONFIG_KEY_RARE_TREE_TOOLTIPS, + name = "Show rare tree type", + description = "Display the type of rare tree in the icon tooltip", + position = 15 ) default boolean rareTreeTooltips() { @@ -209,10 +198,10 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_RARE_TREE_LEVEL_ICON, - name = "Indicate unavailable trees", - description = "Indicate rare trees you do not have the level to cut on the icon", - position = 17 + keyName = WorldMapPlugin.CONFIG_KEY_RARE_TREE_LEVEL_ICON, + name = "Indicate unavailable trees", + description = "Indicate rare trees you do not have the level to cut on the icon", + position = 16 ) default boolean rareTreeLevelIcon() { @@ -220,20 +209,12 @@ public interface WorldMapConfig extends Config } @ConfigItem( - keyName = WorldMapPlugin.CONFIG_KEY_TRANSPORATION_TELEPORT_TOOLTIPS, - name = "Show Transporation Tooltips", - description = "Indicates type of Transporation", - position = 17 + keyName = WorldMapPlugin.CONFIG_KEY_TRANSPORATION_TELEPORT_TOOLTIPS, + name = "Show transporation tooltips", + description = "Indicates types and destinations of Transporation", + position = 17 ) - default boolean TransportationTeleportTooltips() { return true; } - - @ConfigItem( - keyName = "isWaypointEnabled", - name = "Enable waypoint", - description = "Allows you to set a waypoint by double clicking on the worldmap", - position = 17 - ) - default boolean isWaypointEnabled() + default boolean transportationTeleportTooltips() { return true; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java index 63da32b6b1..5fd38d5ff2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java @@ -1,16 +1,16 @@ /* * Copyright (c) 2018, Morgan Lewis - * Copyright (c) 2019, Yani * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. + * * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -25,42 +25,27 @@ */ package net.runelite.client.plugins.worldmap; -import com.google.common.base.Strings; -import com.google.gson.Gson; import com.google.inject.Inject; import com.google.inject.Provides; - import java.awt.image.BufferedImage; import java.util.Arrays; - - -import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.Experience; -import net.runelite.api.GameState; import net.runelite.api.Skill; -import net.runelite.api.events.*; -import net.runelite.api.widgets.WidgetID; -import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ExperienceChanged; -import net.runelite.api.events.GameStateChanged; -import net.runelite.client.chat.ChatMessageBuilder; -import net.runelite.client.chat.ChatMessageManager; -import net.runelite.client.chat.QueuedMessage; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.AgilityShortcut; -import net.runelite.client.input.MouseManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; import net.runelite.client.util.ImageUtil; @PluginDescriptor( - name = "World Map", - description = "Enhance the world map to display additional information", - tags = {"agility", "fairy", "farming", "rings", "teleports"} + name = "World Map", + description = "Enhance the world map to display additional information", + tags = {"agility", "fairy", "farming", "rings", "teleports"} ) public class WorldMapPlugin extends Plugin { @@ -68,9 +53,6 @@ public class WorldMapPlugin extends Plugin private static final BufferedImage FAIRY_TRAVEL_ICON; private static final BufferedImage NOPE_ICON; - private static final BufferedImage STARTED_ICON; - private static final BufferedImage FINISHED_ICON; - static final String CONFIG_KEY = "worldmap"; static final String CONFIG_KEY_FAIRY_RING_TOOLTIPS = "fairyRingTooltips"; static final String CONFIG_KEY_FAIRY_RING_ICON = "fairyRingIcon"; @@ -84,17 +66,12 @@ public class WorldMapPlugin extends Plugin static final String CONFIG_KEY_SCROLL_TELEPORT_ICON = "scrollIcon"; static final String CONFIG_KEY_MISC_TELEPORT_ICON = "miscellaneousTeleportIcon"; static final String CONFIG_KEY_QUEST_START_TOOLTIPS = "questStartTooltips"; - static final String CONFIG_KEY_QUEST_PROGRESS_ICON = "questProgressIcon"; static final String CONFIG_KEY_MINIGAME_TOOLTIP = "minigameTooltip"; static final String CONFIG_KEY_FARMING_PATCH_TOOLTIPS = "farmingpatchTooltips"; static final String CONFIG_KEY_RARE_TREE_TOOLTIPS = "rareTreeTooltips"; static final String CONFIG_KEY_RARE_TREE_LEVEL_ICON = "rareTreeIcon"; static final String CONFIG_KEY_TRANSPORATION_TELEPORT_TOOLTIPS = "transportationTooltips"; - static final String WAYPOINT_SET_MESSAGE = "You have set a waypoint."; - static final String WAYPOINT_UNSET_MESSAGE = "You have cleared your waypoint."; - static final String WAYPOINT_ACTIVE_MESSAGE = "You have an active waypoint."; - static { //A size of 17 gives us a buffer when triggering tooltips @@ -109,43 +86,20 @@ public class WorldMapPlugin extends Plugin NOPE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB); final BufferedImage nopeImage = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "nope_icon.png"); NOPE_ICON.getGraphics().drawImage(nopeImage, 1, 1, null); - - STARTED_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB); - final BufferedImage startedIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "quest_started_icon.png"); - STARTED_ICON.getGraphics().drawImage(startedIcon, 1, 1, null); - FINISHED_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB); - final BufferedImage finishedIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "quest_complete_icon.png"); - FINISHED_ICON.getGraphics().drawImage(finishedIcon, 1, 1, null); } @Inject private Client client; - @Inject - private ConfigManager configManager; - @Inject private WorldMapConfig config; @Inject private WorldMapPointManager worldMapPointManager; - @Inject - private MouseManager mouseManager; - - @Inject - private WayPointWorldMapListener wayPointWorldMapListener; - - @Inject - private ChatMessageManager chatMessageManager; - private int agilityLevel = 0; private int woodcuttingLevel = 0; - private WorldPoint wayPoint; - - private static final Gson gson = new Gson(); - @Provides WorldMapConfig provideConfig(ConfigManager configManager) { @@ -158,23 +112,6 @@ public class WorldMapPlugin extends Plugin agilityLevel = client.getRealSkillLevel(Skill.AGILITY); woodcuttingLevel = client.getRealSkillLevel(Skill.WOODCUTTING); updateShownIcons(); - - mouseManager.registerMouseListener(wayPointWorldMapListener); - wayPoint = loadWayPoint(); - - if (wayPoint != null) - { - updateWayPoint(); - } - } - - @Subscribe - private void onWidgetLoaded(WidgetLoaded l) - { - if (l.getGroupId() == WidgetID.WORLD_MAP_GROUP_ID) - { - updateQuestStartPointIcons(); - } } @Override @@ -188,25 +125,8 @@ public class WorldMapPlugin extends Plugin worldMapPointManager.removeIf(MinigamePoint.class::isInstance); worldMapPointManager.removeIf(FarmingPatchPoint.class::isInstance); worldMapPointManager.removeIf(RareTreePoint.class::isInstance); - worldMapPointManager.removeIf(WayPointWorldMapPoint.class::isInstance); - agilityLevel = 0; woodcuttingLevel = 0; - - if (wayPoint != null) - { - client.clearHintArrow(); - } - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) - { - if (event.getGameState() == GameState.LOGGED_IN) - { - sendChatMessage(WAYPOINT_ACTIVE_MESSAGE); - updateWayPoint(); - } } @Subscribe @@ -218,8 +138,6 @@ public class WorldMapPlugin extends Plugin } updateShownIcons(); - updateQuestStartPointIcons(); - updateWayPoint(); } @Subscribe @@ -249,14 +167,15 @@ public class WorldMapPlugin extends Plugin private void updateAgilityIcons() { worldMapPointManager.removeIf(AgilityShortcutPoint.class::isInstance); + if (config.agilityShortcutLevelIcon() || config.agilityShortcutTooltips()) { Arrays.stream(AgilityShortcut.values()) - .filter(value -> value.getWorldMapLocation() != null) - .map(value -> new AgilityShortcutPoint(value, - agilityLevel > 0 && config.agilityShortcutLevelIcon() && value.getLevel() > agilityLevel ? NOPE_ICON : BLANK_ICON, - config.agilityShortcutTooltips())) - .forEach(worldMapPointManager::add); + .filter(value -> value.getWorldMapLocation() != null) + .map(value -> new AgilityShortcutPoint(value, + agilityLevel > 0 && config.agilityShortcutLevelIcon() && value.getLevel() > agilityLevel ? NOPE_ICON : BLANK_ICON, + config.agilityShortcutTooltips())) + .forEach(worldMapPointManager::add); } } @@ -267,59 +186,13 @@ public class WorldMapPlugin extends Plugin if (config.rareTreeLevelIcon() || config.rareTreeTooltips()) { Arrays.stream(RareTreeLocation.values()).forEach(rareTree -> - Arrays.stream(rareTree.getLocations()) - .map(point -> new RareTreePoint(point, - rareTree.getTooltip(), - woodcuttingLevel > 0 && config.rareTreeLevelIcon() && - rareTree.getLevelReq() > woodcuttingLevel ? NOPE_ICON : BLANK_ICON, - config.rareTreeTooltips())) - .forEach(worldMapPointManager::add)); - } - } - - private void updateQuestStartPointIcons() - { - worldMapPointManager.removeIf(QuestStartPoint.class::isInstance); - - if (config.questStartTooltips() || config.questProgressIcon()) - { - Arrays.stream(QuestStartLocation.values()) - .map(value -> - { - BufferedImage icon; - String tooltip = ""; - - if (config.questStartTooltips()) - { - tooltip += " - " + value.getTooltip(); - } - - if (config.questProgressIcon() && value.getQuest() != null) - { - switch (value.getQuest().getState(client)) - { - case FINISHED: - icon = FINISHED_ICON; - tooltip += " - Finished"; - break; - case IN_PROGRESS: - icon = STARTED_ICON; - tooltip += " - Started"; - break; - default: - icon = BLANK_ICON; - break; - } - } - else - { - icon = BLANK_ICON; - } - - return new QuestStartPoint(value, icon, tooltip); - - }) - .forEach(worldMapPointManager::add); + Arrays.stream(rareTree.getLocations()) + .map(point -> new RareTreePoint(point, + rareTree.getTooltip(), + woodcuttingLevel > 0 && config.rareTreeLevelIcon() && + rareTree.getLevelReq() > woodcuttingLevel ? NOPE_ICON : BLANK_ICON, + config.rareTreeTooltips())) + .forEach(worldMapPointManager::add)); } } @@ -332,141 +205,70 @@ public class WorldMapPlugin extends Plugin if (config.fairyRingIcon() || config.fairyRingTooltips()) { Arrays.stream(FairyRingLocation.values()) - .map(value -> new FairyRingPoint(value, - config.fairyRingIcon() ? FAIRY_TRAVEL_ICON : BLANK_ICON, - config.fairyRingTooltips())) - .forEach(worldMapPointManager::add); + .map(value -> new FairyRingPoint(value, + config.fairyRingIcon() ? FAIRY_TRAVEL_ICON : BLANK_ICON, + config.fairyRingTooltips())) + .forEach(worldMapPointManager::add); } worldMapPointManager.removeIf(MinigamePoint.class::isInstance); if (config.minigameTooltip()) { Arrays.stream(MinigameLocation.values()) - .map(value -> new MinigamePoint(value, BLANK_ICON)) - .forEach(worldMapPointManager::add); + .map(value -> new MinigamePoint(value, BLANK_ICON)) + .forEach(worldMapPointManager::add); + } + + worldMapPointManager.removeIf(QuestStartPoint.class::isInstance); + if (config.questStartTooltips()) + { + Arrays.stream(QuestStartLocation.values()) + .map(value -> new QuestStartPoint(value, BLANK_ICON)) + .forEach(worldMapPointManager::add); } worldMapPointManager.removeIf(TransportationPoint.class::isInstance); - if (config.TransportationTeleportTooltips()) + if (config.transportationTeleportTooltips()) { Arrays.stream(TransportationPointLocation.values()) .map(value -> new TransportationPoint(value, BLANK_ICON)) .forEach((worldMapPointManager::add)); - } - worldMapPointManager.removeIf(FarmingPatchPoint.class::isInstance); if (config.farmingPatchTooltips()) { Arrays.stream(FarmingPatchLocation.values()).forEach(location -> - Arrays.stream(location.getLocations()) - .map(point -> new FarmingPatchPoint(point, location.getTooltip(), BLANK_ICON)) - .forEach(worldMapPointManager::add) + Arrays.stream(location.getLocations()) + .map(point -> new FarmingPatchPoint(point, location.getTooltip(), BLANK_ICON)) + .forEach(worldMapPointManager::add) ); } worldMapPointManager.removeIf(TeleportPoint.class::isInstance); Arrays.stream(TeleportLocationData.values()) - .filter(data -> + .filter(data -> + { + switch (data.getType()) { - switch (data.getType()) - { - case NORMAL_MAGIC: - return config.normalTeleportIcon(); - case ANCIENT_MAGICKS: - return config.ancientTeleportIcon(); - case LUNAR_MAGIC: - return config.lunarTeleportIcon(); - case ARCEUUS_MAGIC: - return config.arceuusTeleportIcon(); - case JEWELLERY: - return config.jewelleryTeleportIcon(); - case SCROLL: - return config.scrollTeleportIcon(); - case OTHER: - return config.miscellaneousTeleportIcon(); - default: - return false; - } - }).map(TeleportPoint::new) - .forEach(worldMapPointManager::add); - } - - private WorldPoint loadWayPoint() - { - String json = configManager.getConfiguration(WorldMapPlugin.CONFIG_KEY, "waypoint_data"); - - if (Strings.isNullOrEmpty(json)) - { - return null; - } - - return gson.fromJson(json, WorldPoint.class); - } - - private void saveWayPoint() - { - if (wayPoint == null) - { - configManager.unsetConfiguration(WorldMapPlugin.CONFIG_KEY, "waypoint_data"); - return; - } - - String json = gson.toJson(wayPoint); - configManager.setConfiguration(WorldMapPlugin.CONFIG_KEY, "waypoint_data", json); - } - - public void setWayPoint(WorldPoint point) - { - wayPoint = point; - saveWayPoint(); - updateWayPoint(); - sendChatMessage(WAYPOINT_SET_MESSAGE); - } - - public void removeWayPoint() - { - wayPoint = null; - saveWayPoint(); - updateWayPoint(); - sendChatMessage(WAYPOINT_UNSET_MESSAGE); - } - - public boolean hasWayPoint() - { - return (wayPoint != null); - } - - private void updateWayPoint() - { - client.clearHintArrow(); - worldMapPointManager.removeIf(WayPointWorldMapPoint.class::isInstance); - - if (!config.isWaypointEnabled()) - { - return; - } - - if (wayPoint == null) - { - return; - } - - client.setHintArrow(wayPoint); - worldMapPointManager.add(new WayPointWorldMapPoint(wayPoint)); - } - - private void sendChatMessage(String chatMessage) - { - final String message = new ChatMessageBuilder() - .append(chatMessage) - .build(); - - chatMessageManager.queue( - QueuedMessage.builder() - .type(ChatMessageType.CONSOLE) - .runeLiteFormattedMessage(message) - .build()); + case NORMAL_MAGIC: + return config.normalTeleportIcon(); + case ANCIENT_MAGICKS: + return config.ancientTeleportIcon(); + case LUNAR_MAGIC: + return config.lunarTeleportIcon(); + case ARCEUUS_MAGIC: + return config.arceuusTeleportIcon(); + case JEWELLERY: + return config.jewelleryTeleportIcon(); + case SCROLL: + return config.scrollTeleportIcon(); + case OTHER: + return config.miscellaneousTeleportIcon(); + default: + return false; + } + }).map(TeleportPoint::new) + .forEach(worldMapPointManager::add); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderConfig.java new file mode 100644 index 0000000000..da657fdee1 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderConfig.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.worldmaphider; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("worldMapHider") +public interface WorldMapHiderConfig extends Config +{ + @ConfigItem( + position = 0, + keyName = "hideWorldMapButton", + name = "Hide World Map Button", + description = "Hides the world map button. Prevents missclicks that open the world map" + ) + default boolean hideWorldMapButton() + { + return false; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderPlugin.java new file mode 100644 index 0000000000..d1f2971cd6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmaphider/WorldMapHiderPlugin.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2019. PKLite - All Rights Reserved + * Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. + * Proprietary and confidential. Refer to PKLite License file for more information on + * full terms of this copyright and to determine what constitutes authorized use. + * Written by PKLite(ST0NEWALL, others) , 2019 + * + */ + +package net.runelite.client.plugins.worldmaphider; + +import com.google.common.collect.ImmutableList; +import com.google.inject.Provides; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.WidgetLoaded; +import net.runelite.api.events.WidgetMenuOptionClicked; +import net.runelite.api.widgets.WidgetID; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.menus.MenuManager; +import net.runelite.client.menus.WidgetMenuOption; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; + +@PluginDescriptor( + name = "Hide Worldmap Button", + description = "Hides the world map button", + type = "PVM", + tags = {"world", "world map", "hide", "button", "map", "hide world map", "pklite"} +) +public class WorldMapHiderPlugin extends Plugin +{ + @Inject + private Client client; + + @Inject + private MenuManager menuManager; + + @Inject + private WorldMapHiderConfig config; + + @Inject + private ConfigManager configManager; + + private WidgetMenuOption hideWidgetMenuOption = new WidgetMenuOption("Hide Map Button", + "Hide Map Button", WidgetInfo.WORLD_MAP_OPTION); + + private ImmutableList widgetList = + ImmutableList.of(WidgetInfo.WORLD_MAP_OPTION, WidgetInfo.WORLD_MAP_BUTTON_BORDER, + WidgetInfo.MINIMAP_WORLD_ORB); + + @Provides + WorldMapHiderConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(WorldMapHiderConfig.class); + } + + @Override + protected void startUp() + { + menuManager.addManagedCustomMenu(hideWidgetMenuOption); + } + + @Override + protected void shutDown() throws Exception + { + if (config.hideWorldMapButton()) + { + setMapHidden(false); + } + menuManager.removeManagedCustomMenu(hideWidgetMenuOption); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (config.hideWorldMapButton()) + { + setMapHidden(true); + } + if (!config.hideWorldMapButton()) + { + setMapHidden(false); + } + } + + @Subscribe + public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event) + { + if (event.getMenuOption().equals("Hide Map Button")) + { + configManager.setConfiguration("worldMapHider", "hideWorldMapButton", true); + } + } + + @Subscribe + public void onWidgetLoaded(WidgetLoaded event) + { + if (config.hideWorldMapButton() && event.getGroupId() == WidgetID.MINIMAP_GROUP_ID) + { + setMapHidden(true); + } + } + + private void setMapHidden(Boolean hidden) + { + if (widgetList.size() > 0) + widgetList.forEach(widgetInfo -> + { + if (widgetInfo != null && client.getWidget(widgetInfo) != null) + { + client.getWidget(widgetInfo).setHidden(hidden); + } + }); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/BloatTimerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/BloatTimerOverlay.java new file mode 100644 index 0000000000..fec801ab51 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/BloatTimerOverlay.java @@ -0,0 +1,83 @@ +package net.runelite.client.plugins.ztob; + +import net.runelite.api.Client; +import net.runelite.api.Perspective; +import net.runelite.api.Point; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.coords.WorldPoint; +import net.runelite.client.ui.overlay.*; + +import javax.inject.Inject; +import java.awt.*; + +public class BloatTimerOverlay extends Overlay { + + private final Client client; + private final TheatrePlugin plugin; + private final TheatreConfig config; + + @Inject + private BloatTimerOverlay(Client client, TheatrePlugin plugin, TheatreConfig config) { + this.client = client; + this.plugin = plugin; + this.config = config; + setPosition(OverlayPosition.DYNAMIC); + setPriority(OverlayPriority.HIGH); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + public Dimension render(Graphics2D graphics) { + + if (config.bloatTimer()) { + final String tickCounter = String.valueOf(plugin.bloatTimer); + int secondConversion = (int) (plugin.bloatTimer * .6); + if (plugin.getBloat_NPC() != null) { + Point canvasPoint = plugin.getBloat_NPC().getCanvasTextLocation(graphics, tickCounter, 60); + if (plugin.bloatTimer <= 37) { + renderTextLocation(graphics, tickCounter + "( " + secondConversion + " )", 15, Font.BOLD, Color.WHITE, canvasPoint); + } else { + renderTextLocation(graphics, tickCounter + "( " + secondConversion + " )", 15, Font.BOLD, Color.RED, canvasPoint); + } + } + } + + + return null; + } + + private void drawTile(Graphics2D graphics, WorldPoint point, Color color, int strokeWidth, int outlineAlpha, int fillAlpha) { + WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation(); + if (point.distanceTo(playerLocation) >= 32) { + return; + } + LocalPoint lp = LocalPoint.fromWorld(client, point); + if (lp == null) { + return; + } + + Polygon poly = Perspective.getCanvasTilePoly(client, lp); + if (poly == null) { + return; + } + //OverlayUtil.renderPolygon(graphics, poly, color); + graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha)); + graphics.setStroke(new BasicStroke(strokeWidth)); + graphics.draw(poly); + graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha)); + graphics.fill(poly); + } + + private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, net.runelite.api.Point canvasPoint) { + graphics.setFont(new Font("Arial", fontStyle, fontSize)); + if (canvasPoint != null) { + final net.runelite.api.Point canvasCenterPoint = new net.runelite.api.Point( + canvasPoint.getX(), + canvasPoint.getY()); + final net.runelite.api.Point canvasCenterPoint_shadow = new Point( + canvasPoint.getX() + 1, + canvasPoint.getY() + 1); + OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK); + OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, txtString, fontColor); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreConfig.java index 6f63951785..0a0a33d982 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreConfig.java @@ -14,15 +14,16 @@ import net.runelite.client.config.ConfigItem; @ConfigGroup("Theatre") -public interface TheatreConfig extends Config -{ +public interface TheatreConfig extends Config { @ConfigItem( position = 0, keyName = "MaidenBlood", name = "Maiden blood attack", description = "" ) - default boolean MaidenBlood(){ return false; } + default boolean MaidenBlood() { + return true; + } @ConfigItem( position = 1, @@ -30,109 +31,181 @@ public interface TheatreConfig extends Config name = "Maiden blood spawns", description = "" ) - default boolean MaidenSpawns(){ return false; } + default boolean MaidenSpawns() { + return true; + } @ConfigItem( position = 2, keyName = "BloatIndicator", - name = "Bloat indicator", + name = "Bloat Indicator", description = "" ) - default boolean BloatIndicator(){ return false; } + default boolean BloatIndicator() { + return true; + } @ConfigItem( position = 3, - keyName = "BloatHands", - name = "Bloat Falling Hands", + keyName = "bloat Timer", + name = "Bloat Timer", description = "" ) - default boolean BloatHands(){ return false; } + default boolean bloatTimer() { + return true; + } @ConfigItem( position = 4, + keyName = "bloatFeet", + name = "Bloat Feet", + description = "" + ) + default boolean bloatFeetIndicator() { + return true; + } + + @ConfigItem( + position = 5, keyName = "NyloPillars", name = "Nylocas pillar health", description = "" ) - default boolean NyloPillars(){ return false; } + default boolean NyloPillars() { + return true; + } + @ConfigItem( - position = 5, + position = 6, keyName = "NyloBlasts", name = "Nylocas explosions", description = "" ) - default boolean NyloBlasts(){ return false; } + default boolean NyloBlasts() { + return true; + } @ConfigItem( - position = 6, + position = 7, + keyName = "NyloMenu", + name = "Hide Attack options for Nylocas", + description = "" + ) + + default boolean NyloMenu() { + return true; + } + + @ConfigItem( + position = 8, keyName = "SotetsegMaze1", name = "Sotetseg maze", description = "" ) - default boolean SotetsegMaze1(){ return false; } + default boolean SotetsegMaze1() { + return true; + } @ConfigItem( - position = 7, + position = 9, keyName = "SotetsegMaze2", name = "Sotetseg maze (solo mode)", description = "" ) - default boolean SotetsegMaze2(){ return false; } - - @ConfigItem( - position = 8, - keyName = "SotetsegTick", - name = "Sotetseg tick eat", - description = "" - ) - default boolean SotetsegTick(){ return false; } - - @ConfigItem( - position = 9, - keyName = "XarpusExhumed", - name = "Xarpus exhumed", - description = "" - ) - default boolean XarpusExhumed(){ return false; } + default boolean SotetsegMaze2() { + return true; + } @ConfigItem( position = 10, - keyName = "XarpusTick", - name = "Xarpus tick", + keyName = "XarpusExhumed", + name = "Xarpus Exhumed", description = "" ) - default boolean XarpusTick(){ return false; } + default boolean XarpusExhumed() { + return true; + } @ConfigItem( position = 11, - keyName = "VerzikCupcakes", - name = "Verzik cupcakes", - description = " " + keyName = "XarpusTick", + name = "Xarpus Tick", + description = "" ) - default boolean VerzikCupcakes(){ return false; } + default boolean XarpusTick() { + return false; + } @ConfigItem( position = 12, - keyName = "VerzikTick", - name = "Verzik p3 tick", + keyName = "xarpusExhumes", + name = "Xarpus Exhume Counter", description = "" ) - default boolean VerzikTick(){ return false; } + default boolean XarpusExhumeOverlay() { + return false; + } @ConfigItem( position = 13, - keyName = "VerzikMelee", - name = "Verzik p3 melee range", + keyName = "VerzikCupcakes", + name = "Verzik Projectile Markers", description = "" ) - default boolean VerzikMelee(){ return false; } + default boolean VerzikCupcakes() { + return false; + } @ConfigItem( position = 14, - keyName = "VerzikYellow", - name = "Verzik yellow timing", + keyName = "VerzikTick", + name = "Verzik P3 Tick", description = "" ) - default boolean VerzikYellow(){ return false; } -} + default boolean VerzikTick() { + return false; + } + + @ConfigItem( + position = 15, + keyName = "VerzikMelee", + name = "Verzik P3 Melee Range", + description = "" + ) + default boolean VerzikMelee() { + return false; + } + + @ConfigItem( + position = 16, + keyName = "VerzikYellow", + name = "Verzik Yellow Timing", + description = "" + ) + default boolean VerzikYellow() { + return false; + } + + @ConfigItem( + position = 17, + keyName = "Verzik Nylo", + name = "Verzik Nylo Overlay", + description = "" + ) + default boolean NyloTargetOverlay() { + return false; + } + + @ConfigItem( + position = 18, + keyName = "VerzikTankTile", + name = "Verzik P3 Tile Overlay", + description = "" + ) + default boolean verzikTankTile() { + return true; + } + + +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreOverlay.java index 07f8e2f7b4..8e650295a7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreOverlay.java @@ -8,27 +8,21 @@ package net.runelite.client.plugins.ztob; +import net.runelite.api.Point; +import net.runelite.api.*; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.coords.WorldArea; +import net.runelite.api.coords.WorldPoint; +import net.runelite.client.ui.overlay.*; + +import javax.inject.Inject; import java.awt.*; import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.inject.Inject; - -import net.runelite.api.*; -import net.runelite.api.Point; -import net.runelite.api.coords.LocalPoint; -import net.runelite.api.coords.WorldArea; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; public class TheatreOverlay extends Overlay { private final Client client; - - private final TheatrePlugin plugin; private final TheatreConfig config; @@ -43,69 +37,71 @@ public class TheatreOverlay extends Overlay { } @Override - public Dimension render(Graphics2D graphics) - { - if (plugin.isRunMaiden()) - { - if (config.MaidenBlood()) - { - for (WorldPoint point : plugin.getMaiden_BloodSpatters()) - { - drawTile(graphics, point, new Color(0,150,200), 2, 150, 10); + public Dimension render(Graphics2D graphics) { + if (plugin.isRunMaiden()) { + if (config.MaidenBlood()) { + for (WorldPoint point : plugin.getMaiden_BloodSpatters()) { + drawTile(graphics, point, new Color(36, 248, 229), 2, 150, 10); } } - if (config.MaidenSpawns()) - { - for (WorldPoint point : plugin.getMaiden_SpawnLocations()) - { - drawTile(graphics, point, new Color(0,150,200), 2, 180, 20); + if (config.MaidenSpawns()) { + for (WorldPoint point : plugin.getMaiden_SpawnLocations()) { + drawTile(graphics, point, new Color(36, 248, 229), 2, 180, 20); } - for (WorldPoint point : plugin.getMaiden_SpawnLocations2()) - { - drawTile(graphics, point, new Color(0,150,200), 1,120, 10); + for (WorldPoint point : plugin.getMaiden_SpawnLocations2()) { + drawTile(graphics, point, new Color(36, 248, 229), 1, 120, 10); } } } - if (plugin.isRunBloat()) - { + if (plugin.isRunBloat() && config.BloatIndicator()) { + if (config.bloatFeetIndicator()) { + if (plugin.getTemp().size() > 0) { + if (plugin.isTempFlag()) { + for (WorldPoint point : plugin.getTemp()) { - if (config.BloatHands()) - { - for (WorldPoint p : plugin.getBloat_Hands()) - { - drawTile(graphics, p, Color.BLACK,3,255,0); + drawTile(graphics, point, Color.black, 4, 255, 0); + + } + + } + } else if (plugin.getTemp2().size() > 0) { + if (plugin.isTemp2Flag()) { + for (WorldPoint point : plugin.getTemp2()) { + + drawTile(graphics, point, Color.black, 4, 255, 0); + + + } + + } } } - if(config.BloatIndicator()) { - NPC bloat = plugin.getBloat_NPC(); - int state = plugin.getBloat_State(); - if (bloat == null) { - return null; - } - switch (state) { - case 2: - renderNpcOverlay(graphics, bloat, Color.GREEN, 3, 150, 0); - break; - case 3: - renderNpcOverlay(graphics, bloat, Color.YELLOW, 3, 150, 0); - break; - default: - renderNpcOverlay(graphics, bloat, new Color(223, 109, 255), 3, 150, 0); - break; - } + NPC bloat = plugin.getBloat_NPC(); + int state = plugin.getBloat_State(); + if (bloat == null) { + return null; + } + switch (state) { + case 2: + renderNpcOverlay(graphics, bloat, Color.GREEN, 3, 150, 0); + break; + case 3: + renderNpcOverlay(graphics, bloat, Color.YELLOW, 3, 150, 0); + break; + default: + renderNpcOverlay(graphics, bloat, new Color(223, 109, 255), 3, 150, 0); + break; } } - if (plugin.isRunNylocas()) - { - if (config.NyloPillars()) - { + if (plugin.isRunNylocas()) { + if (config.NyloPillars()) { Map pillars = plugin.getNylocas_Pillars(); for (NPC npc : pillars.keySet()) { final int health = pillars.get(npc); - final String healthStr = String.valueOf(health) + "%"; + final String healthStr = health + "%"; WorldPoint p = npc.getWorldLocation(); LocalPoint lp = LocalPoint.fromWorld(client, p.getX() + 1, p.getY() + 1); final double rMod = 130.0 * health / 100.0; @@ -118,41 +114,34 @@ public class TheatreOverlay extends Overlay { } } - if (config.NyloBlasts()) - { + if (config.NyloBlasts()) { final Map npcMap = plugin.getNylocas_Map(); - for (NPC npc : npcMap.keySet()) - { + for (NPC npc : npcMap.keySet()) { int ticksLeft = npcMap.get(npc); if (ticksLeft > -1) { if (ticksLeft <= 6) { - Color color = new Color(255, 255,0 ,180); + Color color = new Color(255, 255, 0, 180); int outlineWidth = 2; int outlineAlpha = 150; - renderNpcOverlay(graphics, npc, color, outlineWidth, outlineAlpha, 0); + renderNpcOverlay(graphics, npc, color, outlineWidth, outlineAlpha, 15); } } } } } - if (plugin.isRunSotetseg()) - { - if (config.SotetsegMaze1()) - { + if (plugin.isRunSotetseg()) { + if (config.SotetsegMaze1()) { int i = 1; - for (GroundObject z : plugin.getRedTiles().keySet()) - { - Polygon poly = z.getCanvasTilePoly(); - if (poly != null) - { + for (GroundObject o : plugin.getRedTiles().keySet()) { + Polygon poly = o.getCanvasTilePoly(); + if (poly != null) { graphics.setColor(Color.WHITE); graphics.setStroke(new BasicStroke(2)); graphics.draw(poly); } - Point textLocation = z.getCanvasTextLocation(graphics, String.valueOf(i), 0); - if (textLocation != null) - { + Point textLocation = o.getCanvasTextLocation(graphics, String.valueOf(i), 0); + if (textLocation != null) { OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(i), Color.WHITE); } @@ -160,111 +149,111 @@ public class TheatreOverlay extends Overlay { } } - if (config.SotetsegMaze2()) - { - for (WorldPoint p : plugin.getRedTilesOverworld()) - { + if (config.SotetsegMaze2()) { + for (WorldPoint p : plugin.getRedTilesOverworld()) { drawTile(graphics, p, Color.WHITE, 2, 255, 10); } } - if (config.SotetsegTick()) { - NPC boss = plugin.getSotetseg_NPC(); - int eattick = plugin.getTickTillEat(); - if (eattick > -1) - { - final String eatTicksStr = String.valueOf(eattick); - Point canvasPoint = boss.getCanvasTextLocation(graphics, eatTicksStr, 130); - renderTextLocation(graphics, eatTicksStr, 12, Font.BOLD, Color.WHITE, canvasPoint); - - } - } } - - if (plugin.isRunXarpus()) - { + if (plugin.isRunXarpus()) { NPC boss = plugin.getXarpus_NPC(); - if (boss.getId() == NpcID.XARPUS_8340 && !plugin.isXarpus_Stare() && config.XarpusTick()) - { + if (boss.getId() == NpcID.XARPUS_8340 && !plugin.isXarpus_Stare() && config.XarpusTick()) { int tick = plugin.getXarpus_TicksUntilShoot(); - if (tick < 1) - { + if (tick < 1) { tick = tick % 4 + 4; } final String ticksLeftStr = String.valueOf(tick); Point canvasPoint = boss.getCanvasTextLocation(graphics, ticksLeftStr, 130); renderTextLocation(graphics, ticksLeftStr, 12, Font.BOLD, Color.WHITE, canvasPoint); } - if (boss.getId() == NpcID.XARPUS_8339 && config.XarpusExhumed()) - { - for (GroundObject o : plugin.getXarpus_Exhumeds().keySet()) - { + if (boss.getId() == NpcID.XARPUS_8339 && config.XarpusExhumed()) { + for (GroundObject o : plugin.getXarpus_Exhumeds().keySet()) { + + Polygon poly = o.getCanvasTilePoly(); - if (poly != null) - { + if (poly != null) { graphics.setColor(new Color(0, 255, 0, 130)); graphics.setStroke(new BasicStroke(1)); graphics.draw(poly); } } + for (Map.Entry exhumes : plugin.getXarpusExhumedsTimer().entrySet()) { + final String ticksremaining = String.valueOf(exhumes.getValue()); + if (Integer.valueOf(ticksremaining) > 0) { + GroundObject ex = exhumes.getKey(); + Point point = ex.getCanvasTextLocation(graphics, ticksremaining, 0); + renderTextLocation(graphics, ticksremaining, 12, Font.BOLD, Color.white, point); + } + + } + + } + } - if (plugin.isRunVerzik()) - { - if (config.VerzikCupcakes()) - { - for (WorldPoint p : plugin.getVerzik_RangeProjectiles().values()) - { + + if (plugin.isRunVerzik()) { + + + if (config.VerzikCupcakes()) { + for (WorldPoint p : plugin.getVerzik_RangeProjectiles().values()) { drawTile(graphics, p, Color.RED, 2, 180, 50); } } - if (config.VerzikYellow()) - { - for (WorldPoint p : plugin.getVerzik_YellowTiles()) - { - drawTile(graphics, p, Color.YELLOW,3,255,0); - + if (config.VerzikYellow()) { + for (WorldPoint p : plugin.getVerzik_YellowTiles()) { + drawTile(graphics, p, Color.YELLOW, 3, 255, 0); Projectile yellowBall = plugin.getVerzik_YellowBall(); - if (yellowBall != null) - { - final int ticksToImpact = yellowBall.getRemainingCycles()/30; + if (yellowBall != null) { + final int ticksToImpact = yellowBall.getRemainingCycles() / 30; final String countdownStr = String.valueOf(ticksToImpact); Point canvasPoint = Perspective.getCanvasTextLocation(client, graphics, LocalPoint.fromWorld(client, p), countdownStr, 0); renderTextLocation(graphics, countdownStr, 12, Font.BOLD, Color.WHITE, canvasPoint); + } } } - if (plugin.getVerzik_NPC_P3() != null) { - final NPC boss = plugin.getVerzik_NPC_P3(); - if (boss.getId() == NpcID.VERZIK_VITUR_8374) - { - if (config.VerzikTick()) - { - final int ticksLeft = plugin.getP3_TicksUntilAttack(); - if (ticksLeft > 0 && ticksLeft < 8) - { - final String ticksLeftStr = String.valueOf(ticksLeft); - Point canvasPoint = boss.getCanvasTextLocation(graphics, ticksLeftStr, 60); - renderTextLocation(graphics, ticksLeftStr, 15, Font.BOLD, Color.WHITE, canvasPoint); - } + + final NPC boss = plugin.getVerzik_NPC(); + if (boss.getId() == NpcID.VERZIK_VITUR_8374) { + if (config.verzikTankTile()) { + renderNpcOverlay(graphics, boss, new Color(75, 0, 130), 1, 255, 0); + } + + if (config.VerzikTick()) { + final int ticksLeft = plugin.getP3_TicksUntilAttack(); + if (ticksLeft > 0 && ticksLeft < 8) { + final String ticksLeftStr = String.valueOf(ticksLeft); + Point canvasPoint = boss.getCanvasTextLocation(graphics, ticksLeftStr, 60); + renderTextLocation(graphics, ticksLeftStr, 15, Font.BOLD, Color.WHITE, canvasPoint); } + } - if (config.VerzikMelee() && boss.getAnimation() != 8127) - { - List meleeRange = getHitSquares(boss.getWorldLocation(), 7, 1, false); + if (config.VerzikMelee()) { + List meleeRange = getHitSquares(boss.getWorldLocation(), 7, 1, false); - for (WorldPoint p : meleeRange) - { - drawTile(graphics, p, Color.WHITE, 1,155, 10); - } + for (WorldPoint p : meleeRange) { + drawTile(graphics, p, Color.WHITE, 1, 155, 10); } } } + + if (boss.getAnimation() == 8117) { + final int ticksLeft = plugin.getRedCrabsTimer(); + if (ticksLeft > 0) { + final String ticksLeftStr = String.valueOf(ticksLeft); + Point canvasPoint = boss.getCanvasTextLocation(graphics, ticksLeftStr, 60); + renderTextLocation(graphics, ticksLeftStr, 15, Font.BOLD, Color.WHITE, canvasPoint); + } + } + } + return null; } @@ -290,19 +279,16 @@ public class TheatreOverlay extends Overlay { graphics.fill(poly); } - private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha) - { + private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha) { int size = 1; NPCComposition composition = actor.getTransformedComposition(); - if (composition != null) - { + if (composition != null) { size = composition.getSize(); } LocalPoint lp = actor.getLocalLocation(); Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size); - if (tilePoly != null) - { + if (tilePoly != null) { graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha)); graphics.setStroke(new BasicStroke(outlineWidth)); graphics.draw(tilePoly); @@ -311,37 +297,31 @@ public class TheatreOverlay extends Overlay { } } - private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint) - { + private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint) { graphics.setFont(new Font("Arial", fontStyle, fontSize)); - if (canvasPoint != null) - { + if (canvasPoint != null) { final Point canvasCenterPoint = new Point( canvasPoint.getX(), canvasPoint.getY()); final Point canvasCenterPoint_shadow = new Point( canvasPoint.getX() + 1, - canvasPoint.getY() + 1) ; + canvasPoint.getY() + 1); OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK); OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, txtString, fontColor); } } - private List getHitSquares(WorldPoint npcLoc, int npcSize, int thickness, boolean includeUnder) - { + private List getHitSquares(WorldPoint npcLoc, int npcSize, int thickness, boolean includeUnder) { List little = new WorldArea(npcLoc, npcSize, npcSize).toWorldPointList(); - List big = new WorldArea(npcLoc.getX()-thickness, npcLoc.getY()-thickness, npcSize + (thickness * 2), npcSize + (thickness * 2), npcLoc.getPlane()).toWorldPointList(); - if (!includeUnder) - { - for (Iterator it = big.iterator(); it.hasNext();) - { + List big = new WorldArea(npcLoc.getX() - thickness, npcLoc.getY() - thickness, npcSize + (thickness * 2), npcSize + (thickness * 2), npcLoc.getPlane()).toWorldPointList(); + if (!includeUnder) { + for (Iterator it = big.iterator(); it.hasNext(); ) { WorldPoint p = it.next(); - if (little.contains(p)) - { + if (little.contains(p)) { it.remove(); } } } return big; } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java index 8fa2ee2481..fe91da0930 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java @@ -8,28 +8,30 @@ package net.runelite.client.plugins.ztob; -import java.util.*; -import java.util.Iterator; -import javax.inject.Inject; - -import net.runelite.client.chat.ChatMessageManager; -import net.runelite.client.eventbus.Subscribe; import com.google.inject.Provides; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.*; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.*; +import net.runelite.api.kit.KitType; +import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.util.Text; + +import javax.inject.Inject; +import java.util.*; @PluginDescriptor( - name = "!Theatre of Blood", + name = "Theater of Blood", description = "All-in-one plugin for Theatre of Blood", tags = {"ToB"}, - enabledByDefault = false + enabledByDefault = false, + type = "PVM" ) public class TheatrePlugin extends Plugin { @@ -40,11 +42,6 @@ public class TheatrePlugin extends Plugin { private static final int GROUNDOBJECT_ID_EXHUMED = 32743; private static final int ANIMATION_ID_XARPUS = 8059; private static final int GRAPHICSOBJECT_ID_YELLOW = 1595; - private static final int GRAPHICSOBJECT_ID_BLOAT_HAND1 = 1570; - private static final int GRAPHICSOBJECT_ID_BLOAT_HAND2 = 1571; - private static final int GRAPHICSOBJECT_ID_BLOAT_HAND3 = 1572; - private static final int GRAPHICSOBJECT_ID_BLOAT_HAND4 = 1573; - private static final int GRAPHICSOBJECT_ID_BLOAT_HAND5 = 1576; private static final int PROJECTILE_ID_P2RANGE = 1583; private static final int PROJECTILE_ID_YELLOW = 1596; private static final int ANIMATION_ID_P3_WEB = 8127; @@ -55,11 +52,30 @@ public class TheatrePlugin extends Plugin { private static final int VERZIK_ID_P3 = NpcID.VERZIK_VITUR_8374; private static final int NPC_ID_TORNADO = 8386; private static final int PROJECTILE_ID_P3_GREEN = 1598; - private static final String sotmsg = "A large ball of energy is shot your way..."; - private static final String sotmsg1 = "A large ball of energy is shot your way..."; - @Inject - private ChatMessageManager chatMessageManager; + + @Getter(AccessLevel.PACKAGE) + private final Map xarpusExhumedsTimer = new HashMap<>(); + @Getter + int exhumecount; + @Getter + int bloatTimer = 0; + + int bloatFeetTimer = 0; + NPC BossNylo = null; + private boolean bloatFlag = false; + @Getter + private Set bloatTiles = new HashSet<>(); + @Getter + private Set temp = new HashSet<>(); + @Getter + private Set temp2 = new HashSet<>(); + @Getter + private Set localTemp = new HashSet<>(); + + //@Getter + //private List bloatTiles = new ArrayList<>(); + @Getter(AccessLevel.PACKAGE) private boolean runMaiden; @@ -79,9 +95,6 @@ public class TheatrePlugin extends Plugin { @Getter(AccessLevel.PACKAGE) private boolean runBloat; - @Getter(AccessLevel.PACKAGE) - private int TickTillEat = 20; - @Getter(AccessLevel.PACKAGE) private NPC Bloat_NPC; @@ -111,12 +124,13 @@ public class TheatrePlugin extends Plugin { private List RedTilesOverworld = new ArrayList<>(); private List BlackTilesOverworld = new ArrayList<>(); - - private List BlackTilesUnderworld= new ArrayList<>(); - - private List RedTilesUnderworld= new ArrayList<>(); + @Getter + private boolean tempFlag = false; + @Getter + private boolean temp2Flag = false; private List GridPath = new ArrayList<>(); + private List BlackTilesUnderworld = new ArrayList<>(); @Getter(AccessLevel.PACKAGE) private boolean runXarpus; @@ -128,6 +142,7 @@ public class TheatrePlugin extends Plugin { @Getter(AccessLevel.PACKAGE) private final Map Xarpus_Exhumeds = new HashMap<>(); + private List RedTilesUnderworld = new ArrayList<>(); @Getter(AccessLevel.PACKAGE) private int Xarpus_TicksUntilShoot = 9; @@ -135,9 +150,6 @@ public class TheatrePlugin extends Plugin { @Getter(AccessLevel.PACKAGE) private NPC Xarpus_NPC; - @Getter(AccessLevel.PACKAGE) - private NPC Sotetseg_NPC; - @Getter(AccessLevel.PACKAGE) private boolean runVerzik; @@ -153,17 +165,16 @@ public class TheatrePlugin extends Plugin { @Getter(AccessLevel.PACKAGE) private List Verzik_YellowTiles = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) - private List Bloat_Hands = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) private NPC Verzik_NPC; + @Getter(AccessLevel.PACKAGE) + private List tornadoList; @Getter(AccessLevel.PACKAGE) - private NPC Verzik_NPC_P3; + private List crabList; - @Getter(AccessLevel.PACKAGE) - private NPC Verzik_NPC_P2; + @Getter + private int redCrabsTimer; private int P3_attacksLeft; @@ -179,6 +190,18 @@ public class TheatrePlugin extends Plugin { @Inject private TheatreConfig config; + @Inject + private TheatreXarpusOverlay xarpusOverlay; + + @Inject + private ChatMessageManager chatMessageManager; + + @Inject + private VerzikNyloOverlay verzikNyloOverlay; + + @Inject + private BloatTimerOverlay bloatTimerOverlay; + @Provides TheatreConfig getConfig(ConfigManager configManager) { return configManager.getConfig(TheatreConfig.class); @@ -187,19 +210,116 @@ public class TheatrePlugin extends Plugin { @Override protected void startUp() { overlayManager.add(overlay); + overlayManager.add(xarpusOverlay); + overlayManager.add(verzikNyloOverlay); + overlayManager.add(bloatTimerOverlay); } @Override protected void shutDown() { overlayManager.remove(overlay); + overlayManager.remove(xarpusOverlay); + overlayManager.remove(xarpusOverlay); + overlayManager.remove(bloatTimerOverlay); + } + + + @Subscribe + public void onMenuEntryAdded(MenuEntryAdded event) { + if (client.getGameState() != GameState.LOGGED_IN || !config.NyloMenu() || !runNylocas) { + return; + } + + final String pOptionToReplace = Text.removeTags(event.getOption()).toUpperCase(); + Map playerEquipment = new HashMap<>(); + + int attackType = 0; //0=idk 1= melee 2= range 3= mage + + for (KitType kitType : KitType.values()) { + + int itemId = client.getLocalPlayer().getPlayerComposition().getEquipmentId(kitType); + switch (itemId) { + case ItemID.DRAGON_CLAWS: + case ItemID.SCYTHE_OF_VITUR: + case ItemID.SCYTHE_OF_VITUR_UNCHARGED: + case ItemID.SCYTHE_10735: + case ItemID.SCYTHE_OF_VITUR_22664: + case ItemID.HAM_JOINT: + case ItemID.EVENT_RPG: + case ItemID.ABYSSAL_WHIP: + case ItemID.ABYSSAL_TENTACLE: + case ItemID.FROZEN_ABYSSAL_WHIP: + case ItemID.VOLCANIC_ABYSSAL_WHIP: + case ItemID.GHRAZI_RAPIER: + case ItemID.DRAGON_WARHAMMER: + case ItemID.DRAGON_WARHAMMER_20785: + case ItemID.BANDOS_GODSWORD: + case ItemID.BANDOS_GODSWORD_OR: + case ItemID.BANDOS_GODSWORD_20782: + case ItemID.BANDOS_GODSWORD_21060: + case ItemID.CRYSTAL_HALBERD_510: + case ItemID.CRYSTAL_HALBERD_510_I: + case ItemID.CRYSTAL_HALBERD_610: + case ItemID.CRYSTAL_HALBERD_610_I: + case ItemID.CRYSTAL_HALBERD_710_I: + case ItemID.CRYSTAL_HALBERD_710: + case ItemID.CRYSTAL_HALBERD_110: + case ItemID.CRYSTAL_HALBERD_110_I: + case ItemID.CRYSTAL_HALBERD_210: + case ItemID.CRYSTAL_HALBERD_310: + case ItemID.CRYSTAL_HALBERD_310_I: + case ItemID.CRYSTAL_HALBERD_410: + case ItemID.CRYSTAL_HALBERD_410_I: + case ItemID.CRYSTAL_HALBERD_810: + case ItemID.CRYSTAL_HALBERD_810_I: + case ItemID.CRYSTAL_HALBERD_910: + case ItemID.CRYSTAL_HALBERD_910_I: + attackType = 1; + break; + case ItemID.TOXIC_BLOWPIPE: + case ItemID.TOXIC_BLOWPIPE_EMPTY: + case ItemID.RED_CHINCHOMPA_10034: + case ItemID.BLACK_CHINCHOMPA: + case ItemID.CHINCHOMPA_10033: + case ItemID.TWISTED_BOW: + attackType = 2; + break; + case ItemID.SANGUINESTI_STAFF: + case ItemID.TOXIC_STAFF_OF_THE_DEAD: + case ItemID.TRIDENT_OF_THE_SWAMP: + case ItemID.TRIDENT_OF_THE_SEAS_E: + case ItemID.TRIDENT_OF_THE_SEAS: + case ItemID.TRIDENT_OF_THE_SWAMP_E: + case ItemID.KODAI_WAND: + case ItemID.MASTER_WAND: + case ItemID.MASTER_WAND_20560: + attackType = 3; + break; + } + if (attackType != 0) { + break; + } + + } + if (!pOptionToReplace.equals("ATTACK")) { + return; + } + int Id = 0; + if (BossNylo != null) { + Id = BossNylo.getId(); + } + String target = Text.removeTags(event.getTarget()).toLowerCase(); + if (attackType != 0) { + stripEntries(attackType, target, Id); + } + } @Subscribe - public void onNpcSpawned(NpcSpawned npcSpawned) - { + public void onNpcSpawned(NpcSpawned npcSpawned) { + NPC npc = npcSpawned.getNpc(); - switch (npc.getId()) - { + switch (npc.getId()) { case NpcID.THE_MAIDEN_OF_SUGADINTI: case NpcID.THE_MAIDEN_OF_SUGADINTI_8361: case NpcID.THE_MAIDEN_OF_SUGADINTI_8362: @@ -214,25 +334,40 @@ public class TheatrePlugin extends Plugin { case NpcID.PESTILENT_BLOAT: runBloat = true; Bloat_NPC = npc; + bloatTimer = 0; + bloatFlag = false; + break; + case NpcID.NYLOCAS_VASILIAS: + case NpcID.NYLOCAS_VASILIAS_8355: + case NpcID.NYLOCAS_VASILIAS_8356: + case NpcID.NYLOCAS_VASILIAS_8357: + BossNylo = npc; break; case NPCID_NYLOCAS_PILLAR: runNylocas = true; - if (!Nylocas_Pillars.keySet().contains(npc)) - { + if (!Nylocas_Pillars.keySet().contains(npc)) { Nylocas_Pillars.put(npc, 100); } break; - case 8342: case 8343: case 8344: case 8345: case 8346: case 8347: - case 8348: case 8349: case 8350: case 8351: case 8352: case 8353: - if (runNylocas) - { + case 8342: + case 8343: + case 8344: + case 8345: + case 8346: + case 8347: + case 8348: + case 8349: + case 8350: + case 8351: + case 8352: + case 8353: + if (runNylocas) { Nylocas_Map.put(npc, 52); } break; case NpcID.SOTETSEG: case NpcID.SOTETSEG_8388: runSotetseg = true; - Sotetseg_NPC = npc; RedTiles.clear(); break; case NpcID.XARPUS: @@ -240,6 +375,7 @@ public class TheatrePlugin extends Plugin { case NpcID.XARPUS_8340: case NpcID.XARPUS_8341: runXarpus = true; + exhumecount = 25; Xarpus_NPC = npc; Xarpus_Stare = false; Xarpus_TicksUntilShoot = 9; @@ -248,22 +384,17 @@ public class TheatrePlugin extends Plugin { case NpcID.VERZIK_VITUR_8369: case NpcID.VERZIK_VITUR_8370: case NpcID.VERZIK_VITUR_8371: + case NpcID.VERZIK_VITUR_8372: case NpcID.VERZIK_VITUR_8373: + case NpcID.VERZIK_VITUR_8374: case NpcID.VERZIK_VITUR_8375: + P3_TicksUntilAttack = -1; + P3_attacksLeft = 9; + redCrabsTimer = 13; Verzik_NPC = npc; runVerzik = true; - break; - - case NpcID.VERZIK_VITUR_8372:/*p2 spider*/ - Verzik_NPC_P2 = npc; - runVerzik = true; - break; - - case NpcID.VERZIK_VITUR_8374:/*p3 spider*/ - P3_TicksUntilAttack = 0; - P3_attacksLeft = 9; - Verzik_NPC_P3 = npc; - runVerzik = true; + tornadoList = new ArrayList<>(); + crabList = new ArrayList<>(); break; } } @@ -287,28 +418,35 @@ public class TheatrePlugin extends Plugin { case NpcID.PESTILENT_BLOAT: runBloat = false; Bloat_NPC = null; + bloatTimer = 0; break; case NPCID_NYLOCAS_PILLAR: - if (Nylocas_Pillars.keySet().contains(npc)) - { + if (Nylocas_Pillars.keySet().contains(npc)) { Nylocas_Pillars.remove(npc); } break; - case 8342: case 8343: case 8344: case 8345: case 8346: case 8347: - case 8348: case 8349: case 8350: case 8351: case 8352: case 8353: - if (Nylocas_Map.keySet().contains(npc)) - { + case 8342: + case 8343: + case 8344: + case 8345: + case 8346: + case 8347: + case 8348: + case 8349: + case 8350: + case 8351: + case 8352: + case 8353: + if (Nylocas_Map.keySet().contains(npc)) { Nylocas_Map.remove(npc); } break; case NpcID.SOTETSEG: case NpcID.SOTETSEG_8388: RedTiles.clear(); - if (client.getPlane() != 3) - { + if (client.getPlane() != 3) { runSotetseg = false; } - Sotetseg_NPC = null; break; case NpcID.XARPUS: case NpcID.XARPUS_8339: @@ -320,117 +458,119 @@ public class TheatrePlugin extends Plugin { Xarpus_TicksUntilShoot = 9; Xarpus_previousAnimation = -1; Xarpus_Exhumeds.clear(); + exhumecount = 0; break; case NpcID.VERZIK_VITUR_8369: case NpcID.VERZIK_VITUR_8370: - case NpcID.VERZIK_VITUR_8371:/*p2*/ - + case NpcID.VERZIK_VITUR_8371: + case NpcID.VERZIK_VITUR_8372: case NpcID.VERZIK_VITUR_8373: - + case NpcID.VERZIK_VITUR_8374: case NpcID.VERZIK_VITUR_8375: + runVerzik = false; + redCrabsTimer = 0; Verzik_NPC = null; break; - case NpcID.VERZIK_VITUR_8372: - Verzik_NPC_P2 = null; - break; - case NpcID.VERZIK_VITUR_8374:/*p3 spider*/ - Verzik_NPC_P3 = null; - break; - } } @Subscribe - public void onGroundObjectSpawned(GroundObjectSpawned event) - { - if (runSotetseg) - { + public void onGroundObjectSpawned(GroundObjectSpawned event) { + if (runSotetseg) { GroundObject o = event.getGroundObject(); - if (o.getId() == GROUNDOBJECT_ID_BLACKMAZE) - { + if (o.getId() == GROUNDOBJECT_ID_BLACKMAZE) { Tile t = event.getTile(); WorldPoint p = t.getWorldLocation(); - if (t.getPlane() == 0) - { + if (t.getPlane() == 0) { if (!BlackTilesOverworld.contains(p)) BlackTilesOverworld.add(p); - } - else - { + } else { if (!BlackTilesUnderworld.contains(p)) BlackTilesUnderworld.add(p); } } - if (o.getId() == GROUNDOBJECT_ID_REDMAZE) - { + if (o.getId() == GROUNDOBJECT_ID_REDMAZE) { Tile t = event.getTile(); WorldPoint p = t.getWorldLocation(); - if (p.getPlane() == 0) - { - if (!RedTiles.containsValue(t)) - { - RedTiles.put(o,t); + if (p.getPlane() == 0) { + if (!RedTiles.containsValue(t)) { + RedTiles.put(o, t); } - } - else - { + } else { if (!RedTilesUnderworld.contains(p)) RedTilesUnderworld.add(p); } } } - if (runXarpus) - { + if (runXarpus) { GroundObject o = event.getGroundObject(); - if (o.getId() == GROUNDOBJECT_ID_EXHUMED) - { + if (o.getId() == GROUNDOBJECT_ID_EXHUMED) { + + xarpusExhumedsTimer.put(o, 18); + Xarpus_Exhumeds.put(o, 18); + } + } } @Subscribe - public void onProjectileMoved(ProjectileMoved event) - { - if (runVerzik) - { + public void onProjectileMoved(ProjectileMoved event) { + if (runVerzik) { Projectile projectile = event.getProjectile(); - if (projectile.getId() == PROJECTILE_ID_P2RANGE) - { - WorldPoint p = WorldPoint.fromLocal(client,event.getPosition()); + if (projectile.getId() == PROJECTILE_ID_P2RANGE) { + WorldPoint p = WorldPoint.fromLocal(client, event.getPosition()); Verzik_RangeProjectiles.put(projectile, p); } } } @Subscribe - public void onChatMessage(ChatMessage chatMessage) - { - MessageNode messageNode = chatMessage.getMessageNode(); - - if (messageNode.getValue().toLowerCase().contains(sotmsg.toLowerCase())) - { - TickTillEat = 20; - /*20 ticks*/ - + public void onAnimationChanged(AnimationChanged event) { + if (runVerzik) { + if (event.getActor().getAnimation() == 8117) { + redCrabsTimer = 11; + } } - - } @Subscribe - public void onGameTick(GameTick event) - { - if (runMaiden) - { + public void onVarbitChanged(VarbitChanged event) { + if (runBloat) { + + if (client.getVar(Varbits.BLOAT_ENTERED_ROOM) == 1) { + if (!bloatFlag) { + bloatTimer = 0; + bloatFlag = true; + } + } + } + } + + @Subscribe + public void onGraphicsObjectCreated(GraphicsObjectCreated event) { + GraphicsObject obj = event.getGraphicsObject(); + if (obj.getId() == 1570 || obj.getId() == 1571 || obj.getId() == 1572 || obj.getId() == 1573 || obj.getId() == 1574 || obj.getId() == 1575 || obj.getId() == 1576) { + WorldPoint p = WorldPoint.fromLocal(client, obj.getLocation()); + if (temp.size() == 0) { + + } else { + + } + } + } + + + @Subscribe + public void onGameTick(GameTick event) { + if (runMaiden) { Maiden_BloodSpatters.clear(); - for (GraphicsObject o : client.getGraphicsObjects()) - { - if (o.getId() == GRAPHICSOBJECT_ID_MAIDEN) - { + for (GraphicsObject o : client.getGraphicsObjects()) { + if (o.getId() == GRAPHICSOBJECT_ID_MAIDEN) { Maiden_BloodSpatters.add(WorldPoint.fromLocal(client, o.getLocation())); } } @@ -438,98 +578,117 @@ public class TheatrePlugin extends Plugin { Maiden_SpawnLocations2.clear(); Maiden_SpawnLocations2.addAll(Maiden_SpawnLocations); Maiden_SpawnLocations.clear(); - for (NPC spawn : Maiden_Spawns) - { + for (NPC spawn : Maiden_Spawns) { Maiden_SpawnLocations.add(spawn.getWorldLocation()); } } - if (runBloat) - { + if (runBloat) { + + localTemp.clear(); + + //System.out.println("Temp flag" + tempFlag); + //System.out.println("Temp2 flag" + temp2Flag); + + + for (GraphicsObject obj : client.getGraphicsObjects()) { + if (obj.getId() == 1570 || obj.getId() == 1571 || obj.getId() == 1572 || obj.getId() == 1573 || obj.getId() == 1574 || obj.getId() == 1575 || obj.getId() == 1576) { + WorldPoint p = WorldPoint.fromLocal(client, obj.getLocation()); + //Already have some feet in temp Set + if (temp.size() > 0) { + //System.out.println("temp size > 0, tempflag set false, tempflag2 set true"); + tempFlag = false; + temp2Flag = true; + } else { + //System.out.println("temp size 0, tempflag set true, tempflag2 set false"); + tempFlag = true; + temp2Flag = false; + + } + localTemp.add(p); + } + } + + if (tempFlag) { + temp2.clear(); + temp2Flag = false; + temp.addAll(localTemp); + + + //System.out.println("temp2 cleared, temp2flag set false, added to temp set"); + } else if (temp2Flag) { + temp.clear(); + tempFlag = false; + temp2.addAll(localTemp); + //System.out.println("temp cleared, tempflag set false, added to temp2 set"); + + } Bloat_downCount++; - Bloat_Hands.clear(); - for (GraphicsObject o : client.getGraphicsObjects()) - { - if (o.getId() == GRAPHICSOBJECT_ID_BLOAT_HAND1 || o.getId() == GRAPHICSOBJECT_ID_BLOAT_HAND2 || o.getId() == GRAPHICSOBJECT_ID_BLOAT_HAND3 || o.getId() == GRAPHICSOBJECT_ID_BLOAT_HAND4|| o.getId() == GRAPHICSOBJECT_ID_BLOAT_HAND5) - { - Bloat_Hands.add(WorldPoint.fromLocal(client, o.getLocation())); - } - } - - if (Bloat_NPC.getAnimation() == -1) //1 = up; 2 = down; 3 = warn; { + bloatTimer++; Bloat_downCount = 0; - if (Bloat_NPC.getHealth() == 0) - { + if (Bloat_NPC.getHealth() == 0) { Bloat_State = 2; - } - else + } else Bloat_State = 1; - } - else - { - if (25 it = Nylocas_Map.keySet().iterator(); it.hasNext();) - { + if (runNylocas) { + for (Iterator it = Nylocas_Map.keySet().iterator(); it.hasNext(); ) { NPC npc = it.next(); int ticksLeft = Nylocas_Map.get(npc); - if (ticksLeft < 0) - { + if (ticksLeft < 0) { it.remove(); continue; } Nylocas_Map.replace(npc, ticksLeft - 1); } - for (NPC pillar : Nylocas_Pillars.keySet()) - { + for (NPC pillar : Nylocas_Pillars.keySet()) { int healthPercent = pillar.getHealthRatio(); - if (healthPercent > -1) - { + if (healthPercent > -1) { Nylocas_Pillars.replace(pillar, healthPercent); } } - for (NPC npc : client.getNpcs()) - { - if (npc.getId() == 8358) - { + for (NPC npc : client.getNpcs()) { + if (npc.getId() == 8358) { runNylocas = true; break; } runNylocas = false; + BossNylo = null; } } - if (runSotetseg) - { - TickTillEat--; + if (runSotetseg) { boolean sotetsegFighting = false; - for (NPC npc : client.getNpcs()) - { - if (npc.getId() == NpcID.SOTETSEG_8388) - { + for (NPC npc : client.getNpcs()) { + if (npc.getId() == NpcID.SOTETSEG_8388) { BlackTilesUnderworld.clear(); BlackTilesOverworld.clear(); RedTilesOverworld.clear(); @@ -541,42 +700,33 @@ public class TheatrePlugin extends Plugin { } } - if (!sotetsegFighting) - { - if (!BlackTilesUnderworld.isEmpty() && !RedTilesUnderworld.isEmpty() && GridPath.isEmpty()) - { + if (!sotetsegFighting) { + if (!BlackTilesUnderworld.isEmpty() && !RedTilesUnderworld.isEmpty() && GridPath.isEmpty()) { int minX = 99999; int minY = 99999; - for (WorldPoint p : BlackTilesUnderworld) - { + for (WorldPoint p : BlackTilesUnderworld) { int x = p.getX(); int y = p.getY(); - if (x < minX) - { + if (x < minX) { minX = x; } - if (y < minY) - { + if (y < minY) { minY = y; } } - boolean messageSent = false; - for (WorldPoint p : RedTilesUnderworld) - { + for (WorldPoint p : RedTilesUnderworld) { WorldPoint pN = new WorldPoint(p.getX(), p.getY() + 1, p.getPlane()); WorldPoint pS = new WorldPoint(p.getX(), p.getY() - 1, p.getPlane()); WorldPoint pE = new WorldPoint(p.getX() + 1, p.getY(), p.getPlane()); WorldPoint pW = new WorldPoint(p.getX() - 1, p.getY(), p.getPlane()); - if ( !( (RedTilesUnderworld.contains(pN) && RedTilesUnderworld.contains(pS)) || - (RedTilesUnderworld.contains(pE) && RedTilesUnderworld.contains(pW)) ) ) - { + if (!((RedTilesUnderworld.contains(pN) && RedTilesUnderworld.contains(pS)) || + (RedTilesUnderworld.contains(pE) && RedTilesUnderworld.contains(pW)))) { GridPath.add(new Point(p.getX() - minX, p.getY() - minY)); - if (!messageSent) - { + if (!messageSent) { //client.addChatMessage(ChatMessageType.SERVER, "", "Maze path acquired.", null); messageSent = true; } @@ -585,71 +735,74 @@ public class TheatrePlugin extends Plugin { } } - if (!BlackTilesOverworld.isEmpty() && !GridPath.isEmpty() && RedTilesOverworld.isEmpty()) - { + if (!BlackTilesOverworld.isEmpty() && !GridPath.isEmpty() && RedTilesOverworld.isEmpty()) { int minX = 99999; int minY = 99999; - for (WorldPoint p : BlackTilesOverworld) - { + for (WorldPoint p : BlackTilesOverworld) { int x = p.getX(); int y = p.getY(); - if (x < minX) - { + if (x < minX) { minX = x; } - if (y < minY) - { + if (y < minY) { minY = y; } } - for (Point p : GridPath) - { + for (Point p : GridPath) { RedTilesOverworld.add(new WorldPoint(minX + p.getX(), minY + p.getY(), 0)); } } } } - if (runXarpus) - { - for (Iterator it = Xarpus_Exhumeds.keySet().iterator(); it.hasNext();) - { + if (runXarpus) { + int size = xarpusExhumedsTimer.size(); + for (Map.Entry exhumes : xarpusExhumedsTimer.entrySet()) { + if (size > 0) { + exhumes.setValue(exhumes.getValue() - 1); + } + + } + for (Iterator it = Xarpus_Exhumeds.keySet().iterator(); it.hasNext(); ) { GroundObject key = it.next(); Xarpus_Exhumeds.replace(key, Xarpus_Exhumeds.get(key) - 1); - if (Xarpus_Exhumeds.get(key) < 0) - { + if (Xarpus_Exhumeds.get(key) < 0) { it.remove(); + exhumecount--; } } - if (Xarpus_NPC.getOverheadText() != null ) - { + if ((Xarpus_NPC.getComposition().getOverheadIcon() != null)) { Xarpus_Stare = true; } - if (Xarpus_Stare) - { + if (Xarpus_Stare) { //dont hit xarpus if it looking at u - } - else if (Xarpus_NPC.getId() == NpcID.XARPUS_8340) - { + } else if (Xarpus_NPC.getId() == NpcID.XARPUS_8340) { Xarpus_TicksUntilShoot--; - if (Xarpus_NPC.getAnimation() == ANIMATION_ID_XARPUS && Xarpus_previousAnimation != ANIMATION_ID_XARPUS) - { - Xarpus_TicksUntilShoot = 3; - } - Xarpus_previousAnimation = Xarpus_NPC.getAnimation(); + //if (Xarpus_NPC.getAnimation() == ANIMATION_ID_XARPUS && Xarpus_previousAnimation != ANIMATION_ID_XARPUS) + //{ + //Xarpus_TicksUntilShoot = 3; + //} + //Xarpus_previousAnimation = Xarpus_NPC.getAnimation(); } } - if (runVerzik) - { - if (!Verzik_RangeProjectiles.isEmpty()) - { - for (Iterator it = Verzik_RangeProjectiles.keySet().iterator(); it.hasNext();) - { + if (runVerzik) { + crabList.clear(); + for (NPC npc : client.getNpcs()) { + + if (npc.getName().toLowerCase().contains("nylo")) { + crabList.add(npc); + } + } + + if (Verzik_NPC.getAnimation() == 8117) { + redCrabsTimer = redCrabsTimer - 1; + } + if (!Verzik_RangeProjectiles.isEmpty()) { + for (Iterator it = Verzik_RangeProjectiles.keySet().iterator(); it.hasNext(); ) { Projectile projectile = it.next(); - if (projectile.getRemainingCycles() < 1) - { + if (projectile.getRemainingCycles() < 1) { it.remove(); } } @@ -658,55 +811,40 @@ public class TheatrePlugin extends Plugin { Verzik_YellowBall = null; Verzik_YellowTiles.clear(); - for (Projectile projectile : client.getProjectiles()) - { - if (projectile.getId() == PROJECTILE_ID_YELLOW) - { + for (Projectile projectile : client.getProjectiles()) { + if (projectile.getId() == PROJECTILE_ID_YELLOW) { Verzik_YellowBall = projectile; break; } } - for (GraphicsObject o : client.getGraphicsObjects()) - { - if (o.getId() == GRAPHICSOBJECT_ID_YELLOW) - { + for (GraphicsObject o : client.getGraphicsObjects()) { + if (o.getId() == GRAPHICSOBJECT_ID_YELLOW) { + Verzik_YellowTiles.add(WorldPoint.fromLocal(client, o.getLocation())); } } - for (NPC npc : client.getNpcs()) - { - if (npc.getId() == 8379) - { - runVerzik = true; - break; - } - runVerzik = false; - } - - - if (Verzik_NPC_P3 != null) { + if (Verzik_NPC.getId() == VERZIK_ID_P3) { boolean tornadosActive = false; - for (NPC npc : client.getNpcs()) - { - if (npc.getId() == NPC_ID_TORNADO) - { + for (NPC npc : client.getNpcs()) { + if (npc.getId() == NPC_ID_TORNADO) { + tornadoList.add(npc); tornadosActive = true; break; } } boolean isGreenBall = false; - for (Projectile projectile : client.getProjectiles()) - { + for (Projectile projectile : client.getProjectiles()) { if (projectile.getId() == PROJECTILE_ID_P3_GREEN) { isGreenBall = projectile.getRemainingCycles() > 210; break; } } + P3_TicksUntilAttack--; - switch (Verzik_NPC_P3.getAnimation()) { + switch (Verzik_NPC.getAnimation()) { case ANIMATION_ID_P3_MAGE: if (P3_TicksUntilAttack < 2) { P3_attacksLeft--; @@ -761,6 +899,90 @@ public class TheatrePlugin extends Plugin { } } + + } -} + private void stripEntries(int style, String target, int NyloID) { + String Keep = null; + if (NyloID == 0) { + switch (style) { + case 1: + Keep = "Nylocas Ischyros"; + break; + case 2: + Keep = "Nylocal Toxobolos"; + break; + case 3: + Keep = "Nylocas Hagios"; + break; + } + } else { + Keep = "fuckaadamhypocrticalpos"; + switch (NyloID) { + case 8356://0=idk 1= melee 2= range 3= mage + if (style == 3) { + + Keep = "Nylocas Vasilias"; + } + break; + case 8357: + if (style == 2) { + Keep = "Nylocas Vasilias"; + } + break; + default: + if (style == 1) { + Keep = "Nylocas Vasilias"; + } + } + + } + int entryLength = 0; + List entryList = new ArrayList<>(); + for (MenuEntry entry : client.getMenuEntries()) { + if (Text.removeTags(entry.getTarget()).contains(Keep) && entry.getOption().equals("Attack")) { + + entryList.add(entry); + entryLength++; + } + if (entry.getOption().equalsIgnoreCase("walk here") || entry.getOption().equalsIgnoreCase("pass") || entry.getOption().equalsIgnoreCase("take")) { + entryList.add(entry); + entryLength++; + } + } + + //System.out.println("i see " + entryLength + " good options using style" + style); + if (entryLength != 0) { + MenuEntry[] newEntries = new MenuEntry[entryLength]; + + + for (int i = 0; i < (entryLength); i++) { + newEntries[i] = entryList.get(i); + } + client.setMenuEntries(newEntries); + } + + + } + + private int searchIndex(MenuEntry[] entries, String option, String target, boolean strict) { + for (int i = entries.length - 1; i >= 0; i--) { + MenuEntry entry = entries[i]; + String entryOption = Text.removeTags(entry.getOption()).toLowerCase(); + String entryTarget = Text.removeTags(entry.getTarget()).toLowerCase(); + + if (strict) { + if (entryOption.equals(option) && entryTarget.equals(target)) { + return i; + } + } else { + if (entryOption.contains(option.toLowerCase()) && entryTarget.equals(target)) { + return i; + } + } + } + + return -1; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreXarpusOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreXarpusOverlay.java new file mode 100644 index 0000000000..72757be422 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatreXarpusOverlay.java @@ -0,0 +1,68 @@ +package net.runelite.client.plugins.ztob; + +import com.google.inject.Inject; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayMenuEntry; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; + +import java.awt.*; + +import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; +import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; + +public class TheatreXarpusOverlay extends Overlay { + private final TheatrePlugin plugin; + private final TheatreConfig config; + PanelComponent panelComponent = new PanelComponent(); + + @Inject + private TheatreXarpusOverlay(TheatrePlugin plugin, TheatreConfig config) { + super(plugin); + setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT); + setPosition(OverlayPosition.DYNAMIC); + setPosition(OverlayPosition.DETACHED); + this.plugin = plugin; + this.config = config; + getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Theatre xarpus overlay")); + + } + + @Override + public Dimension render(Graphics2D graphics) { + if (plugin.isRunXarpus()) { + if (config.XarpusExhumeOverlay()) { + if (plugin.getXarpus_NPC().getId() == 8339) { + panelComponent.getChildren().clear(); + String overlayTitle = "Exhume Counter"; + + + // Build overlay title + panelComponent.getChildren().add(TitleComponent.builder() + .text(overlayTitle) + .color(Color.GREEN) + .build()); + + //Set the size of overlay + panelComponent.setPreferredSize(new Dimension( + graphics.getFontMetrics().stringWidth(overlayTitle) + 30, 0 + )); + + panelComponent.getChildren().add(LineComponent.builder() + .left("Exhumes: ") + .right(String.valueOf(plugin.getExhumecount())) + .build()); + } + } + return panelComponent.render(graphics); + } + + return null; + + } + + +} + diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/VerzikNyloOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/VerzikNyloOverlay.java new file mode 100644 index 0000000000..68f0630c12 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/VerzikNyloOverlay.java @@ -0,0 +1,81 @@ +package net.runelite.client.plugins.ztob; + +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.Point; +import net.runelite.client.ui.overlay.*; + +import javax.inject.Inject; +import java.awt.*; + +public class VerzikNyloOverlay extends Overlay { + + private final Client client; + private final TheatrePlugin plugin; + private final TheatreConfig config; + + @Inject + private VerzikNyloOverlay(Client client, TheatrePlugin plugin, TheatreConfig config) { + this.client = client; + this.plugin = plugin; + this.config = config; + setPosition(OverlayPosition.DYNAMIC); + setPriority(OverlayPriority.HIGH); + setLayer(OverlayLayer.ABOVE_SCENE); + } + + public Dimension render(Graphics2D graphics) { + + if (plugin.isRunVerzik()) { + if (config.NyloTargetOverlay()) { + if (plugin.getCrabList().size() > 0) { + + for (NPC npc : plugin.getCrabList()) { + if (npc.isDead()) { + continue; + } + String renderText = ""; + if (npc.getInteracting() != null) { + + renderText = npc.getInteracting().getName(); + Point point = npc.getCanvasTextLocation(graphics, npc.getInteracting().getName(), 0); + + + if (npc.getInteracting().getName().toLowerCase().equals(client.getLocalPlayer().getName().toLowerCase())) { + point = npc.getCanvasTextLocation(graphics, client.getLocalPlayer().getName(), 0); + renderText = "YOU NIGGA RUN!"; + + } else if (npc.getInteracting().getName().toLowerCase().equals("afyy")) { + point = npc.getCanvasTextLocation(graphics, "Ricecup", 0); + renderText = "Ricecup"; + } + if (renderText.equals("YOU NIGGA RUN!")) { + renderTextLocation(graphics, renderText, 12, Font.BOLD, Color.RED, point); + } else { + renderTextLocation(graphics, renderText, 12, Font.BOLD, Color.GREEN, point); + } + } + + } + } + + } + } + + return null; + } + + private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint) { + graphics.setFont(new Font("Arial", fontStyle, fontSize)); + if (canvasPoint != null) { + final Point canvasCenterPoint = new Point( + canvasPoint.getX(), + canvasPoint.getY()); + final Point canvasCenterPoint_shadow = new Point( + canvasPoint.getX() + 1, + canvasPoint.getY() + 1); + OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK); + OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, txtString, fontColor); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java index 10c9f89e74..4fdbe3fa25 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java @@ -21,9 +21,10 @@ import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ImageUtil; @PluginDescriptor( - name = "!Zulrah", + name = "Zulrah", description = "Zulrah Helper", - tags = {"Zulrah", "Helper"} + tags = {"Zulrah", "Helper"}, + type = "PVM" ) public class ZulrahPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java index 9c70435b0b..696acb15f9 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java @@ -45,13 +45,16 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.jar.Attributes; import java.util.jar.JarEntry; @@ -88,6 +91,7 @@ public class ClientLoader private final ClientConfigLoader clientConfigLoader; private ClientUpdateCheckMode updateCheckMode; private JarOutputStream target; + private static String[] preotectedStuffs; @Inject private ClientLoader( @@ -236,7 +240,7 @@ public class ClientLoader hooks.actorClass.equals("") || hooks.playerClass.equals("")) { System.out.println("[RuneLit] Bad hooks, re-scraping."); - ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath()); + ByteCodePatcher.clientInstance = initHookScrape(ByteCodeUtils.injectedClientFile.getPath()); ByteCodePatcher.findHooks(injectedClientFile.getPath()); } else { ByteCodePatcher.clientInstance = hooks.clientInstance; @@ -246,7 +250,8 @@ public class ClientLoader } else { System.out.println("[RuneLit] Hooks file not found, scraping hooks."); - ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath()); + ByteCodePatcher.clientInstance = initHookScrape(ByteCodeUtils.injectedClientFile.getPath()); + ByteCodePatcher.hooks.protectedStuff = preotectedStuffs; ByteCodePatcher.findHooks(injectedClientFile.getPath()); } @@ -335,7 +340,9 @@ public class ClientLoader return certificates.toArray(new Certificate[certificates.size()]); } - public static String getClientInstance(String jarFile) { + public static String initHookScrape(String jarFile) { + List protectedStuff = new ArrayList(); + String clientInstance = ""; JarClassLoader jcl = new JarClassLoader(); try { ClassPool classPool = new ClassPool(true); @@ -363,17 +370,26 @@ public class ClientLoader try { jcl2.add(new FileInputStream(ByteCodeUtils.injectedClientFile)); Field[] fields = classToLoad.getDeclaredFields(); + Method[] methods = classToLoad.getDeclaredMethods(); for (Field f : fields) { try { + if (f.getName().contains("$")) { + System.out.println(classToLoad.getName()+"."+f.getName()); + protectedStuff.add(classToLoad.getName()+"."+f.getName()); + } if (f.getType().getName()=="client") { ByteCodePatcher.hooks.clientInstance = classToLoad.getName()+"."+f.getName(); - System.out.println("[RuneLit] Found client instance at "+classToLoad.getName()+"."+f.getName()); - return classToLoad.getName()+"."+f.getName(); + clientInstance = classToLoad.getName()+"."+f.getName(); } } catch (Exception e) { e.printStackTrace(); } } + for (Method m : methods) { + if (m.getName().contains("$")) { + protectedStuff.add(classToLoad.getName()+"."+m.getName()); + } + } } catch (FileNotFoundException e) { e.printStackTrace(); } @@ -391,6 +407,16 @@ public class ClientLoader } catch (Exception e) { e.printStackTrace(); } - return ""; + int i = 0; + for (Object o : protectedStuff) { + i++; + } + preotectedStuffs = new String[i]; + i = 0; + for (Object o : protectedStuff) { + preotectedStuffs[i] = (String) o; + i++; + } + return clientInstance; } } diff --git a/runelite-client/src/main/java/net/runelite/client/rs/bytecode/ByteCodePatcher.java b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/ByteCodePatcher.java index b75a8c9631..abd4a970dc 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/bytecode/ByteCodePatcher.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/ByteCodePatcher.java @@ -8,22 +8,20 @@ import javassist.NotFoundException; import net.runelite.client.RuneLite; import net.runelite.client.rs.ClientLoader; import net.runelite.client.rs.bytecode.transformers.ActorTransform; +import net.runelite.client.rs.bytecode.transformers.ClientTransform; +import net.runelite.client.rs.bytecode.transformers.ErrorTransform; import net.runelite.client.rs.bytecode.transformers.PlayerTransform; import net.runelite.client.rs.bytecode.transformers.ProjectileTransform; import net.runelite.http.api.RuneLiteAPI; import org.xeustechnologies.jcl.JarClassLoader; import java.io.BufferedInputStream; -import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; -import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; @@ -33,154 +31,168 @@ import java.util.jar.JarInputStream; public class ByteCodePatcher { - public static List modifiedClasses = new ArrayList<>(); - public static Hooks hooks = new Hooks(); - public static String clientInstance; - public static JarClassLoader jcl = new JarClassLoader(); - public static ClassPool classPool = null; - public static ClassLoader cl = ClassLoader.getSystemClassLoader(); + public static List modifiedClasses = new ArrayList<>(); + public static Hooks hooks = new Hooks(); + public static String clientInstance; + public static JarClassLoader jcl = new JarClassLoader(); + public static ClassPool classPool = null; + public static ClassLoader cl = ClassLoader.getSystemClassLoader(); - public static void applyHooks(File jf, Hooks hooks) { - try { - URLClassLoader child = new URLClassLoader( - new URL[] {jf.toURI().toURL()}, - cl - ); - try { - Class actorClass = Class.forName(hooks.actorClass, false, child); - transformActor(actorClass); - Class projectileClass = Class.forName(hooks.projectileClass, false, child); - transformProjectile(projectileClass); - Class playerClass = Class.forName(hooks.playerClass, false, child); - transformPlayer(playerClass); - ByteCodeUtils.updateHijackedJar(); - } catch (Exception e) { - e.printStackTrace(); - } + public static void applyHooks(File jf, Hooks hooks) { + try { + URLClassLoader child = new URLClassLoader( + new URL[] {jf.toURI().toURL()}, + cl + ); + try { + Class actorClass = Class.forName(hooks.actorClass, false, child); + transformActor(actorClass); + Class projectileClass = Class.forName(hooks.projectileClass, false, child); + transformProjectile(projectileClass); + Class playerClass = Class.forName(hooks.playerClass, false, child); + transformPlayer(playerClass); + Class clientClass = Class.forName("client", false, child); + transformBlackjack(clientClass); - } catch (Exception e) { - e.printStackTrace(); - } - } + //Odds and ends + ErrorTransform et = new ErrorTransform(); + et.modify(null); - public static void findHooks(String jf) { - try { - classPool = new ClassPool(true); - classPool.appendClassPath(RuneLite.RUNELITE_DIR+"/injectedClient-"+ RuneLiteAPI.getVersion() +"-.jar"); - } catch (NotFoundException e) { - e.printStackTrace(); - } + ByteCodeUtils.updateHijackedJar(); + } catch (Exception e) { + e.printStackTrace(); + } - try { - jcl.add(new FileInputStream(jf)); - try (JarInputStream in = new JarInputStream(new BufferedInputStream(new FileInputStream(jf)))) { - JarEntry entry; - while ((entry = in.getNextJarEntry()) != null) { - if (entry.getName().endsWith(".class")) { - checkClasses(new File(jf), entry); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - try { - Writer writer = new FileWriter(ClientLoader.hooksFile); - gson.toJson(hooks, writer); - writer.flush(); - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - ByteCodeUtils.updateHijackedJar(); - } + } catch (Exception e) { + e.printStackTrace(); + } + } - public static void checkClasses(File jf, JarEntry entry) { - try { - URLClassLoader child = new URLClassLoader( - new URL[] {jf.toURI().toURL()}, - cl - ); - try { - Class classToLoad = Class.forName(entry.getName().replace(".class", ""), false, child); - checkActor(classToLoad); - checkProjectile(classToLoad); - checkPlayer(classToLoad); - } catch (Exception e) { - e.printStackTrace(); - } + public static void findHooks(String jf) { + try { + classPool = new ClassPool(true); + classPool.appendClassPath(RuneLite.RUNELITE_DIR+"/injectedClient-"+ RuneLiteAPI.getVersion() +"-.jar"); + } catch (NotFoundException e) { + e.printStackTrace(); + } - } catch (Exception e) { - e.printStackTrace(); - System.out.println("Class not found: "+entry.getName()); - } - } + try { + jcl.add(new FileInputStream(jf)); + try (JarInputStream in = new JarInputStream(new BufferedInputStream(new FileInputStream(jf)))) { + JarEntry entry; + while ((entry = in.getNextJarEntry()) != null) { + if (entry.getName().endsWith(".class")) { + checkClasses(new File(jf), entry); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + try { + Writer writer = new FileWriter(ClientLoader.hooksFile); + gson.toJson(hooks, writer); + writer.flush(); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + ByteCodeUtils.updateHijackedJar(); + } - public static void checkActor(Class current) { - try { - Method method = current.getDeclaredMethod("setCombatInfo", new Class[] { int.class, int.class, int.class, int.class, int.class, int.class }); - if (method!=null) { - hooks.actorClass = current.getName(); - System.out.println("[RuneLit] Transforming Actor at class: "+current.getName()); - ActorTransform at = new ActorTransform(); - at.modify(current); - } - } catch (NoSuchMethodException e) { - //e.printStackTrace(); - } catch (NoClassDefFoundError e) { - //e.printStackTrace(); - } - } + public static void checkClasses(File jf, JarEntry entry) { + try { + URLClassLoader child = new URLClassLoader( + new URL[] {jf.toURI().toURL()}, + cl + ); + try { + Class classToLoad = Class.forName(entry.getName().replace(".class", ""), false, child); + checkActor(classToLoad); + checkProjectile(classToLoad); + checkPlayer(classToLoad); + } catch (Exception e) { + e.printStackTrace(); + } - public static void transformActor(Class actor) { - System.out.println("[RuneLit] Transforming Actor at class: "+actor.getName()); - ActorTransform at = new ActorTransform(); - at.modify(actor); - } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Class not found: "+entry.getName()); + } + } - public static void checkProjectile(Class current) { - try { - Method method = current.getDeclaredMethod("projectileMoved", new Class[] { int.class, int.class, int.class, int.class}); - if (method!=null) { - hooks.projectileClass = current.getName(); - System.out.println("[RuneLit] Transforming Projectile at class: "+current.getName()); - ProjectileTransform pt = new ProjectileTransform(); - pt.modify(current); - } - } catch (NoSuchMethodException e) { - //e.printStackTrace(); - } catch (NoClassDefFoundError e) { - //e.printStackTrace(); - } - } + public static void checkActor(Class current) { + try { + Method method = current.getDeclaredMethod("setCombatInfo", new Class[] { int.class, int.class, int.class, int.class, int.class, int.class }); + if (method!=null) { + hooks.actorClass = current.getName(); + System.out.println("[RuneLit] Transforming Actor at class: "+current.getName()); + ActorTransform at = new ActorTransform(); + at.modify(current); + } + } catch (NoSuchMethodException e) { + //e.printStackTrace(); + } catch (NoClassDefFoundError e) { + //e.printStackTrace(); + } + } - public static void transformProjectile(Class projectile) { - System.out.println("[RuneLit] Transforming Projectile at class: "+projectile.getName()); - ProjectileTransform pt = new ProjectileTransform(); - pt.modify(projectile); - } + public static void transformActor(Class actor) { + System.out.println("[RuneLit] Transforming Actor at class: "+actor.getName()); + ActorTransform at = new ActorTransform(); + at.modify(actor); + } - public static void checkPlayer(Class current) { - try { - Method method = current.getDeclaredMethod("getSkullIcon"); - if (method!=null) { - hooks.playerClass = current.getName(); - System.out.println("[RuneLit] Transforming Player at class: "+current.getName()); - PlayerTransform pt = new PlayerTransform(); - pt.modify(current); - } - } catch (NoSuchMethodException e) { - //e.printStackTrace(); - } catch (NoClassDefFoundError e) { - //e.printStackTrace(); - } - } + public static void checkProjectile(Class current) { + try { + Method method = current.getDeclaredMethod("projectileMoved", new Class[] { int.class, int.class, int.class, int.class}); + if (method!=null) { + hooks.projectileClass = current.getName(); + System.out.println("[RuneLit] Transforming Projectile at class: "+current.getName()); + ProjectileTransform pt = new ProjectileTransform(); + pt.modify(current); + } + } catch (NoSuchMethodException e) { + //e.printStackTrace(); + } catch (NoClassDefFoundError e) { + //e.printStackTrace(); + } + } + + public static void transformProjectile(Class projectile) { + System.out.println("[RuneLit] Transforming Projectile at class: "+projectile.getName()); + ProjectileTransform pt = new ProjectileTransform(); + pt.modify(projectile); + } + + public static void checkPlayer(Class current) { + try { + Method method = current.getDeclaredMethod("getSkullIcon"); + if (method!=null) { + hooks.playerClass = current.getName(); + System.out.println("[RuneLit] Transforming Player at class: "+current.getName()); + PlayerTransform pt = new PlayerTransform(); + pt.modify(current); + } + } catch (NoSuchMethodException e) { + //e.printStackTrace(); + } catch (NoClassDefFoundError e) { + //e.printStackTrace(); + } + } + + public static void transformPlayer(Class player) { + System.out.println("[RuneLit] Transforming Player at class: "+player.getName()); + PlayerTransform pt = new PlayerTransform(); + pt.modify(player); + } + + public static void transformBlackjack(Class clazz) { + System.out.println("[RuneLit] Transforming Blackjack at class: "+clazz.getName()); + ClientTransform bt = new ClientTransform(); + bt.modify(clazz); + } - public static void transformPlayer(Class player) { - System.out.println("[RuneLit] Transforming Player at class: "+player.getName()); - PlayerTransform pt = new PlayerTransform(); - pt.modify(player); - } } diff --git a/runelite-client/src/main/java/net/runelite/client/rs/bytecode/Hooks.java b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/Hooks.java index 6d75fc81da..6bbd0ebe01 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/bytecode/Hooks.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/Hooks.java @@ -6,6 +6,7 @@ public class Hooks { public String actorClass = ""; public String projectileClass = ""; public String playerClass = ""; + public String[] protectedStuff; public Hooks() { } diff --git a/runelite-client/src/main/java/net/runelite/client/rs/bytecode/transformers/ClientTransform.java b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/transformers/ClientTransform.java new file mode 100644 index 0000000000..983466e3fc --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/transformers/ClientTransform.java @@ -0,0 +1,250 @@ +package net.runelite.client.rs.bytecode.transformers; + +import javassist.CtBehavior; +import javassist.CtClass; +import javassist.CtMember; +import javassist.CtMethod; +import javassist.CtNewMethod; +import javassist.bytecode.StackMapTable; +import net.runelite.client.rs.bytecode.ByteCodePatcher; + +public class ClientTransform implements Transform { + + public CtClass ct = null; + + @Override + public void modify(Class clazz) { + try { + ct = ByteCodePatcher.classPool.get(clazz.getName()); + transformProtectedGetMenuOptions(); + transformProtectedGetMenuTargets(); + transformProtectedGetMenuIdentifiers(); + transformProtectedGetMenuTypes(); + transformProtectedGetMenuActionParams0(); + transformProtectedGetMenuActionParams1(); + transformGetMenuEntries(); + transformSetMenuEntries(); + transformOnMenuOptionsChanged(); + + ByteCodePatcher.modifiedClasses.add(ct); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void transformProtectedGetMenuOptions() { + CtMethod protectedGetMenuOptions; + try { + protectedGetMenuOptions = ct.getDeclaredMethod("1protect$getMenuOptions"); + ct.removeMethod(protectedGetMenuOptions); + protectedGetMenuOptions.setName("getMenuOptions"); + ct.addMethod(protectedGetMenuOptions); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void transformProtectedGetMenuTargets() { + CtMethod protectedGetMenuTargets; + try { + protectedGetMenuTargets = ct.getDeclaredMethod("1protect$getMenuTargets"); + ct.removeMethod(protectedGetMenuTargets); + protectedGetMenuTargets.setName("getMenuTargets"); + ct.addMethod(protectedGetMenuTargets); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void transformProtectedGetMenuIdentifiers() { + CtMethod protectedGetMenuIdentifiers; + try { + protectedGetMenuIdentifiers = ct.getDeclaredMethod("1protect$getMenuIdentifiers"); + ct.removeMethod(protectedGetMenuIdentifiers); + protectedGetMenuIdentifiers.setName("getMenuIdentifiers"); + ct.addMethod(protectedGetMenuIdentifiers); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void transformProtectedGetMenuTypes() { + CtMethod protectedGetMenuTypes; + try { + protectedGetMenuTypes = ct.getDeclaredMethod("1protect$getMenuTypes"); + // Don't remove as this is referenced elsewhere in client + //ct.removeMethod(protectedGetMenuTypes); + CtMethod newProtectedGetMenuTypes = CtNewMethod.copy(protectedGetMenuTypes, ct, null); + newProtectedGetMenuTypes.setName("getMenuTypes"); + ct.addMethod(newProtectedGetMenuTypes); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void transformProtectedGetMenuActionParams0() { + CtMethod protectedGetMenuActionParams0; + try { + protectedGetMenuActionParams0 = ct.getDeclaredMethod("1protect$getMenuActionParams0"); + ct.removeMethod(protectedGetMenuActionParams0); + protectedGetMenuActionParams0.setName("getMenuActionParams0"); + ct.addMethod(protectedGetMenuActionParams0); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void transformProtectedGetMenuActionParams1() { + CtMethod protectedGetMenuActionParams1; + try { + protectedGetMenuActionParams1 = ct.getDeclaredMethod("1protect$getMenuActionParams1"); + ct.removeMethod(protectedGetMenuActionParams1); + protectedGetMenuActionParams1.setName("getMenuActionParams1"); + ct.addMethod(protectedGetMenuActionParams1); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void transform() {} + + public void transformGetMenuEntries() { + CtMethod getMenuEntries; + try { + getMenuEntries = ct.getDeclaredMethod("getMenuEntries"); + ct.removeMethod(getMenuEntries); + getMenuEntries = CtMethod.make("public net.runelite.api.MenuEntry[] getMenuEntries() {" + + " int n2 = this.getMenuOptionCount();"+ + " String[] arrstring = this.getMenuOptions();"+ + " String[] arrstring2 = this.getMenuTargets();"+ + " int[] arrn = this.getMenuIdentifiers();"+ + " int[] arrn2 = this.getMenuTypes();"+ + " int[] arrn3 = this.getMenuActionParams0();"+ + " int[] arrn4 = this.getMenuActionParams1();"+ + " boolean[] arrbl = this.getMenuForceLeftClick();"+ + " net.runelite.api.MenuEntry[] arrmenuEntry = new net.runelite.api.MenuEntry[n2];"+ + " int n3 = 0;"+ + " while (n3 < n2) {"+ + " net.runelite.api.MenuEntry menuEntry = arrmenuEntry[n3] = new net.runelite.api.MenuEntry();"+ + " menuEntry.setOption(arrstring[n3]);"+ + " menuEntry.setTarget(arrstring2[n3]);"+ + " menuEntry.setIdentifier(arrn[n3]);"+ + " menuEntry.setType(arrn2[n3]);"+ + " menuEntry.setParam0(arrn3[n3]);"+ + " menuEntry.setParam1(arrn4[n3]);"+ + " menuEntry.setForceLeftClick(arrbl[n3]);"+ + " ++n3;"+ + " }"+ + " return arrmenuEntry;"+ + " }", ct); + ct.addMethod(getMenuEntries); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void transformSetMenuEntries() { + CtMethod setMenuEntries; + try { + setMenuEntries = ct.getDeclaredMethod("setMenuEntries"); + ct.removeMethod(setMenuEntries); + String src; + setMenuEntries = CtNewMethod.make( + "public void setMenuEntries(net.runelite.api.MenuEntry[] arrmenuEntry) {" + + "int n2 = 0;" + + "String[] arrstring = this.getMenuOptions();" + + "String[] arrstring2 = this.getMenuTargets();" + + "int[] arrn = this.getMenuIdentifiers();" + + "int[] arrn2 = this.getMenuTypes();" + + "int[] arrn3 = this.getMenuActionParams0();" + + "int[] arrn4 = this.getMenuActionParams1();" + + "boolean[] arrbl = getMenuForceLeftClick();" + + "net.runelite.api.MenuEntry[] arrmenuEntry2 = arrmenuEntry;" + + "int n3 = arrmenuEntry2.length;" + + "int n4 = 0;" + + "do {" + + "String string;" + + "if (n4 >= n3) {" + + "this.setMenuOptionCount(n2);" + + "oldMenuEntryCount = n2;" + + "return;" + + "}" + + "net.runelite.api.MenuEntry menuEntry = arrmenuEntry2[n4];" + + "int n5 = menuEntry.getType();" + + "arrstring[n2] = menuEntry.getOption();" + + "arrstring2[n2] = menuEntry.getTarget();" + + "arrn[n2] = menuEntry.getIdentifier();" + + "arrn2[n2] = n5;" + + "arrn3[n2] = menuEntry.getParam0();" + + "arrn4[n2] = menuEntry.getParam1();" + + "arrbl[n2] = menuEntry.isForceLeftClick();" + + "++n2;" + + "++n4;" + + "} while (true);" + + "}" + , ct); + ct.addMethod(setMenuEntries); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /* + public void setMenuEntries(MenuEntry[] arrmenuEntry) { + int n2 = 0; + String[] arrstring = this.1protect$getMenuOptions(); + String[] arrstring2 = this.1protect$getMenuTargets(); + int[] arrn = this.1protect$getMenuIdentifiers(); + int[] arrn2 = this.1protect$getMenuTypes(); + int[] arrn3 = this.1protect$getMenuActionParams0(); + int[] arrn4 = this.1protect$getMenuActionParams1(); + boolean[] arrbl = this.getMenuForceLeftClick(); + MenuEntry[] arrmenuEntry2 = arrmenuEntry; + int n3 = arrmenuEntry2.length; + int n4 = 0; + do { + String string; + if (n4 >= n3) { + this.setMenuOptionCount(n2); + oldMenuEntryCount = n2; + return; + } + MenuEntry menuEntry = arrmenuEntry2[n4]; + int n5 = menuEntry.getType(); + if (!(n5 != MenuAction.NPC_THIRD_OPTION.getId() && n5 != MenuAction.NPC_FIFTH_OPTION.getId() || n2 != arrmenuEntry.length - 1 || bv.ak.getLocalPlayer().getWorldLocation().getRegionID() != 13358 || (string = menuEntry.getOption().toLowerCase()).hashCode() != 974723797 && string.hashCode() != -1108625161)) { + n5 = MenuAction.CANCEL.getId(); + } + arrstring[n2] = menuEntry.getOption(); + arrstring2[n2] = menuEntry.getTarget(); + arrn[n2] = menuEntry.getIdentifier(); + arrn2[n2] = n5; + arrn3[n2] = menuEntry.getParam0(); + arrn4[n2] = menuEntry.getParam1(); + arrbl[n2] = menuEntry.isForceLeftClick(); + ++n2; + ++n4; + } while (true); +} + */ + + public void transformOnMenuOptionsChanged() { + CtMethod onMenuOptionsChanged; + try { + onMenuOptionsChanged = ct.getDeclaredMethod("onMenuOptionsChanged", new CtClass[]{CtClass.intType}); + ct.removeMethod(onMenuOptionsChanged); + onMenuOptionsChanged = CtMethod.make(" public static void onMenuOptionsChanged(int n2) {"+ + " int n3;" + + " int n4 = oldMenuEntryCount;"+ + " oldMenuEntryCount = n3 = "+ByteCodePatcher.clientInstance+".getMenuOptionCount();"+ + " if (n3 != n4 + 1) return;"+ + " net.runelite.api.events.MenuEntryAdded menuEntryAdded = new net.runelite.api.events.MenuEntryAdded("+ByteCodePatcher.clientInstance+".getMenuOptions()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuTargets()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuTypes()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuIdentifiers()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuActionParams0()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuActionParams1()[n3 - 1]);"+ + " "+ByteCodePatcher.clientInstance+".getCallbacks().post((Object)menuEntryAdded);" + + " }" + , ct); + ct.addMethod(onMenuOptionsChanged); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/rs/bytecode/transformers/ErrorTransform.java b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/transformers/ErrorTransform.java new file mode 100644 index 0000000000..89a3075970 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/rs/bytecode/transformers/ErrorTransform.java @@ -0,0 +1,39 @@ +package net.runelite.client.rs.bytecode.transformers; + +import javassist.CtClass; +import javassist.CtMethod; +import javassist.CtNewMethod; +import net.runelite.client.rs.bytecode.ByteCodePatcher; + +//This prevents the client from sending stack traces to Jagex at all, even classes outside of runelite. +public class ErrorTransform implements Transform { + public CtClass ct = null; + + //Where Runelites error interceptor is located, not auto-scraped. + private final String ERROR_INSTANCE_CLASS = "dp"; + private final String ERROR_INSTANCE_METHOD = "a"; + private final String ERROR_WARNING = "Tried to send a warning"; + + @Override + public void modify(Class clazz) { + try { + System.out.println("[RuneLit] Transforming error method at class: "+ERROR_INSTANCE_CLASS); + ct = ByteCodePatcher.classPool.get(ERROR_INSTANCE_CLASS); + CtMethod error = ct.getDeclaredMethod(ERROR_INSTANCE_METHOD); + ct.removeMethod(error); + error = CtMethod.make("public static void a(String string, Throwable throwable, byte by) {"+ + " throwable.printStackTrace();"+ + " System.out.println(\"[RuneLit] Prevented preceeding stack trace from being sent to Jagex\");"+ + " }", ct); + ct.addMethod(error); + ByteCodePatcher.modifiedClasses.add(ct); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void transform() { + + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 96ba6c31e6..4cb09686b2 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -83,7 +83,6 @@ import net.runelite.client.input.KeyManager; import net.runelite.client.input.MouseAdapter; import net.runelite.client.input.MouseListener; import net.runelite.client.input.MouseManager; -import net.runelite.client.ui.skin.SubstanceRuneLiteLookAndFeel; import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.OSType; @@ -122,10 +121,10 @@ public class ClientUI private boolean withTitleBar; private BufferedImage sidebarOpenIcon; private BufferedImage sidebarClosedIcon; - private ContainableFrame frame; + public static ContainableFrame frame; private JPanel navContainer; - private PluginPanel pluginPanel; - private ClientPluginToolbar pluginToolbar; + public static PluginPanel pluginPanel; + public static ClientPluginToolbar pluginToolbar; private ClientTitleToolbar titleToolbar; private JButton currentButton; private NavigationButton currentNavButton; @@ -300,14 +299,7 @@ public class ClientUI { SwingUtilities.invokeAndWait(() -> { - // Set some sensible swing defaults - SwingUtil.setupDefaults(); - - // Use substance look and feel - SwingUtil.setTheme(new SubstanceRuneLiteLookAndFeel()); - - // Use custom UI font - SwingUtil.setFont(FontManager.getRunescapeFont()); + SwingUtil.setupRuneLiteLookAndFeel(); // Create main window frame = new ContainableFrame(); diff --git a/runelite-client/src/main/java/net/runelite/client/ui/RuneLiteSplashScreen.java b/runelite-client/src/main/java/net/runelite/client/ui/RuneLiteSplashScreen.java new file mode 100644 index 0000000000..211997cdf4 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/ui/RuneLiteSplashScreen.java @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2016-2017, Jeremy Plsek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.ui; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.inject.Singleton; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingUtilities; +import lombok.extern.slf4j.Slf4j; +import net.runelite.client.RuneLite; +import net.runelite.client.RuneLiteProperties; +import net.runelite.client.util.SwingUtil; +import org.pushingpixels.substance.internal.SubstanceSynapse; + +/** + * This is a custom Splash Screen and does not use Java's SplashScreen class. This has helper methods to update the + * status while loading RuneLite. All public methods run non-blocking passed to the swing thread. + */ +@Slf4j +@Singleton +public class RuneLiteSplashScreen +{ + private RuneLiteProperties runeLiteProperties = new RuneLiteProperties(); + + private JFrame frame; + private JLabel messageLabel; + private JLabel subMessageLabel; + private JProgressBar progressBar; + + private int currentStep; + + /** + * This is not done in the constructor in order to avoid processing in case the user chooses to not load + * the splash screen. + * @param estimatedSteps steps until completion, used for the progress bar + */ + private void initLayout(final int estimatedSteps) + { + SwingUtil.setupRuneLiteLookAndFeel(); + + // init fields with updated swing look and feel + frame = new JFrame("RuneLitePlus Loading"); + messageLabel = new JLabel("Loading..."); + subMessageLabel = new JLabel(); + progressBar = new JProgressBar(0, estimatedSteps); + + // frame setup + frame.setSize(220, 290); + frame.setLocationRelativeTo(null); + frame.setUndecorated(true); + + // main panel setup + final JPanel panel = new JPanel(); + // To reduce substance's colorization (tinting) + panel.putClientProperty(SubstanceSynapse.COLORIZATION_FACTOR, 1.0); + panel.setBackground(ColorScheme.DARKER_GRAY_COLOR); + final GridBagLayout layout = new GridBagLayout(); + layout.columnWeights = new double[]{1}; + layout.rowWeights = new double[]{1, 0, 0, 1, 0, 1}; + panel.setLayout(layout); + + // logo + synchronized (ImageIO.class) + { + try + { + final BufferedImage logo = ImageIO.read(RuneLiteSplashScreen.class.getResourceAsStream("/runeliteplus.png")); + frame.setIconImage(logo); + + final BufferedImage logoTransparent = ImageIO.read(RuneLiteSplashScreen.class.getResourceAsStream("/runeliteplus_transparent.png")); + final GridBagConstraints logoConstraints = new GridBagConstraints(); + logoConstraints.anchor = GridBagConstraints.SOUTH; + panel.add(new JLabel(new ImageIcon(logoTransparent.getScaledInstance(96, 96, Image.SCALE_SMOOTH))), logoConstraints); + } + catch (IOException e) + { + log.warn("Error loading logo", e); + } + } + + // runelite title + final JLabel title = new JLabel("RuneLitePlus"); + final GridBagConstraints titleConstraints = new GridBagConstraints(); + titleConstraints.gridy = 1; + panel.add(title, titleConstraints); + + // version + final JLabel version = new JLabel("RuneLite Version : " + runeLiteProperties.getVersion()); + version.setForeground(Color.GREEN); + version.setFont(FontManager.getRunescapeSmallFont()); + version.setForeground(version.getForeground().darker()); + final GridBagConstraints versionConstraints = new GridBagConstraints(); + versionConstraints.gridy = 2; + panel.add(version, versionConstraints); + + // version + final JLabel litVersion = new JLabel("Lit Version : PRE-" + RuneLite.RUNELIT_VERSION); + litVersion.setForeground(Color.GREEN); + litVersion.setFont(FontManager.getRunescapeSmallFont()); + litVersion.setForeground(litVersion.getForeground().darker()); + final GridBagConstraints litVersionConstraints = new GridBagConstraints(); + litVersionConstraints.gridy = 3; + litVersionConstraints.weightx = 4; + panel.add(litVersion, litVersionConstraints); + + // progressbar + final GridBagConstraints progressConstraints = new GridBagConstraints(); + progressConstraints.insets = new Insets(0, 30, 5, 30); + progressConstraints.fill = GridBagConstraints.HORIZONTAL; + progressConstraints.anchor = GridBagConstraints.SOUTH; + progressConstraints.gridy = 4; + panel.add(progressBar, progressConstraints); + + // main message + messageLabel.setFont(FontManager.getRunescapeSmallFont()); + final GridBagConstraints messageConstraints = new GridBagConstraints(); + messageConstraints.gridy = 5; + panel.add(messageLabel, messageConstraints); + + // alternate message + subMessageLabel.setForeground(subMessageLabel.getForeground().darker()); + subMessageLabel.setFont(FontManager.getRunescapeSmallFont()); + final GridBagConstraints altConstrains = new GridBagConstraints(); + altConstrains.anchor = GridBagConstraints.NORTH; + altConstrains.gridy = 6; + panel.add(subMessageLabel, altConstrains); + + frame.setContentPane(panel); + } + + private boolean notActive() + { + return frame == null || !frame.isDisplayable(); + } + + /** + * Close/dispose of the splash screen + */ + public void close() + { + SwingUtilities.invokeLater(() -> + { + if (notActive()) + { + return; + } + + frame.dispose(); + }); + } + + /** + * Set the splash screen to be visible. + * @param estimatedSteps steps until completion, used for the progress bar + */ + public void open(final int estimatedSteps) + { + SwingUtilities.invokeLater(() -> + { + initLayout(estimatedSteps); + frame.setVisible(true); + }); + } + + /** + * Set a loading message. The subMessage will also be removed. + * @param message The main message. It will automatically append an ellipsis. + */ + public void setMessage(final String message) + { + setMessage(message, " "); + } + + /** + * Set a loading message. + * @param message The main message. It will automatically append an ellipsis. + * @param subMessage A separate alternate title. + */ + public void setMessage(final String message, final String subMessage) + { + SwingUtilities.invokeLater(() -> + { + if (notActive()) + { + return; + } + + messageLabel.setText(message + "..."); + subMessageLabel.setText(subMessage); + progressBar.setValue(++currentStep); + }); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java index 0eaae6e50b..9cf6f39217 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java @@ -26,15 +26,33 @@ package net.runelite.client.ui.overlay; import java.awt.Dimension; import java.awt.Graphics2D; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import lombok.AccessLevel; import lombok.Setter; +import net.runelite.api.widgets.Widget; +import static net.runelite.api.widgets.WidgetID.BANK_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.BANK_INVENTORY_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.DEPOSIT_BOX_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.EQUIPMENT_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.EQUIPMENT_INVENTORY_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.GRAND_EXCHANGE_INVENTORY_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.GUIDE_PRICES_INVENTORY_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.INVENTORY_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.SHOP_INVENTORY_GROUP_ID; +import static net.runelite.api.widgets.WidgetInfo.TO_GROUP; import net.runelite.api.widgets.WidgetItem; public abstract class WidgetItemOverlay extends Overlay { @Setter(AccessLevel.PACKAGE) private OverlayManager overlayManager; + /** + * Interfaces to draw overlay over. + */ + private final Set interfaceGroups = new HashSet<>(); protected WidgetItemOverlay() { @@ -49,13 +67,49 @@ public abstract class WidgetItemOverlay extends Overlay public Dimension render(Graphics2D graphics) { final List itemWidgets = overlayManager.getItemWidgets(); - for (WidgetItem widget : itemWidgets) + for (WidgetItem widgetItem : itemWidgets) { - renderItemOverlay(graphics, widget.getId(), widget); + Widget widget = widgetItem.getWidget(); + int interfaceGroup = TO_GROUP(widget.getId()); + + // Don't draw if this widget isn't one of the allowed + if (!interfaceGroups.contains(interfaceGroup)) + { + continue; + } + + renderItemOverlay(graphics, widgetItem.getId(), widgetItem); } return null; } + protected void showOnInventory() + { + showOnInterfaces( + DEPOSIT_BOX_GROUP_ID, + BANK_INVENTORY_GROUP_ID, + SHOP_INVENTORY_GROUP_ID, + GRAND_EXCHANGE_INVENTORY_GROUP_ID, + GUIDE_PRICES_INVENTORY_GROUP_ID, + EQUIPMENT_INVENTORY_GROUP_ID, + INVENTORY_GROUP_ID); + } + + protected void showOnBank() + { + showOnInterfaces(BANK_GROUP_ID); + } + + protected void showOnEquipment() + { + showOnInterfaces(EQUIPMENT_GROUP_ID); + } + + protected void showOnInterfaces(int... ids) + { + Arrays.stream(ids).forEach(interfaceGroups::add); + } + // Don't allow setting position, priority, or layer @Override diff --git a/runelite-client/src/main/java/net/runelite/client/util/Clipboard.java b/runelite-client/src/main/java/net/runelite/client/util/Clipboard.java deleted file mode 100644 index 3474f85543..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/util/Clipboard.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.runelite.client.util; - -import java.awt.Toolkit; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.IOException; - -public class Clipboard { - public static String retrieve() - { - Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); - - if (contents == null || ! contents.isDataFlavorSupported(DataFlavor.stringFlavor)) - { - return null; - } - - try - { - return (String) contents.getTransferData(DataFlavor.stringFlavor); - } - catch (UnsupportedFlavorException | IOException ex) - { - return null; - } - } - - public static void store(String contents) - { - final StringSelection selection = new StringSelection(contents); - - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/util/PvPUtil.java b/runelite-client/src/main/java/net/runelite/client/util/PvPUtil.java new file mode 100644 index 0000000000..3a842c227f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/util/PvPUtil.java @@ -0,0 +1,61 @@ +package net.runelite.client.util; + +import net.runelite.api.ItemComposition; +import java.util.TreeMap; +import java.util.Comparator; +import org.apache.commons.lang3.ArrayUtils; +import java.util.Objects; +import net.runelite.api.ItemContainer; +import net.runelite.api.Item; +import net.runelite.api.InventoryID; +import net.runelite.client.game.ItemManager; +import net.runelite.api.Player; +import net.runelite.api.Client; +import net.runelite.api.coords.WorldPoint; + +public class PvPUtil +{ + public PvPUtil() { + super(); + } + + public static int getWildernessLevelFrom(final WorldPoint point) { + final int x = point.getX(); + final int y = point.getY(); + final int underLevel = (y - 9920) / 8 + 1; + final int upperLevel = (y - 3520) / 8 + 1; + return (y > 6400) ? underLevel : upperLevel; + } + + public static boolean isAttackable(final Client c, final Player p) { + return Math.abs(c.getLocalPlayer().getCombatLevel() - p.getCombatLevel()) < getWildernessLevelFrom(c.getLocalPlayer().getWorldLocation()); + } + + public static int calculateRisk(final Client client, final ItemManager itemManager) { + if (client.getItemContainer(InventoryID.EQUIPMENT) == null) { + return 0; + } + if (client.getItemContainer(InventoryID.INVENTORY).getItems() == null) { + return 0; + } + final Item[] items = (Item[])ArrayUtils.addAll(((ItemContainer)Objects.requireNonNull(client.getItemContainer(InventoryID.EQUIPMENT))).getItems(), ((ItemContainer)Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY))).getItems()); + final TreeMap priceMap = new TreeMap(Comparator.comparingInt(Integer::intValue)); + int wealth = 0; + for (final Item i : items) { + int value = itemManager.getItemPrice(i.getId()) * i.getQuantity(); + final ItemComposition itemComposition = itemManager.getItemComposition(i.getId()); + if (!itemComposition.isTradeable() && value == 0) { + value = itemComposition.getPrice() * i.getQuantity(); + priceMap.put(Integer.valueOf(value), i); + } + else { + value = itemManager.getItemPrice(i.getId()) * i.getQuantity(); + if (i.getId() > 0 && value > 0) { + priceMap.put(Integer.valueOf(value), i); + } + } + wealth += value; + } + return Integer.parseInt(StackFormatter.quantityToRSDecimalStack(priceMap.keySet().stream().mapToInt(Integer::intValue).sum())); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/util/ScreenCapture.java b/runelite-client/src/main/java/net/runelite/client/util/ScreenCapture.java deleted file mode 100644 index 7f84f6f1ac..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/util/ScreenCapture.java +++ /dev/null @@ -1,206 +0,0 @@ -package net.runelite.client.util; - -import java.awt.Toolkit; -import java.awt.TrayIcon; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.EnumSet; -import java.util.concurrent.ScheduledExecutorService; -import javax.imageio.ImageIO; -import javax.inject.Inject; -import javax.inject.Singleton; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.WorldType; -import net.runelite.client.Notifier; -import static net.runelite.client.RuneLite.SCREENSHOT_DIR; -import net.runelite.client.plugins.screenshot.imgur.ImageUploadRequest; -import net.runelite.client.plugins.screenshot.imgur.ImageUploadResponse; -import net.runelite.http.api.RuneLiteAPI; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.HttpUrl; -import okhttp3.MediaType; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; - -@Slf4j -@Singleton -public class ScreenCapture -{ - private static final String IMGUR_CLIENT_ID = "30d71e5f6860809"; - private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.parse("https://api.imgur.com/3/image"); - private static final MediaType JSON = MediaType.parse("application/json"); - private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - - @Inject - private ScheduledExecutorService executor; - - @Inject - private Client client; - - @Inject - private Notifier notifier; - - /** - * Saves a screenshot of the client window to the screenshot folder as a PNG, - * sends a notification to the system tray, and uploads it to an image-hosting service. - * - * @param screenshot BufferedImage to capture. - * @param notify Send a notification to the system tray when the image is captured. - * @param subDirectory Subdirectory of the default screenshot directory to save the image in. - */ - public void takeScreenshot(BufferedImage screenshot, boolean notify, String subDirectory) - { - takeScreenshot(screenshot, null, notify, true, subDirectory); - } - - /** - * Saves a screenshot of the client window to the screenshot folder as a PNG, - * and optionally uploads it to an image-hosting service. - * - * @param screenshot BufferedImage to capture. - * @param name Filename to use, without file extension. - * @param notify Send a notification to the system tray when the image is captured. - * @param upload Upload the image to a hosting service. - */ - public void takeScreenshot(BufferedImage screenshot, String name, boolean notify, boolean upload) - { - takeScreenshot(screenshot, name, notify, upload, null); - } - - /** - * Saves a screenshot of the client window to the screenshot folder as a PNG, - * and optionally uploads it to an image-hosting service. - * - * @param screenshot BufferedImage to capture. - * @param name Filename to use, without file extension. - * @param subDirectory Subdirectory of the default screenshot directory to save the image in. - * @param notify Send a notification to the system tray when the image is captured. - * @param upload Upload the image to a hosting service. - */ - public void takeScreenshot(BufferedImage screenshot, String name, boolean notify, boolean upload, String subDirectory) - { - if (client.getGameState() == GameState.LOGIN_SCREEN) - { - // Prevent the screenshot from being captured - log.info("Login screenshot prevented"); - return; - } - - if (name == null) - name = format(new Date()); - - String fileName = name; - File imageDirectory; - if (client.getLocalPlayer() != null && client.getLocalPlayer().getName() != null) - { - final EnumSet worldTypes = client.getWorldType(); - final boolean dmm = worldTypes.contains(WorldType.DEADMAN); - final boolean sdmm = worldTypes.contains(WorldType.SEASONAL_DEADMAN); - final boolean dmmt = worldTypes.contains(WorldType.DEADMAN_TOURNAMENT); - final boolean isDmmWorld = dmm || sdmm || dmmt; - - String playerDir = client.getLocalPlayer().getName(); - if (isDmmWorld) - playerDir += "-Deadman"; - imageDirectory = new File(SCREENSHOT_DIR, playerDir); - } - else - { - imageDirectory = SCREENSHOT_DIR; - } - if (subDirectory != null) - imageDirectory = new File(imageDirectory, subDirectory); - - imageDirectory.mkdirs(); - File writeDirectory = imageDirectory; - - executor.execute(() -> - { - try - { - File screenshotFile = new File(writeDirectory, fileName + ".png"); - - ImageIO.write(screenshot, "PNG", screenshotFile); - - if (upload) - uploadScreenshot(screenshotFile, notify); - else if (notify) - notifier.notify("A screenshot was saved to " + screenshotFile, TrayIcon.MessageType.INFO); - } - catch (IOException ex) - { - log.warn("error writing screenshot", ex); - } - }); - } - - /** - * Uploads a screenshot to the Imgur image-hosting service, - * and copies the image link to the clipboard. - * - * @param screenshotFile Image file to upload. - * @throws IOException Thrown if the file cannot be read. - */ - private void uploadScreenshot(File screenshotFile, boolean notify) throws IOException - { - String json = RuneLiteAPI.GSON.toJson(new ImageUploadRequest(screenshotFile)); - - Request request = new Request.Builder() - .url(IMGUR_IMAGE_UPLOAD_URL) - .addHeader("Authorization", "Client-ID " + IMGUR_CLIENT_ID) - .post(RequestBody.create(JSON, json)) - .build(); - - executor.execute(() -> - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() - { - @Override - public void onFailure(Call call, IOException ex) - { - log.warn("error uploading screenshot", ex); - } - - @Override - public void onResponse(Call call, Response response) throws IOException - { - try (InputStream in = response.body().byteStream()) - { - ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON - .fromJson(new InputStreamReader(in), ImageUploadResponse.class); - - if (imageUploadResponse.isSuccess()) - { - String link = imageUploadResponse.getData().getLink(); - - StringSelection selection = new StringSelection(link); - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - clipboard.setContents(selection, selection); - if (notify) - notifier.notify("A screenshot was uploaded and inserted into your clipboard!", TrayIcon.MessageType.INFO); - } - } - } - }) - ); - } - - private static String format(Date date) - { - synchronized (TIME_FORMAT) - { - return TIME_FORMAT.format(date); - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java b/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java index 39fc738f1f..e8aaef79a6 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/util/SwingUtil.java @@ -26,6 +26,7 @@ package net.runelite.client.util; import java.awt.AWTException; import java.awt.Color; +import java.awt.Dimension; import java.awt.Font; import java.awt.Frame; import java.awt.Image; @@ -52,11 +53,15 @@ import javax.swing.ToolTipManager; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import static javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE; +import javax.swing.border.EmptyBorder; import javax.swing.plaf.FontUIResource; +import javax.swing.plaf.basic.BasicProgressBarUI; import lombok.extern.slf4j.Slf4j; import net.runelite.client.ui.ColorScheme; +import net.runelite.client.ui.FontManager; import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.components.CustomScrollBarUI; +import net.runelite.client.ui.skin.SubstanceRuneLiteLookAndFeel; import org.pushingpixels.substance.internal.SubstanceSynapse; /** @@ -65,6 +70,8 @@ import org.pushingpixels.substance.internal.SubstanceSynapse; @Slf4j public class SwingUtil { + private static boolean lookAndFeelIsSet = false; + /** * Sets some sensible defaults for swing. * IMPORTANT! Needs to be called before main frame creation @@ -87,6 +94,14 @@ public class SwingUtil UIManager.put("FormattedTextField.selectionForeground", Color.WHITE); UIManager.put("TextArea.selectionBackground", ColorScheme.BRAND_ORANGE_TRANSPARENT); UIManager.put("TextArea.selectionForeground", Color.WHITE); + UIManager.put("ProgressBar.background", ColorScheme.BRAND_ORANGE_TRANSPARENT.darker()); + UIManager.put("ProgressBar.foreground", ColorScheme.BRAND_ORANGE); + UIManager.put("ProgressBar.selectionBackground", ColorScheme.BRAND_ORANGE); + UIManager.put("ProgressBar.selectionForeground", Color.BLACK); + UIManager.put("ProgressBar.border", new EmptyBorder(0, 0, 0, 0)); + UIManager.put("ProgressBar.verticalSize", new Dimension(12, 10)); + UIManager.put("ProgressBar.horizontalSize", new Dimension(10, 12)); + UIManager.put("ProgressBarUI", BasicProgressBarUI.class.getName()); // Do not render shadows under popups/tooltips. // Fixes black boxes under popups that are above the game applet. @@ -277,4 +292,24 @@ public class SwingUtil navigationButton.setOnSelect(button::doClick); return button; } + + /** + * Sets up the RuneLite look and feel. Checks to see if the look and feel + * was already set up before running in case the splash screen has already + * set up the theme. + * This must be run inside the Swing Event Dispatch thread. + */ + public static void setupRuneLiteLookAndFeel() + { + if (!lookAndFeelIsSet) + { + lookAndFeelIsSet = true; + // Set some sensible swing defaults + SwingUtil.setupDefaults(); + // Use substance look and feel + SwingUtil.setTheme(new SubstanceRuneLiteLookAndFeel()); + // Use custom UI font + SwingUtil.setFont(FontManager.getRunescapeFont()); + } + } } diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/add_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/add_icon.png deleted file mode 100644 index 343c3dce0c..0000000000 Binary files a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/add_icon.png and /dev/null differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/inventorysetups_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/inventorysetups_icon.png deleted file mode 100644 index 70e415beec..0000000000 Binary files a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/inventorysetups_icon.png and /dev/null differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/remove_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/remove_icon.png deleted file mode 100644 index 3f4915d041..0000000000 Binary files a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/remove_icon.png and /dev/null differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/pvptools/skull.png b/runelite-client/src/main/resources/net/runelite/client/plugins/pvptools/skull.png new file mode 100644 index 0000000000..09869ea0e1 Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/pvptools/skull.png differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/quest_complete_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/quest_complete_icon.png deleted file mode 100644 index 31acc0fdb4..0000000000 Binary files a/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/quest_complete_icon.png and /dev/null differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/quest_started_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/quest_started_icon.png deleted file mode 100644 index 0c567b0664..0000000000 Binary files a/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/quest_started_icon.png and /dev/null differ diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/waypoint_marker.png b/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/waypoint_marker.png deleted file mode 100644 index 8e229a7bf7..0000000000 Binary files a/runelite-client/src/main/resources/net/runelite/client/plugins/worldmap/waypoint_marker.png and /dev/null differ diff --git a/runelite-client/src/main/resources/runelite_transparent.png b/runelite-client/src/main/resources/runelite_transparent.png new file mode 100644 index 0000000000..c60bc7ee66 Binary files /dev/null and b/runelite-client/src/main/resources/runelite_transparent.png differ diff --git a/runelite-client/src/main/resources/runeliteplus.png b/runelite-client/src/main/resources/runeliteplus.png new file mode 100644 index 0000000000..e4057a8084 Binary files /dev/null and b/runelite-client/src/main/resources/runeliteplus.png differ diff --git a/runelite-client/src/main/resources/runeliteplus_transparent.png b/runelite-client/src/main/resources/runeliteplus_transparent.png new file mode 100644 index 0000000000..60565f1b40 Binary files /dev/null and b/runelite-client/src/main/resources/runeliteplus_transparent.png differ diff --git a/runelite-api/src/main/java/net/runelite/api/queries/ShopItemQuery.java b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/MaxHitCalculatorTest.java similarity index 51% rename from runelite-api/src/main/java/net/runelite/api/queries/ShopItemQuery.java rename to runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/MaxHitCalculatorTest.java index cd037f0a28..8c28256b89 100644 --- a/runelite-api/src/main/java/net/runelite/api/queries/ShopItemQuery.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/MaxHitCalculatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Devin French + * Copyright (c) 2019, Bartvollebregt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,50 +22,48 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.runelite.api.queries; +package net.runelite.client.plugins.maxhit.calculators; +import com.google.inject.Guice; +import com.google.inject.testing.fieldbinder.Bind; +import com.google.inject.testing.fieldbinder.BoundFieldModule; import net.runelite.api.Client; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetItem; +import net.runelite.client.plugins.maxhit.calculators.testconfig.MagicMaxHitConfig; +import net.runelite.client.plugins.maxhit.calculators.testconfig.MaxHitConfig; +import net.runelite.client.plugins.maxhit.calculators.testconfig.MeleeMaxHitConfig; +import net.runelite.client.plugins.maxhit.calculators.testconfig.RangeMaxHitConfig; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Objects; - -public class ShopItemQuery extends WidgetItemQuery +@RunWith(MockitoJUnitRunner.class) +public class MaxHitCalculatorTest { - @Override - public WidgetItem[] result(Client client) + @Mock + @Bind + protected Client client; + + @Before + public void setUp() { - Collection widgetItems = getShopItems(client); - if (widgetItems != null) - { - return widgetItems.stream() - .filter(Objects::nonNull) - .filter(predicate) - .toArray(WidgetItem[]::new); - } - return new WidgetItem[0]; + Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); } - private Collection getShopItems(Client client) + @Test + public void calculate() { - Collection widgetItems = new ArrayList<>(); - Widget shop = client.getWidget(WidgetInfo.SHOP_ITEMS_CONTAINER); - if (shop != null && !shop.isHidden()) + testMaxHitConfig(MeleeMaxHitConfig.values()); + testMaxHitConfig(RangeMaxHitConfig.values()); + testMaxHitConfig(MagicMaxHitConfig.values()); + } + + private void testMaxHitConfig(MaxHitConfig[] maxHitConfigs) + { + for (MaxHitConfig maxHitConfig : maxHitConfigs) { - Widget[] children = shop.getDynamicChildren(); - for (int i = 1; i < children.length; i++) - { - Widget child = children[i]; - // set bounds to same size as default inventory - Rectangle bounds = child.getBounds(); - bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32); - widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i - 1, bounds)); - } + maxHitConfig.test(client); } - return widgetItems; } } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MagicMaxHitConfig.java b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MagicMaxHitConfig.java new file mode 100644 index 0000000000..452aa484fc --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MagicMaxHitConfig.java @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators.testconfig; + +import net.runelite.api.*; +import net.runelite.client.plugins.maxhit.calculators.MagicMaxHitCalculator; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public enum MagicMaxHitConfig implements MaxHitConfig +{ + + TRIDENT_SLAYER(new int[] {75, 83, 99}, 0, new Item[] + { + mockItem(ItemID.SLAYER_HELMET_I), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.OCCULT_NECKLACE), + mockItem(ItemID.TRIDENT_OF_THE_SEAS), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.BROODOO_SHIELD), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, new int[] {25, 27, 34}), + + TRIDENT_OF_SEAS(new int[] {75, 83, 99}, 0, new Item[] + { + mockItem(ItemID.MYSTIC_HAT), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.AMULET_OF_GLORY), + mockItem(ItemID.TRIDENT_OF_THE_SEAS), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.BROODOO_SHIELD), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, new int[] {20, 22, 28}), + + TRIDENT_OF_SWAMP(new int[] {75, 83, 99}, 0, new Item[] + { + mockItem(ItemID.MYSTIC_HAT), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.AMULET_OF_GLORY), + mockItem(ItemID.TRIDENT_OF_THE_SWAMP), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.BROODOO_SHIELD), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, new int[] {23, 25, 31}), + + MAGIC_DART(new int[] {75, 83, 99}, 18, new Item[] + { + mockItem(ItemID.MYSTIC_HAT), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.AMULET_OF_GLORY), + mockItem(ItemID.SLAYERS_STAFF), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.BROODOO_SHIELD), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, new int[] {17, 18, 19}), + + + FIRE_BOLT(75, 8, new Item[] + { + mockItem(ItemID.SLAYER_HELMET_I), + mockItem(ItemID.IMBUED_SARADOMIN_CAPE), + mockItem(ItemID.OCCULT_NECKLACE), + mockItem(ItemID.STAFF_OF_THE_DEAD), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.TOME_OF_FIRE), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.CHAOS_GAUNTLETS), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, 31), + + + WIND_BLAST(75, 9, new Item[] + { + mockItem(ItemID.MYSTIC_HAT), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.AMULET_OF_GLORY), + mockItem(ItemID.STAFF_OF_AIR), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.BROODOO_SHIELD), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, 13), + + + EARTH_WAVE(75, 15, new Item[] + { + mockItem(ItemID.MYSTIC_HAT), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.OCCULT_NECKLACE), + mockItem(ItemID.STAFF_OF_EARTH), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.TOME_OF_FIRE), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, 20), + + FLAMES_OF_ZAMORAK(75, 20, new Item[] + { + mockItem(ItemID.MYSTIC_HAT), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.AMULET_OF_GLORY), + mockItem(ItemID.STAFF_OF_THE_DEAD), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.BROODOO_SHIELD), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, 23), + + SARADOMIN_STRIKE(75, 52, new Item[] + { + mockItem(ItemID.MYSTIC_HAT), + mockItem(ItemID.SARADOMIN_CAPE), + mockItem(ItemID.AMULET_OF_GLORY), + mockItem(ItemID.STAFF_OF_LIGHT), + mockItem(ItemID.MYSTIC_ROBE_TOP), + mockItem(ItemID.BROODOO_SHIELD), + null, + mockItem(ItemID.MYSTIC_ROBE_BOTTOM), + null, + mockItem(ItemID.MYSTIC_GLOVES), + mockItem(ItemID.WIZARD_BOOTS), + mockItem(ItemID.RING_OF_WEALTH) + }, 23), + + + ; + + + private final int[] magicLevels; + private final int spellId; + private final Item[] equipedItems; + private final int[] expectedMaxHits; + + MagicMaxHitConfig(int magicLevel, int spellId, Item[] equipedItems, int expectedMaxHit) + { + this.magicLevels = new int[] {magicLevel}; + this.spellId = spellId; + this.equipedItems = equipedItems; + this.expectedMaxHits = new int[] {expectedMaxHit}; + } + + MagicMaxHitConfig(int[] magicLevels, int spellId, Item[] equipedItems, int[] expectedMaxHits) + { + this.magicLevels = magicLevels; + this.spellId = spellId; + this.equipedItems = equipedItems; + this.expectedMaxHits = expectedMaxHits; + } + + + private static Item mockItem(int itemId) + { + Item item = mock(Item.class); + when(item.getId()).thenReturn(itemId); + return item; + } + + public void test(Client client) + { + int[] magicLevels = this.magicLevels; + for (int i = 0, magicLevelsLength = magicLevels.length; i < magicLevelsLength; i++) + { + int magicLevel = magicLevels[i]; + int expectedMaxHit = this.expectedMaxHits[i]; + + // Mock equipment container + ItemContainer equipmentContainer = mock(ItemContainer.class); + when(equipmentContainer.getItems()) + .thenReturn(this.equipedItems); + when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentContainer); + + // Mock Varbits + when(client.getBoostedSkillLevel(Skill.MAGIC)).thenReturn(magicLevel); + when(client.getVar(Varbits.AUTO_CAST_SPELL)).thenReturn(this.spellId); + + // Test + MagicMaxHitCalculator maxHitCalculator = new MagicMaxHitCalculator(client, this.equipedItems); + assertEquals(this.toString(), expectedMaxHit, maxHitCalculator.getMaxHit(), 0); + + } + + } + +} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MaxHitConfig.java b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MaxHitConfig.java new file mode 100644 index 0000000000..309abe1727 --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MaxHitConfig.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators.testconfig; + +import net.runelite.api.Client; + +public interface MaxHitConfig +{ + void test(Client client); +} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MeleeMaxHitConfig.java b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MeleeMaxHitConfig.java new file mode 100644 index 0000000000..dd03f9487e --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/MeleeMaxHitConfig.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators.testconfig; + +import net.runelite.api.*; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.plugins.maxhit.attackstyle.WeaponType; +import net.runelite.client.plugins.maxhit.calculators.MeleeMaxHitCalculator; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public enum MeleeMaxHitConfig implements MaxHitConfig +{ + + DRAGON_SCIMITAR(new int[] {75, 83, 99}, 66, WeaponType.TYPE_9, 1, new Item[] + { + mockItem(ItemID.IRON_FULL_HELM), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.DRAGON_SCIMITAR), + mockItem(ItemID.IRON_PLATEBODY), + mockItem(ItemID.IRON_KITESHIELD), + null, + mockItem(ItemID.IRON_PLATELEGS), + null, + mockItem(ItemID.LEATHER_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING) + }, new int[] {17, 19, 22}), + + DRAGON_SCIMITAR_DEFENDER(new int[] {75, 83, 99}, 76, WeaponType.TYPE_9, 1, new Item[] + { + mockItem(ItemID.IRON_FULL_HELM), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.DRAGON_SCIMITAR), + mockItem(ItemID.IRON_PLATEBODY), + mockItem(ItemID.DRAGON_DEFENDER), + null, + mockItem(ItemID.IRON_PLATELEGS), + null, + mockItem(ItemID.LEATHER_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING) + }, new int[] {19, 21, 24}), + + DRAGON_SCIMITAR_COMPLETE(new int[] {75, 83, 99}, 108, WeaponType.TYPE_9, 1, new Item[] + { + mockItem(ItemID.SLAYER_HELMET), + mockItem(ItemID.FIRE_CAPE), + mockItem(ItemID.AMULET_OF_FURY), + mockItem(ItemID.DRAGON_SCIMITAR), + mockItem(ItemID.FIGHTER_TORSO), + mockItem(ItemID.DRAGON_DEFENDER), + null, + mockItem(ItemID.IRON_PLATELEGS), + null, + mockItem(ItemID.BARROWS_GLOVES), + mockItem(ItemID.DRAGON_BOOTS), + mockItem(ItemID.BERSERKER_RING) + }, new int[] {26, 29, 35}), + + OBSIDIAN_SET(new int[] {75, 83, 99}, 61, WeaponType.TYPE_17, 2, new Item[] + { + mockItem(ItemID.OBSIDIAN_HELMET), + mockItem(ItemID.OBSIDIAN_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.TOKTZXILAK), + mockItem(ItemID.OBSIDIAN_PLATEBODY), + mockItem(ItemID.TOKTZKETXIL), + null, + mockItem(ItemID.OBSIDIAN_PLATELEGS), + null, + mockItem(ItemID.LEATHER_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING) + }, new int[] {18, 19, 23}), + + DHAROK_SET(new int[] {75, 75, 75, 83, 83, 83, 99, 99, 99}, 105, WeaponType.TYPE_1, 1, + new int[][] {{99, 99}, {1, 99}, {32, 75}, {99, 99}, {1, 99}, {32, 75}, {99, 99}, {1, 99}, {32, 75}}, + new Item[] + { + mockItem(ItemID.DHAROKS_HELM_100), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.DHAROKS_GREATAXE_100), + mockItem(ItemID.DHAROKS_PLATEBODY_100), + null, + null, + mockItem(ItemID.DHAROKS_PLATELEGS_100), + null, + mockItem(ItemID.LEATHER_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING) + }, new int[] {23, 45, 30, 25, 49, 33, 29, 57, 38}), + + VOID_SET(new int[] {75, 83, 99}, 66, WeaponType.TYPE_9, 1, new Item[] + { + mockItem(ItemID.VOID_MELEE_HELM), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.DRAGON_SCIMITAR), + mockItem(ItemID.VOID_KNIGHT_TOP), + mockItem(ItemID.IRON_KITESHIELD), + null, + mockItem(ItemID.VOID_KNIGHT_ROBE), + null, + mockItem(ItemID.VOID_KNIGHT_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING) + }, new int[] {19, 21, 25}), + ; + + + private final int[] strengthLevels; + private final WeaponType weaponType; + private final int attackStyleId; + private final Item[] equipedItems; + private final int[] expectedMaxHits; + private final int[][] hitpoints; + private final int meleeEquipmentStrength; + + MeleeMaxHitConfig(int[] strengthLevels, int meleeEquipmentStrength, WeaponType weaponType, int attackStyleId, int[][] hitpoints, Item[] equipedItems, int[] expectedMaxHits) + { + this.strengthLevels = strengthLevels; + this.meleeEquipmentStrength = meleeEquipmentStrength; + this.weaponType = weaponType; + this.attackStyleId = attackStyleId; + this.hitpoints = hitpoints; + this.equipedItems = equipedItems; + this.expectedMaxHits = expectedMaxHits; + } + + MeleeMaxHitConfig(int[] strengthLevels, int meleeEquipmentStrength, WeaponType weaponType, int attackStyleId, Item[] equipedItems, int[] expectedMaxHits) + { + this.strengthLevels = strengthLevels; + this.hitpoints = new int[strengthLevels.length][2]; + this.meleeEquipmentStrength = meleeEquipmentStrength; + this.weaponType = weaponType; + this.attackStyleId = attackStyleId; + this.equipedItems = equipedItems; + this.expectedMaxHits = expectedMaxHits; + } + + + private static Item mockItem(int itemId) + { + Item item = mock(Item.class); + when(item.getId()).thenReturn(itemId); + return item; + } + + public void test(Client client) + { + int[] strengthLevels = this.strengthLevels; + for (int i = 0, strengthLevelsLength = strengthLevels.length; i < strengthLevelsLength; i++) + { + int strengthLevel = strengthLevels[i]; + int[] hitpoints = this.hitpoints[i]; + int expectedMaxHit = this.expectedMaxHits[i]; + + // Mock equipment container + ItemContainer equipmentContainer = mock(ItemContainer.class); + when(equipmentContainer.getItems()) + .thenReturn(this.equipedItems); + when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentContainer); + + // Mock equipment strength + Widget equipmentWidget = mock(Widget.class); + when(client.getWidget(WidgetInfo.EQUIPMENT_MELEE_STRENGTH)).thenReturn(equipmentWidget); + when(equipmentWidget.getText()).thenReturn("Melee strength: " + this.meleeEquipmentStrength); + + // Mock Varbits + when(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(this.weaponType.ordinal()); + when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(this.attackStyleId); + + // Mock strength + when(client.getBoostedSkillLevel(Skill.STRENGTH)).thenReturn(strengthLevel); + + // Mock hitpoints + when(client.getBoostedSkillLevel(Skill.HITPOINTS)).thenReturn(hitpoints[0]); + when(client.getRealSkillLevel(Skill.HITPOINTS)).thenReturn(hitpoints[1]); + + // Test + MeleeMaxHitCalculator maxHitCalculator = new MeleeMaxHitCalculator(client, this.equipedItems); + assertEquals(this.toString(), expectedMaxHit, maxHitCalculator.getMaxHit(), 0); + + } + + } + +} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/RangeMaxHitConfig.java b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/RangeMaxHitConfig.java new file mode 100644 index 0000000000..31ac795bb5 --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/maxhit/calculators/testconfig/RangeMaxHitConfig.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2019, Bartvollebregt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.maxhit.calculators.testconfig; + +import net.runelite.api.*; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.plugins.maxhit.attackstyle.WeaponType; +import net.runelite.client.plugins.maxhit.calculators.RangeMaxHitCalculator; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public enum RangeMaxHitConfig implements MaxHitConfig +{ + + MAGIC_SHORTBOW(new int[] {75, 83, 99}, 49, WeaponType.TYPE_3, 1, new Item[] + { + mockItem(ItemID.IRON_FULL_HELM), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.MAGIC_SHORTBOW), + mockItem(ItemID.IRON_PLATEBODY), + null, + null, + mockItem(ItemID.IRON_PLATELEGS), + null, + mockItem(ItemID.LEATHER_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING), + mockItem(ItemID.RUNE_ARROW) + }, new int[] {15, 16, 19}), + + RUNE_CROSSBOW(new int[] {75, 83, 99}, 115, WeaponType.TYPE_5, 0, new Item[] + { + mockItem(ItemID.IRON_FULL_HELM), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.RUNE_CROSSBOW), + mockItem(ItemID.IRON_PLATEBODY), + null, + null, + mockItem(ItemID.IRON_PLATELEGS), + null, + mockItem(ItemID.LEATHER_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING), + mockItem(ItemID.RUNITE_BOLTS) + }, new int[] {24, 26, 31}), + + BLOwPIPE(new int[] {75, 83, 99}, 50, WeaponType.TYPE_19, 1, new Item[] + { + mockItem(ItemID.IRON_FULL_HELM), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.TOXIC_BLOWPIPE), + mockItem(ItemID.IRON_PLATEBODY), + null, + null, + mockItem(ItemID.IRON_PLATELEGS), + null, + mockItem(ItemID.LEATHER_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING) + }, new int[] {15, 16, 19}), + + VOID_SET(new int[] {75, 83, 99}, 115, WeaponType.TYPE_5, 1, new Item[] + { + mockItem(ItemID.VOID_RANGER_HELM), + mockItem(ItemID.BLACK_CAPE), + mockItem(ItemID.GOLD_NECKLACE), + mockItem(ItemID.RUNE_CROSSBOW), + mockItem(ItemID.VOID_KNIGHT_TOP), + mockItem(ItemID.IRON_KITESHIELD), + null, + mockItem(ItemID.VOID_KNIGHT_ROBE), + null, + mockItem(ItemID.VOID_KNIGHT_GLOVES), + mockItem(ItemID.LEATHER_BOOTS), + mockItem(ItemID.GOLD_RING) + }, new int[] {26, 28, 33}), + + ; + + private final int[] rangeLevels; + private final WeaponType weaponType; + private final int attackStyleId; + private final Item[] equipedItems; + private final int[] expectedMaxHits; + private final int ammoEquipmentStrength; + + RangeMaxHitConfig(int[] rangeLevels, int ammoEquipmentStrength, WeaponType weaponType, int attackStyleId, Item[] equipedItems, int[] expectedMaxHits) + { + this.rangeLevels = rangeLevels; + this.ammoEquipmentStrength = ammoEquipmentStrength; + this.weaponType = weaponType; + this.attackStyleId = attackStyleId; + this.equipedItems = equipedItems; + this.expectedMaxHits = expectedMaxHits; + } + + + private static Item mockItem(int itemId) + { + Item item = mock(Item.class); + when(item.getId()).thenReturn(itemId); + return item; + } + + public void test(Client client) + { + int[] rangeLevels = this.rangeLevels; + for (int i = 0, rangeLevelsLength = rangeLevels.length; i < rangeLevelsLength; i++) + { + int rangeLevel = rangeLevels[i]; + int expectedMaxHit = this.expectedMaxHits[i]; + + // Mock equipment container + ItemContainer equipmentContainer = mock(ItemContainer.class); + when(equipmentContainer.getItems()) + .thenReturn(this.equipedItems); + when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentContainer); + + // Mock equipment strength + Widget equipmentWidget = mock(Widget.class); + when(client.getWidget(WidgetInfo.EQUIPMENT_RANGED_STRENGTH)).thenReturn(equipmentWidget); + when(equipmentWidget.getText()).thenReturn("Ranged strength: " + this.ammoEquipmentStrength); + + // Mock Varbits + when(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(this.weaponType.ordinal()); + when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(this.attackStyleId); + + // Mock strength + when(client.getBoostedSkillLevel(Skill.RANGED)).thenReturn(rangeLevel); + + // Test + RangeMaxHitCalculator maxHitCalculator = new RangeMaxHitCalculator(client, this.equipedItems); + assertEquals(this.toString(), expectedMaxHit, maxHitCalculator.getMaxHit(), 0); + + } + + } + +} diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSActorMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSActorMixin.java index 7c2d19323f..714b1dcd17 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSActorMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSActorMixin.java @@ -135,9 +135,9 @@ public abstract class RSActorMixin implements RSActor public WorldPoint getWorldLocation() { return WorldPoint.fromLocal(client, - this.getPathX()[0] * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2, - this.getPathY()[0] * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2, - client.getPlane()); + this.getPathX()[0] * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2, + this.getPathY()[0] * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2, + client.getPlane()); } @Inject diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index 56b9190ead..7c934a265d 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -1335,7 +1335,7 @@ public abstract class RSClientMixin implements RSClient for (Widget rlWidget : widgets) { RSWidget widget = (RSWidget) rlWidget; - if (widget == null || widget.getRSParentId() != parentId) + if (widget == null || widget.getRSParentId() != parentId || widget.isSelfHidden()) { continue; } @@ -1355,7 +1355,7 @@ public abstract class RSClientMixin implements RSClient { if (renderX >= minX && renderX <= maxX && renderY >= minY && renderY <= maxY) { - WidgetItem widgetItem = new WidgetItem(widget.getItemId(), widget.getItemQuantity(), -1, widget.getBounds()); + WidgetItem widgetItem = new WidgetItem(widget.getItemId(), widget.getItemQuantity(), -1, widget.getBounds(), widget); callbacks.drawItem(widget.getItemId(), widgetItem); } } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java index 4130ce5930..1b4bda7fc6 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java @@ -300,7 +300,7 @@ public abstract class RSWidgetMixin implements RSWidget int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + yPitch) * row); Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE); - return new WidgetItem(itemId - 1, itemQuantity, index, bounds); + return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this); } @Inject